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 LBRY_HLS = "lbry_hls"
const val AUTO_FULLSCREEN_SHORTS = "auto_fullscreen_shorts" const val AUTO_FULLSCREEN_SHORTS = "auto_fullscreen_shorts"
const val PLAY_AUTOMATICALLY = "play_automatically" const val PLAY_AUTOMATICALLY = "play_automatically"
const val FULLSCREEN_GESTURES = "fullscreen_gestures"
/** /**
* Background mode * Background mode

View File

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

View File

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

View File

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

View File

@ -462,6 +462,7 @@
<string name="edit_group">Edit group</string> <string name="edit_group">Edit group</string>
<string name="play_automatically">Play automatically</string> <string name="play_automatically">Play automatically</string>
<string name="play_automatically_summary">Start playing video automatically when selecting</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 --> <!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string> <string name="download_channel_name">Download Service</string>

View File

@ -11,6 +11,12 @@
app:key="player_swipe_controls" app:key="player_swipe_controls"
app:title="@string/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 <SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:icon="@drawable/ic_pinch_gesture" android:icon="@drawable/ic_pinch_gesture"