Skip to content

Commit

Permalink
Merge pull request #2189 from hieupham007/timob-9098-2_0_X
Browse files Browse the repository at this point in the history
Timob 9098-2_0_X: Password not masked properly
  • Loading branch information
vishalduggal committed May 17, 2012
2 parents a0182e1 + 5adc3c7 commit b7f0219
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
import android.text.Editable;
import android.text.InputType;
import android.text.TextUtils.TruncateAt;
Expand Down Expand Up @@ -324,15 +325,11 @@ public void handleKeyboard(KrollDict d)
int type = KEYBOARD_ASCII;
boolean passwordMask = false;
boolean editable = true;
int autocorrect = InputType.TYPE_TEXT_FLAG_AUTO_CORRECT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
int autocorrect = InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
int autoCapValue = 0;

if (d.containsKey(TiC.PROPERTY_AUTOCORRECT)) {
if(TiConvert.toBoolean(d, TiC.PROPERTY_AUTOCORRECT)) {
autocorrect = InputType.TYPE_TEXT_FLAG_AUTO_CORRECT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
} else {
autocorrect = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
}
if (d.containsKey(TiC.PROPERTY_AUTOCORRECT) && !TiConvert.toBoolean(d, TiC.PROPERTY_AUTOCORRECT)) {
autocorrect = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
}

if (d.containsKey(TiC.PROPERTY_EDITABLE)) {
Expand Down Expand Up @@ -374,10 +371,9 @@ public void handleKeyboard(KrollDict d)

int typeModifiers = autocorrect | autoCapValue;
int textTypeAndClass = typeModifiers;
// For some reason you can't set both TYPE_CLASS_TEXT and
// TYPE_TEXT_FLAG_NO_SUGGESTIONS together.
if (autocorrect != InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) {
// Go ahead and tack on text class
// For some reason you can't set both TYPE_CLASS_TEXT and TYPE_TEXT_FLAG_NO_SUGGESTIONS together.
// Also, we need TYPE_CLASS_TEXT for passwords.
if (autocorrect != InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS || passwordMask) {
textTypeAndClass = textTypeAndClass | InputType.TYPE_CLASS_TEXT;
}
tv.setCursorVisible(true);
Expand Down Expand Up @@ -430,6 +426,11 @@ protected char[] getAcceptedChars() {
if (passwordMask) {
tv.setTransformationMethod(PasswordTransformationMethod.getInstance());
textTypeAndClass |= InputType.TYPE_TEXT_VARIATION_PASSWORD;
//turn off text UI in landscape mode b/c Android numeric passwords are not masked correctly in landscape mode.
if (type == KEYBOARD_NUMBERS_PUNCTUATION || type == KEYBOARD_DECIMAL_PAD || type == KEYBOARD_NUMBER_PAD) {
tv.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
}

} else {
if (tv.getTransformationMethod() instanceof PasswordTransformationMethod) {
tv.setTransformationMethod(null);
Expand Down

0 comments on commit b7f0219

Please sign in to comment.