summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2021-01-14 11:07:55 +0100
committerChristian Strømme <christian.stromme@qt.io>2021-02-04 21:09:30 +0000
commit41883b3b9ef43bc4c7b47a19b59f3ee8143db3da (patch)
treeb529b0b37c0eac2e96ee5364e197945b67f4f62d
parent4193115b1b084649847fcf15da02c4974bd1d87d (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: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
index b06ccc5ec6..27f7f990b5 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -338,25 +338,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;
@@ -365,11 +364,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)