summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2021-01-14 11:07:55 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-02-02 16:57:12 +0000
commit7e6adc11156bc911969299ef1cebf1566f0b351f (patch)
tree2c4957a0561134f962a798e8570d81ef886b2c05
parent7834756da680da853f0372417c3cdcc276be557d (diff)
Android: Fix input method hints for ImhHiddenText
If ImhHiddenText is set then that should take precedence over the other input method hints. Also, certain combinations aren't really possible. E.g., ImhEmailCharactersOnly and ImhHiddenText doesn't have its own specific variation on Android. ImhSensitiveData and ImhNoPredictiveText are also likely to not work as TYPE_TEXT_FLAG_NO_SUGGESTIONS is normally ignored by Android keyboards. A common workaround is to use the visible password variation but since this will force the layout to use latin characters it's not something we can use as an universal workaround, so users will need to manually enable it through the environment variable QT_ANDROID_ENABLE_WORKAROUND_TO_DISABLE_PREDICTIVE_TEXT Fixes: QTBUG-85787 Change-Id: I0ff591ec9acf8dd556c7987e6d997cff3ddfe38e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 5e95fab53ffa138c1039c71097e77626483c88a8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java24
1 files changed, 9 insertions, 15 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 3785eb4011..5b144f8af7 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
@@ -355,25 +355,24 @@ public class QtActivityDelegate
inputType |= android.text.InputType.TYPE_DATETIME_VARIATION_TIME;
} // else { TYPE_DATETIME_VARIATION_NORMAL(0) }
} else { // CLASS_TEXT
- if ((inputHints & (ImhEmailCharactersOnly | ImhUrlCharactersOnly)) != 0) {
- if ((inputHints & ImhUrlCharactersOnly) != 0) {
- inputType |= android.text.InputType.TYPE_TEXT_VARIATION_URI;
-
- if (enterKeyType == 0) // not explicitly overridden
- imeOptions = android.view.inputmethod.EditorInfo.IME_ACTION_GO;
- } else if ((inputHints & ImhEmailCharactersOnly) != 0) {
- inputType |= android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
- }
- } else if ((inputHints & ImhHiddenText) != 0) {
+ if ((inputHints & ImhHiddenText) != 0) {
inputType |= android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD;
} else if ((inputHints & ImhSensitiveData) != 0 ||
((inputHints & ImhNoPredictiveText) != 0 &&
System.getenv("QT_ANDROID_ENABLE_WORKAROUND_TO_DISABLE_PREDICTIVE_TEXT") != null)) {
inputType |= android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
+ } else if ((inputHints & ImhUrlCharactersOnly) != 0) {
+ inputType |= android.text.InputType.TYPE_TEXT_VARIATION_URI;
+ if (enterKeyType == 0) // not explicitly overridden
+ imeOptions = android.view.inputmethod.EditorInfo.IME_ACTION_GO;
+ } else if ((inputHints & ImhEmailCharactersOnly) != 0) {
+ inputType |= android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
}
if ((inputHints & ImhMultiLine) != 0)
inputType |= android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE;
+ if ((inputHints & (ImhNoPredictiveText | ImhSensitiveData | ImhHiddenText)) != 0)
+ inputType |= android.text.InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
if ((inputHints & ImhUppercaseOnly) != 0) {
initialCapsMode |= android.text.TextUtils.CAP_MODE_CHARACTERS;
@@ -382,11 +381,6 @@ public class QtActivityDelegate
initialCapsMode |= android.text.TextUtils.CAP_MODE_SENTENCES;
inputType |= android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
}
-
- if ((inputHints & ImhNoPredictiveText) != 0 || (inputHints & ImhSensitiveData) != 0
- || (inputHints & ImhHiddenText) != 0) {
- inputType |= android.text.InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
- }
}
if (enterKeyType == 0 && (inputHints & ImhMultiLine) != 0)