Merge change 25465 into eclair
* changes: Reset typeface when changing from visible password inputType
This commit is contained in:
@@ -2874,26 +2874,23 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
* @attr ref android.R.styleable#TextView_inputType
|
* @attr ref android.R.styleable#TextView_inputType
|
||||||
*/
|
*/
|
||||||
public void setInputType(int type) {
|
public void setInputType(int type) {
|
||||||
|
final boolean wasPassword = isPasswordInputType(mInputType);
|
||||||
|
final boolean wasVisiblePassword = isVisiblePasswordInputType(mInputType);
|
||||||
setInputType(type, false);
|
setInputType(type, false);
|
||||||
final int variation = type&(EditorInfo.TYPE_MASK_CLASS
|
final boolean isPassword = isPasswordInputType(type);
|
||||||
|EditorInfo.TYPE_MASK_VARIATION);
|
final boolean isVisiblePassword = isVisiblePasswordInputType(type);
|
||||||
final boolean isPassword = variation
|
|
||||||
== (EditorInfo.TYPE_CLASS_TEXT
|
|
||||||
|EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
|
|
||||||
boolean forceUpdate = false;
|
boolean forceUpdate = false;
|
||||||
if (isPassword) {
|
if (isPassword) {
|
||||||
setTransformationMethod(PasswordTransformationMethod.getInstance());
|
setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||||
setTypefaceByIndex(MONOSPACE, 0);
|
setTypefaceByIndex(MONOSPACE, 0);
|
||||||
} else if (mTransformation == PasswordTransformationMethod.getInstance()) {
|
} else if (isVisiblePassword) {
|
||||||
// We need to clean up if we were previously in password mode.
|
|
||||||
if (variation != (EditorInfo.TYPE_CLASS_TEXT
|
|
||||||
|EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD)) {
|
|
||||||
setTypefaceByIndex(-1, -1);
|
|
||||||
}
|
|
||||||
forceUpdate = true;
|
|
||||||
} else if (variation == (EditorInfo.TYPE_CLASS_TEXT
|
|
||||||
|EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD)) {
|
|
||||||
setTypefaceByIndex(MONOSPACE, 0);
|
setTypefaceByIndex(MONOSPACE, 0);
|
||||||
|
} else if (wasPassword || wasVisiblePassword) {
|
||||||
|
// not in password mode, clean up typeface and transformation
|
||||||
|
setTypefaceByIndex(-1, -1);
|
||||||
|
if (mTransformation == PasswordTransformationMethod.getInstance()) {
|
||||||
|
forceUpdate = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean multiLine = (type&(EditorInfo.TYPE_MASK_CLASS
|
boolean multiLine = (type&(EditorInfo.TYPE_MASK_CLASS
|
||||||
@@ -2913,6 +2910,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
if (imm != null) imm.restartInput(this);
|
if (imm != null) imm.restartInput(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isPasswordInputType(int inputType) {
|
||||||
|
final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS
|
||||||
|
| EditorInfo.TYPE_MASK_VARIATION);
|
||||||
|
return variation
|
||||||
|
== (EditorInfo.TYPE_CLASS_TEXT
|
||||||
|
| EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isVisiblePasswordInputType(int inputType) {
|
||||||
|
final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS
|
||||||
|
| EditorInfo.TYPE_MASK_VARIATION);
|
||||||
|
return variation
|
||||||
|
== (EditorInfo.TYPE_CLASS_TEXT
|
||||||
|
| EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directly change the content type integer of the text view, without
|
* Directly change the content type integer of the text view, without
|
||||||
* modifying any other state.
|
* modifying any other state.
|
||||||
|
|||||||
Reference in New Issue
Block a user