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>
This commit is contained in:
parent
7834756da6
commit
7e6adc1115
@ -355,25 +355,24 @@ public class QtActivityDelegate
|
|||||||
inputType |= android.text.InputType.TYPE_DATETIME_VARIATION_TIME;
|
inputType |= android.text.InputType.TYPE_DATETIME_VARIATION_TIME;
|
||||||
} // else { TYPE_DATETIME_VARIATION_NORMAL(0) }
|
} // else { TYPE_DATETIME_VARIATION_NORMAL(0) }
|
||||||
} else { // CLASS_TEXT
|
} else { // CLASS_TEXT
|
||||||
if ((inputHints & (ImhEmailCharactersOnly | ImhUrlCharactersOnly)) != 0) {
|
if ((inputHints & ImhHiddenText) != 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) {
|
|
||||||
inputType |= android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD;
|
inputType |= android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD;
|
||||||
} else if ((inputHints & ImhSensitiveData) != 0 ||
|
} else if ((inputHints & ImhSensitiveData) != 0 ||
|
||||||
((inputHints & ImhNoPredictiveText) != 0 &&
|
((inputHints & ImhNoPredictiveText) != 0 &&
|
||||||
System.getenv("QT_ANDROID_ENABLE_WORKAROUND_TO_DISABLE_PREDICTIVE_TEXT") != null)) {
|
System.getenv("QT_ANDROID_ENABLE_WORKAROUND_TO_DISABLE_PREDICTIVE_TEXT") != null)) {
|
||||||
inputType |= android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
|
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)
|
if ((inputHints & ImhMultiLine) != 0)
|
||||||
inputType |= android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE;
|
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) {
|
if ((inputHints & ImhUppercaseOnly) != 0) {
|
||||||
initialCapsMode |= android.text.TextUtils.CAP_MODE_CHARACTERS;
|
initialCapsMode |= android.text.TextUtils.CAP_MODE_CHARACTERS;
|
||||||
@ -382,11 +381,6 @@ public class QtActivityDelegate
|
|||||||
initialCapsMode |= android.text.TextUtils.CAP_MODE_SENTENCES;
|
initialCapsMode |= android.text.TextUtils.CAP_MODE_SENTENCES;
|
||||||
inputType |= android.text.InputType.TYPE_TEXT_FLAG_CAP_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)
|
if (enterKeyType == 0 && (inputHints & ImhMultiLine) != 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user