diff options
| author | Gilles Debunne <debunne@google.com> | 2010-10-15 16:29:25 -0700 |
|---|---|---|
| committer | Gilles Debunne <debunne@google.com> | 2010-10-15 16:29:25 -0700 |
| commit | 0dcad2bd017227b5cc186e657b5b24b52a00a1c8 (patch) | |
| tree | 11b28a3fab3fc78186dbbd682c7186a531f877c4 | |
| parent | e1f3976bb4eab0d7c46bc8596679d4d00695148c (diff) | |
| download | frameworks_base-0dcad2bd017227b5cc186e657b5b24b52a00a1c8.zip frameworks_base-0dcad2bd017227b5cc186e657b5b24b52a00a1c8.tar.gz frameworks_base-0dcad2bd017227b5cc186e657b5b24b52a00a1c8.tar.bz2 | |
Removed "Select word" option on password fields.
It would return an arbitrary selection around current position.
Rely on select all instead.
Bug: 3100750
Change-Id: I73d995e6481d7c230cc9f334c72fbfb7e9828007
| -rw-r--r-- | core/java/android/widget/TextView.java | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 9080f96..d719783 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -2956,6 +2956,25 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (imm != null) imm.restartInput(this); } + /** + * It would be better to rely on the input type for everything. A password inputType should have + * a password transformation. We should hence use isPasswordInputType instead of this method. + * + * We should: + * - Call setInputType in setKeyListener instead of changing the input type directly (which + * would install the correct transformation). + * - Refuse the installation of a non-password transformation in setTransformation if the input + * type is password. + * + * However, this is like this for legacy reasons and we cannot break existing apps. This method + * is useful since it matches what the user can see (obfuscated text or not). + * + * @return true if the current transformation method is of the password type. + */ + private boolean hasPasswordTransformationMethod() { + return mTransformation instanceof PasswordTransformationMethod; + } + private boolean isPasswordInputType(int inputType) { final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION); @@ -7135,7 +7154,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } private boolean canCut() { - if (mTransformation instanceof PasswordTransformationMethod) { + if (hasPasswordTransformationMethod()) { return false; } @@ -7149,7 +7168,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } private boolean canCopy() { - if (mTransformation instanceof PasswordTransformationMethod) { + if (hasPasswordTransformationMethod()) { return false; } @@ -7398,8 +7417,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener MenuHandler handler = new MenuHandler(); if (canSelectText()) { - menu.add(0, ID_START_SELECTING_TEXT, 0, com.android.internal.R.string.selectText). - setOnMenuItemClickListener(handler); + if (!hasPasswordTransformationMethod()) { + // selectCurrentWord is not available on a password field and would return an + // arbitrary 10-charater selection around pressed position. Discard it. + // SelectAll is still useful to be able to clear the field using the delete key. + menu.add(0, ID_START_SELECTING_TEXT, 0, com.android.internal.R.string.selectText). + setOnMenuItemClickListener(handler); + } menu.add(0, ID_SELECT_ALL, 0, com.android.internal.R.string.selectAll). setOnMenuItemClickListener(handler). setAlphabeticShortcut('a'); |
