Skip to content

Commit 8082d5d

Browse files
Devin TaylorGarmin Android technology group
authored andcommitted
Fix last character of password field being visible after rotation
This is a fix for http://code.google.com/p/android/issues/detail?id=907. Note that that issue was declined without comment, but the bug (while incredibly minor) does exist. This can be seen on the facebook app, as well as many third party apps. Change-Id: I8f1449c47228f5f757a5baf389656e51c817b150
1 parent 0d3b202 commit 8082d5d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

core/java/android/text/method/PasswordTransformationMethod.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public CharSequence getTransformation(CharSequence source, View view) {
5151
sp.removeSpan(vr[i]);
5252
}
5353

54+
removeVisibleSpans(sp);
55+
5456
sp.setSpan(new ViewReference(view), 0, 0,
5557
Spannable.SPAN_POINT_POINT);
5658
}
@@ -100,10 +102,7 @@ public void onTextChanged(CharSequence s, int start,
100102
int pref = TextKeyListener.getInstance().getPrefs(v.getContext());
101103
if ((pref & TextKeyListener.SHOW_PASSWORD) != 0) {
102104
if (count > 0) {
103-
Visible[] old = sp.getSpans(0, sp.length(), Visible.class);
104-
for (int i = 0; i < old.length; i++) {
105-
sp.removeSpan(old[i]);
106-
}
105+
removeVisibleSpans(sp);
107106

108107
if (count == 1) {
109108
sp.setSpan(new Visible(sp, this), start, start + count,
@@ -125,14 +124,18 @@ public void onFocusChanged(View view, CharSequence sourceText,
125124
if (sourceText instanceof Spannable) {
126125
Spannable sp = (Spannable) sourceText;
127126

128-
Visible[] old = sp.getSpans(0, sp.length(), Visible.class);
129-
for (int i = 0; i < old.length; i++) {
130-
sp.removeSpan(old[i]);
131-
}
127+
removeVisibleSpans(sp);
132128
}
133129
}
134130
}
135131

132+
private static void removeVisibleSpans(Spannable sp) {
133+
Visible[] old = sp.getSpans(0, sp.length(), Visible.class);
134+
for (int i = 0; i < old.length; i++) {
135+
sp.removeSpan(old[i]);
136+
}
137+
}
138+
136139
private static class PasswordCharSequence
137140
implements CharSequence, GetChars
138141
{

0 commit comments

Comments
 (0)