Merge pull request #2268 from Bnyro/master

Improve the behavior for expanding the mini player
This commit is contained in:
Bnyro 2022-12-06 12:27:28 +01:00 committed by GitHub
commit 700fe75770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 21 deletions

View File

@ -18,7 +18,6 @@ import android.text.util.Linkify
import android.util.Base64
import android.util.Log
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
@ -276,18 +275,6 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
binding.playerMotionLayout.progress = 1.toFloat()
binding.playerMotionLayout.transitionToStart()
// quitting miniPlayer on single click
binding.titleTextView.setOnTouchListener { view, motionEvent ->
view.onTouchEvent(motionEvent)
if (motionEvent.action == MotionEvent.ACTION_UP) view.performClick()
binding.root.onTouchEvent(motionEvent)
}
binding.titleTextView.setOnClickListener {
binding.playerMotionLayout.setTransitionDuration(300)
binding.playerMotionLayout.transitionToStart()
}
if (usePiP()) activity?.setPictureInPictureParams(getPipParams())
if (SDK_INT < Build.VERSION_CODES.O) {

View File

@ -81,18 +81,20 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
transitionListenerList += listener
}
private val gestureDetector = GestureDetector(
context,
object : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
transitionToEnd()
return false
}
private inner class Listener : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapUp(e: MotionEvent): Boolean {
setTransitionDuration(200)
transitionToStart()
return true
}
)
}
val gestureDetector = GestureDetector(context, Listener())
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
gestureDetector.onTouchEvent(event)
// gestureDetector.onTouchEvent(event)
when (event.actionMasked) {
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {