Merge "New PIN unlock screen layout."
diff --git a/core/java/com/android/internal/widget/PasswordEntryKeyboardHelper.java b/core/java/com/android/internal/widget/PasswordEntryKeyboardHelper.java
index 366b983..01df48a 100644
--- a/core/java/com/android/internal/widget/PasswordEntryKeyboardHelper.java
+++ b/core/java/com/android/internal/widget/PasswordEntryKeyboardHelper.java
@@ -48,11 +48,11 @@
     private PasswordEntryKeyboard mSymbolsKeyboard;
     private PasswordEntryKeyboard mSymbolsKeyboardShifted;
     private PasswordEntryKeyboard mNumericKeyboard;
-    private Context mContext;
-    private View mTargetView;
-    private KeyboardView mKeyboardView;
+    private final Context mContext;
+    private final View mTargetView;
+    private final KeyboardView mKeyboardView;
     private long[] mVibratePattern;
-    private Vibrator mVibrator;
+    private final Vibrator mVibrator;
 
     public PasswordEntryKeyboardHelper(Context context, KeyboardView keyboardView, View targetView) {
         this(context, keyboardView, targetView, true);
@@ -228,7 +228,7 @@
         }
     }
 
-    private void handleBackspace() {
+    public void handleBackspace() {
         sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
     }
 
diff --git a/core/res/res/layout/keyguard_screen_password_landscape.xml b/core/res/res/layout/keyguard_screen_password_landscape.xml
index 8bc5f34..e34822d 100644
--- a/core/res/res/layout/keyguard_screen_password_landscape.xml
+++ b/core/res/res/layout/keyguard_screen_password_landscape.xml
@@ -135,7 +135,8 @@
     <LinearLayout
         android:orientation="horizontal"
         android:layout_width="270dip"
-        android:layout_gravity="center_vertical">
+        android:layout_gravity="center_vertical"
+        android:background="@drawable/lockscreen_password_field_dark">
 
         <EditText android:id="@+id/passwordEntry"
             android:layout_height="wrap_content"
@@ -148,11 +149,23 @@
             android:textSize="24sp"
             android:minEms="8"
             android:textAppearance="?android:attr/textAppearanceMedium"
-            android:background="@drawable/lockscreen_password_field_dark"
+            android:background="@null"
             android:textColor="?android:attr/textColorPrimary"
             android:imeOptions="flagNoFullscreen|actionDone"
             />
 
+        <!-- This delete button is only visible for numeric PIN entry -->
+        <ImageButton android:id="@+id/pinDel"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:src="@android:drawable/ic_input_delete"
+            android:clickable="true"
+            android:padding="8dip"
+            android:layout_gravity="center"
+            android:background="?android:attr/selectableItemBackground"
+            android:visibility="gone"
+            />
+
         <ImageView android:id="@+id/switch_ime_button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
diff --git a/core/res/res/layout/keyguard_screen_password_portrait.xml b/core/res/res/layout/keyguard_screen_password_portrait.xml
index 2a66d7d..e1280ba 100644
--- a/core/res/res/layout/keyguard_screen_password_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_password_portrait.xml
@@ -95,9 +95,12 @@
         />
 
     <!-- Password entry field -->
+    <!-- Note: the entire container is styled to look like the edit field,
+         since the backspace/IME switcher looks better inside -->
     <LinearLayout
         android:layout_gravity="center_vertical|fill_horizontal"
         android:orientation="horizontal"
+        android:background="@drawable/lockscreen_password_field_dark"
         android:layout_marginLeft="16dip"
         android:layout_marginRight="16dip">
 
@@ -110,12 +113,24 @@
             android:textStyle="normal"
             android:inputType="textPassword"
             android:textSize="36sp"
-            android:background="@drawable/lockscreen_password_field_dark"
+            android:background="@null"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:textColor="#ffffffff"
             android:imeOptions="actionDone"
             />
 
+        <!-- This delete button is only visible for numeric PIN entry -->
+        <ImageButton android:id="@+id/pinDel"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:src="@android:drawable/ic_input_delete"
+            android:clickable="true"
+            android:padding="8dip"
+            android:layout_gravity="center_vertical"
+            android:background="?android:attr/selectableItemBackground"
+            android:visibility="gone"
+            />
+
         <ImageView android:id="@+id/switch_ime_button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
diff --git a/core/res/res/xml/password_kbd_numeric.xml b/core/res/res/xml/password_kbd_numeric.xml
index 2fd5aa0..560f867 100755
--- a/core/res/res/xml/password_kbd_numeric.xml
+++ b/core/res/res/xml/password_kbd_numeric.xml
@@ -49,12 +49,10 @@
     </Row>
 
     <Row android:rowEdgeFlags="bottom">
+        <Key android:codes="48" android:keyIcon="@drawable/sym_keyboard_num0_no_plus"
+             android:keyWidth="66.66%p" android:keyEdgeFlags="left"/>
         <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_ok"
-             android:keyEdgeFlags="left"/>
-        <Key android:codes="48" android:keyIcon="@drawable/sym_keyboard_num0_no_plus"/>
-        <Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete"
-             android:iconPreview="@drawable/sym_keyboard_feedback_delete"
-             android:isRepeatable="true" android:keyEdgeFlags="right"/>
+             android:keyEdgeFlags="right"/>
     </Row>
 
 </Keyboard>
diff --git a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
index 6d2f2f2..ec0072c 100644
--- a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
@@ -60,19 +60,18 @@
     private final KeyguardUpdateMonitor mUpdateMonitor;
     private final KeyguardScreenCallback mCallback;
 
-    private boolean mIsAlpha;
+    private final boolean mIsAlpha;
 
-    private EditText mPasswordEntry;
-    private LockPatternUtils mLockPatternUtils;
-    private PasswordEntryKeyboardView mKeyboardView;
-    private PasswordEntryKeyboardHelper mKeyboardHelper;
+    private final EditText mPasswordEntry;
+    private final LockPatternUtils mLockPatternUtils;
+    private final PasswordEntryKeyboardView mKeyboardView;
+    private final PasswordEntryKeyboardHelper mKeyboardHelper;
 
-    private int mCreationOrientation;
-    private int mCreationHardKeyboardHidden;
-    private CountDownTimer mCountdownTimer;
+    private final int mCreationOrientation;
+    private final int mCreationHardKeyboardHidden;
 
-    private KeyguardStatusViewManager mStatusViewManager;
-    private boolean mUseSystemIME = true; // TODO: Make configurable
+    private final KeyguardStatusViewManager mStatusViewManager;
+    private final boolean mUseSystemIME = true; // TODO: Make configurable
     private boolean mResuming; // used to prevent poking the wakelock during onResume()
 
     // To avoid accidental lockout due to events while the device in in the pocket, ignore
@@ -119,6 +118,19 @@
             mKeyboardHelper.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
             mKeyboardView.setVisibility(mCreationHardKeyboardHidden
                     == Configuration.HARDKEYBOARDHIDDEN_NO ? View.INVISIBLE : View.VISIBLE);
+
+            // The delete button is of the PIN keyboard itself in some (e.g. tablet) layouts,
+            // not a separate view
+            View pinDelete = findViewById(R.id.pinDel);
+            if (pinDelete != null) {
+                pinDelete.setVisibility(View.VISIBLE);
+                pinDelete.setOnClickListener(new OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        mKeyboardHelper.handleBackspace();
+                    }
+                });
+            }
         }
 
         mPasswordEntry.requestFocus();
@@ -293,7 +305,7 @@
         mPasswordEntry.setEnabled(false);
         mKeyboardView.setEnabled(false);
         long elapsedRealtime = SystemClock.elapsedRealtime();
-        mCountdownTimer = new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime, 1000) {
+        new CountDownTimer(elapsedRealtimeDeadline - elapsedRealtime, 1000) {
 
             @Override
             public void onTick(long millisUntilFinished) {
@@ -309,7 +321,6 @@
                 mPasswordEntry.setEnabled(true);
                 mKeyboardView.setEnabled(true);
                 mStatusViewManager.resetStatusInfo();
-                mCountdownTimer = null;
             }
         }.start();
     }