mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
add alternative layout for related streams
This commit is contained in:
parent
32bd35aa48
commit
610121dd90
@ -17,6 +17,7 @@ import com.github.libretube.constants.PreferenceKeys
|
||||
import com.github.libretube.databinding.TrendingRowBinding
|
||||
import com.github.libretube.databinding.VideoRowBinding
|
||||
import com.github.libretube.extensions.formatShort
|
||||
import com.github.libretube.extensions.toDp
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.ui.extensions.setFormattedDuration
|
||||
import com.github.libretube.ui.extensions.setWatchProgressLength
|
||||
@ -59,7 +60,7 @@ class VideosAdapter(
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VideosViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
return when {
|
||||
forceMode == ForceMode.TRENDING -> VideosViewHolder(TrendingRowBinding.inflate(layoutInflater, parent, false))
|
||||
forceMode in listOf(ForceMode.TRENDING, ForceMode.RELATED) -> VideosViewHolder(TrendingRowBinding.inflate(layoutInflater, parent, false))
|
||||
forceMode == ForceMode.CHANNEL -> VideosViewHolder(VideoRowBinding.inflate(layoutInflater, parent, false))
|
||||
PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.ALTERNATIVE_VIDEOS_LAYOUT,
|
||||
@ -82,6 +83,12 @@ class VideosAdapter(
|
||||
|
||||
// Trending layout
|
||||
holder.trendingRowBinding?.apply {
|
||||
if (forceMode == ForceMode.RELATED) {
|
||||
val params = root.layoutParams
|
||||
params.width = (180).toDp(root.context.resources).toInt()
|
||||
root.layoutParams = params
|
||||
}
|
||||
|
||||
textViewTitle.text = video.title
|
||||
textViewChannel.text =
|
||||
video.uploaderName + TextUtils.SEPARATOR +
|
||||
@ -160,7 +167,8 @@ class VideosAdapter(
|
||||
NONE,
|
||||
TRENDING,
|
||||
ROW,
|
||||
CHANNEL
|
||||
CHANNEL,
|
||||
RELATED
|
||||
}
|
||||
|
||||
fun getLayout(context: Context): LayoutManager {
|
||||
|
@ -38,6 +38,7 @@ import com.github.libretube.api.CronetHelper
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.api.obj.ChapterSegment
|
||||
import com.github.libretube.api.obj.SegmentData
|
||||
import com.github.libretube.api.obj.Streams
|
||||
import com.github.libretube.constants.IntentData
|
||||
import com.github.libretube.constants.PreferenceKeys
|
||||
import com.github.libretube.databinding.DoubleTapOverlayBinding
|
||||
@ -120,7 +121,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
private var videoId: String? = null
|
||||
private var playlistId: String? = null
|
||||
private var isLive = false
|
||||
private lateinit var streams: com.github.libretube.api.obj.Streams
|
||||
private lateinit var streams: Streams
|
||||
|
||||
/**
|
||||
* for the transition
|
||||
@ -383,6 +384,12 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
binding.commentsRecView.setItemViewCacheSize(20)
|
||||
|
||||
binding.relatedRecView.layoutManager = VideosAdapter.getLayout(requireContext())
|
||||
|
||||
binding.alternativeTrendingRec.layoutManager = LinearLayoutManager(
|
||||
context,
|
||||
LinearLayoutManager.HORIZONTAL,
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
private fun setFullscreen() {
|
||||
@ -897,6 +904,12 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
response.relatedStreams.orEmpty().toMutableList(),
|
||||
childFragmentManager
|
||||
)
|
||||
|
||||
binding.alternativeTrendingRec.adapter = VideosAdapter(
|
||||
response.relatedStreams.orEmpty().toMutableList(),
|
||||
childFragmentManager,
|
||||
forceMode = VideosAdapter.Companion.ForceMode.RELATED
|
||||
)
|
||||
}
|
||||
// set video description
|
||||
val description = response.description!!
|
||||
|
@ -1,10 +1,6 @@
|
||||
package com.github.libretube.ui.preferences
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.widget.Toast
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.SwitchPreferenceCompat
|
||||
@ -14,7 +10,6 @@ import com.github.libretube.ui.activities.SettingsActivity
|
||||
import com.github.libretube.ui.base.BasePreferenceFragment
|
||||
import com.github.libretube.ui.dialogs.NavBarOptionsDialog
|
||||
import com.github.libretube.ui.dialogs.RequireRestartDialog
|
||||
import com.github.libretube.util.PreferenceHelper
|
||||
import com.github.libretube.util.ThemeHelper
|
||||
import com.google.android.material.color.DynamicColors
|
||||
|
||||
@ -69,27 +64,6 @@ class AppearanceSettings : BasePreferenceFragment() {
|
||||
true
|
||||
}
|
||||
|
||||
val systemCaptionStyle =
|
||||
findPreference<SwitchPreferenceCompat>(PreferenceKeys.SYSTEM_CAPTION_STYLE)
|
||||
val captionSettings = findPreference<Preference>(PreferenceKeys.CAPTION_SETTINGS)
|
||||
|
||||
captionSettings?.isVisible =
|
||||
PreferenceHelper.getBoolean(PreferenceKeys.SYSTEM_CAPTION_STYLE, true)
|
||||
systemCaptionStyle?.setOnPreferenceChangeListener { _, newValue ->
|
||||
captionSettings?.isVisible = newValue as Boolean
|
||||
true
|
||||
}
|
||||
|
||||
captionSettings?.setOnPreferenceClickListener {
|
||||
try {
|
||||
val captionSettingsIntent = Intent(Settings.ACTION_CAPTIONING_SETTINGS)
|
||||
startActivity(captionSettingsIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(activity, R.string.error, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
val legacySubscriptionView =
|
||||
findPreference<SwitchPreferenceCompat>(PreferenceKeys.LEGACY_SUBSCRIPTIONS)
|
||||
val legacySubscriptionColumns =
|
||||
|
@ -1,6 +1,10 @@
|
||||
package com.github.libretube.ui.preferences
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.widget.Toast
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.SwitchPreferenceCompat
|
||||
@ -37,6 +41,27 @@ class PlayerSettings : BasePreferenceFragment() {
|
||||
|
||||
val defaultSubtitle = findPreference<ListPreference>(PreferenceKeys.DEFAULT_SUBTITLE)
|
||||
defaultSubtitle?.let { setupSubtitlePref(it) }
|
||||
|
||||
val systemCaptionStyle =
|
||||
findPreference<SwitchPreferenceCompat>(PreferenceKeys.SYSTEM_CAPTION_STYLE)
|
||||
val captionSettings = findPreference<Preference>(PreferenceKeys.CAPTION_SETTINGS)
|
||||
|
||||
captionSettings?.isVisible =
|
||||
PreferenceHelper.getBoolean(PreferenceKeys.SYSTEM_CAPTION_STYLE, true)
|
||||
systemCaptionStyle?.setOnPreferenceChangeListener { _, newValue ->
|
||||
captionSettings?.isVisible = newValue as Boolean
|
||||
true
|
||||
}
|
||||
|
||||
captionSettings?.setOnPreferenceClickListener {
|
||||
try {
|
||||
val captionSettingsIntent = Intent(Settings.ACTION_CAPTIONING_SETTINGS)
|
||||
startActivity(captionSettingsIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(activity, R.string.error, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSubtitlePref(preference: ListPreference) {
|
||||
|
@ -5,8 +5,7 @@
|
||||
android:id="@+id/playerMotionLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutDescription="@xml/player_scene"
|
||||
tools:context=".ui.fragments.PlayerFragment">
|
||||
app:layoutDescription="@xml/player_scene">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/player_scrollView"
|
||||
@ -147,13 +146,13 @@
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:gravity="center"
|
||||
android:weightSum="5"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="5">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/relPlayer_share"
|
||||
android:layout_weight="1"
|
||||
style="@style/PlayerActionsLayout">
|
||||
style="@style/PlayerActionsLayout"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
@ -161,16 +160,16 @@
|
||||
android:src="@drawable/ic_share" />
|
||||
|
||||
<TextView
|
||||
style="@style/PlayerActionsText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PlayerActionsText"
|
||||
android:text="@string/share" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/relPlayer_download"
|
||||
android:layout_weight="1"
|
||||
style="@style/PlayerActionsLayout">
|
||||
style="@style/PlayerActionsLayout"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
@ -178,16 +177,16 @@
|
||||
android:src="@drawable/ic_download" />
|
||||
|
||||
<TextView
|
||||
style="@style/PlayerActionsText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PlayerActionsText"
|
||||
android:text="@string/download" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/relPlayer_open"
|
||||
android:layout_weight="1"
|
||||
style="@style/PlayerActionsLayout">
|
||||
style="@style/PlayerActionsLayout"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
@ -196,16 +195,16 @@
|
||||
android:src="@drawable/ic_open" />
|
||||
|
||||
<TextView
|
||||
style="@style/PlayerActionsText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PlayerActionsText"
|
||||
android:text="@string/open" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/relPlayer_background"
|
||||
android:layout_weight="1"
|
||||
style="@style/PlayerActionsLayout">
|
||||
style="@style/PlayerActionsLayout"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
@ -213,16 +212,16 @@
|
||||
android:src="@drawable/ic_headphones" />
|
||||
|
||||
<TextView
|
||||
style="@style/PlayerActionsText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PlayerActionsText"
|
||||
android:text="@string/audio" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/relPlayer_save"
|
||||
android:layout_weight="1"
|
||||
style="@style/PlayerActionsLayout">
|
||||
style="@style/PlayerActionsLayout"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
@ -230,9 +229,9 @@
|
||||
android:src="@drawable/ic_save" />
|
||||
|
||||
<TextView
|
||||
style="@style/PlayerActionsText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PlayerActionsText"
|
||||
android:text="@string/save" />
|
||||
</LinearLayout>
|
||||
|
||||
@ -300,6 +299,13 @@
|
||||
app:cornerRadius="11dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/alternativeTrendingRec"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/comments_toggle"
|
||||
style="@style/Widget.Material3.CardView.Elevated"
|
||||
|
@ -82,6 +82,8 @@
|
||||
android:id="@+id/textView_channel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:paddingBottom="16dp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/textView_title"
|
||||
app:layout_constraintStart_toStartOf="@+id/textView_title"
|
||||
|
@ -228,7 +228,7 @@
|
||||
<string name="change_playback_speed">Playback speed</string>
|
||||
<string name="require_restart">App restart required</string>
|
||||
<string name="require_restart_message">This change requires the app to be restarted. Press \'Ok\' to restart now.</string>
|
||||
<string name="navLabelVisibility">Navbar label visibility</string>
|
||||
<string name="navLabelVisibility">Label visibility</string>
|
||||
<string name="always">Always</string>
|
||||
<string name="selected">Selected</string>
|
||||
<string name="never">Never</string>
|
||||
@ -365,6 +365,9 @@
|
||||
<string name="end_time">End time</string>
|
||||
<string name="notification_time">Notification time</string>
|
||||
<string name="notification_time_summary">Time span in which notifications are allowed to show.</string>
|
||||
<string name="alternative_trending_layout">Alternative trending layout</string>
|
||||
<string name="navbar_order">Order</string>
|
||||
<string name="layout">Layout</string>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
|
@ -38,14 +38,14 @@
|
||||
app:title="@string/app_icon"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/navigation_bar">
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_home"
|
||||
app:key="navbar_items"
|
||||
app:title="@string/navigation_bar" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/app_behavior">
|
||||
app:title="@string/navbar_order" />
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_label"
|
||||
@ -56,33 +56,9 @@
|
||||
app:title="@string/navLabelVisibility"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_grid"
|
||||
app:defaultValue="@integer/grid_items"
|
||||
app:entries="@array/grid"
|
||||
app:entryValues="@array/grid"
|
||||
app:key="grid"
|
||||
app:title="@string/grid"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/player">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:icon="@drawable/ic_caption"
|
||||
app:defaultValue="true"
|
||||
app:key="system_caption_style"
|
||||
app:title="@string/system_caption_style" />
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_settings"
|
||||
app:key="caption_settings"
|
||||
app:title="@string/caption_settings" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/misc">
|
||||
<PreferenceCategory app:title="@string/layout">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
@ -105,6 +81,19 @@
|
||||
app:key="alternative_videos_layout"
|
||||
app:title="@string/alternative_videos_layout" />
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_grid"
|
||||
app:defaultValue="@integer/grid_items"
|
||||
app:entries="@array/grid"
|
||||
app:entryValues="@array/grid"
|
||||
app:key="grid"
|
||||
app:title="@string/grid"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/misc">
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="recent"
|
||||
android:entries="@array/playlistSortingOptions"
|
||||
|
@ -55,6 +55,21 @@
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/appearance">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:icon="@drawable/ic_caption"
|
||||
app:defaultValue="true"
|
||||
app:key="system_caption_style"
|
||||
app:title="@string/system_caption_style" />
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_settings"
|
||||
app:key="caption_settings"
|
||||
app:title="@string/caption_settings" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/behavior">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
|
Loading…
Reference in New Issue
Block a user