Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate swipe gestures and fullscreen gestures #3523

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,10 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
}
})

if (PlayerHelper.swipeGestureEnabled) {
binding.playerMotionLayout.addSwipeUpListener {
if (this::streams.isInitialized) {
binding.player.hideController()
setFullscreen()
}
binding.playerMotionLayout.addSwipeUpListener {
if (this::streams.isInitialized && PlayerHelper.fullscreenGesturesEnabled) {
binding.player.hideController()
setFullscreen()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,15 +691,14 @@ 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
}
playerGestureController.isMoving = false
(context as? AppCompatActivity)?.onBackPressedDispatcher?.onBackPressed()
playerViewModel?.isFullscreen?.value = false
}

override fun onSwipeEnd() {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/player_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down