Skip to content

Commit d9d0945

Browse files
author
Jim Miller
committed
Fix 5231823: PIN/Password polish on lock screen
Fixes these issues: - add IME button to switch IMEs on password screen on tablet - centers '0' on PIN screen for phones and tablets - tablets now use the same ICS background key asset as phones - make PIN layout consistent between phones and tablet - center the I-beam when any button is showing in the password entry field Change-Id: I4da0173f9b2efeab46617c5a41a8132895b63a97
1 parent c37f98e commit d9d0945

File tree

10 files changed

+123
-32
lines changed

10 files changed

+123
-32
lines changed
-468 Bytes
Loading
-95 Bytes
Loading
-495 Bytes
Loading

core/res/res/layout-sw600dp/keyguard_screen_password_landscape.xml

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,64 @@
5050
android:layout_centerVertical="true"
5151
android:layout_marginRight="155dip">
5252

53-
<!-- Password entry field -->
54-
<EditText android:id="@+id/passwordEntry"
55-
android:layout_height="wrap_content"
53+
54+
<LinearLayout
55+
android:orientation="horizontal"
5656
android:layout_width="match_parent"
57-
android:singleLine="true"
58-
android:textStyle="normal"
59-
android:inputType="textPassword"
60-
android:gravity="center"
61-
android:textSize="24sp"
62-
android:textAppearance="?android:attr/textAppearanceMedium"
63-
android:background="@drawable/lockscreen_password_field_dark"
64-
android:textColor="#ffffffff"
65-
android:privateImeOptions="com.google.android.inputmethod.latin.forceAscii"
66-
/>
57+
android:layout_height="wrap_content"
58+
android:layout_gravity="center_vertical"
59+
android:background="@drawable/lockscreen_password_field_dark">
60+
61+
<EditText android:id="@+id/passwordEntry"
62+
android:layout_height="wrap_content"
63+
android:layout_width="0dip"
64+
android:layout_weight="1"
65+
android:gravity="center"
66+
android:layout_gravity="center"
67+
android:layout_marginLeft="@dimen/keyguard_lockscreen_pin_margin_left"
68+
android:singleLine="true"
69+
android:textStyle="normal"
70+
android:inputType="textPassword"
71+
android:textSize="24sp"
72+
android:textAppearance="?android:attr/textAppearanceMedium"
73+
android:background="@null"
74+
android:textColor="#ffffffff"
75+
android:imeOptions="flagNoFullscreen|actionDone"
76+
android:privateImeOptions="com.google.android.inputmethod.latin.forceAscii"
77+
/>
78+
79+
<!-- This delete button is only visible for numeric PIN entry -->
80+
<ImageButton android:id="@+id/pinDel"
81+
android:layout_width="wrap_content"
82+
android:layout_height="wrap_content"
83+
android:src="@android:drawable/ic_input_delete"
84+
android:clickable="true"
85+
android:padding="8dip"
86+
android:layout_gravity="center"
87+
android:background="?android:attr/selectableItemBackground"
88+
android:visibility="gone"
89+
/>
90+
91+
<ImageView android:id="@+id/switch_ime_button"
92+
android:layout_width="wrap_content"
93+
android:layout_height="wrap_content"
94+
android:src="@drawable/ic_lockscreen_ime"
95+
android:clickable="true"
96+
android:padding="8dip"
97+
android:layout_gravity="center"
98+
android:background="?android:attr/selectableItemBackground"
99+
android:visibility="gone"
100+
/>
101+
102+
</LinearLayout>
67103

68104
<!-- Numeric keyboard -->
69105
<com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
70106
android:layout_width="330dip"
71107
android:layout_height="330dip"
72108
android:background="#40000000"
73109
android:layout_marginTop="5dip"
74-
android:keyBackground="@drawable/btn_keyboard_key_fulltrans"
110+
android:keyBackground="@drawable/btn_keyboard_key_ics"
75111
android:visibility="gone"
76112
/>
77113
</LinearLayout>

core/res/res/layout-sw600dp/keyguard_screen_password_portrait.xml

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,56 @@
4444
android:gravity="center">
4545

4646
<!-- Password entry field -->
47-
<EditText android:id="@+id/passwordEntry"
48-
android:layout_height="wrap_content"
47+
<LinearLayout
48+
android:orientation="horizontal"
4949
android:layout_width="330dip"
50-
android:singleLine="true"
51-
android:textStyle="normal"
52-
android:inputType="textPassword"
53-
android:gravity="center"
50+
android:layout_height="wrap_content"
5451
android:layout_gravity="center"
55-
android:textSize="24sp"
5652
android:layout_marginTop="120dip"
5753
android:layout_marginBottom="5dip"
58-
android:textAppearance="?android:attr/textAppearanceMedium"
59-
android:background="@drawable/lockscreen_password_field_dark"
60-
android:textColor="#ffffffff"
61-
android:privateImeOptions="com.google.android.inputmethod.latin.forceAscii"
62-
/>
54+
android:background="@drawable/lockscreen_password_field_dark">
55+
56+
<EditText android:id="@+id/passwordEntry"
57+
android:layout_height="wrap_content"
58+
android:layout_width="0dip"
59+
android:layout_weight="1"
60+
android:singleLine="true"
61+
android:textStyle="normal"
62+
android:inputType="textPassword"
63+
android:gravity="center"
64+
android:layout_gravity="center"
65+
android:layout_marginLeft="@dimen/keyguard_lockscreen_pin_margin_left"
66+
android:textSize="24sp"
67+
android:textAppearance="?android:attr/textAppearanceMedium"
68+
android:background="@null"
69+
android:textColor="#ffffffff"
70+
android:privateImeOptions="com.google.android.inputmethod.latin.forceAscii"
71+
/>
72+
73+
<!-- This delete button is only visible for numeric PIN entry -->
74+
<ImageButton android:id="@+id/pinDel"
75+
android:layout_width="wrap_content"
76+
android:layout_height="wrap_content"
77+
android:src="@android:drawable/ic_input_delete"
78+
android:clickable="true"
79+
android:padding="8dip"
80+
android:layout_gravity="center"
81+
android:background="?android:attr/selectableItemBackground"
82+
android:visibility="gone"
83+
/>
84+
85+
<ImageView android:id="@+id/switch_ime_button"
86+
android:layout_width="wrap_content"
87+
android:layout_height="wrap_content"
88+
android:src="@drawable/ic_lockscreen_ime"
89+
android:clickable="true"
90+
android:padding="8dip"
91+
android:layout_gravity="center"
92+
android:background="?android:attr/selectableItemBackground"
93+
android:visibility="gone"
94+
/>
95+
96+
</LinearLayout>
6397

6498
<View
6599
android:layout_width="match_parent"
@@ -72,7 +106,7 @@
72106
android:layout_width="330dip"
73107
android:layout_height="260dip"
74108
android:background="#40000000"
75-
android:keyBackground="@drawable/btn_keyboard_key_fulltrans"
109+
android:keyBackground="@drawable/btn_keyboard_key_ics"
76110
android:layout_marginBottom="80dip"
77111
/>
78112

core/res/res/layout/keyguard_screen_password_landscape.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@
143143
android:layout_width="0dip"
144144
android:layout_weight="1"
145145
android:gravity="center"
146+
android:layout_marginLeft="@dimen/keyguard_lockscreen_pin_margin_left"
147+
android:layout_gravity="center_vertical"
146148
android:singleLine="true"
147149
android:textStyle="normal"
148150
android:inputType="textPassword"

core/res/res/layout/keyguard_screen_password_portrait.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@
109109
android:layout_height="wrap_content"
110110
android:layout_weight="1"
111111
android:gravity="center_horizontal"
112+
android:layout_gravity="center_vertical"
113+
android:layout_marginLeft="@dimen/keyguard_lockscreen_pin_margin_left"
112114
android:singleLine="true"
113115
android:textStyle="normal"
114116
android:inputType="textPassword"

core/res/res/values/dimens.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@
169169
<!-- Size of top margin on Clock font to edge on unlock LockScreen -->
170170
<dimen name="keyguard_lockscreen_status_line_clockfont_bottom_margin">12dip</dimen>
171171

172+
<!-- Padding on left margin of PIN text entry field to center it when del button is showing -->
173+
<dimen name="keyguard_lockscreen_pin_margin_left">40dip</dimen>
174+
172175
<!-- Minimum popup width for selecting an activity in ActivityChooserDialog/ActivityChooserView. -->
173176
<dimen name="activity_chooser_popup_min_width">200dip</dimen>
174177

core/res/res/xml-xlarge/password_kbd_numeric.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@
4949
</Row>
5050

5151
<Row android:rowEdgeFlags="bottom">
52+
<Key android:codes="48" android:keyIcon="@drawable/sym_keyboard_num0_no_plus"
53+
android:keyWidth="66.66%p" android:keyEdgeFlags="left"/>
5254
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_ok"
53-
android:keyEdgeFlags="left"/>
54-
<Key android:codes="48" android:keyIcon="@drawable/sym_keyboard_num0_no_plus"/>
55-
<Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete"
56-
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
57-
android:isRepeatable="true" android:keyEdgeFlags="right"/>
55+
android:keyEdgeFlags="right"/>
5856
</Row>
5957

6058
</Keyboard>

policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@
3535
import android.text.TextWatcher;
3636
import android.text.method.DigitsKeyListener;
3737
import android.text.method.TextKeyListener;
38+
import android.view.Gravity;
3839
import android.view.KeyEvent;
3940
import android.view.LayoutInflater;
4041
import android.view.View;
42+
import android.view.ViewGroup.LayoutParams;
4143
import android.view.inputmethod.EditorInfo;
4244
import android.view.inputmethod.InputMethodInfo;
4345
import android.view.inputmethod.InputMethodManager;
4446
import android.view.inputmethod.InputMethodSubtype;
4547
import android.widget.EditText;
4648
import android.widget.LinearLayout;
49+
import android.widget.Space;
4750
import android.widget.TextView;
4851
import android.widget.TextView.OnEditorActionListener;
4952

@@ -114,6 +117,7 @@ public PasswordUnlockScreen(Context context, Configuration configuration,
114117
Settings.Secure.getInt(mContext.getContentResolver(),
115118
Settings.Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED, 0)
116119
!= 0);
120+
boolean imeOrDeleteButtonVisible = false;
117121
if (mIsAlpha) {
118122
// We always use the system IME for alpha keyboard, so hide lockscreen's soft keyboard
119123
mKeyboardHelper.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA);
@@ -129,6 +133,7 @@ public PasswordUnlockScreen(Context context, Configuration configuration,
129133
View pinDelete = findViewById(R.id.pinDel);
130134
if (pinDelete != null) {
131135
pinDelete.setVisibility(View.VISIBLE);
136+
imeOrDeleteButtonVisible = true;
132137
pinDelete.setOnClickListener(new OnClickListener() {
133138
@Override
134139
public void onClick(View v) {
@@ -181,13 +186,24 @@ public void afterTextChanged(Editable s) {
181186
Context.INPUT_METHOD_SERVICE);
182187
if (mIsAlpha && switchImeButton != null && hasMultipleEnabledIMEsOrSubtypes(imm, false)) {
183188
switchImeButton.setVisibility(View.VISIBLE);
189+
imeOrDeleteButtonVisible = true;
184190
switchImeButton.setOnClickListener(new OnClickListener() {
185191
public void onClick(View v) {
186192
mCallback.pokeWakelock(); // Leave the screen on a bit longer
187193
imm.showInputMethodPicker();
188194
}
189195
});
190196
}
197+
198+
// If no icon is visible, reset the left margin on the password field so the text is
199+
// still centered.
200+
if (!imeOrDeleteButtonVisible) {
201+
android.view.ViewGroup.LayoutParams params = mPasswordEntry.getLayoutParams();
202+
if (params instanceof MarginLayoutParams) {
203+
((MarginLayoutParams)params).leftMargin = 0;
204+
mPasswordEntry.setLayoutParams(params);
205+
}
206+
}
191207
}
192208

193209
/**

0 commit comments

Comments
 (0)