mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Merge pull request #2118 from Bnyro/master
Option to disable double tap to seek
This commit is contained in:
commit
a6f1027fff
@ -86,6 +86,7 @@ object PreferenceKeys {
|
||||
const val PLAYER_SWIPE_CONTROLS = "player_swipe_controls"
|
||||
const val PLAYER_SCREEN_BRIGHTNESS = "player_screen_brightness"
|
||||
const val CAPTIONS_SIZE = "captions_size"
|
||||
const val DOUBLE_TAP_TO_SEEK = "double_tap_seek"
|
||||
|
||||
/**
|
||||
* Background mode
|
||||
|
@ -92,7 +92,8 @@ internal class CustomExoPlayerView(
|
||||
// Set touch listner for tap and swipe gestures.
|
||||
setOnTouchListener(playerGestureController)
|
||||
initializeGestureProgress()
|
||||
enableDoubleTapToSeek()
|
||||
|
||||
initRewindAndForward()
|
||||
|
||||
initializeAdvancedOptions(context)
|
||||
|
||||
@ -138,6 +139,29 @@ internal class CustomExoPlayerView(
|
||||
return false
|
||||
}
|
||||
|
||||
private fun initRewindAndForward() {
|
||||
val seekIncrementText = (PlayerHelper.seekIncrement / 1000).toString()
|
||||
listOf(
|
||||
doubleTapOverlayBinding?.rewindTV,
|
||||
doubleTapOverlayBinding?.forwardTV,
|
||||
binding.forwardTV,
|
||||
binding.rewindTV
|
||||
).forEach {
|
||||
it?.text = seekIncrementText
|
||||
}
|
||||
binding.forwardBTN.setOnClickListener {
|
||||
player?.seekTo(player!!.currentPosition + PlayerHelper.seekIncrement)
|
||||
}
|
||||
binding.rewindBTN.setOnClickListener {
|
||||
player?.seekTo(player!!.currentPosition - PlayerHelper.seekIncrement)
|
||||
}
|
||||
if (PlayerHelper.doubleTapToSeek) return
|
||||
|
||||
listOf(binding.forwardBTN, binding.rewindBTN).forEach {
|
||||
it.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
private fun initializeAdvancedOptions(context: Context) {
|
||||
binding.toggleOptions.setOnClickListener {
|
||||
val items = mutableListOf(
|
||||
@ -254,13 +278,6 @@ internal class CustomExoPlayerView(
|
||||
playerGestureController.isEnabled = isLocked
|
||||
}
|
||||
|
||||
private fun enableDoubleTapToSeek() {
|
||||
// set seek increment text
|
||||
val seekIncrementText = (PlayerHelper.seekIncrement / 1000).toString()
|
||||
doubleTapOverlayBinding?.rewindTV?.text = seekIncrementText
|
||||
doubleTapOverlayBinding?.forwardTV?.text = seekIncrementText
|
||||
}
|
||||
|
||||
private fun rewind() {
|
||||
player?.seekTo((player?.currentPosition ?: 0L) - PlayerHelper.seekIncrement)
|
||||
|
||||
@ -322,7 +339,8 @@ internal class CustomExoPlayerView(
|
||||
|
||||
private fun initializeGestureProgress() {
|
||||
gestureViewBinding.brightnessProgressBar.let { bar ->
|
||||
bar.progress = brightnessHelper.getBrightnessWithScale(bar.max.toFloat(), saved = true).toInt()
|
||||
bar.progress =
|
||||
brightnessHelper.getBrightnessWithScale(bar.max.toFloat(), saved = true).toInt()
|
||||
}
|
||||
gestureViewBinding.volumeProgressBar.let { bar ->
|
||||
bar.progress = audioHelper.getVolumeWithScale(bar.max)
|
||||
@ -469,10 +487,12 @@ internal class CustomExoPlayerView(
|
||||
}
|
||||
|
||||
override fun onDoubleTapLeftScreen() {
|
||||
if (!PlayerHelper.doubleTapToSeek) return
|
||||
rewind()
|
||||
}
|
||||
|
||||
override fun onDoubleTapRightScreen() {
|
||||
if (!PlayerHelper.doubleTapToSeek) return
|
||||
forward()
|
||||
}
|
||||
|
||||
|
@ -306,6 +306,12 @@ object PlayerHelper {
|
||||
"18"
|
||||
).toFloat()
|
||||
|
||||
val doubleTapToSeek: Boolean
|
||||
get() = PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.DOUBLE_TAP_TO_SEEK,
|
||||
true
|
||||
)
|
||||
|
||||
fun getDefaultResolution(context: Context): String {
|
||||
return if (NetworkHelper.isNetworkMobile(context)) {
|
||||
PreferenceHelper.getString(
|
||||
|
@ -237,7 +237,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@android:color/transparent"
|
||||
android:clipToPadding="false"
|
||||
android:gravity="center"
|
||||
android:padding="20dp">
|
||||
|
||||
@ -249,12 +248,69 @@
|
||||
android:visibility="invisible"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/rewindBTN"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:scaleX="0.8"
|
||||
android:scaleY="0.8"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_rewind"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rewindTV"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@id/exo_play_pause"
|
||||
style="@style/ExoStyledControls.Button.Center.PlayPause"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/forwardBTN"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:scaleX="0.8"
|
||||
android:scaleY="0.8"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_forward"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/forwardTV"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/skip_next"
|
||||
style="@style/PlayerControlCenter"
|
||||
|
@ -399,6 +399,8 @@
|
||||
<string name="comments_disabled">Comments are disabled by the uploader.</string>
|
||||
<string name="no_comments_available">This video has no comments available.</string>
|
||||
<string name="captions_size">Captions size</string>
|
||||
<string name="double_tap_seek">Double tap to seek</string>
|
||||
<string name="double_tap_seek_summary">Tap twice at the left or right to rewind or forward the player position.</string>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
|
@ -18,6 +18,13 @@
|
||||
app:key="skip_buttons"
|
||||
app:title="@string/skip_buttons" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_skip"
|
||||
android:summary="@string/double_tap_seek_summary"
|
||||
app:key="double_tap_seek"
|
||||
app:title="@string/double_tap_seek" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_window"
|
||||
@ -27,7 +34,7 @@
|
||||
<SwitchPreferenceCompat
|
||||
android:icon="@drawable/ic_rotating_circle"
|
||||
android:summary="@string/autoRotatePlayer_summary"
|
||||
app:defaultValue="false"
|
||||
app:defaultValue="true"
|
||||
app:key="auto_fullscreen"
|
||||
app:title="@string/autoRotatePlayer" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user