Skip to content

Commit

Permalink
MyAccessibilityService: don't perform a short press action more than …
Browse files Browse the repository at this point in the history
…once after a long press action has been performed
  • Loading branch information
sds100 committed Apr 4, 2019
1 parent 08a34b6 commit 03b541e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,13 @@ class MyAccessibilityService : AccessibilityService(), IContext, IPerformGlobalA
mLongPressPendingActions.any { it.trigger.keys.contains(event.keyCode) }) {
imitateButtonPress(event.keyCode)
}
} else {
/* must remove all short press pending actions created during the down press. But don't run them
* since only the long press should be ran. */
mShortPressPendingActions.filter { it.trigger.keys.contains(event.keyCode) }.forEach {
mHandler.removeCallbacks(it)
mShortPressPendingActions.remove(it)
}
}

//remove all pending long press actions since their trigger has been released
Expand Down Expand Up @@ -381,7 +388,7 @@ class MyAccessibilityService : AccessibilityService(), IContext, IPerformGlobalA

mKeyMapListCache.forEach { keymap ->
/* only add a trigger to the list if it hasn't already been registered as a long press trigger */
if (keymap.isLongPress) {
if (keymap.isLongPress && keymap.isEnabled) {
val newLongPressTriggers = keymap.triggerList.filter { !mTriggersAwaitingLongPress.contains(it) }

mTriggersAwaitingLongPress.addAll(newLongPressTriggers)
Expand Down

0 comments on commit 03b541e

Please sign in to comment.