Merge "Update fingerprint layouts for landscape" into sc-dev
diff --git a/res/layout-land/fingerprint_enroll_enrolling.xml b/res/layout-land/fingerprint_enroll_enrolling.xml
deleted file mode 100644
index 184c9c6..0000000
--- a/res/layout-land/fingerprint_enroll_enrolling.xml
+++ /dev/null
@@ -1,135 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2015 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License
-  -->
-
-<com.google.android.setupdesign.GlifLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/setup_wizard_layout"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layout="@layout/sud_glif_blank_template"
-    style="?attr/fingerprint_layout_theme">
-
-    <ScrollView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:fillViewport="true">
-        <LinearLayout
-            style="@style/SudContentFrame"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="horizontal"
-            android:clipToPadding="false"
-            android:clipChildren="false"
-            android:paddingBottom="0dp">
-
-            <!-- Both texts are kept as separate text views so it doesn't jump around in portrait.
-                 See layouts/fingerprint_enroll_enrolling_base.xml. -->
-            <LinearLayout
-                android:layout_width="0dp"
-                android:layout_weight="1"
-                android:layout_height="match_parent"
-                android:layout_marginStart="?attr/sudMarginStart"
-                android:layout_marginBottom="@dimen/sud_content_frame_padding_bottom"
-                android:clipChildren="false"
-                android:clipToPadding="false"
-                android:orientation="vertical">
-
-                <ImageView
-                    android:id="@+id/sud_layout_icon"
-                    style="@style/SudGlifIcon"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_gravity="?attr/sudGlifHeaderGravity"
-                    android:layout_marginStart="0dp"
-                    android:layout_marginEnd="0dp"
-                    android:src="@drawable/ic_fingerprint_header" />
-
-                <TextView
-                    android:id="@+id/suc_layout_title"
-                    style="@style/SudGlifHeaderTitle"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_marginStart="0dp"
-                    android:layout_marginEnd="0dp" />
-
-                <FrameLayout
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content">
-
-                    <TextView
-                        style="@style/SudDescription.Glif"
-                        android:id="@+id/sud_layout_description"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:text="@string/security_settings_fingerprint_enroll_start_message"/>
-
-                    <TextView
-                        style="@style/SudDescription.Glif"
-                        android:id="@+id/repeat_message"
-                        android:layout_width="match_parent"
-                        android:layout_height="wrap_content"
-                        android:text="@string/security_settings_fingerprint_enroll_repeat_message"
-                        android:visibility="invisible"/>
-
-                </FrameLayout>
-
-                <Space
-                    android:layout_width="0dp"
-                    android:layout_height="0dp"
-                    android:layout_weight="1" />
-
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="0dp"
-                android:layout_weight="1"
-                android:layout_height="match_parent"
-                android:gravity="center"
-                android:orientation="vertical">
-
-                <com.google.android.setupdesign.view.FillContentLayout
-                    android:layout_width="wrap_content"
-                    android:layout_height="0dp"
-                    android:layout_marginVertical="24dp"
-                    android:layout_weight="1"
-                    android:paddingTop="0dp"
-                    android:paddingBottom="0dp">
-
-                    <include layout="@layout/fingerprint_enroll_enrolling_content"
-                         android:layout_width="match_parent"
-                         android:layout_height="match_parent"
-                         android:layout_gravity="center" />
-                </com.google.android.setupdesign.view.FillContentLayout>
-
-                <TextView
-                    style="@style/TextAppearance.ErrorText"
-                    android:id="@+id/error_text"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_marginBottom="16dp"
-                    android:layout_gravity="center_horizontal|bottom"
-                    android:accessibilityLiveRegion="polite"
-                    android:gravity="center_horizontal"
-                    android:paddingEnd="5dp"
-                    android:paddingStart="5dp"
-                    android:visibility="invisible"/>
-
-            </LinearLayout>
-
-        </LinearLayout>
-    </ScrollView>
-</com.google.android.setupdesign.GlifLayout>
diff --git a/res/layout-land/fingerprint_enroll_finish.xml b/res/layout-land/fingerprint_enroll_finish.xml
deleted file mode 100644
index 4159516..0000000
--- a/res/layout-land/fingerprint_enroll_finish.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2015 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License
-  -->
-
-<com.google.android.setupdesign.GlifLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/setup_wizard_layout"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:layout="@layout/sud_glif_blank_template"
-    style="?attr/fingerprint_layout_theme">
-
-    <ScrollView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:fillViewport="true">
-
-        <LinearLayout
-            style="@style/SudContentFrame"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="horizontal"
-            android:clipToPadding="false"
-            android:clipChildren="false">
-
-            <LinearLayout
-                android:layout_width="0dp"
-                android:layout_weight="1"
-                android:layout_height="match_parent"
-                android:clipChildren="false"
-                android:clipToPadding="false"
-                android:orientation="vertical">
-
-                <ImageView
-                    android:id="@+id/sud_layout_icon"
-                    style="@style/SudGlifIcon"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_gravity="?attr/sudGlifHeaderGravity"
-                    android:layout_marginLeft="0dp"
-                    android:layout_marginRight="0dp"
-                    android:contentDescription="@null"
-                    android:src="@drawable/ic_fingerprint_header"/>
-
-                <TextView
-                    android:id="@+id/suc_layout_title"
-                    style="@style/SudGlifHeaderTitle"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_marginLeft="0dp"
-                    android:layout_marginRight="0dp"/>
-
-                <TextView
-                    android:id="@+id/sud_layout_description"
-                    style="@style/SudDescription.Glif"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:text="@string/security_settings_fingerprint_enroll_finish_message"/>
-
-            </LinearLayout>
-
-            <com.google.android.setupdesign.view.FillContentLayout
-                android:layout_width="0dp"
-                android:layout_weight="1"
-                android:layout_height="match_parent">
-
-                <ImageView
-                    android:id="@+id/fingerprint_in_app_indicator"
-                    style="@style/SudContentIllustration"
-                    android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:contentDescription="@android:string/fingerprint_icon_content_description"
-                    android:src="@drawable/fingerprint_enroll_finish" />
-
-            </com.google.android.setupdesign.view.FillContentLayout>
-
-        </LinearLayout>
-    </ScrollView>
-</com.google.android.setupdesign.GlifLayout>
diff --git a/res/layout/fingerprint_enroll_enrolling_base.xml b/res/layout/fingerprint_enroll_enrolling_base.xml
index e1a9707..a0805ba 100644
--- a/res/layout/fingerprint_enroll_enrolling_base.xml
+++ b/res/layout/fingerprint_enroll_enrolling_base.xml
@@ -30,31 +30,6 @@
         android:clipToPadding="false"
         android:clipChildren="false">
 
-        <!-- Make both texts included for layout, so the lower part doesn't jump around when we
-             switch the text -->
-        <FrameLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
-
-            <TextView
-                style="@style/SudDescription.Glif"
-                android:id="@+id/sud_layout_description"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:minLines="3"
-                android:text="@string/security_settings_fingerprint_enroll_start_message"/>
-
-            <TextView
-                style="@style/SudDescription.Glif"
-                android:id="@+id/repeat_message"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:minLines="3"
-                android:text="@string/security_settings_fingerprint_enroll_repeat_message"
-                android:visibility="invisible"/>
-
-        </FrameLayout>
-
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="0dp"
diff --git a/res/layout/fingerprint_enroll_finish_base.xml b/res/layout/fingerprint_enroll_finish_base.xml
index 1f9167e..262374d 100644
--- a/res/layout/fingerprint_enroll_finish_base.xml
+++ b/res/layout/fingerprint_enroll_finish_base.xml
@@ -30,15 +30,6 @@
         android:clipToPadding="false"
         android:clipChildren="false">
 
-        <TextView
-            android:id="@+id/sud_layout_description"
-            style="@style/SudDescription.Glif"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/sud_description_glif_margin_top"
-            android:minLines="3"
-            android:text="@string/security_settings_fingerprint_enroll_finish_message"/>
-
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="0dp"
diff --git a/res/layout/udfps_enroll_enrolling.xml b/res/layout/udfps_enroll_enrolling.xml
index 6b3382c..67c127b 100644
--- a/res/layout/udfps_enroll_enrolling.xml
+++ b/res/layout/udfps_enroll_enrolling.xml
@@ -30,28 +30,6 @@
         android:clipChildren="false"
         android:orientation="vertical">
 
-        <FrameLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
-
-            <TextView
-                android:id="@+id/sud_layout_description"
-                style="@style/SudDescription.Glif"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:minLines="3"
-                android:text="@string/security_settings_fingerprint_enroll_start_message" />
-
-            <TextView
-                android:id="@+id/repeat_message"
-                style="@style/SudDescription.Glif"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:text="@string/security_settings_fingerprint_enroll_repeat_message"
-                android:visibility="invisible" />
-
-        </FrameLayout>
-
         <TextView
             android:id="@+id/error_text"
             style="@style/TextAppearance.ErrorText"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index be455ac..9bae3a5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -962,10 +962,18 @@
     <string name="security_settings_fingerprint_enroll_start_title">Touch the sensor</string>
     <!-- Message shown in fingerprint enrollment dialog to begin enrollment [CHAR LIMIT=NONE] -->
     <string name="security_settings_fingerprint_enroll_start_message">Put your finger on the sensor and lift after you feel a vibration</string>
+    <!-- Message shown in fingerprint enrollment dialog to begin enrollment [CHAR LIMIT=NONE] -->
+    <string name="security_settings_udfps_enroll_start_message">Each time you touch, keep your finger on the icon until you feel a vibration</string>
     <!-- Title shown in fingerprint enrollment dialog to repeat touching the fingerprint sensor [CHAR LIMIT=40] -->
     <string name="security_settings_fingerprint_enroll_repeat_title">Lift, then touch again</string>
+    <!-- Title shown in fingerprint enrollment dialog to repeat touching the fingerprint sensor [CHAR LIMIT=40] -->
+    <string name="security_settings_udfps_enroll_title_one_more_time">One more time</string>
+    <!-- Title shown in fingerprint enrollment dialog to repeat touching the fingerprint sensor [CHAR LIMIT=60] -->
+    <string name="security_settings_udfps_enroll_repeat_title_touch_icon">Touch the fingerprint icon as it moves</string>
     <!-- Message shown in fingerprint enrollment dialog to repeat touching the fingerprint sensor [CHAR LIMIT=NONE] -->
     <string name="security_settings_fingerprint_enroll_repeat_message">Keep lifting your finger to add the different parts of your fingerprint</string>
+    <!-- Message shown in fingerprint enrollment dialog to repeat touching the fingerprint sensor [CHAR LIMIT=NONE] -->
+    <string name="security_settings_udfps_enroll_repeat_message">This helps capture your full fingerprint</string>
     <!-- Title shown in fingerprint enrollment dialog once enrollment is completed [CHAR LIMIT=29] -->
     <string name="security_settings_fingerprint_enroll_finish_title">Fingerprint added</string>
     <!-- Message shown in fingerprint enrollment dialog once enrollment is completed -->
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index 1b2a6a5..b403e42 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -52,7 +52,6 @@
 
 import com.google.android.setupcompat.template.FooterBarMixin;
 import com.google.android.setupcompat.template.FooterButton;
-import com.google.android.setupdesign.util.DescriptionStyler;
 
 import java.util.List;
 
@@ -66,6 +65,10 @@
 
     private static final int PROGRESS_BAR_MAX = 10000;
     private static final int FINISH_DELAY = 250;
+    /**
+     * Enroll with two center touches before going to guided enrollment.
+     */
+    private static final int NUM_CENTER_TOUCHES = 2;
 
     /**
      * If we don't see progress during this time, we show an error message to remind the users that
@@ -95,8 +98,6 @@
     private boolean mCanAssumeUdfps;
     @Nullable private ProgressBar mProgressBar;
     private ObjectAnimator mProgressAnim;
-    private TextView mStartMessage;
-    private TextView mRepeatMessage;
     private TextView mErrorText;
     private Interpolator mFastOutSlowInInterpolator;
     private Interpolator mLinearOutSlowInInterpolator;
@@ -145,23 +146,18 @@
 
         if (mCanAssumeUdfps) {
             setContentView(R.layout.udfps_enroll_enrolling);
+            setDescriptionText(R.string.security_settings_udfps_enroll_start_message);
         } else {
             setContentView(R.layout.fingerprint_enroll_enrolling);
+            setDescriptionText(R.string.security_settings_fingerprint_enroll_start_message);
         }
 
         setHeaderText(R.string.security_settings_fingerprint_enroll_repeat_title);
 
-        mStartMessage = findViewById(R.id.sud_layout_description);
-        mRepeatMessage = findViewById(R.id.repeat_message);
         mErrorText = findViewById(R.id.error_text);
         mProgressBar = findViewById(R.id.fingerprint_progress_bar);
         mVibrator = getSystemService(Vibrator.class);
 
-        if (getLayout().shouldApplyPartnerHeavyThemeResource()) {
-            DescriptionStyler.applyPartnerCustomizationHeavyStyle(mRepeatMessage);
-        } else if (getLayout().shouldApplyPartnerResource()) {
-            DescriptionStyler.applyPartnerCustomizationLightStyle(mRepeatMessage);
-        }
         mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
         mFooterBarMixin.setSecondaryButton(
                 new FooterButton.Builder(this)
@@ -229,7 +225,7 @@
     protected void onStart() {
         super.onStart();
         updateProgress(false /* animate */);
-        updateDescription();
+        updateTitleAndDescription();
         if (mRestoring) {
             startIconAnimation();
         }
@@ -297,16 +293,34 @@
         return new Intent(this, FingerprintEnrollFinish.class);
     }
 
-    private void updateDescription() {
+    private void updateTitleAndDescription() {
         if (mSidecar == null || mSidecar.getEnrollmentSteps() == -1) {
-            mStartMessage.setVisibility(View.VISIBLE);
-            mRepeatMessage.setVisibility(View.INVISIBLE);
+            if (mCanAssumeUdfps) {
+                setDescriptionText(R.string.security_settings_udfps_enroll_start_message);
+            } else {
+                setDescriptionText(R.string.security_settings_fingerprint_enroll_start_message);
+            }
+        } else if (mCanAssumeUdfps && !isCenterEnrollmentComplete()) {
+            setHeaderText(R.string.security_settings_udfps_enroll_title_one_more_time);
+            setDescriptionText(R.string.security_settings_udfps_enroll_start_message);
         } else {
-            mStartMessage.setVisibility(View.INVISIBLE);
-            mRepeatMessage.setVisibility(View.VISIBLE);
+            if (mCanAssumeUdfps) {
+                setHeaderText(R.string.security_settings_udfps_enroll_repeat_title_touch_icon);
+                setDescriptionText(R.string.security_settings_udfps_enroll_repeat_message);
+            } else {
+                setDescriptionText(R.string.security_settings_fingerprint_enroll_repeat_message);
+            }
         }
     }
 
+    private boolean isCenterEnrollmentComplete() {
+        if (mSidecar == null || mSidecar.getEnrollmentSteps() == -1) {
+            return false;
+        }
+        final int stepsEnrolled = mSidecar.getEnrollmentSteps() - mSidecar.getEnrollmentRemaining();
+        return stepsEnrolled >= NUM_CENTER_TOUCHES;
+    }
+
     @Override
     public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
         if (!TextUtils.isEmpty(helpString)) {
@@ -337,7 +351,7 @@
     @Override
     public void onEnrollmentProgressChange(int steps, int remaining) {
         updateProgress(true /* animate */);
-        updateDescription();
+        updateTitleAndDescription();
         clearError();
         animateFlash();
         mErrorText.removeCallbacks(mTouchAgainRunnable);
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index 3adbd0d..481da1b 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -55,6 +55,7 @@
         super.onCreate(savedInstanceState);
         setContentView(R.layout.fingerprint_enroll_finish);
         setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title);
+        setDescriptionText(R.string.security_settings_fingerprint_enroll_finish_message);
 
         mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
         mFooterBarMixin.setSecondaryButton(