diff options
author | Gilles Debunne <debunne@google.com> | 2010-11-11 13:46:17 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-11-11 13:46:17 -0800 |
commit | a61cc93199b90870f7a7dce0610c8c6a785e7090 (patch) | |
tree | 2c406450e85ca3b91611e899013e9fed48a6eca8 | |
parent | 5c7d5ae094ab90f1d0f0b1d3dbc5696bea87749e (diff) | |
parent | d7483bfffcbbd4715a9e3cc2c704fb702ec529bf (diff) | |
download | frameworks_base-a61cc93199b90870f7a7dce0610c8c6a785e7090.zip frameworks_base-a61cc93199b90870f7a7dce0610c8c6a785e7090.tar.gz frameworks_base-a61cc93199b90870f7a7dce0610c8c6a785e7090.tar.bz2 |
Merge "Lock screen should not display password."
-rw-r--r-- | core/java/android/widget/TextView.java | 75 |
1 files changed, 46 insertions, 29 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index acefe5d..fdd75d5 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -761,6 +761,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener BufferType bufferType = BufferType.EDITABLE; + final int variation = + inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION); + final boolean passwordInputType = variation + == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD); + final boolean webPasswordInputType = variation + == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD); + if (inputMethod != null) { Class<?> c; @@ -856,19 +863,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } - if (password) { - // Caller used the deprecated xml attribute "password". Ensure that - // the inputType is correct. - boolean normalText = (mInputType & EditorInfo.TYPE_MASK_CLASS) - == EditorInfo.TYPE_CLASS_TEXT; - if (normalText && !isPasswordInputType(mInputType)) { + // mInputType has been set from inputType, possibly modified by mInputMethod. + // Specialize mInputType to [web]password if we have a text class and the original input + // type was a password. + if ((mInputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) { + if (password || passwordInputType) { + mInputType = (mInputType & ~(EditorInfo.TYPE_MASK_VARIATION)) + | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD; + } + if (webPasswordInputType) { mInputType = (mInputType & ~(EditorInfo.TYPE_MASK_VARIATION)) - | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD; + | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD; } - } else if (isPasswordInputType(mInputType)) { - // Caller did not use the deprecated xml attribute "password", but - // did set the input properly. Set password to true. - password = true; } if (selectallonfocus) { @@ -882,7 +888,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener drawableLeft, drawableTop, drawableRight, drawableBottom); setCompoundDrawablePadding(drawablePadding); - setSingleLine(singleLine); + // Same as setSingleLine, but make sure the transformation method is unchanged. + setInputTypeSingleLine(singleLine); + applySingleLine(singleLine, false); + if (singleLine && mInput == null && ellipsize < 0) { ellipsize = 3; // END } @@ -911,13 +920,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } setRawTextSize(textSize); - if (password) { + if (password || passwordInputType || webPasswordInputType) { setTransformationMethod(PasswordTransformationMethod.getInstance()); typefaceIndex = MONOSPACE; - } else if ((mInputType&(EditorInfo.TYPE_MASK_CLASS - |EditorInfo.TYPE_MASK_VARIATION)) - == (EditorInfo.TYPE_CLASS_TEXT - |EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)) { + } else if ((mInputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION)) + == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)) { typefaceIndex = MONOSPACE; } @@ -1148,7 +1155,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } catch (IncompatibleClassChangeError e) { mInputType = EditorInfo.TYPE_CLASS_TEXT; } - setSingleLine(mSingleLine); + // Change inputType, without affecting transformation. + // No need to applySingleLine since mSingleLine is unchanged. + setInputTypeSingleLine(mSingleLine); } else { mInputType = EditorInfo.TYPE_NULL; } @@ -3051,21 +3060,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } private boolean isPasswordInputType(int inputType) { - final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS - | EditorInfo.TYPE_MASK_VARIATION); + final int variation = + inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION); return variation - == (EditorInfo.TYPE_CLASS_TEXT - | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD) - || variation == (EditorInfo.TYPE_CLASS_TEXT - | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD); + == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD) + || variation + == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD); } private boolean isVisiblePasswordInputType(int inputType) { - final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS - | EditorInfo.TYPE_MASK_VARIATION); + final int variation = + inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION); return variation - == (EditorInfo.TYPE_CLASS_TEXT - | EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } /** @@ -6075,6 +6082,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ @android.view.RemotableViewMethod public void setSingleLine(boolean singleLine) { + setInputTypeSingleLine(singleLine); + applySingleLine(singleLine, true); + } + + /** + * Adds or remove the EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE on the mInputType. + * @param singleLine + */ + private void setInputTypeSingleLine(boolean singleLine) { if ((mInputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) { if (singleLine) { mInputType &= ~EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; @@ -6082,7 +6098,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mInputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } } - applySingleLine(singleLine, true); } private void applySingleLine(boolean singleLine, boolean applyTransformation) { @@ -7875,6 +7890,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (hasPasswordTransformationMethod()) { // selectCurrentWord is not available on a password field and would return an // arbitrary 10-charater selection around pressed position. Select all instead. + // Note that cut/copy menu entries are not available for passwords. + // This is however useful to delete or paste to replace the entire content. Selection.setSelection((Spannable) mText, 0, mText.length()); } else { selectCurrentWord(); |