mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
bug fixes
This commit is contained in:
parent
1d5d254457
commit
50f8ae898c
@ -22,7 +22,7 @@ class BottomSheetAdapter(
|
||||
override fun onBindViewHolder(holder: BottomSheetViewHolder, position: Int) {
|
||||
val item = items[position]
|
||||
holder.binding.apply {
|
||||
title.text = item.title
|
||||
title.text = if (item.currentValue != null) "${item.title} (${item.currentValue})" else item.title
|
||||
drawable.setImageResource(item.drawable)
|
||||
|
||||
root.setOnClickListener {
|
||||
|
@ -19,7 +19,6 @@ import com.github.libretube.models.SubscriptionsViewModel
|
||||
import com.github.libretube.obj.BottomSheetItem
|
||||
import com.github.libretube.util.PreferenceHelper
|
||||
import com.github.libretube.views.BottomSheet
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class SubscriptionsFragment : BaseFragment() {
|
||||
private lateinit var binding: FragmentSubscriptionsBinding
|
||||
@ -112,7 +111,8 @@ class SubscriptionsFragment : BaseFragment() {
|
||||
val items = mutableListOf<BottomSheetItem>()
|
||||
sortOptions.forEach {
|
||||
items += BottomSheetItem(
|
||||
it, R.drawable.ic_arrow_down
|
||||
it,
|
||||
R.drawable.ic_arrow_down
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2,5 +2,6 @@ package com.github.libretube.obj
|
||||
|
||||
data class BottomSheetItem(
|
||||
val title: String,
|
||||
val drawable: Int
|
||||
val drawable: Int,
|
||||
val currentValue: String? = null
|
||||
)
|
||||
|
@ -99,7 +99,7 @@ internal class CustomExoPlayerView(
|
||||
|
||||
enableDoubleTapToSeek()
|
||||
|
||||
initializeAdvancedOptions()
|
||||
initializeAdvancedOptions(context)
|
||||
|
||||
// locking the player
|
||||
binding.lockPlayer.setOnClickListener {
|
||||
@ -139,50 +139,58 @@ internal class CustomExoPlayerView(
|
||||
return false
|
||||
}
|
||||
|
||||
private fun initializeAdvancedOptions() {
|
||||
private fun initializeAdvancedOptions(context: Context) {
|
||||
binding.toggleOptions.setOnClickListener {
|
||||
val bottomSheetFragment = BottomSheet().apply {
|
||||
val items = listOf(
|
||||
BottomSheetItem(
|
||||
context?.getString(R.string.player_autoplay) + if (autoplayEnabled) {
|
||||
context?.getString(R.string.enabled)
|
||||
context.getString(R.string.player_autoplay),
|
||||
R.drawable.ic_play,
|
||||
if (autoplayEnabled) {
|
||||
context.getString(R.string.enabled)
|
||||
} else {
|
||||
context?.getString(R.string.disabled)
|
||||
},
|
||||
R.drawable.ic_play
|
||||
context.getString(R.string.disabled)
|
||||
}
|
||||
),
|
||||
BottomSheetItem(
|
||||
context?.getString(R.string.playback_speed) + "${
|
||||
player?.playbackParameters?.speed.toString()
|
||||
context.getString(R.string.playback_speed),
|
||||
R.drawable.ic_speed,
|
||||
"${player?.playbackParameters?.speed
|
||||
.toString()
|
||||
.replace(".0", "")
|
||||
}x",
|
||||
R.drawable.ic_speed
|
||||
}x"
|
||||
),
|
||||
BottomSheetItem(
|
||||
context?.getString(R.string.repeat_mode) + if (player?.repeatMode == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE) {
|
||||
context?.getString(R.string.repeat_mode_none)
|
||||
context.getString(R.string.repeat_mode),
|
||||
R.drawable.ic_repeat,
|
||||
if (player?.repeatMode == RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE) {
|
||||
context.getString(R.string.repeat_mode_none)
|
||||
} else {
|
||||
context?.getString(R.string.repeat_mode_current)
|
||||
},
|
||||
R.drawable.ic_repeat
|
||||
context.getString(R.string.repeat_mode_current)
|
||||
}
|
||||
),
|
||||
BottomSheetItem(
|
||||
context?.getString(R.string.player_resize_mode) + when (resizeMode) {
|
||||
AspectRatioFrameLayout.RESIZE_MODE_FIT -> context?.getString(R.string.resize_mode_fit)
|
||||
AspectRatioFrameLayout.RESIZE_MODE_FILL -> context?.getString(R.string.resize_mode_fill)
|
||||
else -> context?.getString(R.string.resize_mode_zoom)
|
||||
},
|
||||
R.drawable.ic_aspect_ratio
|
||||
context.getString(R.string.player_resize_mode),
|
||||
R.drawable.ic_aspect_ratio,
|
||||
when (resizeMode) {
|
||||
AspectRatioFrameLayout.RESIZE_MODE_FIT -> context.getString(R.string.resize_mode_fit)
|
||||
AspectRatioFrameLayout.RESIZE_MODE_FILL -> context.getString(R.string.resize_mode_fill)
|
||||
else -> context.getString(R.string.resize_mode_zoom)
|
||||
}
|
||||
),
|
||||
BottomSheetItem(
|
||||
context?.getString(R.string.quality) + "${player?.videoSize?.height}p",
|
||||
R.drawable.ic_hd
|
||||
context.getString(R.string.quality),
|
||||
R.drawable.ic_hd,
|
||||
"${player?.videoSize?.height}p"
|
||||
),
|
||||
BottomSheetItem(
|
||||
context?.getString(R.string.captions) + if (trackSelector != null && trackSelector!!.parameters.preferredTextLanguages.isNotEmpty()) {
|
||||
context.getString(R.string.captions),
|
||||
R.drawable.ic_caption,
|
||||
if (trackSelector != null && trackSelector!!.parameters.preferredTextLanguages.isNotEmpty()) {
|
||||
trackSelector!!.parameters.preferredTextLanguages[0]
|
||||
} else context?.getString(R.string.none),
|
||||
R.drawable.ic_caption
|
||||
} else {
|
||||
context.getString(R.string.none)
|
||||
}
|
||||
)
|
||||
)
|
||||
setItems(items) { index ->
|
||||
@ -192,7 +200,7 @@ internal class CustomExoPlayerView(
|
||||
2 -> onRepeatModeClicked()
|
||||
3 -> onResizeModeClicked()
|
||||
4 -> playerOptionsInterface?.onQualityClicked()
|
||||
5 -> playerOptionsInterface?.onQualityClicked()
|
||||
5 -> playerOptionsInterface?.onCaptionClicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -359,8 +367,9 @@ internal class CustomExoPlayerView(
|
||||
)
|
||||
|
||||
val repeatModes = arrayOf(
|
||||
RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL,
|
||||
RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE
|
||||
RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE,
|
||||
RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL
|
||||
|
||||
)
|
||||
// repeat mode options dialog
|
||||
MaterialAlertDialogBuilder(context)
|
||||
|
Loading…
Reference in New Issue
Block a user