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

Add swipe gesture exclusion size preference #995

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lucacataldo
Copy link

@lucacataldo lucacataldo commented Mar 20, 2023

Changes
Adds preference to modify the existing SWIPE_GESTURE_EXCLUSION_SIZE_VERTICAL constant, allowing the user to configure the size of the vertical exclusion zone when using ExoPlayer. Also implemented the necessary conditionals to enable / disable this setting based on other relevant settings. Retains the current default value of 64, allows for a range between 0-128.

NOTE: SWIPE_GESTURE_EXCLUSION_SIZE_VERTICAL was changed to PREF_EXOPLAYER_SWIPE_GESTURE_EXCLUSION_SIZE_VERTICAL to better conform with existing conventions - let me know if a different name is desired.

Issues

Implements #994

@@ -90,6 +90,7 @@
<string name="pref_exoplayer_start_landscape_video_in_landscape">Start landscape mode videos in landscape orientation</string>
<string name="pref_exoplayer_allow_brightness_volume_gesture">Brightness and volume gestures</string>
<string name="pref_exoplayer_remember_brightness">Remember display brightness</string>
<string name="pref_exoplayer_swipe_exclusion_size_vertical">Gesture dead zone</string>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the desired label would be here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine as is.

@nielsvanvelzen nielsvanvelzen modified the milestones: v2.5.0, v2.6.0 Mar 20, 2023
Copy link
Member

@Maxr1998 Maxr1998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that my suggestion with insets doesn't really work (the gesture insets are way smaller than what we have now, even), so I prefer your solution. A few small things to fix, then it's good to go.

@@ -91,6 +91,9 @@ class AppPreferences(context: Context) {
val exoPlayerAllowSwipeGestures: Boolean
get() = sharedPreferences.getBoolean(Constants.PREF_EXOPLAYER_ALLOW_SWIPE_GESTURES, true)

val exoPlayerSwipeExclusionSizeVertical: Int
get() = sharedPreferences.getInt(Constants.PREF_EXOPLAYER_SWIPE_GESTURE_EXCLUSION_SIZE_VERTICAL, 64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
get() = sharedPreferences.getInt(Constants.PREF_EXOPLAYER_SWIPE_GESTURE_EXCLUSION_SIZE_VERTICAL, 64)
get() = sharedPreferences.getInt(Constants.PREF_EXOPLAYER_SWIPE_GESTURE_EXCLUSION_SIZE_VERTICAL, 64)

I think you could still use the previous constant here.

@@ -35,6 +35,7 @@ object Constants {
const val PREF_VIDEO_PLAYER_TYPE = "pref_video_player_type"
const val PREF_EXOPLAYER_START_LANDSCAPE_VIDEO_IN_LANDSCAPE = "pref_exoplayer_start_landscape_video_in_landscape"
const val PREF_EXOPLAYER_ALLOW_SWIPE_GESTURES = "pref_exoplayer_allow_swipe_gestures"
const val PREF_EXOPLAYER_SWIPE_GESTURE_EXCLUSION_SIZE_VERTICAL = "pref_exoplayer_swipe_exclusion_size_vertical"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk why I originally named it like that, but this is better:

Suggested change
const val PREF_EXOPLAYER_SWIPE_GESTURE_EXCLUSION_SIZE_VERTICAL = "pref_exoplayer_swipe_exclusion_size_vertical"
const val PREF_EXOPLAYER_SWIPE_GESTURE_EXCLUSION_ZONE_HEIGHT = "pref_exoplayer_swipe_exclusion_zone_height"

Please rename the constant/preference/string name in other places as well.

@@ -101,7 +102,6 @@ object Constants {
const val TICKS_PER_MILLISECOND = 10000
const val PLAYER_TIME_UPDATE_RATE = 10000L
const val DEFAULT_CONTROLS_TIMEOUT_MS = 2500
const val SWIPE_GESTURE_EXCLUSION_SIZE_VERTICAL = 64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be kept and used as a default for the preference, see above.

@@ -90,6 +90,7 @@
<string name="pref_exoplayer_start_landscape_video_in_landscape">Start landscape mode videos in landscape orientation</string>
<string name="pref_exoplayer_allow_brightness_volume_gesture">Brightness and volume gestures</string>
<string name="pref_exoplayer_remember_brightness">Remember display brightness</string>
<string name="pref_exoplayer_swipe_exclusion_size_vertical">Gesture dead zone</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine as is.

Comment on lines +124 to +127
min = 0
default = 64
max = 128
step = 8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferably use constants here as well.

step = 8
enabled = appPreferences.videoPlayerType == VideoPlayerType.EXO_PLAYER && appPreferences.exoPlayerAllowSwipeGestures
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -97,6 +99,7 @@ class SettingsFragment : Fragment() {
defaultOnSelectionChange { selection ->
startLandscapeVideoInLandscapePreference.enabled = selection == VideoPlayerType.EXO_PLAYER
swipeGesturesPreference.enabled = selection == VideoPlayerType.EXO_PLAYER
swipeExclusionZoneVertical.enabled = selection == VideoPlayerType.EXO_PLAYER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
swipeExclusionZoneVertical.enabled = selection == VideoPlayerType.EXO_PLAYER
swipeExclusionZoneVertical.enabled = selection == VideoPlayerType.EXO_PLAYER && swipeGesturesPreference.checked

@jellyfin-bot jellyfin-bot added the merge conflict Conflicts prevent merging label Aug 19, 2023
@nielsvanvelzen nielsvanvelzen modified the milestones: v2.6.0, v2.7.0 Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge conflict Conflicts prevent merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants