summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2010-10-18 17:19:57 -0700
committerGilles Debunne <debunne@google.com>2010-10-18 17:19:57 -0700
commitb82213d54bec0b11625e96d105763562ad78c258 (patch)
tree925fa40b2e4ddcd20d67833cb6eaac4efc2ef021
parentc44651dc1d3817ddbffcd1f5ea8284d3fc332b7a (diff)
parent6775754ae3b765e50466048ab02a8d43d0ea6c61 (diff)
downloadframeworks_base-b82213d54bec0b11625e96d105763562ad78c258.zip
frameworks_base-b82213d54bec0b11625e96d105763562ad78c258.tar.gz
frameworks_base-b82213d54bec0b11625e96d105763562ad78c258.tar.bz2
resolved conflicts for merge of 6775754a to master
Change-Id: Ib03417aa3f13839b7fdf24f7d66b2d449589d41e
-rw-r--r--core/java/android/widget/TextView.java33
1 files changed, 29 insertions, 4 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 9e6f342..d071dd2 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -3015,6 +3015,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);
@@ -7233,7 +7252,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
private boolean canCut() {
- if (mTransformation instanceof PasswordTransformationMethod) {
+ if (hasPasswordTransformationMethod()) {
return false;
}
@@ -7247,7 +7266,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
private boolean canCopy() {
- if (mTransformation instanceof PasswordTransformationMethod) {
+ if (hasPasswordTransformationMethod()) {
return false;
}
@@ -7721,11 +7740,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mode.setTitle(mContext.getString(com.android.internal.R.string.textSelectionCABTitle));
mode.setSubtitle(null);
- selectCurrentWord();
-
boolean atLeastOne = false;
if (canSelectText()) {
+ if (hasPasswordTransformationMethod()) {
+ // selectCurrentWord is not available on a password field and would return an
+ // arbitrary 10-charater selection around pressed position. Select all instead.
+ Selection.setSelection((Spannable) mText, 0, mText.length());
+ } else {
+ selectCurrentWord();
+ }
+
menu.add(0, ID_SELECT_ALL, 0, com.android.internal.R.string.selectAll).
setIcon(com.android.internal.R.drawable.ic_menu_select_all).
setAlphabeticShortcut('a').