Merge pull request #3523 from Bnyro/master

Separate swipe gestures and fullscreen gestures
This commit is contained in:
Bnyro 2023-04-10 14:53:52 +02:00 committed by GitHub
commit f517d8492f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 12 deletions

View File

@ -96,6 +96,7 @@ object PreferenceKeys {
const val LBRY_HLS = "lbry_hls"
const val AUTO_FULLSCREEN_SHORTS = "auto_fullscreen_shorts"
const val PLAY_AUTOMATICALLY = "play_automatically"
const val FULLSCREEN_GESTURES = "fullscreen_gestures"
/**
* Background mode

View File

@ -322,6 +322,12 @@ object PlayerHelper {
true
)
val fullscreenGesturesEnabled: Boolean
get() = PreferenceHelper.getBoolean(
PreferenceKeys.FULLSCREEN_GESTURES,
false
)
val pinchGestureEnabled: Boolean
get() = PreferenceHelper.getBoolean(
PreferenceKeys.PLAYER_PINCH_CONTROL,

View File

@ -322,14 +322,12 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
}
})
if (PlayerHelper.swipeGestureEnabled) {
binding.playerMotionLayout.addSwipeUpListener {
if (this::streams.isInitialized) {
if (this::streams.isInitialized && PlayerHelper.fullscreenGesturesEnabled) {
binding.player.hideController()
setFullscreen()
}
}
}
binding.playerMotionLayout.progress = 1.toFloat()
binding.playerMotionLayout.transitionToStart()

View File

@ -691,16 +691,15 @@ internal class CustomExoPlayerView(
}
override fun onSwipeCenterScreen(distanceY: Float) {
if (!PlayerHelper.swipeGestureEnabled) return
if (!PlayerHelper.fullscreenGesturesEnabled) return
if (isControllerFullyVisible) hideController()
if (distanceY >= 0) return
if (distanceY < 0) {
playerGestureController.isMoving = false
(context as? AppCompatActivity)?.onBackPressedDispatcher?.onBackPressed()
playerViewModel?.isFullscreen?.value = false
}
}
override fun onSwipeEnd() {
gestureViewBinding.brightnessControlView.visibility = View.GONE

View File

@ -462,6 +462,7 @@
<string name="edit_group">Edit group</string>
<string name="play_automatically">Play automatically</string>
<string name="play_automatically_summary">Start playing video automatically when selecting</string>
<string name="fullscreen_gestures">Enter/exit fullscreen gestures</string>
<!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string>

View File

@ -11,6 +11,12 @@
app:key="player_swipe_controls"
app:title="@string/swipe_controls" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:icon="@drawable/ic_fullscreen"
app:key="fullscreen_gestures"
app:title="@string/fullscreen_gestures" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_pinch_gesture"