diff --git a/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt index c6bcba59c..a1651cbdd 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt @@ -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 { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index df0195ffe..f56d7dcc5 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -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!! diff --git a/app/src/main/java/com/github/libretube/ui/preferences/AppearanceSettings.kt b/app/src/main/java/com/github/libretube/ui/preferences/AppearanceSettings.kt index 799a2d63d..67ec84f5c 100644 --- a/app/src/main/java/com/github/libretube/ui/preferences/AppearanceSettings.kt +++ b/app/src/main/java/com/github/libretube/ui/preferences/AppearanceSettings.kt @@ -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(PreferenceKeys.SYSTEM_CAPTION_STYLE) - val captionSettings = findPreference(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(PreferenceKeys.LEGACY_SUBSCRIPTIONS) val legacySubscriptionColumns = diff --git a/app/src/main/java/com/github/libretube/ui/preferences/PlayerSettings.kt b/app/src/main/java/com/github/libretube/ui/preferences/PlayerSettings.kt index 557cb4c7e..75d4d9f40 100644 --- a/app/src/main/java/com/github/libretube/ui/preferences/PlayerSettings.kt +++ b/app/src/main/java/com/github/libretube/ui/preferences/PlayerSettings.kt @@ -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(PreferenceKeys.DEFAULT_SUBTITLE) defaultSubtitle?.let { setupSubtitlePref(it) } + + val systemCaptionStyle = + findPreference(PreferenceKeys.SYSTEM_CAPTION_STYLE) + val captionSettings = findPreference(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) { diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index 10327cd90..c323e8c75 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -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"> + android:orientation="horizontal" + android:weightSum="5"> + style="@style/PlayerActionsLayout" + android:layout_weight="1"> + style="@style/PlayerActionsLayout" + android:layout_weight="1"> + style="@style/PlayerActionsLayout" + android:layout_weight="1"> + style="@style/PlayerActionsLayout" + android:layout_weight="1"> + style="@style/PlayerActionsLayout" + android:layout_weight="1"> @@ -300,6 +299,13 @@ app:cornerRadius="11dp" /> + + Playback speed App restart required This change requires the app to be restarted. Press \'Ok\' to restart now. - Navbar label visibility + Label visibility Always Selected Never @@ -365,6 +365,9 @@ End time Notification time Time span in which notifications are allowed to show. + Alternative trending layout + Order + Layout Download Service diff --git a/app/src/main/res/xml/appearance_settings.xml b/app/src/main/res/xml/appearance_settings.xml index e4759d1f1..19f3533a5 100644 --- a/app/src/main/res/xml/appearance_settings.xml +++ b/app/src/main/res/xml/appearance_settings.xml @@ -38,14 +38,14 @@ app:title="@string/app_icon" app:useSimpleSummaryProvider="true" /> + + + + - - - - + app:title="@string/navbar_order" /> - - - - - - - - - - - + + + + + + + + + + + + + + +