summaryrefslogtreecommitdiffstats
path: root/src/android/jar
diff options
context:
space:
mode:
authorBartlomiej Moskal <bartlomiej.moskal@qt.io>2021-02-18 13:34:34 +0100
committerBartlomiej Moskal <bartlomiej.moskal@qt.io>2021-05-05 07:43:10 +0000
commite5686b35f07ea54f59e81d04a054bd832bee69b9 (patch)
treefecae9b00212972f11e158940e9b079fc59ddb15 /src/android/jar
parent33ac3cf7664aa08e3455e516c0d44d923b29955d (diff)
Android: handle ImEnterKeyType flag
Replace KEYCODE_ENTER to KEYCODE_TAB if IME_ACTION_NEXT or IME_ACTION_PREVIOUS flag is set. Before this change any of imKeyEntryType [1] was handled as default return key. After the fix, event is changed to Tab or Backtab (if any of mentioned flag is set) [1] https://doc.qt.io/qt-5/qt.html#EnterKeyType-enum Fixes: QTBUG-61652 Pick-to: 5.15 Change-Id: Ia27aa308fdae75bc17d1e892d17048c5afa3e2cb Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/android/jar')
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java6
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtInputConnection.java26
2 files changed, 31 insertions, 1 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
index 166786134b..d8456e7554 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
@@ -375,8 +375,12 @@ public class QtActivityDelegate
inputType |= android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
}
- if ((inputHints & ImhMultiLine) != 0)
+ if ((inputHints & ImhMultiLine) != 0) {
inputType |= android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE;
+ // Clear imeOptions for Multi-Line Type
+ // User should be able to insert new line in such case
+ imeOptions = android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
+ }
if ((inputHints & (ImhNoPredictiveText | ImhSensitiveData | ImhHiddenText)) != 0)
inputType |= android.text.InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtInputConnection.java b/src/android/jar/src/org/qtproject/qt/android/QtInputConnection.java
index e90de9e24d..6cf1aca5bf 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtInputConnection.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtInputConnection.java
@@ -257,6 +257,32 @@ public class QtInputConnection extends BaseInputConnection
// If the sendKeyEvent was invoked, it means that the button not related with composingText was used
// In such case composing text (if it exists) should be finished immediately
finishComposingText();
+ if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && m_view != null) {
+ KeyEvent fakeEvent;
+ switch (m_view.m_imeOptions) {
+ case android.view.inputmethod.EditorInfo.IME_ACTION_NEXT:
+ fakeEvent = new KeyEvent(event.getDownTime(),
+ event.getEventTime(),
+ event.getAction(),
+ KeyEvent.KEYCODE_TAB,
+ event.getRepeatCount(),
+ event.getMetaState());
+ return super.sendKeyEvent(fakeEvent);
+
+ case android.view.inputmethod.EditorInfo.IME_ACTION_PREVIOUS:
+ fakeEvent = new KeyEvent(event.getDownTime(),
+ event.getEventTime(),
+ event.getAction(),
+ KeyEvent.KEYCODE_TAB,
+ event.getRepeatCount(),
+ KeyEvent.META_SHIFT_ON);
+ return super.sendKeyEvent(fakeEvent);
+
+ default:
+ break;
+ }
+ }
+
return super.sendKeyEvent(event);
}