summaryrefslogtreecommitdiffstats
path: root/src/android/jar
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@digia.com>2013-12-12 16:03:12 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-07 23:27:01 +0100
commit2b3f293d892c5268bd2a07ed17fa9fc5adacbd76 (patch)
tree042675e2e64238a97b1cf7ff10d3183afeb7b66e /src/android/jar
parent6112f8938c962e49b9277ef7152bf1303789ade7 (diff)
Android: Refactor the InputType mapping code.
- Fix issue where input flags and classes where wrongly mixed. - Adds DATETIME class (support for Qt::ImhDate/Qt::ImhTime). - Adds TYPE_NUMBER_VARIATION_PASSWORD for API level > 10. Task-number: QTBUG-35198 Change-Id: I794159ca7c19d38b0b97521448cef0f5112ee8ba Reviewed-by: BogDan Vatra <bogdan@kde.org>
Diffstat (limited to 'src/android/jar')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java76
1 files changed, 41 insertions, 35 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 07b517d3d0..d8c560933f 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -242,50 +242,56 @@ public class QtActivityDelegate
int imeOptions = android.view.inputmethod.EditorInfo.IME_ACTION_DONE;
int inputType = android.text.InputType.TYPE_CLASS_TEXT;
- if ((inputHints & ImhMultiLine) != 0) {
- inputType = android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE;
- imeOptions = android.view.inputmethod.EditorInfo.IME_FLAG_NO_ENTER_ACTION;
- }
-
- if (((inputHints & ImhNoAutoUppercase) != 0 || (inputHints & ImhPreferUppercase) != 0)
- && (inputHints & ImhLowercaseOnly) == 0) {
- initialCapsMode = android.text.TextUtils.CAP_MODE_SENTENCES;
- }
-
- if ((inputHints & ImhUppercaseOnly) != 0)
- initialCapsMode = android.text.TextUtils.CAP_MODE_CHARACTERS;
-
- if ((inputHints & ImhHiddenText) != 0)
- inputType = android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD;
-
- if ((inputHints & ImhPreferNumbers) != 0)
+ if ((inputHints & (ImhPreferNumbers | ImhDigitsOnly | ImhFormattedNumbersOnly)) != 0) {
inputType = android.text.InputType.TYPE_CLASS_NUMBER;
+ if ((inputHints & ImhFormattedNumbersOnly) != 0) {
+ inputType |= (android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL
+ | android.text.InputType.TYPE_NUMBER_FLAG_SIGNED);
+ }
- if ((inputHints & ImhDigitsOnly) != 0)
- inputType = android.text.InputType.TYPE_CLASS_NUMBER;
+ if (Build.VERSION.SDK_INT > 10 && (inputHints & ImhHiddenText) != 0)
+ inputType |= 0x10;
+ } else if ((inputHints & ImhDialableCharactersOnly) != 0) {
+ inputType = android.text.InputType.TYPE_CLASS_PHONE;
+ } else if ((inputHints & (ImhDate | ImhTime)) != 0) {
+ inputType = android.text.InputType.TYPE_CLASS_DATETIME;
+ if ((inputHints & ImhDate) != 0)
+ inputType |= android.text.InputType.TYPE_DATETIME_VARIATION_DATE;
+ if ((inputHints & ImhTime) != 0)
+ inputType |= android.text.InputType.TYPE_DATETIME_VARIATION_TIME;
+ } else { // CLASS_TEXT
+ if ((inputHints & ImhHiddenText) != 0) {
+ inputType |= android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD;
+ } else if ((inputHints & (ImhNoAutoUppercase | ImhNoPredictiveText | ImhSensitiveData)) != 0) {
+ inputType |= android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
+ }
- if ((inputHints & ImhFormattedNumbersOnly) != 0) {
- inputType = android.text.InputType.TYPE_CLASS_NUMBER
- | android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL
- | android.text.InputType.TYPE_NUMBER_FLAG_SIGNED;
- }
+ if ((inputHints & ImhEmailCharactersOnly) != 0)
+ inputType |= android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
- if ((inputHints & ImhDialableCharactersOnly) != 0)
- inputType = android.text.InputType.TYPE_CLASS_PHONE;
+ if ((inputHints & ImhUrlCharactersOnly) != 0) {
+ inputType |= android.text.InputType.TYPE_TEXT_VARIATION_URI;
+ imeOptions = android.view.inputmethod.EditorInfo.IME_ACTION_GO;
+ }
- 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 & ImhUrlCharactersOnly) != 0) {
- inputType = android.text.InputType.TYPE_TEXT_VARIATION_URI;
- imeOptions = android.view.inputmethod.EditorInfo.IME_ACTION_GO;
- }
+ if ((inputHints & ImhUppercaseOnly) != 0) {
+ initialCapsMode |= android.text.TextUtils.CAP_MODE_CHARACTERS;
+ inputType |= android.text.InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;
+ } else if ((inputHints & ImhLowercaseOnly) == 0 && (inputHints & ImhNoAutoUppercase) == 0) {
+ initialCapsMode |= android.text.TextUtils.CAP_MODE_SENTENCES;
+ inputType |= android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
+ }
- if ((inputHints & ImhNoPredictiveText) != 0) {
- //android.text.InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | android.text.InputType.TYPE_CLASS_TEXT;
- inputType = android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
+ if ((inputHints & ImhNoPredictiveText) != 0 || (inputHints & ImhSensitiveData) != 0)
+ inputType |= android.text.InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
}
+ if ((inputHints & ImhMultiLine) != 0)
+ imeOptions = android.view.inputmethod.EditorInfo.IME_FLAG_NO_ENTER_ACTION;
+
m_editText.setInitialCapsMode(initialCapsMode);
m_editText.setImeOptions(imeOptions);
m_editText.setInputType(inputType);