From c000b1ee7b4c7abf62ad24a66160d663c8f58351 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 23 Oct 2023 18:00:40 +0200 Subject: [PATCH] refactor: enabled alternative player layout by default and remove option --- .../libretube/constants/PreferenceKeys.kt | 1 - .../github/libretube/helpers/PlayerHelper.kt | 6 ---- .../libretube/ui/fragments/PlayerFragment.kt | 28 ++++++------------- app/src/main/res/layout/fragment_player.xml | 25 +++-------------- app/src/main/res/xml/appearance_settings.xml | 7 ----- 5 files changed, 12 insertions(+), 55 deletions(-) diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt index 5d683c495..cce096293 100644 --- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt @@ -83,7 +83,6 @@ object PreferenceKeys { const val PICTURE_IN_PICTURE = "picture_in_picture" const val PLAYER_RESIZE_MODE = "player_resize_mode" const val DEARROW = "dearrow" - const val ALTERNATIVE_PLAYER_LAYOUT = "alternative_player_layout" const val USE_HLS_OVER_DASH = "use_hls" const val QUEUE_AUTO_INSERT_RELATED = "queue_insert_related_videos" const val AUTOPLAY_PLAYLISTS = "autoplay_playlists" diff --git a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt index 21a8ac25d..49215f71d 100644 --- a/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt +++ b/app/src/main/java/com/github/libretube/helpers/PlayerHelper.kt @@ -259,12 +259,6 @@ object PlayerHelper { "fit" ) - val alternativeVideoLayout: Boolean - get() = PreferenceHelper.getBoolean( - PreferenceKeys.ALTERNATIVE_PLAYER_LAYOUT, - false - ) - val autoInsertRelatedVideos: Boolean get() = PreferenceHelper.getBoolean( PreferenceKeys.QUEUE_AUTO_INSERT_RELATED, 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 cf3d5323d..05743bb11 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 @@ -54,7 +54,6 @@ import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.obj.ChapterSegment import com.github.libretube.api.obj.Message import com.github.libretube.api.obj.Segment -import com.github.libretube.api.obj.StreamItem import com.github.libretube.api.obj.Streams import com.github.libretube.api.obj.Subtitle import com.github.libretube.compat.PictureInPictureCompat @@ -492,9 +491,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { playOnBackground() } - binding.relatedRecView.layoutManager = VideosAdapter.getLayout(requireContext()) - - binding.alternativeTrendingRec.layoutManager = LinearLayoutManager( + binding.relatedRecView.layoutManager = LinearLayoutManager( context, LinearLayoutManager.HORIZONTAL, false @@ -982,7 +979,13 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { binding.relPlayerPip.setOnClickListener { PictureInPictureCompat.enterPictureInPictureMode(requireActivity(), pipParams) } - initializeRelatedVideos(streams.relatedStreams.filter { !it.title.isNullOrBlank() }) + + if (PlayerHelper.relatedStreamsEnabled) { + binding.relatedRecView.adapter = VideosAdapter( + streams.relatedStreams.filter { !it.title.isNullOrBlank() }.toMutableList(), + forceMode = VideosAdapter.Companion.ForceMode.RELATED + ) + } binding.playerChannel.setOnClickListener { val activity = view?.context as MainActivity @@ -1100,21 +1103,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { ) } - private fun initializeRelatedVideos(relatedStreams: List?) { - if (!PlayerHelper.relatedStreamsEnabled) return - - if (PlayerHelper.alternativeVideoLayout) { - binding.alternativeTrendingRec.adapter = VideosAdapter( - relatedStreams.orEmpty().toMutableList(), - forceMode = VideosAdapter.Companion.ForceMode.RELATED - ) - } else { - binding.relatedRecView.adapter = VideosAdapter( - relatedStreams.orEmpty().toMutableList() - ) - } - } - private suspend fun initializeHighlight(highlight: Segment) { val frameReceiver = OnlineTimeFrameReceiver(requireContext(), streams.previewFrames) val highlightStart = highlight.segmentStartAndEnd.first.toLong() diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index 346c770d0..2c330efc7 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -140,12 +140,6 @@ app:cornerRadius="16dp" /> - - - - - - + android:layout_marginHorizontal="12dp" /> diff --git a/app/src/main/res/xml/appearance_settings.xml b/app/src/main/res/xml/appearance_settings.xml index 61c8e6d0b..69e0ed9e3 100644 --- a/app/src/main/res/xml/appearance_settings.xml +++ b/app/src/main/res/xml/appearance_settings.xml @@ -85,13 +85,6 @@ app:key="alternative_videos_layout" app:title="@string/alternative_videos_layout" /> - -