mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +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.ChaptersAdapter
|
||||||
import com.github.libretube.adapters.CommentsAdapter
|
import com.github.libretube.adapters.CommentsAdapter
|
||||||
import com.github.libretube.adapters.TrendingAdapter
|
import com.github.libretube.adapters.TrendingAdapter
|
||||||
|
import com.github.libretube.databinding.DoubleTapOverlayBinding
|
||||||
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
||||||
import com.github.libretube.databinding.FragmentPlayerBinding
|
import com.github.libretube.databinding.FragmentPlayerBinding
|
||||||
import com.github.libretube.dialogs.AddtoPlaylistDialog
|
import com.github.libretube.dialogs.AddtoPlaylistDialog
|
||||||
@ -105,6 +106,7 @@ class PlayerFragment : Fragment() {
|
|||||||
private val TAG = "PlayerFragment"
|
private val TAG = "PlayerFragment"
|
||||||
private lateinit var binding: FragmentPlayerBinding
|
private lateinit var binding: FragmentPlayerBinding
|
||||||
private lateinit var playerBinding: ExoStyledPlayerControlViewBinding
|
private lateinit var playerBinding: ExoStyledPlayerControlViewBinding
|
||||||
|
private lateinit var doubleTapOverlayBinding: DoubleTapOverlayBinding
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* video information
|
* video information
|
||||||
@ -199,6 +201,8 @@ class PlayerFragment : Fragment() {
|
|||||||
): View {
|
): View {
|
||||||
binding = FragmentPlayerBinding.inflate(layoutInflater, container, false)
|
binding = FragmentPlayerBinding.inflate(layoutInflater, container, false)
|
||||||
playerBinding = binding.player.binding
|
playerBinding = binding.player.binding
|
||||||
|
doubleTapOverlayBinding = binding.doubleTapOverlay.binding
|
||||||
|
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
@ -1061,8 +1065,8 @@ class PlayerFragment : Fragment() {
|
|||||||
private fun enableDoubleTapToSeek() {
|
private fun enableDoubleTapToSeek() {
|
||||||
// set seek increment text
|
// set seek increment text
|
||||||
val seekIncrementText = (seekIncrement / 1000).toString()
|
val seekIncrementText = (seekIncrement / 1000).toString()
|
||||||
binding.rewindTV.text = seekIncrementText
|
doubleTapOverlayBinding.rewindTV.text = seekIncrementText
|
||||||
binding.forwardTV.text = seekIncrementText
|
doubleTapOverlayBinding.forwardTV.text = seekIncrementText
|
||||||
|
|
||||||
// enable rewind button
|
// enable rewind button
|
||||||
val rewindGestureDetector = GestureDetector(
|
val rewindGestureDetector = GestureDetector(
|
||||||
@ -1080,7 +1084,7 @@ class PlayerFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.rewindFL.setOnTouchListener { view, event ->
|
doubleTapOverlayBinding.rewindFL.setOnTouchListener { view, event ->
|
||||||
rewindGestureDetector.onTouchEvent(event)
|
rewindGestureDetector.onTouchEvent(event)
|
||||||
view.performClick()
|
view.performClick()
|
||||||
true
|
true
|
||||||
@ -1102,7 +1106,7 @@ class PlayerFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
binding.forwardFL.setOnTouchListener { view, event ->
|
doubleTapOverlayBinding.forwardFL.setOnTouchListener { view, event ->
|
||||||
forwardGestureDetector.onTouchEvent(event)
|
forwardGestureDetector.onTouchEvent(event)
|
||||||
view.performClick()
|
view.performClick()
|
||||||
true
|
true
|
||||||
@ -1113,7 +1117,7 @@ class PlayerFragment : Fragment() {
|
|||||||
exoPlayer.seekTo(exoPlayer.currentPosition - seekIncrement)
|
exoPlayer.seekTo(exoPlayer.currentPosition - seekIncrement)
|
||||||
|
|
||||||
// show the rewind button
|
// show the rewind button
|
||||||
binding.rewindBTN.apply {
|
doubleTapOverlayBinding.rewindBTN.apply {
|
||||||
visibility = View.VISIBLE
|
visibility = View.VISIBLE
|
||||||
// clear previous animation
|
// clear previous animation
|
||||||
animate().rotation(0F).setDuration(0).start()
|
animate().rotation(0F).setDuration(0).start()
|
||||||
@ -1137,7 +1141,7 @@ class PlayerFragment : Fragment() {
|
|||||||
exoPlayer.seekTo(exoPlayer.currentPosition + seekIncrement)
|
exoPlayer.seekTo(exoPlayer.currentPosition + seekIncrement)
|
||||||
|
|
||||||
// show the forward button
|
// show the forward button
|
||||||
binding.forwardBTN.apply {
|
doubleTapOverlayBinding.forwardBTN.apply {
|
||||||
visibility = View.VISIBLE
|
visibility = View.VISIBLE
|
||||||
// clear previous animation
|
// clear previous animation
|
||||||
animate().rotation(0F).setDuration(0).start()
|
animate().rotation(0F).setDuration(0).start()
|
||||||
@ -1158,12 +1162,12 @@ class PlayerFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val hideForwardButtonRunnable = Runnable {
|
private val hideForwardButtonRunnable = Runnable {
|
||||||
binding.forwardBTN.apply {
|
doubleTapOverlayBinding.forwardBTN.apply {
|
||||||
visibility = View.GONE
|
visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private val hideRewindButtonRunnable = Runnable {
|
private val hideRewindButtonRunnable = Runnable {
|
||||||
binding.rewindBTN.apply {
|
doubleTapOverlayBinding.rewindBTN.apply {
|
||||||
visibility = View.GONE
|
visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1515,12 +1519,10 @@ class PlayerFragment : Fragment() {
|
|||||||
// disable double tap to seek when the player is locked
|
// disable double tap to seek when the player is locked
|
||||||
if (isLocked) {
|
if (isLocked) {
|
||||||
// enable fast forward and rewind by double tapping
|
// enable fast forward and rewind by double tapping
|
||||||
binding.forwardFL.visibility = View.VISIBLE
|
binding.doubleTapOverlay.visibility = View.VISIBLE
|
||||||
binding.rewindFL.visibility = View.VISIBLE
|
|
||||||
} else {
|
} else {
|
||||||
// disable fast forward and rewind by double tapping
|
// disable fast forward and rewind by double tapping
|
||||||
binding.forwardFL.visibility = View.GONE
|
binding.doubleTapOverlay.visibility = View.GONE
|
||||||
binding.rewindFL.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?>()
|
private val transitionListenerList = mutableListOf<TransitionListener?>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
addTransitionListener(object : MotionLayout.TransitionListener {
|
addTransitionListener(object : TransitionListener {
|
||||||
override fun onTransitionStarted(
|
override fun onTransitionStarted(
|
||||||
motionLayout: MotionLayout?,
|
motionLayout: MotionLayout?,
|
||||||
startId: Int,
|
startId: Int,
|
||||||
@ -50,7 +50,7 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
super.setTransitionListener(object : MotionLayout.TransitionListener {
|
super.setTransitionListener(object : TransitionListener {
|
||||||
override fun onTransitionStarted(
|
override fun onTransitionStarted(
|
||||||
motionLayout: MotionLayout?,
|
motionLayout: MotionLayout?,
|
||||||
startId: Int,
|
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>
|
@ -372,93 +372,19 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="@id/main_container"
|
app:layout_constraintBottom_toBottomOf="@id/main_container"
|
||||||
app:layout_constraintStart_toStartOf="@id/main_container"
|
app:layout_constraintStart_toStartOf="@id/main_container"
|
||||||
app:layout_constraintTop_toTopOf="@id/main_container"
|
app:layout_constraintTop_toTopOf="@id/main_container"
|
||||||
app:show_buffering="when_playing">
|
app:show_buffering="when_playing" >
|
||||||
|
|
||||||
<!-- double tap to rewind/forward overlay -->
|
<com.github.libretube.views.DoubleTapOverlay
|
||||||
<LinearLayout
|
android:id="@+id/doubleTapOverlay"
|
||||||
android:id="@+id/doubleTapOverlayLL"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginVertical="65dp">
|
app:layout_constraintBottom_toBottomOf="@id/main_container"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/main_container"
|
||||||
<!-- double tap rewind btn -->
|
app:layout_constraintTop_toTopOf="@id/main_container" />
|
||||||
<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>
|
|
||||||
|
|
||||||
</com.github.libretube.views.CustomExoPlayerView>
|
</com.github.libretube.views.CustomExoPlayerView>
|
||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/close_imageView"
|
android:id="@+id/close_imageView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user