Skip to content
Closed
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
23 changes: 23 additions & 0 deletions app/src/main/java/com/gaurav/avnc/ui/vnc/input/TouchHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import android.view.InputDevice
import android.view.MotionEvent
import android.view.ScaleGestureDetector
import android.view.ViewConfiguration
import androidx.core.view.postDelayed
import com.gaurav.avnc.ui.vnc.FrameView
import com.gaurav.avnc.util.AppPreferences
import com.gaurav.avnc.vnc.PointerButton
Expand Down Expand Up @@ -240,6 +241,7 @@ class TouchHandler(private val frameView: FrameView, private val dispatcher: Dis
}

private inner class FingerGestureListener : GestureDetectorEx.GestureListenerEx {
var repeatingClicks = false

override fun onSingleTapConfirmed(e: MotionEvent) = dispatcher.onTap1(e.point())
override fun onDoubleTapConfirmed(e: MotionEvent) = dispatcher.onDoubleTap(e.point())
Expand All @@ -254,11 +256,31 @@ class TouchHandler(private val frameView: FrameView, private val dispatcher: Dis
override fun onLongPress(e: MotionEvent) {
frameView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)

if (pref.input.gesture.longPress == "repeated-clicks")
{
dispatcher.onTap1(e.point())
repeatingClicks = true
frameView.postDelayed(ViewConfiguration.getLongPressTimeout().toLong()) {
repeatClick(e.point())
}
}

// If long-press-swipe is disabled, we can dispatch long-press immediately
if (!longPressSwipeEnabled) dispatcher.onLongPress(e.point())
}

private fun repeatClick(p: PointF) {
if (!repeatingClicks) {
return
}
dispatcher.onTap1(p)
frameView.postDelayed(ViewConfiguration.getKeyRepeatDelay().toLong()) {
repeatClick(p)
}
}

override fun onLongPressConfirmed(e: MotionEvent) {
repeatingClicks = false
if (longPressSwipeEnabled) dispatcher.onLongPress(e.point())
}

Expand All @@ -278,6 +300,7 @@ class TouchHandler(private val frameView: FrameView, private val dispatcher: Dis
}

override fun onScrollAfterLongPress(e1: MotionEvent, e2: MotionEvent, dx: Float, dy: Float) {
repeatingClicks = false
dispatcher.onLongPressSwipe(e1.point(), e2.point(), dx, dy)
}

Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/com/gaurav/avnc/util/AppPreferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class AppPreferences(context: Context) {
val swipe3; get() = prefs.getString("gesture_swipe3", "pan")!!
val doubleTapSwipe; get() = prefs.getString("gesture_double_tap_swipe", "remote-drag")!!
val longPressSwipe; get() = prefs.getString("gesture_long_press_swipe", "none")!!
val longPressSwipeEnabled; get() = (longPressSwipe != "none" && longPress != "left-press")
val longPressSwipeEnabled; get() = (longPressSwipe != "none"
&& longPress != "left-press"
&& longPress != "repeated-clicks")
val longPressDetectionEnabled; get() = (longPress != "none" || longPressSwipeEnabled)
val swipeSensitivity; get() = prefs.getInt("gesture_swipe_sensitivity", 10) / 10f
val invertVerticalScrolling; get() = prefs.getBoolean("invert_vertical_scrolling", false)
Expand Down Expand Up @@ -177,4 +179,4 @@ class AppPreferences(context: Context) {
putBoolean("run_info_right_meta_keys_migrated", true)
}
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<string name="pref_experimental_summary">Bonus</string>
<string name="pref_tools">Outils</string>
<string name="pref_gesture_action_left_click">Clic gauche</string>
<string name="pref_gesture_action_repeated_clicks">Clics répétés</string>
<string name="pref_gesture_action_middle_click">Clic du milieu</string>
<string name="pref_theme">Thème</string>
<string name="tip_empty_server_list">La liste des serveurs est vide.
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@
<item>@string/pref_gesture_action_middle_click</item>
<item>@string/pref_gesture_action_right_click</item>
<item>@string/pref_gesture_action_left_press</item>
<item>@string/pref_gesture_action_repeated_clicks</item>
</string-array>
<string-array name="long_press_action_values">
<item>none</item>
<item>double-click</item>
<item>middle-click</item>
<item>right-click</item>
<item>left-press</item>
<item>repeated-clicks</item>
</string-array>

<string-array name="swipe1_action_entries">
Expand Down Expand Up @@ -227,4 +229,4 @@
<item>Item 2</item>
<item>Item 3</item>
</string-array>
</resources>
</resources>
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 @@ -166,6 +166,7 @@
<string name="pref_gesture_action_none" translatable="false">@string/title_none</string>
<string name="pref_gesture_action_left_click">Left-click</string>
<string name="pref_gesture_action_left_press">Long-press</string>
<string name="pref_gesture_action_repeated_clicks">Repeated clicks</string>
<string name="pref_gesture_action_middle_click">Middle-click</string>
<string name="pref_gesture_action_right_click">Right-click</string>
<string name="pref_gesture_action_double_click">Double-click</string>
Expand Down