mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Merge pull request #5031 from Bnyro/master
refactor: enabled alternative player layout by default and remove option
This commit is contained in:
commit
40bb01b15d
@ -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"
|
||||
|
@ -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,
|
||||
|
@ -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<StreamItem>?) {
|
||||
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()
|
||||
|
@ -140,12 +140,6 @@
|
||||
app:cornerRadius="16dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/alternativeTrendingRec"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="12dp" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/comments_toggle"
|
||||
style="@style/Widget.Material3.CardView.Elevated"
|
||||
@ -166,22 +160,11 @@
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/related_rec_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true"
|
||||
android:descendantFocusability="blocksDescendants">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/related_rec_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:nestedScrollingEnabled="false" />
|
||||
</RelativeLayout>
|
||||
android:layout_marginHorizontal="12dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -85,13 +85,6 @@
|
||||
app:key="alternative_videos_layout"
|
||||
app:title="@string/alternative_videos_layout" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:icon="@drawable/ic_list"
|
||||
app:defaultValue="false"
|
||||
app:key="alternative_player_layout"
|
||||
app:summary="@string/alternative_player_layout_summary"
|
||||
app:title="@string/alternative_player_layout" />
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_grid"
|
||||
app:defaultValue="@integer/grid_items"
|
||||
|
Loading…
Reference in New Issue
Block a user