-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(android): Pass longpress delay to KeymanWeb #12185
Conversation
User Test ResultsTest specification and instructions Test Artifacts |
Test ResultsI tested this issue with the attached "Keyman 18.0.89-alpha-test-12185" build on the Android 14 physical device and Android 9(emulator) Here is my observation.
|
@jahorton - Dina and I have seen changing the longpress delay from the default 0.5 seconds to 0.3 seconds seems to prevent the flick down gesture from activating. Is this a side effect in KeymanWeb? From my testing, immediately trying to flick down is triggering a longpress from the row below (e.g. flick down from f is triggering longpresses on the c key) When I set longpress delay to 0.7 seconds, flick gestures are still disabled. Gonna retest on master... |
... so I can't get the down flick gestures to work on master branch either. Maybe a side effect from #12176? |
While I started to update the KMManager API on help.keyman.com, I realized I needed to do a slight refactor to separate setLongpressDelay (store the new preference, then calls applyLongpressDelay) and applyLongpressDelay (sends the updated value to KeymanWeb) The flick issue will resolve after merging #12187 |
That was going to be my first comment on the PR 😁 - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically LGTM, just want to move ownership of the longpressDelay value entirely into KMManager.
int longpressDelay = KMManager.getLongpressDelay(this); | ||
KMManager.setLongpressDelay(longpressDelay); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of an anti-pattern. We shouldn't be reading from KMManager's longPressDelay property and then writing back to it -- that looks like a no-op. Instead if we need to tell it to refresh we should be doing that with something like KMManager.sendLongpressDelay()
(or perhaps better, KMManager.sendOptionsToKeyboard()
)
// Initialize the longpress delay | ||
int longpressDelay = KMManager.getLongpressDelay(); | ||
KMManager.applyLongpressDelay(longpressDelay); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not very comfortable with this. KMManager should be able to manage the value internally, and we shouldn't be passing the value back and forth. If we need to ask KMManager to re-apply the longpressDelay that it already knows, it should be just something like:
// Initialize the longpress delay | |
int longpressDelay = KMManager.getLongpressDelay(); | |
KMManager.applyLongpressDelay(longpressDelay); | |
KMManager.applyLongpressDelay(); |
@@ -472,7 +472,7 @@ public boolean onKeyUp(int keycode, KeyEvent e) { | |||
|
|||
@Override | |||
public void onKeyboardLoaded(KeyboardType keyboardType) { | |||
// Do nothing | |||
checkLongpressDelay(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkLongpressDelay(); | |
KMManager.applyLongpressDelay(); |
private void checkLongpressDelay() { | ||
// Initialize the longpress delay | ||
int longpressDelay = KMManager.getLongpressDelay(); | ||
KMManager.applyLongpressDelay(longpressDelay); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private void checkLongpressDelay() { | |
// Initialize the longpress delay | |
int longpressDelay = KMManager.getLongpressDelay(); | |
KMManager.applyLongpressDelay(longpressDelay); | |
} |
This should not be needed if KMManager.applyLongpressDelay()
does the work
if (keyman.osk) { | ||
keyman.osk.gestureParams.longpress.waitLength = delay; | ||
console.debug('setLongpressDelay('+delay+')'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If keyman.osk
is not assigned, we may need to log that?
*/ | ||
public static void setLongpressDelay(int longpressDelay) { | ||
public static void applyLongpressDelay(int longpressDelay) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static void applyLongpressDelay(int longpressDelay) { | |
public static void applyLongpressDelay() { | |
int longpressDelay = getLongpressDelay(); |
editor.putInt(KMKey_LongpressDelay, longpressDelay); | ||
editor.commit(); | ||
|
||
applyLongpressDelay(longpressDelay); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applyLongpressDelay(longpressDelay); | |
applyLongpressDelay(); |
Test Results
|
Test Results
|
…ea-set-longpress-delay
Changes in this pull request will be available for download in Keyman version 18.0.93-alpha |
Follows #12170 and fixes #877
This adds KMManager APIs to get/set the longpress duration between 300 ms and 1500 ms. Default KeymanWeb longpress delay is 500ms.
Since the keyboard needs to be loaded for the setting to take effect, I put the initialization in MainActivity.onKeyboardLoaded
User Testing
Setup - Install the PR build of Keyman for Android on a device/emulator
Note: the reported issue on flick gestures is handled on a separate PR #12187
TEST_LONGPRESS - Verifies longpress delay changes with the menu