mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
move double tap overlay to custom view
This commit is contained in:
parent
dd4ae9bd5d
commit
98c3df00ab
@ -42,6 +42,7 @@ import com.github.libretube.activities.hideKeyboard
|
||||
import com.github.libretube.adapters.ChaptersAdapter
|
||||
import com.github.libretube.adapters.CommentsAdapter
|
||||
import com.github.libretube.adapters.TrendingAdapter
|
||||
import com.github.libretube.databinding.DoubleTapOverlayBinding
|
||||
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
||||
import com.github.libretube.databinding.FragmentPlayerBinding
|
||||
import com.github.libretube.dialogs.AddtoPlaylistDialog
|
||||
@ -105,6 +106,7 @@ class PlayerFragment : Fragment() {
|
||||
private val TAG = "PlayerFragment"
|
||||
private lateinit var binding: FragmentPlayerBinding
|
||||
private lateinit var playerBinding: ExoStyledPlayerControlViewBinding
|
||||
private lateinit var doubleTapOverlayBinding: DoubleTapOverlayBinding
|
||||
|
||||
/**
|
||||
* video information
|
||||
@ -199,6 +201,8 @@ class PlayerFragment : Fragment() {
|
||||
): View {
|
||||
binding = FragmentPlayerBinding.inflate(layoutInflater, container, false)
|
||||
playerBinding = binding.player.binding
|
||||
doubleTapOverlayBinding = binding.doubleTapOverlay.binding
|
||||
|
||||
// Inflate the layout for this fragment
|
||||
return binding.root
|
||||
}
|
||||
@ -1061,8 +1065,8 @@ class PlayerFragment : Fragment() {
|
||||
private fun enableDoubleTapToSeek() {
|
||||
// set seek increment text
|
||||
val seekIncrementText = (seekIncrement / 1000).toString()
|
||||
binding.rewindTV.text = seekIncrementText
|
||||
binding.forwardTV.text = seekIncrementText
|
||||
doubleTapOverlayBinding.rewindTV.text = seekIncrementText
|
||||
doubleTapOverlayBinding.forwardTV.text = seekIncrementText
|
||||
|
||||
// enable rewind button
|
||||
val rewindGestureDetector = GestureDetector(
|
||||
@ -1080,7 +1084,7 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
)
|
||||
|
||||
binding.rewindFL.setOnTouchListener { view, event ->
|
||||
doubleTapOverlayBinding.rewindFL.setOnTouchListener { view, event ->
|
||||
rewindGestureDetector.onTouchEvent(event)
|
||||
view.performClick()
|
||||
true
|
||||
@ -1102,7 +1106,7 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
)
|
||||
|
||||
binding.forwardFL.setOnTouchListener { view, event ->
|
||||
doubleTapOverlayBinding.forwardFL.setOnTouchListener { view, event ->
|
||||
forwardGestureDetector.onTouchEvent(event)
|
||||
view.performClick()
|
||||
true
|
||||
@ -1113,7 +1117,7 @@ class PlayerFragment : Fragment() {
|
||||
exoPlayer.seekTo(exoPlayer.currentPosition - seekIncrement)
|
||||
|
||||
// show the rewind button
|
||||
binding.rewindBTN.apply {
|
||||
doubleTapOverlayBinding.rewindBTN.apply {
|
||||
visibility = View.VISIBLE
|
||||
// clear previous animation
|
||||
animate().rotation(0F).setDuration(0).start()
|
||||
@ -1137,7 +1141,7 @@ class PlayerFragment : Fragment() {
|
||||
exoPlayer.seekTo(exoPlayer.currentPosition + seekIncrement)
|
||||
|
||||
// show the forward button
|
||||
binding.forwardBTN.apply {
|
||||
doubleTapOverlayBinding.forwardBTN.apply {
|
||||
visibility = View.VISIBLE
|
||||
// clear previous animation
|
||||
animate().rotation(0F).setDuration(0).start()
|
||||
@ -1158,12 +1162,12 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
|
||||
private val hideForwardButtonRunnable = Runnable {
|
||||
binding.forwardBTN.apply {
|
||||
doubleTapOverlayBinding.forwardBTN.apply {
|
||||
visibility = View.GONE
|
||||
}
|
||||
}
|
||||
private val hideRewindButtonRunnable = Runnable {
|
||||
binding.rewindBTN.apply {
|
||||
doubleTapOverlayBinding.rewindBTN.apply {
|
||||
visibility = View.GONE
|
||||
}
|
||||
}
|
||||
@ -1515,12 +1519,10 @@ class PlayerFragment : Fragment() {
|
||||
// disable double tap to seek when the player is locked
|
||||
if (isLocked) {
|
||||
// enable fast forward and rewind by double tapping
|
||||
binding.forwardFL.visibility = View.VISIBLE
|
||||
binding.rewindFL.visibility = View.VISIBLE
|
||||
binding.doubleTapOverlay.visibility = View.VISIBLE
|
||||
} else {
|
||||
// disable fast forward and rewind by double tapping
|
||||
binding.forwardFL.visibility = View.GONE
|
||||
binding.rewindFL.visibility = View.GONE
|
||||
binding.doubleTapOverlay.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.github.libretube.views
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import com.github.libretube.databinding.DoubleTapOverlayBinding
|
||||
|
||||
class DoubleTapOverlay(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) : LinearLayout(context, attrs) {
|
||||
lateinit var binding: DoubleTapOverlayBinding
|
||||
|
||||
init {
|
||||
val layoutInflater = LayoutInflater.from(context)
|
||||
binding = DoubleTapOverlayBinding.inflate(layoutInflater, this, true)
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
|
||||
private val transitionListenerList = mutableListOf<TransitionListener?>()
|
||||
|
||||
init {
|
||||
addTransitionListener(object : MotionLayout.TransitionListener {
|
||||
addTransitionListener(object : TransitionListener {
|
||||
override fun onTransitionStarted(
|
||||
motionLayout: MotionLayout?,
|
||||
startId: Int,
|
||||
@ -50,7 +50,7 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
|
||||
}
|
||||
})
|
||||
|
||||
super.setTransitionListener(object : MotionLayout.TransitionListener {
|
||||
super.setTransitionListener(object : TransitionListener {
|
||||
override fun onTransitionStarted(
|
||||
motionLayout: MotionLayout?,
|
||||
startId: Int,
|
||||
|
84
app/src/main/res/layout/double_tap_overlay.xml
Normal file
84
app/src/main/res/layout/double_tap_overlay.xml
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginVertical="65dp"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<!-- double tap rewind btn -->
|
||||
<FrameLayout
|
||||
android:id="@+id/rewindFL"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight=".40">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/rewindBTN"
|
||||
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"
|
||||
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 -->
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
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=".40">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/forwardBTN"
|
||||
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"
|
||||
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>
|
@ -374,91 +374,17 @@
|
||||
app:layout_constraintTop_toTopOf="@id/main_container"
|
||||
app:show_buffering="when_playing" >
|
||||
|
||||
<!-- double tap to rewind/forward overlay -->
|
||||
<LinearLayout
|
||||
android:id="@+id/doubleTapOverlayLL"
|
||||
<com.github.libretube.views.DoubleTapOverlay
|
||||
android:id="@+id/doubleTapOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
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=".40">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/rewindBTN"
|
||||
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"
|
||||
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=".20" />
|
||||
|
||||
<!-- double tap forward btn -->
|
||||
<FrameLayout
|
||||
android:id="@+id/forwardFL"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight=".40">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/forwardBTN"
|
||||
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"
|
||||
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>
|
||||
app:layout_constraintBottom_toBottomOf="@id/main_container"
|
||||
app:layout_constraintStart_toStartOf="@id/main_container"
|
||||
app:layout_constraintTop_toTopOf="@id/main_container" />
|
||||
|
||||
</com.github.libretube.views.CustomExoPlayerView>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close_imageView"
|
||||
android:layout_width="wrap_content"
|
||||
|
Loading…
Reference in New Issue
Block a user