am 3d01cb93: Merge "Removed "Select word" option on password fields." into gingerbread
Merge commit '3d01cb934ba2c5161689834d49f520313e554571' into gingerbread-plus-aosp * commit '3d01cb934ba2c5161689834d49f520313e554571': Removed "Select word" option on password fields.
This commit is contained in:
@@ -2956,6 +2956,25 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
if (imm != null) imm.restartInput(this);
|
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) {
|
private boolean isPasswordInputType(int inputType) {
|
||||||
final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS
|
final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS
|
||||||
| EditorInfo.TYPE_MASK_VARIATION);
|
| EditorInfo.TYPE_MASK_VARIATION);
|
||||||
@@ -7140,7 +7159,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean canCut() {
|
private boolean canCut() {
|
||||||
if (mTransformation instanceof PasswordTransformationMethod) {
|
if (hasPasswordTransformationMethod()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7154,7 +7173,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean canCopy() {
|
private boolean canCopy() {
|
||||||
if (mTransformation instanceof PasswordTransformationMethod) {
|
if (hasPasswordTransformationMethod()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7403,8 +7422,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
MenuHandler handler = new MenuHandler();
|
MenuHandler handler = new MenuHandler();
|
||||||
|
|
||||||
if (canSelectText()) {
|
if (canSelectText()) {
|
||||||
|
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).
|
menu.add(0, ID_START_SELECTING_TEXT, 0, com.android.internal.R.string.selectText).
|
||||||
setOnMenuItemClickListener(handler);
|
setOnMenuItemClickListener(handler);
|
||||||
|
}
|
||||||
menu.add(0, ID_SELECT_ALL, 0, com.android.internal.R.string.selectAll).
|
menu.add(0, ID_SELECT_ALL, 0, com.android.internal.R.string.selectAll).
|
||||||
setOnMenuItemClickListener(handler).
|
setOnMenuItemClickListener(handler).
|
||||||
setAlphabeticShortcut('a');
|
setAlphabeticShortcut('a');
|
||||||
|
|||||||
Reference in New Issue
Block a user