Add setting to enable or disable pinch gesture

This commit is contained in:
Krunal Patel 2022-12-01 23:03:30 +05:30
parent 677a01a055
commit 09d709dca8
6 changed files with 31 additions and 0 deletions

View File

@ -83,6 +83,7 @@ object PreferenceKeys {
const val QUEUE_AUTO_INSERT_RELATED = "queue_insert_related_videos"
const val PLAYER_SWIPE_CONTROLS = "player_swipe_controls"
const val PLAYER_SCREEN_BRIGHTNESS = "player_screen_brightness"
const val PLAYER_PINCH_CONTROL = "player_pinch_control"
const val CAPTIONS_SIZE = "captions_size"
const val DOUBLE_TAP_TO_SEEK = "double_tap_seek"

View File

@ -509,10 +509,12 @@ internal class CustomExoPlayerView(
}
override fun onZoom() {
if (!PlayerHelper.pinchGestureEnabled) return
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
}
override fun onMinimize() {
if (!PlayerHelper.pinchGestureEnabled) return
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
}

View File

@ -300,6 +300,12 @@ object PlayerHelper {
true
)
val pinchGestureEnabled: Boolean
get() = PreferenceHelper.getBoolean(
PreferenceKeys.PLAYER_PINCH_CONTROL,
true
)
val captionsTextSize: Float
get() = PreferenceHelper.getString(
PreferenceKeys.CAPTIONS_SIZE,

View File

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="238.06"
android:viewportHeight="238.06">
<path
android:fillColor="#ffffff"
android:pathData="M237.1,120.17c-3.77,-22.44 -19.64,-25.95 -27,-26.34c-2.27,-0.12 -4.39,-1.27 -5.63,-3.18c-5.37,-8.25 -12.58,-10.43 -18.71,-10.43c-2.74,0 -5.27,0.44 -7.31,0.96c-0.62,0.16 -1.26,0.24 -1.88,0.24c-2.28,0 -4.47,-1.04 -5.85,-2.93c-5.29,-7.25 -12.17,-9.21 -18.07,-9.21c-1.46,0 -2.87,0.12 -4.17,0.31c-0.37,0.05 -0.77,0.08 -1.13,0.08c-3.96,0 -7.35,-3.18 -7.35,-7.27V19.56c0,-10.98 -8.26,-16.47 -16.5,-16.47S107,8.57 107,19.56v105.36c0,8.24 -6.69,14.19 -14.11,14.19c-2.2,0 -4.42,-0.52 -6.57,-1.66c-10.06,-5.31 -20.86,-9.97 -32.11,-14.38c-2.51,-0.98 -4.93,-1.43 -7.21,-1.43c-15.43,-0 -24.11,20.33 -7.04,31.32c19.59,12.61 44.43,19.51 54.09,33.77c5.97,8.81 18.53,34.14 23.4,44.02c1.23,2.49 3.76,4.22 6.53,4.22h77c3.65,0 6.74,-2.87 7.22,-6.49l4.06,-30.63c0.14,-1.09 0.54,-2.17 1.14,-3.09C234.6,162.43 240.67,141.43 237.1,120.17z" />
<path
android:fillColor="#ffffff"
android:pathData="M48.33,84.97c0,-3.31 -2.69,-6 -6,-6H21.43L75,24.96v20.9c0,3.31 2.69,6 6,6s6,-2.69 6,-6v-36c0,-3.31 -2.35,-5.89 -5.67,-5.89h-35c-3.31,0 -6,2.69 -6,6s2.69,6 6,6h21.13L12,70.99v-21.13c0,-3.31 -2.69,-6 -6,-6s-6,2.69 -6,6v35c0,3.31 3.02,6.11 6.33,6.11h36C45.65,90.97 48.33,88.29 48.33,84.97z" />
</vector>

View File

@ -394,6 +394,8 @@
<string name="auto">Auto</string>
<string name="swipe_controls">Swipe controls</string>
<string name="swipe_controls_summary">Use swipe gesture to adjust the brightness and volume.</string>
<string name="pinch_control">Pinch control</string>
<string name="pinch_control_summary">Use pinch gesture to zoom in/out.</string>
<string name="defaults">Defaults</string>
<string name="pop_up">Pop-Up</string>
<string name="comments_disabled">Comments are disabled by the uploader.</string>

View File

@ -11,6 +11,13 @@
app:key="player_swipe_controls"
app:title="@string/swipe_controls" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_pinch_gesture"
android:summary="@string/pinch_control_summary"
app:key="player_pinch_control"
app:title="@string/pinch_control" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:icon="@drawable/ic_next"