From d099e27cfc2885f28b36764f7c0917e5d708e778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 23 Oct 2014 15:24:25 +0200 Subject: [PATCH] Android: Fix input method hints. 1. Add comment about the magic TYPE_NUMBER_VARIATION_PASSWORD value. 2. ImhHiddenText, ImhNoPredictiveText and ImhSensitiveData should all disable suggestions. 3. Only ImhSensitiveData sets TYPE_TEXT_VARIATION_VISIBLE_PASSWORD 4. Don't OR date and time to get DateTime... Task-number: QTBUG-38080 Change-Id: If456563983130e9af409ffa8cb717ddf259f1d6b Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../qt5/android/QtActivityDelegate.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 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 62a0263780..cab5da9dbc 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -265,30 +265,31 @@ public class QtActivityDelegate } if (Build.VERSION.SDK_INT > 10 && (inputHints & ImhHiddenText) != 0) - inputType |= 0x10; + inputType |= 0x10 /* TYPE_NUMBER_VARIATION_PASSWORD */; } 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; + if ((inputHints & (ImhDate | ImhTime)) != (ImhDate | ImhTime)) { + 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 { TYPE_DATETIME_VARIATION_NORMAL(0) } } else { // CLASS_TEXT - if ((inputHints & ImhHiddenText) != 0) { + if ((inputHints & (ImhEmailCharactersOnly | ImhUrlCharactersOnly)) != 0) { + if ((inputHints & ImhUrlCharactersOnly) != 0) { + inputType |= android.text.InputType.TYPE_TEXT_VARIATION_URI; + 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; - } else if ((inputHints & (ImhNoAutoUppercase | ImhNoPredictiveText | ImhSensitiveData)) != 0) { + } else if ((inputHints & ImhSensitiveData) != 0) { inputType |= android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD; } - if ((inputHints & ImhEmailCharactersOnly) != 0) - inputType |= android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; - - if ((inputHints & ImhUrlCharactersOnly) != 0) { - inputType |= android.text.InputType.TYPE_TEXT_VARIATION_URI; - imeOptions = android.view.inputmethod.EditorInfo.IME_ACTION_GO; - } - if ((inputHints & ImhMultiLine) != 0) inputType |= android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE; @@ -300,8 +301,10 @@ public class QtActivityDelegate inputType |= android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; } - if ((inputHints & ImhNoPredictiveText) != 0 || (inputHints & ImhSensitiveData) != 0) + if ((inputHints & ImhNoPredictiveText) != 0 || (inputHints & ImhSensitiveData) != 0 + || (inputHints & ImhHiddenText) != 0) { inputType |= android.text.InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; + } } if ((inputHints & ImhMultiLine) != 0)