mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
improve controller behavior
This commit is contained in:
parent
98c3df00ab
commit
77abc8eef6
@ -1078,7 +1078,7 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
|
||||
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
|
||||
binding.player.performClick()
|
||||
toggleController()
|
||||
return super.onSingleTapConfirmed(e)
|
||||
}
|
||||
}
|
||||
@ -1100,7 +1100,7 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
|
||||
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
|
||||
binding.player.performClick()
|
||||
toggleController()
|
||||
return super.onSingleTapConfirmed(e)
|
||||
}
|
||||
}
|
||||
@ -1172,6 +1172,11 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleController() {
|
||||
if (exoPlayerView.isControllerFullyVisible) exoPlayerView.hideController()
|
||||
else exoPlayerView.showController()
|
||||
}
|
||||
|
||||
// enable seek bar preview
|
||||
private fun enableSeekbarPreview() {
|
||||
playerBinding.exoProgress.addListener(object : TimeBar.OnScrubListener {
|
||||
|
@ -5,6 +5,7 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
|
||||
@ -12,12 +13,35 @@ internal class CustomExoPlayerView(
|
||||
context: Context,
|
||||
attributeSet: AttributeSet? = null
|
||||
) : StyledPlayerView(context, attributeSet) {
|
||||
val TAG = "CustomExoPlayerView"
|
||||
val binding: ExoStyledPlayerControlViewBinding = ExoStyledPlayerControlViewBinding.bind(this)
|
||||
|
||||
init {
|
||||
setControllerVisibilityListener {
|
||||
// hide the advanced options
|
||||
binding.toggleOptions.animate().rotationX(0F).setDuration(0).start()
|
||||
binding.advancedOptions.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
override fun hideController() {
|
||||
super.hideController()
|
||||
binding.toggleOptions.animate().rotationX(0F).setDuration(1000).start()
|
||||
binding.advancedOptions.visibility = View.GONE
|
||||
setDoubleTapOverlayLayoutParams(0)
|
||||
}
|
||||
|
||||
override fun showController() {
|
||||
setDoubleTapOverlayLayoutParams(90)
|
||||
super.showController()
|
||||
}
|
||||
|
||||
// set the top and bottom margin of the double tap overlay
|
||||
private fun setDoubleTapOverlayLayoutParams(margin: Int) {
|
||||
val dpMargin = resources?.displayMetrics?.density!!.toInt() * margin
|
||||
val doubleTapOverlay = binding.root.findViewById<DoubleTapOverlay>(R.id.doubleTapOverlay)
|
||||
val params = doubleTapOverlay.layoutParams as MarginLayoutParams
|
||||
params.topMargin = dpMargin
|
||||
params.bottomMargin = dpMargin
|
||||
doubleTapOverlay.layoutParams = params
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
@ -10,7 +10,7 @@ class DoubleTapOverlay(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) : LinearLayout(context, attrs) {
|
||||
lateinit var binding: DoubleTapOverlayBinding
|
||||
var binding: DoubleTapOverlayBinding
|
||||
|
||||
init {
|
||||
val layoutInflater = LayoutInflater.from(context)
|
||||
|
@ -4,7 +4,6 @@
|
||||
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 -->
|
||||
|
@ -377,14 +377,12 @@
|
||||
<com.github.libretube.views.DoubleTapOverlay
|
||||
android:id="@+id/doubleTapOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="@id/main_container"
|
||||
app:layout_constraintStart_toStartOf="@id/main_container"
|
||||
app:layout_constraintTop_toTopOf="@id/main_container" />
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</com.github.libretube.views.CustomExoPlayerView>
|
||||
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close_imageView"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -66,6 +66,7 @@
|
||||
motion:layout_constraintBottom_toBottomOf="@id/main_container"
|
||||
motion:layout_constraintStart_toStartOf="@id/main_container"
|
||||
motion:layout_constraintTop_toTopOf="@id/main_container" />
|
||||
<Constraint android:id="@+id/doubleTapOverlay" />
|
||||
</ConstraintSet>
|
||||
|
||||
<ConstraintSet android:id="@+id/end">
|
||||
|
Loading…
x
Reference in New Issue
Block a user