mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-29 09:39:03 +03:00
Add option to lock controls in mpv player (#491)
This commit is contained in:
parent
895e822e3d
commit
c15ff1c564
3 changed files with 36 additions and 2 deletions
|
@ -44,6 +44,7 @@ class Gestures(
|
|||
}
|
||||
|
||||
override fun onDoubleTap(e: MotionEvent): Boolean {
|
||||
if (activity.isLocked) return false
|
||||
if (e.y < height * 0.05F || e.y > height * 0.95F) return false
|
||||
val interval = preferences.skipLengthPreference()
|
||||
when {
|
||||
|
@ -60,6 +61,7 @@ class Gestures(
|
|||
distanceX: Float,
|
||||
distanceY: Float
|
||||
): Boolean {
|
||||
if (activity.isLocked) return false
|
||||
if (e1.y < height * 0.05F || e1.y > height * 0.95F) return false
|
||||
val dx = e1.x - e2.x
|
||||
val dy = e1.y - e2.y
|
||||
|
|
|
@ -80,6 +80,8 @@ class PlayerActivity :
|
|||
private var width = 0
|
||||
private var height = 0
|
||||
|
||||
internal var isLocked = false
|
||||
|
||||
private var audioFocusRestore: () -> Unit = {}
|
||||
|
||||
private val audioFocusChangeListener = AudioManager.OnAudioFocusChangeListener { type ->
|
||||
|
@ -247,6 +249,12 @@ class PlayerActivity :
|
|||
gestures.onTouch(v, event)
|
||||
mDetector.onTouchEvent(event)
|
||||
}
|
||||
|
||||
// Lock and Unlock controls
|
||||
binding.lockControls.setOnClickListener { isLocked = true; toggleControls() }
|
||||
binding.unlockControls.setOnClickListener { isLocked = false; toggleControls() }
|
||||
|
||||
// Cycle, Long click controls
|
||||
binding.cycleAudioBtn.setOnLongClickListener { pickAudio(); true }
|
||||
binding.cycleSpeedBtn.setOnLongClickListener { pickSpeed(); true }
|
||||
binding.cycleSubsBtn.setOnLongClickListener { pickSub(); true }
|
||||
|
@ -271,7 +279,13 @@ class PlayerActivity :
|
|||
}
|
||||
|
||||
fun toggleControls() {
|
||||
binding.controls.isVisible = !binding.controls.isVisible
|
||||
if (isLocked) {
|
||||
binding.unlockControls.isVisible = !binding.unlockControls.isVisible
|
||||
binding.controls.isVisible = false
|
||||
} else {
|
||||
binding.unlockControls.isVisible = false
|
||||
binding.controls.isVisible = !binding.controls.isVisible
|
||||
}
|
||||
}
|
||||
|
||||
private fun pickAudio() {
|
||||
|
|
|
@ -13,6 +13,16 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ImageButton
|
||||
android:layout_marginHorizontal="5dp"
|
||||
android:id="@+id/unlockControls"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/ic_lock_open_24dp"
|
||||
android:visibility="gone"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
app:tint="?attr/colorOnPrimarySurface" />
|
||||
|
||||
<!-- This LinearLayout only exists to prevent clipping -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -180,7 +190,15 @@
|
|||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<ImageButton
|
||||
android:layout_marginHorizontal="5dp"
|
||||
android:id="@+id/lockControls"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:onClick="cycleAudio"
|
||||
android:src="@drawable/ic_lock_24dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
app:tint="?attr/colorOnPrimarySurface" />
|
||||
|
||||
<ImageButton
|
||||
android:layout_marginHorizontal="5dp"
|
||||
|
|
Loading…
Reference in a new issue