Add preference for swipe sensitivity
This commit is contained in:
parent
c6b28ea6f1
commit
ee28bf184d
4 changed files with 15 additions and 2 deletions
|
|
@ -185,6 +185,7 @@ class TouchHandler(private val viewModel: VncViewModel, private val dispatcher:
|
|||
private val multiFingerTapDetector = MultiFingerTapDetector()
|
||||
private val dragDetector = DragDetector()
|
||||
private val dragEnabled = viewModel.pref.input.gesture.dragEnabled
|
||||
private val swipeSensitivity = viewModel.pref.input.gesture.swipeSensitivity
|
||||
|
||||
|
||||
private fun handleGestureEvent(event: MotionEvent): Boolean {
|
||||
|
|
@ -230,10 +231,12 @@ class TouchHandler(private val viewModel: VncViewModel, private val dispatcher:
|
|||
override fun onScroll(e1: MotionEvent, e2: MotionEvent, dX: Float, dY: Float): Boolean {
|
||||
val startPoint = e1.point()
|
||||
val currentPoint = e2.point()
|
||||
val normalizedDx = -dX * swipeSensitivity
|
||||
val normalizedDy = -dY * swipeSensitivity
|
||||
|
||||
when (e2.pointerCount) {
|
||||
1 -> dispatcher.onSwipe1(startPoint, currentPoint, -dX, -dY)
|
||||
2 -> dispatcher.onSwipe2(startPoint, currentPoint, -dX, -dY)
|
||||
1 -> dispatcher.onSwipe1(startPoint, currentPoint, normalizedDx, normalizedDy)
|
||||
2 -> dispatcher.onSwipe2(startPoint, currentPoint, normalizedDx, normalizedDy)
|
||||
}
|
||||
|
||||
multiFingerTapDetector.reset()
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ class AppPreferences(context: Context) {
|
|||
val swipe2; get() = prefs.getString("gesture_swipe2", "pan")!!
|
||||
val drag; get() = prefs.getString("gesture_drag", "none")!!
|
||||
val dragEnabled; get() = (drag != "none")
|
||||
val swipeSensitivity; get() = prefs.getInt("gesture_swipe_sensitivity", 10) / 10f
|
||||
}
|
||||
|
||||
inner class Input {
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@
|
|||
<string name="pref_swipe1">One-finger swipe</string>
|
||||
<string name="pref_swipe2">Two-finger swipe</string>
|
||||
<string name="pref_drag">Drag (long press and swipe)</string>
|
||||
<string name="pref_swipe_sensitivity">Swipe sensitivity</string>
|
||||
<string name="pref_mouse">Mouse</string>
|
||||
<string name="pref_mouse_passthrough">Mouse passthrough</string>
|
||||
<string name="pref_mouse_passthrough_summary_off">Use mouse events for local gestures</string>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
-->
|
||||
|
||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
app:title="@string/pref_input">
|
||||
|
||||
<PreferenceCategory
|
||||
|
|
@ -76,6 +77,13 @@
|
|||
app:key="gesture_drag"
|
||||
app:title="@string/pref_drag"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SeekBarPreference
|
||||
android:max="15"
|
||||
app:defaultValue="10"
|
||||
app:key="gesture_swipe_sensitivity"
|
||||
app:min="5"
|
||||
app:title="@string/pref_swipe_sensitivity" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue