Skip to content

Commit a1aebdf

Browse files
Ben KomaloAndroid (Google) Code Review
authored andcommitted
Merge "New PIN unlock screen layout."
2 parents cac15eb + 51ea88a commit a1aebdf

File tree

5 files changed

+62
-25
lines changed

5 files changed

+62
-25
lines changed

core/java/com/android/internal/widget/PasswordEntryKeyboardHelper.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public class PasswordEntryKeyboardHelper implements OnKeyboardActionListener {
4848
private PasswordEntryKeyboard mSymbolsKeyboard;
4949
private PasswordEntryKeyboard mSymbolsKeyboardShifted;
5050
private PasswordEntryKeyboard mNumericKeyboard;
51-
private Context mContext;
52-
private View mTargetView;
53-
private KeyboardView mKeyboardView;
51+
private final Context mContext;
52+
private final View mTargetView;
53+
private final KeyboardView mKeyboardView;
5454
private long[] mVibratePattern;
55-
private Vibrator mVibrator;
55+
private final Vibrator mVibrator;
5656

5757
public PasswordEntryKeyboardHelper(Context context, KeyboardView keyboardView, View targetView) {
5858
this(context, keyboardView, targetView, true);
@@ -228,7 +228,7 @@ private void handleModeChange() {
228228
}
229229
}
230230

231-
private void handleBackspace() {
231+
public void handleBackspace() {
232232
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
233233
}
234234

core/res/res/layout/keyguard_screen_password_landscape.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@
135135
<LinearLayout
136136
android:orientation="horizontal"
137137
android:layout_width="270dip"
138-
android:layout_gravity="center_vertical">
138+
android:layout_gravity="center_vertical"
139+
android:background="@drawable/lockscreen_password_field_dark">
139140

140141
<EditText android:id="@+id/passwordEntry"
141142
android:layout_height="wrap_content"
@@ -148,11 +149,23 @@
148149
android:textSize="24sp"
149150
android:minEms="8"
150151
android:textAppearance="?android:attr/textAppearanceMedium"
151-
android:background="@drawable/lockscreen_password_field_dark"
152+
android:background="@null"
152153
android:textColor="?android:attr/textColorPrimary"
153154
android:imeOptions="flagNoFullscreen|actionDone"
154155
/>
155156

157+
<!-- This delete button is only visible for numeric PIN entry -->
158+
<ImageButton android:id="@+id/pinDel"
159+
android:layout_width="wrap_content"
160+
android:layout_height="wrap_content"
161+
android:src="@android:drawable/ic_input_delete"
162+
android:clickable="true"
163+
android:padding="8dip"
164+
android:layout_gravity="center"
165+
android:background="?android:attr/selectableItemBackground"
166+
android:visibility="gone"
167+
/>
168+
156169
<ImageView android:id="@+id/switch_ime_button"
157170
android:layout_width="wrap_content"
158171
android:layout_height="wrap_content"

core/res/res/layout/keyguard_screen_password_portrait.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,12 @@
9595
/>
9696

9797
<!-- Password entry field -->
98+
<!-- Note: the entire container is styled to look like the edit field,
99+
since the backspace/IME switcher looks better inside -->
98100
<LinearLayout
99101
android:layout_gravity="center_vertical|fill_horizontal"
100102
android:orientation="horizontal"
103+
android:background="@drawable/lockscreen_password_field_dark"
101104
android:layout_marginLeft="16dip"
102105
android:layout_marginRight="16dip">
103106

@@ -110,12 +113,24 @@
110113
android:textStyle="normal"
111114
android:inputType="textPassword"
112115
android:textSize="36sp"
113-
android:background="@drawable/lockscreen_password_field_dark"
116+
android:background="@null"
114117
android:textAppearance="?android:attr/textAppearanceMedium"
115118
android:textColor="#ffffffff"
116119
android:imeOptions="actionDone"
117120
/>
118121

122+
<!-- This delete button is only visible for numeric PIN entry -->
123+
<ImageButton android:id="@+id/pinDel"
124+
android:layout_width="wrap_content"
125+
android:layout_height="wrap_content"
126+
android:src="@android:drawable/ic_input_delete"
127+
android:clickable="true"
128+
android:padding="8dip"
129+
android:layout_gravity="center_vertical"
130+
android:background="?android:attr/selectableItemBackground"
131+
android:visibility="gone"
132+
/>
133+
119134
<ImageView android:id="@+id/switch_ime_button"
120135
android:layout_width="wrap_content"
121136
android:layout_height="wrap_content"

core/res/res/xml/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: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,18 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
6060
private final KeyguardUpdateMonitor mUpdateMonitor;
6161
private final KeyguardScreenCallback mCallback;
6262

63-
private boolean mIsAlpha;
63+
private final boolean mIsAlpha;
6464

65-
private EditText mPasswordEntry;
66-
private LockPatternUtils mLockPatternUtils;
67-
private PasswordEntryKeyboardView mKeyboardView;
68-
private PasswordEntryKeyboardHelper mKeyboardHelper;
65+
private final EditText mPasswordEntry;
66+
private final LockPatternUtils mLockPatternUtils;
67+
private final PasswordEntryKeyboardView mKeyboardView;
68+
private final PasswordEntryKeyboardHelper mKeyboardHelper;
6969

70-
private int mCreationOrientation;
71-
private int mCreationHardKeyboardHidden;
72-
private CountDownTimer mCountdownTimer;
70+
private final int mCreationOrientation;
71+
private final int mCreationHardKeyboardHidden;
7372

74-
private KeyguardStatusViewManager mStatusViewManager;
75-
private boolean mUseSystemIME = true; // TODO: Make configurable
73+
private final KeyguardStatusViewManager mStatusViewManager;
74+
private final boolean mUseSystemIME = true; // TODO: Make configurable
7675
private boolean mResuming; // used to prevent poking the wakelock during onResume()
7776

7877
// To avoid accidental lockout due to events while the device in in the pocket, ignore
@@ -119,6 +118,19 @@ public PasswordUnlockScreen(Context context, Configuration configuration,
119118
mKeyboardHelper.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
120119
mKeyboardView.setVisibility(mCreationHardKeyboardHidden
121120
== Configuration.HARDKEYBOARDHIDDEN_NO ? View.INVISIBLE : View.VISIBLE);
121+
122+
// The delete button is of the PIN keyboard itself in some (e.g. tablet) layouts,
123+
// not a separate view
124+
View pinDelete = findViewById(R.id.pinDel);
125+
if (pinDelete != null) {
126+
pinDelete.setVisibility(View.VISIBLE);
127+
pinDelete.setOnClickListener(new OnClickListener() {
128+
@Override
129+
public void onClick(View v) {
130+
mKeyboardHelper.handleBackspace();
131+
}
132+
});
133+
}
122134
}
123135

124136
mPasswordEntry.requestFocus();
@@ -293,7 +305,7 @@ private void handleAttemptLockout(long elapsedRealtimeDeadline) {
293305
mPasswordEntry.setEnabled(false);
294306
mKeyboardView.setEnabled(false);
295307
long elapsedRealtime = SystemClock.elapsedRealtime();
296-
mCountdownTimer = new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime, 1000) {
308+
new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime, 1000) {
297309

298310
@Override
299311
public void onTick(long millisUntilFinished) {
@@ -309,7 +321,6 @@ public void onFinish() {
309321
mPasswordEntry.setEnabled(true);
310322
mKeyboardView.setEnabled(true);
311323
mStatusViewManager.resetStatusInfo();
312-
mCountdownTimer = null;
313324
}
314325
}.start();
315326
}

0 commit comments

Comments
 (0)