Fix 3281395: Use breadcrumb area to display title for LockScreen

Change-Id: Icd631b4c70e7b9f6b9a8c24dd513aed259a22d6a
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b82d931..356ba64 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -710,24 +710,33 @@
 
         <!-- Second and third-level settings -->
 
-        <activity android:name="ConfirmLockPattern"/>
 
-        <activity android:name="ConfirmLockPassword"/>>
+        <!-- Lock screen settings -->
+        <activity android:name="ConfirmLockPattern"
+            android:label="@string/lockpassword_confirm_your_pattern_header"/>
 
-        <activity android:name="ChooseLockGeneric">
+        <activity android:name="ConfirmLockPassword"
+            android:label="@string/lockpassword_confirm_your_password_header"/>>
+
+        <activity android:name="ChooseLockGeneric"
+            android:label="@string/lockpassword_choose_lock_generic_header">
             <intent-filter>
                 <action android:name="android.app.action.SET_NEW_PASSWORD" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </activity>
 
-        <activity android:name="ChooseLockPattern" android:exported="false"/>
+        <activity android:name="ChooseLockPattern" android:exported="false"
+            android:label="@string/lockpassword_choose_your_pattern_header"/>
 
-        <activity android:name="ChooseLockPassword" android:exported="false"/>
+        <activity android:name="ChooseLockPassword" android:exported="false"
+            android:label="@string/lockpassword_choose_your_password_header"/>
 
-        <activity android:name="ChooseLockPatternTutorial"/>
+        <activity android:name="ChooseLockPatternTutorial"
+            android:label="@string/lockpassword_choose_your_pattern_header"/>
 
-        <activity android:name="ChooseLockPatternExample"/>
+        <activity android:name="ChooseLockPatternExample"
+            android:label="@string/lockpassword_choose_your_pattern_header"/>
 
         <!-- Runs in the phone process since it needs access to the Phone object -->
         <activity android:name=".deviceinfo.Status"
diff --git a/res/layout-xlarge/choose_lock_password.xml b/res/layout-xlarge/choose_lock_password.xml
index ef27a0f..f923971 100644
--- a/res/layout-xlarge/choose_lock_password.xml
+++ b/res/layout-xlarge/choose_lock_password.xml
@@ -74,25 +74,36 @@
         android:visibility="gone"
     />
 
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="0dip"
+    />
+
     <RelativeLayout
         android:layout_height="wrap_content"
         android:layout_width="match_parent">
 
-        <Button android:id="@+id/cancel_button"
-            android:layout_width="150dip"
+        <LinearLayout
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_margin="5dip"
-            android:layout_alignParentLeft="true"
-            android:text="@string/lockpassword_cancel_label"
-        />
-
-        <Button android:id="@+id/next_button"
-            android:layout_width="150dip"
-            android:layout_height="wrap_content"
-            android:layout_margin="5dip"
             android:layout_alignParentRight="true"
-            android:text="@string/lockpassword_continue_label"
-        />
+            android:orientation="horizontal">
+
+            <Button android:id="@+id/cancel_button"
+                android:layout_width="140dip"
+                android:layout_height="wrap_content"
+                android:ellipsize="marquee"
+                android:singleLine="true"
+                android:text="@string/lockpassword_cancel_label"/>
+
+            <Button android:id="@+id/next_button"
+                android:layout_width="140dip"
+                android:layout_height="wrap_content"
+                android:ellipsize="marquee"
+                android:singleLine="true"
+                android:text="@string/lockpassword_continue_label"/>
+
+        </LinearLayout>
 
     </RelativeLayout>
 
diff --git a/res/layout-xlarge/confirm_lock_password.xml b/res/layout-xlarge/confirm_lock_password.xml
index 5a5d6b2..abb0d79 100644
--- a/res/layout-xlarge/confirm_lock_password.xml
+++ b/res/layout-xlarge/confirm_lock_password.xml
@@ -77,27 +77,36 @@
         android:visibility="gone"
     />
 
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="0dip"
+    />
+
     <RelativeLayout
         android:layout_height="wrap_content"
         android:layout_width="match_parent">
 
-        <Button android:id="@+id/cancel_button"
-            android:layout_width="150dip"
+        <LinearLayout
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_margin="5dip"
-            android:layout_alignParentLeft="true"
-            android:text="@string/lockpassword_cancel_label"
-        />
-
-        <Button android:id="@+id/next_button"
-            android:layout_width="150dip"
-            android:layout_height="wrap_content"
-            android:layout_margin="5dip"
             android:layout_alignParentRight="true"
-            android:drawableRight="@drawable/ic_btn_next"
-            android:drawablePadding="10dip"
-            android:text="@string/lockpassword_continue_label"
-        />
+            android:orientation="horizontal">
+
+            <Button android:id="@+id/cancel_button"
+                android:layout_width="140dip"
+                android:layout_height="wrap_content"
+                android:ellipsize="marquee"
+                android:singleLine="true"
+                android:text="@string/lockpassword_cancel_label"/>
+
+            <Button android:id="@+id/next_button"
+                android:layout_width="140dip"
+                android:layout_height="wrap_content"
+                android:ellipsize="marquee"
+                android:singleLine="true"
+                android:text="@string/lockpassword_continue_label"/>
+
+        </LinearLayout>
 
     </RelativeLayout>
 
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 73d1ee2..e550345 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1789,18 +1789,24 @@
     <string name="settings_safetylegal_activity_loading">Loading\u2026</string>
 
     <!-- Lock Pattern settings -->
-    <!-- Header on first screen of choose password/PIN flow -->
+    <!-- Header on first screen of choose password/PIN flow [CHAR LIMIT=30] -->
     <string name="lockpassword_choose_your_password_header">Choose your password</string>
-    <!-- Header on first screen of choose password/PIN flow -->
+    <!-- Header on first screen of choose pattern flow [CHAR LIMIT=30] -->
+    <string name="lockpassword_choose_your_pattern_header">Choose your pattern</string>
+    <!-- Header on first screen of choose password/PIN flow [CHAR LIMIT=30] -->
     <string name="lockpassword_choose_your_pin_header">Choose your PIN</string>
-    <!-- Header on password confirm screen -->
+    <!-- Header on password confirm screen [CHAR LIMIT=30] -->
     <string name="lockpassword_confirm_your_password_header">Confirm your password</string>
-    <!-- Header on password confirm screen -->
+    <!-- Header on pattern confirm screen [CHAR LIMIT=30] -->
+    <string name="lockpassword_confirm_your_pattern_header">Confirm your pattern</string>
+    <!-- Header on password confirm screen [CHAR LIMIT=30] -->
     <string name="lockpassword_confirm_your_pin_header">Confirm your PIN</string>
-    <!-- Header on password confirm screen if second password doesn't match the first. -->
+    <!-- Header on password confirm screen if second password doesn't match the first. [CHAR LIMIT=30] -->
     <string name="lockpassword_confirm_passwords_dont_match">Passwords don\'t match</string>
-    <!-- Header on pin confirm screen if second pin doesn't match the first. -->
+    <!-- Header on pin confirm screen if second pin doesn't match the first. [CHAR LIMIT=30]-->
     <string name="lockpassword_confirm_pins_dont_match">PINs don\'t match</string>
+    <!-- Header shown to ask the user to select an unlock method [CHAR LIMIT=30] -->
+    <string name="lockpassword_choose_lock_generic_header">Unlock selection</string>
     <!-- Toast shown if setting password was successful -->
     <string name="lockpassword_password_set_toast">Password has been set</string>
     <!-- Toast shown if setting PIN was successful -->
diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/ChooseLockPassword.java
index a37d3da..98bd019 100644
--- a/src/com/android/settings/ChooseLockPassword.java
+++ b/src/com/android/settings/ChooseLockPassword.java
@@ -183,7 +183,8 @@
             mPasswordEntry.setOnEditorActionListener(this);
             mPasswordEntry.addTextChangedListener(this);
 
-            mKeyboardHelper = new PasswordEntryKeyboardHelper(getActivity(),
+            final Activity activity = getActivity();
+            mKeyboardHelper = new PasswordEntryKeyboardHelper(activity,
                     mKeyboardView, mPasswordEntry);
             mKeyboardHelper.setKeyboardMode(mIsAlphaMode ?
                     PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
@@ -212,6 +213,14 @@
                     updateStage(mUiStage);
                 }
             }
+            // Update the breadcrumb (title) if this is embedded in a PreferenceActivity
+            if (activity instanceof PreferenceActivity) {
+                final PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
+                int id = mIsAlphaMode ? R.string.lockpassword_confirm_your_password_header
+                        : R.string.lockpassword_confirm_your_pin_header;
+                CharSequence title = getText(id);
+                preferenceActivity.showBreadCrumbs(title, title);
+            }
 
             return view;
         }
diff --git a/src/com/android/settings/ConfirmLockPassword.java b/src/com/android/settings/ConfirmLockPassword.java
index d824588..08e99ea 100644
--- a/src/com/android/settings/ConfirmLockPassword.java
+++ b/src/com/android/settings/ConfirmLockPassword.java
@@ -20,6 +20,7 @@
 import com.android.internal.widget.PasswordEntryKeyboardHelper;
 import com.android.internal.widget.PasswordEntryKeyboardView;
 
+import android.app.Activity;
 import android.app.Fragment;
 import android.app.admin.DevicePolicyManager;
 import android.content.Intent;
@@ -94,9 +95,12 @@
                     || DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == storedQuality;
             mHeaderText.setText(isAlpha ? R.string.lockpassword_confirm_your_password_header
                     : R.string.lockpassword_confirm_your_pin_header);
-            mKeyboardHelper = new PasswordEntryKeyboardHelper(getActivity(),
-                        mKeyboardView, mPasswordEntry);
-            mKeyboardHelper.setKeyboardMode(isAlpha ? PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
+
+            final Activity activity = getActivity();
+            mKeyboardHelper = new PasswordEntryKeyboardHelper(activity,
+                    mKeyboardView, mPasswordEntry);
+            mKeyboardHelper.setKeyboardMode(isAlpha ?
+                    PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
                     : PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
             mKeyboardView.requestFocus();
 
@@ -104,6 +108,15 @@
             mPasswordEntry.setInputType(isAlpha ? currentType
                     : (currentType | InputType.TYPE_CLASS_NUMBER));
 
+            // Update the breadcrumb (title) if this is embedded in a PreferenceActivity
+            if (activity instanceof PreferenceActivity) {
+                final PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
+                int id = isAlpha ? R.string.lockpassword_confirm_your_password_header
+                        : R.string.lockpassword_confirm_your_pin_header;
+                CharSequence title = getText(id);
+                preferenceActivity.showBreadCrumbs(title, title);
+            }
+
             return view;
         }