OSDN Git Service

Change header in choose lock password
authorMaurice Lam <yukl@google.com>
Fri, 19 May 2017 03:42:58 +0000 (20:42 -0700)
committerMaurice Lam <yukl@google.com>
Fri, 26 May 2017 01:00:41 +0000 (01:00 +0000)
Instead of a separate headerText view, change the header in the
GlifLayout directly.

Test: Manual. Existing tests pass
Bug: 38180862
Change-Id: I02d692870f5e2230ccae87a5ac2aee4def8f61af

res/layout/choose_lock_password.xml
src/com/android/settings/password/ChooseLockPassword.java

index 988f331..02912ee 100644 (file)
         android:gravity="center_horizontal"
         android:orientation="vertical">
 
-        <!-- header text ('Enter Pin') -->
-        <TextView
-            android:id="@+id/headerText"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:accessibilityLiveRegion="polite"
-            android:gravity="center"
-            android:lines="2"
-            android:textAppearance="?android:attr/textAppearanceMedium"/>
-
         <LinearLayout
             android:id="@+id/password_container"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_marginTop="16dp"
             android:clipChildren="false"
             android:clipToPadding="false"
             android:orientation="vertical"
index df0621e..5f1c949 100644 (file)
@@ -185,8 +185,8 @@ public class ChooseLockPassword extends SettingsActivity {
         private ChooseLockSettingsHelper mChooseLockSettingsHelper;
         private Stage mUiStage = Stage.Introduction;
         private PasswordRequirementAdapter mPasswordRequirementAdapter;
+        private GlifLayout mLayout;
 
-        private TextView mHeaderText;
         private String mFirstPin;
         private RecyclerView mPasswordRestrictionView;
         protected boolean mIsAlphaMode;
@@ -292,6 +292,8 @@ public class ChooseLockPassword extends SettingsActivity {
         public void onViewCreated(View view, Bundle savedInstanceState) {
             super.onViewCreated(view, savedInstanceState);
 
+            mLayout = (GlifLayout) view;
+
             // Make the password container consume the optical insets so the edit text is aligned
             // with the sides of the parent visually.
             ViewGroup container = view.findViewById(R.id.password_container);
@@ -316,7 +318,6 @@ public class ChooseLockPassword extends SettingsActivity {
             mPasswordEntryInputDisabler = new TextViewInputDisabler(mPasswordEntry);
 
             final Activity activity = getActivity();
-            mHeaderText = (TextView) view.findViewById(R.id.headerText);
 
             int currentType = mPasswordEntry.getInputType();
             mPasswordEntry.setInputType(mIsAlphaMode ? currentType
@@ -360,7 +361,7 @@ public class ChooseLockPassword extends SettingsActivity {
                         : R.string.lockpassword_choose_your_pin_header;
                 CharSequence title = getText(id);
                 sa.setTitle(title);
-                ((GlifLayout) view).setHeaderText(title);
+                mLayout.setHeaderText(title);
             }
         }
 
@@ -479,7 +480,7 @@ public class ChooseLockPassword extends SettingsActivity {
             // If the stage changed, announce the header for accessibility. This
             // is a no-op when accessibility is disabled.
             if (previousStage != stage) {
-                mHeaderText.announceForAccessibility(mHeaderText.getText());
+                mLayout.announceForAccessibility(mLayout.getHeaderText());
             }
         }
 
@@ -788,11 +789,11 @@ public class ChooseLockPassword extends SettingsActivity {
 
         private void setHeaderText(String text) {
             // Only set the text if it is different than the existing one to avoid announcing again.
-            if (!TextUtils.isEmpty(mHeaderText.getText())
-                    && mHeaderText.getText().toString().equals(text)) {
+            if (!TextUtils.isEmpty(mLayout.getHeaderText())
+                    && mLayout.getHeaderText().toString().equals(text)) {
                 return;
             }
-            mHeaderText.setText(text);
+            mLayout.setHeaderText(text);
         }
 
         public void afterTextChanged(Editable s) {