Merge pull request #6984 from keymanapp/fix/android/6981-longpress-movement-threshold

fix(android): rework longpress movement trigger 🎁
This commit is contained in:
Marc Durdin 2022-07-26 13:57:44 +10:00 committed by GitHub
commit eb8fa4c294
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

3
android/KMEA/.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View file

@ -187,10 +187,21 @@ final class KMKeyboard extends WebView {
return true;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if(e2.getY() - e1.getY() < -5) { // TODO: get better threshold value from KMW
if (subKeysList != null && (subKeysWindow == null || !subKeysWindow.isShowing())) {
showSubKeys(context);
return true;
}
}
return false;
}
@Override
public void onLongPress(MotionEvent event) {
// This is also called for banner longpresses! Need a way to differentiate the sources.
if (subKeysList != null && subKeysWindow != null && !subKeysWindow.isShowing()) {
if (subKeysList != null && (subKeysWindow == null || !subKeysWindow.isShowing())) {
showSubKeys(context);
return;
} else if (KMManager.getGlobeKeyState() == KMManager.GlobeKeyState.GLOBE_KEY_STATE_DOWN) {
@ -286,17 +297,12 @@ final class KMKeyboard extends WebView {
// Come to think of it, I wonder if suggestionMenuWindow was work being done to link with
// suggestion banner longpresses - if so, it's not yet ready for proper integration...
// and would need its own rung in this if-else ladder.
if (subKeysWindow != null && suggestionMenuWindow == null) {
if (subKeysWindow != null && suggestionMenuWindow == null && subKeysWindow.isShowing()) {
// Passes KMKeyboard (subclass of WebView)'s touch events off to our subkey window
// if active, allowing for smooth, integrated gesture control.
subKeysWindow.getContentView().findViewById(R.id.grid).dispatchTouchEvent(event);
} else {
//handleTouchEvent(event);
gestureDetector.onTouchEvent(event);
if (action == MotionEvent.ACTION_MOVE && subKeysList != null && subKeysWindow == null) {
// Display subkeys during move
showSubKeys(context);
}
}
if (action == MotionEvent.ACTION_UP) {