mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
rewrite double tap forward/rewind UI
This commit is contained in:
parent
599eafddf2
commit
e48da1109a
@ -250,7 +250,7 @@ class PlayerFragment : Fragment() {
|
||||
playbackSpeed = PreferenceHelper.getString(
|
||||
PreferenceKeys.PLAYBACK_SPEED,
|
||||
"1"
|
||||
)!!
|
||||
)!!.replace("F", "") // due to old way to handle it (with float)
|
||||
|
||||
fullscreenOrientationPref = PreferenceHelper.getString(
|
||||
PreferenceKeys.FULLSCREEN_ORIENTATION,
|
||||
@ -1061,21 +1061,17 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun enableDoubleTapToSeek() {
|
||||
val hideDoubleTapOverlayDelay = 700L
|
||||
// set seek increment text
|
||||
val seekIncrementText = (seekIncrement / 1000).toString()
|
||||
binding.rewindTV.text = seekIncrementText
|
||||
binding.forwardTV.text = seekIncrementText
|
||||
|
||||
// enable rewind button
|
||||
val rewindGestureDetector = GestureDetector(
|
||||
context,
|
||||
object : SimpleOnGestureListener() {
|
||||
override fun onDoubleTap(e: MotionEvent): Boolean {
|
||||
exoPlayer.seekTo(exoPlayer.currentPosition - seekIncrement)
|
||||
|
||||
// show the rewind button
|
||||
binding.rewindBTN.apply {
|
||||
visibility = View.VISIBLE
|
||||
removeCallbacks(hideRewindButtonRunnable)
|
||||
postDelayed(hideRewindButtonRunnable, hideDoubleTapOverlayDelay)
|
||||
}
|
||||
rewind()
|
||||
return super.onDoubleTap(e)
|
||||
}
|
||||
|
||||
@ -1097,14 +1093,7 @@ class PlayerFragment : Fragment() {
|
||||
context,
|
||||
object : SimpleOnGestureListener() {
|
||||
override fun onDoubleTap(e: MotionEvent): Boolean {
|
||||
exoPlayer.seekTo(exoPlayer.currentPosition + seekIncrement)
|
||||
|
||||
// show the forward button
|
||||
binding.forwardBTN.apply {
|
||||
visibility = View.VISIBLE
|
||||
removeCallbacks(hideForwardButtonRunnable)
|
||||
postDelayed(hideForwardButtonRunnable, hideDoubleTapOverlayDelay)
|
||||
}
|
||||
forward()
|
||||
return super.onDoubleTap(e)
|
||||
}
|
||||
|
||||
@ -1122,8 +1111,64 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private val hideForwardButtonRunnable = Runnable { binding.forwardBTN.visibility = View.GONE }
|
||||
private val hideRewindButtonRunnable = Runnable { binding.rewindBTN.visibility = View.GONE }
|
||||
private fun rewind() {
|
||||
exoPlayer.seekTo(exoPlayer.currentPosition - seekIncrement)
|
||||
|
||||
// show the rewind button
|
||||
binding.rewindBTN.apply {
|
||||
visibility = View.VISIBLE
|
||||
// clear previous animation
|
||||
animate().rotation(0F).setDuration(0).start()
|
||||
// start new animation
|
||||
animate()
|
||||
.rotation(-30F)
|
||||
.setDuration(100)
|
||||
.withEndAction {
|
||||
// reset the animation when finished
|
||||
animate().rotation(0F).setDuration(100).start()
|
||||
}
|
||||
.start()
|
||||
|
||||
removeCallbacks(hideRewindButtonRunnable)
|
||||
// start callback to hide the button
|
||||
postDelayed(hideRewindButtonRunnable, 700)
|
||||
}
|
||||
}
|
||||
|
||||
private fun forward() {
|
||||
exoPlayer.seekTo(exoPlayer.currentPosition + seekIncrement)
|
||||
|
||||
// show the forward button
|
||||
binding.forwardBTN.apply {
|
||||
visibility = View.VISIBLE
|
||||
// clear previous animation
|
||||
animate().rotation(0F).setDuration(0).start()
|
||||
// start new animation
|
||||
animate()
|
||||
.rotation(30F)
|
||||
.setDuration(100)
|
||||
.withEndAction {
|
||||
// reset the animation when finished
|
||||
animate().rotation(0F).setDuration(100).start()
|
||||
}
|
||||
.start()
|
||||
|
||||
// start callback to hide the button
|
||||
removeCallbacks(hideForwardButtonRunnable)
|
||||
postDelayed(hideForwardButtonRunnable, 700)
|
||||
}
|
||||
}
|
||||
|
||||
private val hideForwardButtonRunnable = Runnable {
|
||||
binding.forwardBTN.apply {
|
||||
visibility = View.GONE
|
||||
}
|
||||
}
|
||||
private val hideRewindButtonRunnable = Runnable {
|
||||
binding.rewindBTN.apply {
|
||||
visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
// enable seek bar preview
|
||||
private fun enableSeekbarPreview() {
|
||||
|
@ -1,10 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:width="40dp"
|
||||
android:height="40dp"
|
||||
android:tint="@android:color/white"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M4,18l8.5,-6L4,6v12zM13,6v12l8.5,-6L13,6z" />
|
||||
android:pathData="M18,13c0,3.31 -2.69,6 -6,6s-6,-2.69 -6,-6s2.69,-6 6,-6v4l5,-5l-5,-5v4c-4.42,0 -8,3.58 -8,8c0,4.42 3.58,8 8,8c4.42,0 8,-3.58 8,-8H18z" />
|
||||
</vector>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:width="40dp"
|
||||
android:height="40dp"
|
||||
android:tint="@android:color/white"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M11,18L11,6l-8.5,6 8.5,6zM11.5,12l8.5,6L20,6l-8.5,6z" />
|
||||
android:pathData="m6,13c0,3.31 2.69,6 6,6 3.31,0 6,-2.69 6,-6 0,-3.31 -2.69,-6 -6,-6v4L7,6 12,1v4c4.42,0 8,3.58 8,8 0,4.42 -3.58,8 -8,8 -4.42,0 -8,-3.58 -8,-8z"
|
||||
android:fillColor="@android:color/white"/>
|
||||
</vector>
|
||||
|
@ -379,51 +379,80 @@
|
||||
android:id="@+id/doubleTapOverlayLL"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="70dp"
|
||||
android:layout_marginBottom="60dp">
|
||||
android:layout_marginVertical="65dp">
|
||||
|
||||
<!-- double tap rewind btn -->
|
||||
<FrameLayout
|
||||
android:id="@+id/rewindFL"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight=".35">
|
||||
android:layout_weight=".40">
|
||||
|
||||
<ImageButton
|
||||
<FrameLayout
|
||||
android:id="@+id/rewindBTN"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:clickable="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="30dp"
|
||||
android:visibility="invisible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_rewind"
|
||||
android:visibility="invisible"
|
||||
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="11sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<!-- place holder for the center controls -->
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight=".30" />
|
||||
android:layout_weight=".20" />
|
||||
|
||||
<!-- double tap forward btn -->
|
||||
<FrameLayout
|
||||
android:id="@+id/forwardFL"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight=".35">
|
||||
android:layout_weight=".40">
|
||||
|
||||
<ImageButton
|
||||
<FrameLayout
|
||||
android:id="@+id/forwardBTN"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackgroundBorderless"
|
||||
android:clickable="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:visibility="invisible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_forward"
|
||||
android:visibility="invisible"
|
||||
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="11sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user