mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40: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 PICTURE_IN_PICTURE = "picture_in_picture"
|
||||||
const val PLAYER_RESIZE_MODE = "player_resize_mode"
|
const val PLAYER_RESIZE_MODE = "player_resize_mode"
|
||||||
const val DEARROW = "dearrow"
|
const val DEARROW = "dearrow"
|
||||||
const val ALTERNATIVE_PLAYER_LAYOUT = "alternative_player_layout"
|
|
||||||
const val USE_HLS_OVER_DASH = "use_hls"
|
const val USE_HLS_OVER_DASH = "use_hls"
|
||||||
const val QUEUE_AUTO_INSERT_RELATED = "queue_insert_related_videos"
|
const val QUEUE_AUTO_INSERT_RELATED = "queue_insert_related_videos"
|
||||||
const val AUTOPLAY_PLAYLISTS = "autoplay_playlists"
|
const val AUTOPLAY_PLAYLISTS = "autoplay_playlists"
|
||||||
|
@ -259,12 +259,6 @@ object PlayerHelper {
|
|||||||
"fit"
|
"fit"
|
||||||
)
|
)
|
||||||
|
|
||||||
val alternativeVideoLayout: Boolean
|
|
||||||
get() = PreferenceHelper.getBoolean(
|
|
||||||
PreferenceKeys.ALTERNATIVE_PLAYER_LAYOUT,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
val autoInsertRelatedVideos: Boolean
|
val autoInsertRelatedVideos: Boolean
|
||||||
get() = PreferenceHelper.getBoolean(
|
get() = PreferenceHelper.getBoolean(
|
||||||
PreferenceKeys.QUEUE_AUTO_INSERT_RELATED,
|
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.ChapterSegment
|
||||||
import com.github.libretube.api.obj.Message
|
import com.github.libretube.api.obj.Message
|
||||||
import com.github.libretube.api.obj.Segment
|
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.Streams
|
||||||
import com.github.libretube.api.obj.Subtitle
|
import com.github.libretube.api.obj.Subtitle
|
||||||
import com.github.libretube.compat.PictureInPictureCompat
|
import com.github.libretube.compat.PictureInPictureCompat
|
||||||
@ -492,9 +491,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
playOnBackground()
|
playOnBackground()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.relatedRecView.layoutManager = VideosAdapter.getLayout(requireContext())
|
binding.relatedRecView.layoutManager = LinearLayoutManager(
|
||||||
|
|
||||||
binding.alternativeTrendingRec.layoutManager = LinearLayoutManager(
|
|
||||||
context,
|
context,
|
||||||
LinearLayoutManager.HORIZONTAL,
|
LinearLayoutManager.HORIZONTAL,
|
||||||
false
|
false
|
||||||
@ -982,7 +979,13 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
binding.relPlayerPip.setOnClickListener {
|
binding.relPlayerPip.setOnClickListener {
|
||||||
PictureInPictureCompat.enterPictureInPictureMode(requireActivity(), pipParams)
|
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 {
|
binding.playerChannel.setOnClickListener {
|
||||||
val activity = view?.context as MainActivity
|
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) {
|
private suspend fun initializeHighlight(highlight: Segment) {
|
||||||
val frameReceiver = OnlineTimeFrameReceiver(requireContext(), streams.previewFrames)
|
val frameReceiver = OnlineTimeFrameReceiver(requireContext(), streams.previewFrames)
|
||||||
val highlightStart = highlight.segmentStartAndEnd.first.toLong()
|
val highlightStart = highlight.segmentStartAndEnd.first.toLong()
|
||||||
|
@ -140,12 +140,6 @@
|
|||||||
app:cornerRadius="16dp" />
|
app:cornerRadius="16dp" />
|
||||||
</LinearLayout>
|
</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
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/comments_toggle"
|
android:id="@+id/comments_toggle"
|
||||||
style="@style/Widget.Material3.CardView.Elevated"
|
style="@style/Widget.Material3.CardView.Elevated"
|
||||||
@ -166,22 +160,11 @@
|
|||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
<RelativeLayout
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/related_rec_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:animateLayoutChanges="true"
|
android:layout_marginHorizontal="12dp" />
|
||||||
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>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -85,13 +85,6 @@
|
|||||||
app:key="alternative_videos_layout"
|
app:key="alternative_videos_layout"
|
||||||
app:title="@string/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
|
<ListPreference
|
||||||
android:icon="@drawable/ic_grid"
|
android:icon="@drawable/ic_grid"
|
||||||
app:defaultValue="@integer/grid_items"
|
app:defaultValue="@integer/grid_items"
|
||||||
|
Loading…
Reference in New Issue
Block a user