mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Merge pull request #2170 from Kruna1Pate1/fix/swipe-gesture-improvement
Add pinch gesture setting, Fix control buttons appear on pinch gesture
This commit is contained in:
commit
223e9e61d0
@ -83,6 +83,7 @@ object PreferenceKeys {
|
|||||||
const val QUEUE_AUTO_INSERT_RELATED = "queue_insert_related_videos"
|
const val QUEUE_AUTO_INSERT_RELATED = "queue_insert_related_videos"
|
||||||
const val PLAYER_SWIPE_CONTROLS = "player_swipe_controls"
|
const val PLAYER_SWIPE_CONTROLS = "player_swipe_controls"
|
||||||
const val PLAYER_SCREEN_BRIGHTNESS = "player_screen_brightness"
|
const val PLAYER_SCREEN_BRIGHTNESS = "player_screen_brightness"
|
||||||
|
const val PLAYER_PINCH_CONTROL = "player_pinch_control"
|
||||||
const val CAPTIONS_SIZE = "captions_size"
|
const val CAPTIONS_SIZE = "captions_size"
|
||||||
const val DOUBLE_TAP_TO_SEEK = "double_tap_seek"
|
const val DOUBLE_TAP_TO_SEEK = "double_tap_seek"
|
||||||
|
|
||||||
|
@ -509,10 +509,12 @@ internal class CustomExoPlayerView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onZoom() {
|
override fun onZoom() {
|
||||||
|
if (!PlayerHelper.pinchGestureEnabled) return
|
||||||
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMinimize() {
|
override fun onMinimize() {
|
||||||
|
if (!PlayerHelper.pinchGestureEnabled) return
|
||||||
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
|
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,10 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play
|
|||||||
private var isMoving = false
|
private var isMoving = false
|
||||||
var isEnabled = true
|
var isEnabled = true
|
||||||
|
|
||||||
|
// Indicates last touch event was for click or other gesture, used to avoid single click
|
||||||
|
// by runnable when scroll or pinch gesture already completed.
|
||||||
|
var wasClick = true
|
||||||
|
|
||||||
init {
|
init {
|
||||||
gestureDetector = GestureDetector(activity, GestureListener(), handler)
|
gestureDetector = GestureDetector(activity, GestureListener(), handler)
|
||||||
scaleGestureDetector = ScaleGestureDetector(activity, ScaleGestureListener(), handler)
|
scaleGestureDetector = ScaleGestureDetector(activity, ScaleGestureListener(), handler)
|
||||||
@ -66,6 +70,7 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play
|
|||||||
var scaleFactor: Float = 1f
|
var scaleFactor: Float = 1f
|
||||||
|
|
||||||
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
override fun onScale(detector: ScaleGestureDetector): Boolean {
|
||||||
|
wasClick = false
|
||||||
scaleFactor *= detector.scaleFactor
|
scaleFactor *= detector.scaleFactor
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -89,6 +94,9 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play
|
|||||||
private var xPos = 0.0F
|
private var xPos = 0.0F
|
||||||
|
|
||||||
override fun onDown(e: MotionEvent): Boolean {
|
override fun onDown(e: MotionEvent): Boolean {
|
||||||
|
// Initially assume this event is for click
|
||||||
|
wasClick = true
|
||||||
|
|
||||||
if (isMoving || scaleGestureDetector.isInProgress) return false
|
if (isMoving || scaleGestureDetector.isInProgress) return false
|
||||||
|
|
||||||
if (isEnabled && isSecondClick()) {
|
if (isEnabled && isSecondClick()) {
|
||||||
@ -135,6 +143,7 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
isMoving = true
|
isMoving = true
|
||||||
|
wasClick = false
|
||||||
|
|
||||||
when {
|
when {
|
||||||
width * 0.5 > e1.x -> listener.onSwipeLeftScreen(distanceY)
|
width * 0.5 > e1.x -> listener.onSwipeLeftScreen(distanceY)
|
||||||
@ -144,8 +153,8 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val runnable = Runnable {
|
private val runnable = Runnable {
|
||||||
// If user is scrolling then avoid single tap call
|
// If the last event was for scroll or pinch then avoid single tap call
|
||||||
if (isMoving || isSecondClick()) return@Runnable
|
if (!wasClick || isSecondClick()) return@Runnable
|
||||||
listener.onSingleTap()
|
listener.onSingleTap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,6 +300,12 @@ object PlayerHelper {
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val pinchGestureEnabled: Boolean
|
||||||
|
get() = PreferenceHelper.getBoolean(
|
||||||
|
PreferenceKeys.PLAYER_PINCH_CONTROL,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
val captionsTextSize: Float
|
val captionsTextSize: Float
|
||||||
get() = PreferenceHelper.getString(
|
get() = PreferenceHelper.getString(
|
||||||
PreferenceKeys.CAPTIONS_SIZE,
|
PreferenceKeys.CAPTIONS_SIZE,
|
||||||
|
13
app/src/main/res/drawable/ic_pinch_gesture.xml
Normal file
13
app/src/main/res/drawable/ic_pinch_gesture.xml
Normal 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>
|
@ -394,6 +394,8 @@
|
|||||||
<string name="auto">Auto</string>
|
<string name="auto">Auto</string>
|
||||||
<string name="swipe_controls">Swipe controls</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="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="defaults">Defaults</string>
|
||||||
<string name="pop_up">Pop-Up</string>
|
<string name="pop_up">Pop-Up</string>
|
||||||
<string name="comments_disabled">Comments are disabled by the uploader.</string>
|
<string name="comments_disabled">Comments are disabled by the uploader.</string>
|
||||||
|
@ -11,6 +11,13 @@
|
|||||||
app:key="player_swipe_controls"
|
app:key="player_swipe_controls"
|
||||||
app:title="@string/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
|
<SwitchPreferenceCompat
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:icon="@drawable/ic_next"
|
android:icon="@drawable/ic_next"
|
||||||
|
Loading…
Reference in New Issue
Block a user