diff options
39 files changed, 1285 insertions, 766 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 6e7b19e75..0ea75cdca 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1365,8 +1365,11 @@ android:windowSoftInputMode="stateVisible|adjustResize" android:theme="@style/Theme.ConfirmDeviceCredentials"/> - <activity android:name="FingerprintSettings" android:exported="false"/> - <activity android:name="FingerprintEnroll" android:exported="false"/> + <activity android:name=".fingerprint.FingerprintSettings" android:exported="false"/> + <activity android:name=".fingerprint.FingerprintEnrollOnboard" android:exported="false"/> + <activity android:name=".fingerprint.FingerprintEnrollFindSensor" android:exported="false"/> + <activity android:name=".fingerprint.FingerprintEnrollEnrolling" android:exported="false"/> + <activity android:name=".fingerprint.FingerprintEnrollFinish" android:exported="false"/> <!-- Note this must not be exported since it returns the password in the intent --> <activity android:name="ConfirmLockPattern$InternalActivity" diff --git a/res/drawable-xxhdpi/fingerprint_indicator.png b/res/drawable-nodpi/fingerprint_indicator.png Binary files differindex fc5ef0ffc..fc5ef0ffc 100644 --- a/res/drawable-xxhdpi/fingerprint_indicator.png +++ b/res/drawable-nodpi/fingerprint_indicator.png diff --git a/res/drawable-xxhdpi/fingerprint_sensor_location.png b/res/drawable-nodpi/fingerprint_sensor_location.png Binary files differindex b95816fb3..b95816fb3 100644 --- a/res/drawable-xxhdpi/fingerprint_sensor_location.png +++ b/res/drawable-nodpi/fingerprint_sensor_location.png diff --git a/res/drawable-nodpi/fp_app_indicator.png b/res/drawable-nodpi/fp_app_indicator.png Binary files differnew file mode 100644 index 000000000..d4d6ea13b --- /dev/null +++ b/res/drawable-nodpi/fp_app_indicator.png diff --git a/res/drawable-nodpi/fp_enrollment_header.png b/res/drawable-nodpi/fp_enrollment_header.png Binary files differnew file mode 100644 index 000000000..4e7b93163 --- /dev/null +++ b/res/drawable-nodpi/fp_enrollment_header.png diff --git a/res/drawable-xxhdpi/fingerprint_in_app_indicator.png b/res/drawable-xxhdpi/fingerprint_in_app_indicator.png Binary files differdeleted file mode 100644 index fc56a9a3d..000000000 --- a/res/drawable-xxhdpi/fingerprint_in_app_indicator.png +++ /dev/null diff --git a/res/drawable/ic_check.xml b/res/drawable/ic_check.xml new file mode 100644 index 000000000..9dda32f89 --- /dev/null +++ b/res/drawable/ic_check.xml @@ -0,0 +1,24 @@ +<!-- +Copyright (C) 2014 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24.0dp" + android:height="24.0dp" + android:viewportWidth="48.0" + android:viewportHeight="48.0"> + <path + android:fillColor="#FF000000" + android:pathData="M18.0,32.34L9.66,24.0l-2.83,2.83L18.0,38.0l24.0,-24.0 -2.83,-2.83z"/> +</vector> diff --git a/res/layout-land/fingerprint_enroll.xml b/res/layout-land/fingerprint_enroll.xml deleted file mode 100644 index 7bd41d1a7..000000000 --- a/res/layout-land/fingerprint_enroll.xml +++ /dev/null @@ -1,140 +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. ---> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="horizontal" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center_vertical"> - - <!-- Left area --> - <LinearLayout - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1" - android:orientation="vertical"> - - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="0dip" - android:layout_weight="0.4" - android:background="@color/fingerprint_title_area_bg" - android:orientation="vertical"> - - <TextView - android:id="@+id/fingerprint_enroll_title" - android:background="@color/fingerprint_title_area_bg" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="20dip" - android:layout_marginStart="40dip" - android:layout_marginEnd="40dip" - style="@style/TextAppearance.FingerprintTitle" - android:layout_alignParentBottom="true"/> - </LinearLayout> - - <TextView - android:id="@+id/fingerprint_enroll_message" - android:layout_width="match_parent" - android:layout_height="0dip" - android:layout_weight="0.6" - android:layout_marginTop="24dip" - android:layout_marginStart="40dip" - android:layout_marginEnd="40dip" - android:layout_marginBottom="36dip" - style="@style/TextAppearance.FingerprintMessage"/> - - </LinearLayout> - - <!-- Right area --> - <LinearLayout - android:layout_width="0dip" - android:layout_height="match_parent" - android:layout_weight="1" - android:orientation="vertical"> - - <RelativeLayout - android:id="@+id/fingerprint_view_selector" - android:layout_width="match_parent" - android:layout_height="0dip" - android:layout_weight="1" - android:layout_gravity="center" - android:gravity="center"> - - <!-- Only one of the following views will show for any given mode --> - <RelativeLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true"> - - <ImageView - android:id="@+id/fingerprint_animator" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true" - android:src="@drawable/fingerprint_indicator" /> - - <ProgressBar - android:id="@+id/fingerprint_progress_bar" - android:layout_width="200dip" - android:layout_height="200dip" - android:layout_centerInParent="true" - style="?android:attr/progressBarStyleHorizontal" - android:max="10000" - android:progress="0" - android:indeterminate="false" - android:progressDrawable="@drawable/fingerprint_progress_ring" /> - - </RelativeLayout> - - <ImageView - android:id="@+id/fingerprint_sensor_location" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true" - android:src="@drawable/fingerprint_sensor_location" /> - - <ImageView - android:id="@+id/fingerprint_in_app_indicator" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true" - android:src="@drawable/fingerprint_in_app_indicator" /> - </RelativeLayout> - - <!-- Button area --> - <LinearLayout - android:id="@+id/fingerprint_enroll_button_area" - android:orientation="horizontal" - android:layout_width="match_parent" - android:layout_height="wrap_content"> - - <Button - android:id="@+id/fingerprint_enroll_button_add" - style="@style/SecurityPreferenceButton" - android:text="@string/fingerprint_enroll_button_add" /> - - <Button - android:id="@+id/fingerprint_enroll_button_next" - style="@style/SecurityPreferenceButton" - android:text="@string/fingerprint_enroll_button_next" /> - - </LinearLayout> - - </LinearLayout> - -</LinearLayout> diff --git a/res/layout-land/fingerprint_enroll_enrolling.xml b/res/layout-land/fingerprint_enroll_enrolling.xml new file mode 100644 index 000000000..c60888b5a --- /dev/null +++ b/res/layout-land/fingerprint_enroll_enrolling.xml @@ -0,0 +1,78 @@ +<?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.android.setupwizardlib.SetupWizardLayout + 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" + style="@style/SetupWizardFingerprintStyle"> + + <LinearLayout + style="@style/SuwContentFrame" + 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. --> + <FrameLayout + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical"> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + android:id="@+id/start_message" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/security_settings_fingerprint_enroll_start_message"/> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + 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> + + <FrameLayout + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="match_parent"> + + <include layout="@layout/fingerprint_enroll_enrolling_content"/> + + <TextView + style="@style/TextAppearance.FingerprintErrorText" + 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"/> + + </FrameLayout> + + </LinearLayout> + +</com.android.setupwizardlib.SetupWizardLayout> diff --git a/res/layout-land/fingerprint_enroll_find_sensor.xml b/res/layout-land/fingerprint_enroll_find_sensor.xml new file mode 100644 index 000000000..1eaa815dc --- /dev/null +++ b/res/layout-land/fingerprint_enroll_find_sensor.xml @@ -0,0 +1,77 @@ +<?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.android.setupwizardlib.SetupWizardLayout + 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" + style="@style/SetupWizardFingerprintStyle"> + + <LinearLayout + style="@style/SuwContentFrame" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal" + android:clipToPadding="false" + android:clipChildren="false" + android:paddingBottom="0dp"> + + <LinearLayout + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:orientation="vertical"> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/security_settings_fingerprint_enroll_find_sensor_message"/> + + <Button + style="@style/Button.FingerprintButton" + android:id="@+id/next_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginStart="-12dp" + android:gravity="start|center_vertical" + android:text="@string/fingerprint_enroll_button_next" /> + </LinearLayout> + + <FrameLayout + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical"> + + <ImageView + android:id="@+id/fingerprint_sensor_location" + android:layout_width="200dp" + android:layout_height="200dp" + android:layout_gravity="center" + android:contentDescription="@string/security_settings_fingerprint_enroll_find_sensor_content_description" + android:src="@drawable/fingerprint_sensor_location" + android:scaleType="centerInside"/> + + </FrameLayout> + + </LinearLayout> + +</com.android.setupwizardlib.SetupWizardLayout> diff --git a/res/layout-land/fingerprint_enroll_finish.xml b/res/layout-land/fingerprint_enroll_finish.xml new file mode 100644 index 000000000..aeadd5d0e --- /dev/null +++ b/res/layout-land/fingerprint_enroll_finish.xml @@ -0,0 +1,91 @@ +<?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.android.setupwizardlib.SetupWizardLayout + 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" + style="@style/SetupWizardFingerprintStyle"> + + <LinearLayout + style="@style/SuwContentFrame" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal" + android:clipToPadding="false" + android:clipChildren="false" + android:paddingBottom="0dp"> + + <LinearLayout + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:orientation="vertical"> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/security_settings_fingerprint_enroll_finish_message"/> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginStart="-12dp" + android:orientation="horizontal"> + + <Button + style="@style/Button.FingerprintButton" + android:id="@+id/add_another_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginEnd="8dp" + android:gravity="start|center_vertical" + android:text="@string/fingerprint_enroll_button_add" /> + + <Button + style="@style/Button.FingerprintButton" + android:id="@+id/next_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/security_settings_fingerprint_enroll_done" /> + + </LinearLayout> + + </LinearLayout> + + <FrameLayout + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical"> + + <ImageView + android:id="@+id/fingerprint_in_app_indicator" + android:layout_width="120dp" + android:layout_height="120dp" + android:layout_gravity="center_horizontal" + android:src="@drawable/fp_app_indicator" /> + + </FrameLayout> + + </LinearLayout> + +</com.android.setupwizardlib.SetupWizardLayout> diff --git a/res/layout/fingerprint_enroll.xml b/res/layout/fingerprint_enroll.xml deleted file mode 100644 index 5a0b24b98..000000000 --- a/res/layout/fingerprint_enroll.xml +++ /dev/null @@ -1,133 +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. ---> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center_horizontal"> - - <!-- Upper title area --> - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="0dip" - android:layout_weight="0.25" - android:background="@color/fingerprint_title_area_bg"> - - <TextView - android:id="@+id/fingerprint_enroll_title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginBottom="20dip" - android:layout_marginStart="40dip" - android:layout_marginEnd="40dip" - style="@style/TextAppearance.FingerprintTitle" - android:layout_alignParentBottom="true"/> - - </RelativeLayout> - - <!-- Lower message area --> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="0dip" - android:layout_weight="0.75" - android:orientation="vertical"> - - <TextView - android:id="@+id/fingerprint_enroll_message" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="24dip" - android:layout_marginStart="40dip" - android:layout_marginEnd="40dip" - android:layout_marginBottom="36dip" - style="@style/TextAppearance.FingerprintMessage"/> - - <RelativeLayout - android:id="@+id/fingerprint_view_selector" - android:layout_width="wrap_content" - android:layout_height="0dip" - android:layout_weight="1" - android:layout_gravity="center" - android:gravity="center"> - - <!-- Only one of the following views will show for any given mode --> - <RelativeLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true"> - - <ImageView - android:id="@+id/fingerprint_animator" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true" - android:src="@drawable/fingerprint_indicator" /> - - <ProgressBar - android:id="@+id/fingerprint_progress_bar" - android:layout_width="200dip" - android:layout_height="200dip" - android:layout_centerInParent="true" - style="?android:attr/progressBarStyleHorizontal" - android:max="10000" - android:progress="0" - android:indeterminate="false" - android:progressDrawable="@drawable/fingerprint_progress_ring" /> - - </RelativeLayout> - - <ImageView - android:id="@+id/fingerprint_sensor_location" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true" - android:src="@drawable/fingerprint_sensor_location" /> - - <ImageView - android:id="@+id/fingerprint_in_app_indicator" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerInParent="true" - android:src="@drawable/fingerprint_in_app_indicator" /> - - </RelativeLayout> - - </LinearLayout> - - <!-- Button area --> - <LinearLayout - android:id="@+id/fingerprint_enroll_button_area" - android:orientation="horizontal" - android:layout_width="match_parent" - android:layout_height="wrap_content"> - - <Button - android:id="@+id/fingerprint_enroll_button_add" - style="@style/SecurityPreferenceButton" - android:text="@string/fingerprint_enroll_button_add" - android:layout_margin="10dip" /> - - <Button - android:id="@+id/fingerprint_enroll_button_next" - style="@style/SecurityPreferenceButton" - android:text="@string/fingerprint_enroll_button_next" - android:layout_margin="10dip" /> - - </LinearLayout> - -</LinearLayout> diff --git a/res/layout/fingerprint_enroll_enrolling_base.xml b/res/layout/fingerprint_enroll_enrolling_base.xml new file mode 100644 index 000000000..37e10bae5 --- /dev/null +++ b/res/layout/fingerprint_enroll_enrolling_base.xml @@ -0,0 +1,73 @@ +<?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.android.setupwizardlib.SetupWizardLayout + 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" + style="@style/SetupWizardFingerprintStyle"> + + <LinearLayout + style="@style/SuwContentFrame" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + 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" + android:layout_marginTop="@dimen/suw_description_margin_top"> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + android:id="@+id/start_message" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/security_settings_fingerprint_enroll_start_message"/> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + 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> + + <include layout="@layout/fingerprint_enroll_enrolling_content" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="36dp" + android:layout_gravity="center_horizontal"/> + + <TextView + style="@style/TextAppearance.FingerprintErrorText" + android:id="@+id/error_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:layout_gravity="center_horizontal"/> + + </LinearLayout> + +</com.android.setupwizardlib.SetupWizardLayout> diff --git a/res/layout/fingerprint_enroll_enrolling_content.xml b/res/layout/fingerprint_enroll_enrolling_content.xml new file mode 100644 index 000000000..5570bdbe2 --- /dev/null +++ b/res/layout/fingerprint_enroll_enrolling_content.xml @@ -0,0 +1,43 @@ +<?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 + --> + +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="36dp" + android:layout_gravity="center_horizontal"> + + <ImageView + android:id="@+id/fingerprint_animator" + android:layout_width="88dp" + android:layout_height="88dp" + android:layout_centerInParent="true" + android:src="@drawable/fingerprint_indicator" /> + + <ProgressBar + android:id="@+id/fingerprint_progress_bar" + android:layout_width="192dp" + android:layout_height="192dp" + android:layout_centerInParent="true" + style="?android:attr/progressBarStyleHorizontal" + android:max="10000" + android:progress="0" + android:indeterminate="false" + android:progressDrawable="@drawable/fingerprint_progress_ring" /> + +</RelativeLayout> diff --git a/res/layout/fingerprint_enroll_find_sensor_base.xml b/res/layout/fingerprint_enroll_find_sensor_base.xml new file mode 100644 index 000000000..89b45945b --- /dev/null +++ b/res/layout/fingerprint_enroll_find_sensor_base.xml @@ -0,0 +1,68 @@ +<?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.android.setupwizardlib.SetupWizardLayout + 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" + style="@style/SetupWizardFingerprintStyle"> + + <LinearLayout + style="@style/SuwContentFrame" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:clipToPadding="false" + android:clipChildren="false"> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/suw_description_margin_top" + android:text="@string/security_settings_fingerprint_enroll_find_sensor_message"/> + + <ImageView + android:id="@+id/fingerprint_sensor_location" + android:layout_width="204dp" + android:layout_height="204dp" + android:layout_marginTop="32dp" + android:layout_gravity="center_horizontal" + android:contentDescription="@string/security_settings_fingerprint_enroll_find_sensor_content_description" + android:src="@drawable/fingerprint_sensor_location" + android:scaleType="centerInside"/> + + <View + android:layout_height="0dp" + android:layout_width="match_parent" + android:layout_weight="1"/> + + <Button + style="@style/Button.FingerprintButton" + android:id="@+id/next_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="4dp" + android:layout_marginEnd="-12dp" + android:layout_gravity="end" + android:gravity="end|center_vertical" + android:text="@string/fingerprint_enroll_button_next" /> + + </LinearLayout> + +</com.android.setupwizardlib.SetupWizardLayout> diff --git a/res/layout/fingerprint_enroll_finish_base.xml b/res/layout/fingerprint_enroll_finish_base.xml new file mode 100644 index 000000000..981c9f045 --- /dev/null +++ b/res/layout/fingerprint_enroll_finish_base.xml @@ -0,0 +1,81 @@ +<?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.android.setupwizardlib.SetupWizardLayout + 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" + style="@style/SetupWizardFingerprintStyle"> + + <LinearLayout + style="@style/SuwContentFrame" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:clipToPadding="false" + android:clipChildren="false"> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/suw_description_margin_top" + android:text="@string/security_settings_fingerprint_enroll_finish_message"/> + + <ImageView + android:id="@+id/fingerprint_in_app_indicator" + android:layout_width="120dp" + android:layout_height="120dp" + android:layout_marginTop="56dp" + android:layout_gravity="center_horizontal" + android:src="@drawable/fp_app_indicator" /> + + <View + android:layout_height="0dp" + android:layout_width="match_parent" + android:layout_weight="1"/> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginEnd="-12dp" + android:layout_marginBottom="4dp" + android:layout_gravity="end" + android:orientation="horizontal"> + + <Button + style="@style/Button.FingerprintButton" + android:id="@+id/add_another_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginEnd="8dp" + android:text="@string/fingerprint_enroll_button_add" /> + + <Button + style="@style/Button.FingerprintButton" + android:id="@+id/next_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="end|center_vertical" + android:text="@string/security_settings_fingerprint_enroll_done" /> + + </LinearLayout> + + </LinearLayout> + +</com.android.setupwizardlib.SetupWizardLayout> diff --git a/res/layout/fingerprint_enroll_onboard.xml b/res/layout/fingerprint_enroll_onboard.xml new file mode 100644 index 000000000..efe90ae7d --- /dev/null +++ b/res/layout/fingerprint_enroll_onboard.xml @@ -0,0 +1,108 @@ +<?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.android.setupwizardlib.SetupWizardLayout + 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" + style="@style/SetupWizardFingerprintStyle"> + + <LinearLayout + style="@style/SuwContentFrame" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:clipToPadding="false" + android:clipChildren="false"> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/suw_description_margin_top" + android:layout_marginBottom="@dimen/suw_description_margin_top" + android:text="@string/security_settings_fingerprint_enroll_onboard_message"/> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingTop="12dp" + android:paddingBottom="12dp"> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_marginEnd="24dp" + android:importantForAccessibility="no" + android:src="@drawable/ic_check" + android:tint="?android:attr/textColorPrimary" /> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/security_settings_fingerprint_enroll_onboard_message_1"/> + + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingTop="12dp" + android:paddingBottom="12dp"> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_marginEnd="24dp" + android:importantForAccessibility="no" + android:src="@drawable/ic_check" + android:tint="?android:attr/textColorPrimary" /> + + <TextView + style="@style/TextAppearance.FingerprintMessage" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:text="@string/security_settings_fingerprint_enroll_onboard_message_2"/> + + </LinearLayout> + + <View + android:layout_height="0dp" + android:layout_width="match_parent" + android:layout_weight="1"/> + + <Button + style="@style/Button.FingerprintButton" + android:id="@+id/next_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="4dp" + android:layout_marginEnd="-12dp" + android:layout_gravity="end" + android:gravity="end|center_vertical" + android:text="@string/security_settings_fingerprint_enroll_setup_screen_lock"/> + + </LinearLayout> + +</com.android.setupwizardlib.SetupWizardLayout> diff --git a/res/values-land/colors.xml b/res/values-land/colors.xml new file mode 100644 index 000000000..5bab9d13a --- /dev/null +++ b/res/values-land/colors.xml @@ -0,0 +1,20 @@ +<?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 + --> + +<resources> + <drawable name="fp_enrollment_header">#009688</drawable> +</resources> diff --git a/res/values-land/config.xml b/res/values-land/config.xml index 543dfeeab..7f5c1426d 100644 --- a/res/values-land/config.xml +++ b/res/values-land/config.xml @@ -16,7 +16,7 @@ <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <!-- Dashboard number of columns --> - <integer name="dashboard_num_columns">2</integer> + <!-- Dashboard number of columns --> + <integer name="dashboard_num_columns">2</integer> </resources> diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml index 79529e2ed..d15c254cc 100755 --- a/res/values-land/dimens.xml +++ b/res/values-land/dimens.xml @@ -45,4 +45,7 @@ <!-- Dashboard tile image margin start / end --> <dimen name="dashboard_tile_image_margin_start">12dp</dimen> + <!-- Fingerprint --> + <item name="fingerprint_illustration_aspect_ratio" format="float" type="dimen">0.0</item> + <dimen name="fingerprint_decor_padding_top">24dp</dimen> </resources> diff --git a/res/values-sw600dp/aliases.xml b/res/values-sw600dp/aliases.xml new file mode 100644 index 000000000..193867e66 --- /dev/null +++ b/res/values-sw600dp/aliases.xml @@ -0,0 +1,23 @@ +<?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 + --> + +<resources> + <item name="fingerprint_enroll_find_sensor" type="layout">@layout/fingerprint_enroll_find_sensor_base</item> + <item name="fingerprint_enroll_enrolling" type="layout">@layout/fingerprint_enroll_enrolling_base</item> + <item name="fingerprint_enroll_finish" type="layout">@layout/fingerprint_enroll_finish_base</item> +</resources> + diff --git a/res/values/aliases.xml b/res/values/aliases.xml index 248ac7126..c30aa30c1 100644 --- a/res/values/aliases.xml +++ b/res/values/aliases.xml @@ -18,5 +18,8 @@ <item name="notification_app_section" type="layout">@*android:layout/preference_category_material</item> <item name="confirm_lock_pattern" type="layout">@layout/confirm_lock_pattern_base</item> <item name="confirm_lock_password" type="layout">@layout/confirm_lock_password_base</item> + <item name="fingerprint_enroll_find_sensor" type="layout">@layout/fingerprint_enroll_find_sensor_base</item> + <item name="fingerprint_enroll_enrolling" type="layout">@layout/fingerprint_enroll_enrolling_base</item> + <item name="fingerprint_enroll_finish" type="layout">@layout/fingerprint_enroll_finish_base</item> </resources> diff --git a/res/values/colors.xml b/res/values/colors.xml index 3115da3e6..858af0e60 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -83,4 +83,6 @@ <color name="fab_ripple">#1fffffff</color><!-- 12% white --> <color name="fab_shape">#ff009688</color><!-- Teal 500 --> <color name="voice_interaction_highlight">#33b5e5</color> + + <drawable name="fp_enrollment_header_landscape">#009688</drawable> </resources> diff --git a/res/values/config.xml b/res/values/config.xml index f830e0667..295d5d1a4 100755 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -37,4 +37,5 @@ <!-- The duration (in milliseconds) of activity transitions --> <integer name="setup_wizard_transition_duration">300</integer> + </resources> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index cd11c2ccd..c2d192d98 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -217,8 +217,10 @@ <dimen name="redaction_vertical_margins">8dp</dimen> <!-- Fingerprint --> - <dimen name="fingerprint_ring_radius">96dip</dimen> + <dimen name="fingerprint_ring_radius">92dip</dimen> <dimen name="fingerprint_ring_thickness">4dip</dimen> + <item name="fingerprint_illustration_aspect_ratio" format="float" type="dimen">2.6</item> + <dimen name="fingerprint_decor_padding_top">0dp</dimen> <dimen name="confirm_credentials_security_method_margin">48dp</dimen> <dimen name="fab_size">56dp</dimen> diff --git a/res/values/strings.xml b/res/values/strings.xml index f2732fa64..9ca27b89e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -752,15 +752,20 @@ <string name="security_settings_fingerprint_enroll_onboard_title">Fingerprint setup</string> <!-- Introduction message shown in fingerprint enrollment dialog when the user needs to choose an alternate screen unlock (pin, pattern or password) as a backup to fingerprint. --> - <string name="security_settings_fingerprint_enroll_onboard_message"> - To use your fingerprint to unlock your screen or confirm purchases, we\'ll need to: - \n\n\u2713 Set up your backup screen lock method - \n\n\u2713 Add your fingerprint</string> + <string name="security_settings_fingerprint_enroll_onboard_message">To use your fingerprint to unlock your screen or confirm purchases, we\'ll need to:</string> + <!-- Introduction message shown in fingerprint enrollment dialog, first item to describe what + the user needs to do. --> + <string name="security_settings_fingerprint_enroll_onboard_message_1">Setup your backup screen lock method</string> + <!-- Introduction message shown in fingerprint enrollment dialog, second item to describe what + the user needs to do. --> + <string name="security_settings_fingerprint_enroll_onboard_message_2">Add your fingerprint</string> <!-- Introduction title shown in fingerprint enrollment dialog to locate the sensor [CHAR LIMIT=22] --> <string name="security_settings_fingerprint_enroll_find_sensor_title">Find the sensor</string> <!-- Introduction detail message shown in fingerprint enrollment dialog --> <string name="security_settings_fingerprint_enroll_find_sensor_message"> Locate the fingerprint sensor on the back of your phone.</string> + <!-- Content description of graphic that shows where the fingerprint of the device is [CHAR LIMIT=NONE] --> + <string name="security_settings_fingerprint_enroll_find_sensor_content_description">Illustration with device and fingerprint sensor location</string> <!-- Label text shown in fingerprint dialog for renaming a fingerprint template [CHAR LIMIT=22] --> <string name="security_settings_fingerprint_enroll_dialog_name_label">Name</string> <!-- Button text shown in fingerprint dialog that allows the user to rename a fingerprint template [CHAR LIMIT=22] --> @@ -779,8 +784,12 @@ <string name="security_settings_fingerprint_enroll_finish_title">Fingerprint added!</string> <!-- Message shown in fingerprint enrollment dialog once enrollment is completed --> <string name="security_settings_fingerprint_enroll_finish_message">Whenever you see this icon, you can use your fingerprint for identification or to authorize a purchase.</string> + <!-- Button text to setup screen lock in onboard dialog [CHAR LIMIT=34] --> + <string name="security_settings_fingerprint_enroll_setup_screen_lock">Setup screen lock</string> + <!-- Button text to exit fingerprint wizard after everything is done [CHAR LIMIT=15] --> + <string name="security_settings_fingerprint_enroll_done">Done</string> <!-- Button text shown at the end of enrollment that allows the user to add another fingerprint --> - <string name="fingerprint_enroll_button_add">Add</string> + <string name="fingerprint_enroll_button_add">Add another</string> <!-- Button text shown at the end of enrollment that allows the user to move to the next step --> <string name="fingerprint_enroll_button_next">Next</string> diff --git a/res/values/styles.xml b/res/values/styles.xml index f9f45618c..7a917a962 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -296,18 +296,26 @@ <style name="TextAppearance.RecentsTitle" parent="TextAppearance.CategoryTitle" /> <style name="TextAppearance.ResultTitle" parent="TextAppearance.CategoryTitle" /> - <style name="TextAppearance.FingerprintTitle" - parent="android:TextAppearance.Material.Large.Inverse"> - <item name="android:textStyle">bold</item> - <item name="android:textSize">24sp</item> - <item name="android:textColor">@color/fingerprint_title_color</item> + <style name="TextAppearance.FingerprintMessage" + parent="android:TextAppearance.Material.Subhead"> + <item name="android:lineSpacingExtra">@dimen/suw_description_line_spacing_extra</item> </style> - <style name="TextAppearance.FingerprintMessage" - parent="android:TextAppearance.Material.Medium.Inverse"> - <item name="android:textStyle">bold</item> - <item name="android:textSize">16sp</item> - <item name="android:textColor">@color/fingerprint_message_color</item> + <style name="Button.FingerprintButton" + parent="android:Widget.Material.Button.Borderless"> + <item name="android:lineSpacingExtra">@dimen/suw_description_line_spacing_extra</item> + <item name="android:textColor">?android:attr/colorAccent</item> + </style> + + <style name="TextAppearance.FingerprintErrorText" + parent="android:TextAppearance.Material.Caption"> + <item name="android:textColor">@color/warning</item> + </style> + + <style name="SetupWizardFingerprintStyle"> + <item name="suwBackground">@drawable/fp_enrollment_header</item> + <item name="suwIllustrationAspectRatio">@dimen/fingerprint_illustration_aspect_ratio</item> + <item name="suwDecorPaddingTop">@dimen/fingerprint_decor_padding_top</item> </style> <style name="TextAppearance.ConfirmDeviceCredentialsErrorText" diff --git a/res/values/themes.xml b/res/values/themes.xml index f3d5e40c2..edba85f42 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -219,4 +219,8 @@ <item name="@*android:successColor">@color/lock_pattern_view_regular_color_dark</item> <item name="@*android:errorColor">@color/lock_pattern_view_error_color</item> </style> + + <style name="Theme.FingerprintEnroll" parent="@android:style/Theme.Material.Light.NoActionBar"> + </style> + </resources> diff --git a/src/com/android/settings/ChooseLockSettingsHelper.java b/src/com/android/settings/ChooseLockSettingsHelper.java index c113b1d67..c9f20ffa8 100644 --- a/src/com/android/settings/ChooseLockSettingsHelper.java +++ b/src/com/android/settings/ChooseLockSettingsHelper.java @@ -28,9 +28,9 @@ public final class ChooseLockSettingsHelper { static final String EXTRA_KEY_TYPE = "type"; static final String EXTRA_KEY_PASSWORD = "password"; - static final String EXTRA_KEY_HAS_CHALLENGE = "has_challenge"; - static final String EXTRA_KEY_CHALLENGE = "challenge"; - static final String EXTRA_KEY_CHALLENGE_TOKEN = "hw_auth_token"; + public static final String EXTRA_KEY_HAS_CHALLENGE = "has_challenge"; + public static final String EXTRA_KEY_CHALLENGE = "challenge"; + public static final String EXTRA_KEY_CHALLENGE_TOKEN = "hw_auth_token"; private LockPatternUtils mLockPatternUtils; @@ -104,7 +104,7 @@ public final class ChooseLockSettingsHelper { * @return true if one exists and we launched an activity to confirm it * @see #onActivityResult(int, int, android.content.Intent) */ - boolean launchConfirmationActivity(int request, @Nullable CharSequence title, + public boolean launchConfirmationActivity(int request, @Nullable CharSequence title, @Nullable CharSequence header, @Nullable CharSequence description, long challenge) { return launchConfirmationActivity(request, title, header, description, diff --git a/src/com/android/settings/ConfirmDeviceCredentialBaseFragment.java b/src/com/android/settings/ConfirmDeviceCredentialBaseFragment.java index fc8edf8e8..414aa011c 100644 --- a/src/com/android/settings/ConfirmDeviceCredentialBaseFragment.java +++ b/src/com/android/settings/ConfirmDeviceCredentialBaseFragment.java @@ -17,13 +17,14 @@ package com.android.settings; import android.annotation.Nullable; -import android.app.Fragment; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; +import com.android.settings.fingerprint.FingerprintUiHelper; + /** * Base fragment to be shared for PIN/Pattern/Password confirmation fragments. */ diff --git a/src/com/android/settings/FingerprintEnroll.java b/src/com/android/settings/FingerprintEnroll.java deleted file mode 100644 index c5ea7b471..000000000 --- a/src/com/android/settings/FingerprintEnroll.java +++ /dev/null @@ -1,460 +0,0 @@ -/* - * 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. - */ - -package com.android.settings; - -import android.animation.Animator; -import android.animation.Animator.AnimatorListener; -import android.animation.ObjectAnimator; -import android.app.Activity; -import android.app.Fragment; -import android.app.admin.DevicePolicyManager; -import android.content.Context; -import android.content.Intent; -import android.graphics.drawable.AnimationDrawable; -import android.graphics.drawable.Drawable; -import android.media.AudioAttributes; -import android.os.Bundle; -import android.os.CancellationSignal; -import android.os.PowerManager; -import android.os.SystemClock; -import android.hardware.fingerprint.FingerprintManager; -import android.hardware.fingerprint.FingerprintManager.EnrollmentCallback; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.widget.ImageView; -import android.widget.ProgressBar; -import android.widget.TextView; - -import com.android.internal.logging.MetricsLogger; -import com.android.internal.widget.LockPatternUtils; - -/** - * Wizard to enroll a fingerprint - */ -public class FingerprintEnroll extends SettingsActivity { - /** - * Used by the choose fingerprint wizard to indicate the wizard is - * finished, and each activity in the wizard should finish. - * <p> - * Previously, each activity in the wizard would finish itself after - * starting the next activity. However, this leads to broken 'Back' - * behavior. So, now an activity does not finish itself until it gets this - * result. - */ - static final int RESULT_FINISHED = RESULT_FIRST_USER; - - @Override - public Intent getIntent() { - Intent modIntent = new Intent(super.getIntent()); - modIntent.putExtra(EXTRA_SHOW_FRAGMENT, FingerprintEnrollFragment.class.getName()); - return modIntent; - } - - @Override - protected boolean isValidFragment(String fragmentName) { - if (FingerprintEnrollFragment.class.getName().equals(fragmentName)) return true; - return false; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - requestWindowFeature(Window.FEATURE_NO_TITLE); - super.onCreate(savedInstanceState); - CharSequence msg = getText(R.string.security_settings_fingerprint_preference_title); - setTitle(msg); - } - - public static class FingerprintEnrollFragment extends InstrumentedFragment - implements View.OnClickListener { - private static final String EXTRA_PROGRESS = "progress"; - private static final String EXTRA_STAGE = "stage"; - private static final int PROGRESS_BAR_MAX = 10000; - private static final String TAG = "FingerprintEnroll"; - private static final boolean DEBUG = true; - private static final int CONFIRM_REQUEST = 101; - private static final int CHOOSE_LOCK_GENERIC_REQUEST = 102; - private static final int FINISH_DELAY = 250; - - private PowerManager mPowerManager; - private FingerprintManager mFingerprintManager; - private View mContentView; - private TextView mTitleText; - private TextView mMessageText; - private Stage mStage; - private int mEnrollmentSteps; - private boolean mEnrolling; - private ProgressBar mProgressBar; - private ImageView mFingerprintAnimator; - private ObjectAnimator mProgressAnim; - private byte[] mToken; - - // Give the user a chance to see progress completed before jumping to the next stage. - Runnable mDelayedFinishRunnable = new Runnable() { - @Override - public void run() { - updateStage(Stage.EnrollingFinish); - } - }; - - private final AnimatorListener mProgressAnimationListener = new AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) { } - - @Override - public void onAnimationRepeat(Animator animation) { } - - @Override - public void onAnimationEnd(Animator animation) { - if (mProgressBar.getProgress() >= PROGRESS_BAR_MAX) { - mContentView.postDelayed(mDelayedFinishRunnable, FINISH_DELAY); - } - } - - @Override - public void onAnimationCancel(Animator animation) { } - }; - private CancellationSignal mEnrollmentCancel = new CancellationSignal(); - - // This contains a list of all views managed by the UI. Used to determine which views - // need to be shown/hidden at each stage. It should be the union of the lists that follow - private static final int MANAGED_VIEWS[] = { - R.id.fingerprint_sensor_location, - R.id.fingerprint_animator, - R.id.fingerprint_enroll_button_area, - R.id.fingerprint_in_app_indicator, - R.id.fingerprint_enroll_button_add, - R.id.fingerprint_enroll_button_next, - R.id.fingerprint_progress_bar - }; - - private static final int VIEWS_ENROLL_ONBOARD[] = { - R.id.fingerprint_enroll_button_area, - R.id.fingerprint_enroll_button_next - }; - - private static final int VIEWS_ENROLL_FIND_SENSOR[] = { - R.id.fingerprint_sensor_location, - R.id.fingerprint_enroll_button_area, - R.id.fingerprint_enroll_button_next - }; - - private static final int VIEWS_ENROLL_START[] = { - R.id.fingerprint_animator, - }; - - private static final int VIEWS_ENROLL_REPEAT[] = { - R.id.fingerprint_animator, - R.id.fingerprint_progress_bar - }; - - private static final int VIEWS_ENROLL_FINISH[] = { - R.id.fingerprint_enroll_button_area, - R.id.fingerprint_in_app_indicator, - R.id.fingerprint_enroll_button_add, - R.id.fingerprint_enroll_button_next - }; - private static final boolean ALWAYS_SHOW_FIND_SCREEN = true; - - @Override - protected int getMetricsCategory() { - return MetricsLogger.FINGERPRINT_ENROLL; - } - - private enum Stage { - EnrollingOnboard(R.string.security_settings_fingerprint_enroll_onboard_title, - R.string.security_settings_fingerprint_enroll_onboard_message, - VIEWS_ENROLL_ONBOARD), - EnrollingFindSensor(R.string.security_settings_fingerprint_enroll_find_sensor_title, - R.string.security_settings_fingerprint_enroll_find_sensor_message, - VIEWS_ENROLL_FIND_SENSOR), - EnrollingStart(R.string.security_settings_fingerprint_enroll_start_title, - R.string.security_settings_fingerprint_enroll_start_message, - VIEWS_ENROLL_START), - EnrollingRepeat(R.string.security_settings_fingerprint_enroll_repeat_title, - R.string.security_settings_fingerprint_enroll_repeat_message, - VIEWS_ENROLL_REPEAT), - EnrollingFinish(R.string.security_settings_fingerprint_enroll_finish_title, - R.string.security_settings_fingerprint_enroll_finish_message, - VIEWS_ENROLL_FINISH); - - Stage(int title, int message, int[] enabledViewIds) { - this.title = title; - this.message = message; - this.enabledViewIds = enabledViewIds; - } - - public int title; - public int message; - public int[] enabledViewIds; - }; - - void updateStage(Stage stage) { - if (DEBUG) Log.v(TAG, "updateStage(" + stage.toString() + ")"); - - // Show/hide views - for (int i = 0; i < MANAGED_VIEWS.length; i++) { - mContentView.findViewById(MANAGED_VIEWS[i]).setVisibility(View.INVISIBLE); - } - for (int i = 0; i < stage.enabledViewIds.length; i++) { - mContentView.findViewById(stage.enabledViewIds[i]).setVisibility(View.VISIBLE); - } - - setTitleMessage(stage.title); - setMessage(stage.message); - - if (mStage != stage) { - onStageChanged(stage); - mStage = stage; - } - } - - private void startFingerprintAnimator() { - final Drawable d = mFingerprintAnimator.getDrawable(); - if (d instanceof AnimationDrawable) { - ((AnimationDrawable) d).start(); - } - } - - private void stopFingerprintAnimator() { - final Drawable d = mFingerprintAnimator.getDrawable(); - if (d instanceof AnimationDrawable) { - final AnimationDrawable drawable = (AnimationDrawable) d; - drawable.stop(); - drawable.setLevel(0); - } - } - - private void onStageChanged(Stage stage) { - // Update state - switch (stage) { - case EnrollingOnboard: // pass through - case EnrollingFindSensor: - mEnrollmentSteps = -1; - mEnrolling = false; - break; - - case EnrollingStart: - mEnrollmentSteps = -1; - mFingerprintManager.enroll(mToken, mEnrollmentCancel, mEnrollmentCallback, 0); - mProgressBar.setProgress(0); - mEnrolling = true; - startFingerprintAnimator(); // XXX hack - this should follow fingerprint detection - break; - - case EnrollingRepeat: - break; - - case EnrollingFinish: - stopFingerprintAnimator(); // XXX hack - this should follow fingerprint detection - mEnrolling = false; - break; - - default: - break; - } - } - - private void cancelEnrollment() { - if (mEnrolling) { - if (DEBUG) Log.v(TAG, "Cancel enrollment\n"); - mEnrollmentCancel.cancel(); - mEnrolling = false; - } - } - - @Override - public void onDetach() { - super.onDetach(); - cancelEnrollment(); // Do a little cleanup - } - - private void updateProgress(int progress) { - if (DEBUG) Log.v(TAG, "Progress: " + progress); - if (mProgressAnim != null) { - mProgressAnim.cancel(); - } - ObjectAnimator anim = ObjectAnimator.ofInt(mProgressBar, "progress", - mProgressBar.getProgress(), progress); - anim.addListener(mProgressAnimationListener); - anim.start(); - mProgressAnim = anim; - } - - protected void setMessage(CharSequence msg) { - if (msg != null) mMessageText.setText(msg); - } - - private void setMessage(int id) { - if (id != 0) mMessageText.setText(id); - } - - private void setTitleMessage(int title) { - if (title != 0) mTitleText.setText(title); - } - - private EnrollmentCallback mEnrollmentCallback = new EnrollmentCallback() { - - @Override - public void onEnrollmentProgress(int remaining) { - if (DEBUG) Log.v(TAG, "onEnrollResult(id=" + ", rem=" + remaining); - if (mEnrollmentSteps == -1) { - mEnrollmentSteps = remaining; - updateStage(Stage.EnrollingRepeat); - } - if (remaining >= 0) { - int progress = Math.max(0, mEnrollmentSteps + 1 - remaining); - updateProgress(PROGRESS_BAR_MAX * progress / (mEnrollmentSteps + 1)); - // Treat fingerprint like a touch event - mPowerManager.userActivity(SystemClock.uptimeMillis(), - PowerManager.USER_ACTIVITY_EVENT_OTHER, - PowerManager.USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS); - } - } - - @Override - public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) { - setMessage(helpString); - } - - @Override - public void onEnrollmentError(int errMsgId, CharSequence errString) { - setMessage(errString); - } - }; - - @Override - public void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - - if (requestCode == CHOOSE_LOCK_GENERIC_REQUEST - || requestCode == CONFIRM_REQUEST) { - if (resultCode == RESULT_FINISHED || resultCode == RESULT_OK) { - // The lock pin/pattern/password was set. Start enrolling! - mToken = data.getByteArrayExtra( - ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); - updateStage(Stage.EnrollingFindSensor); - } - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - final Activity activity = getActivity(); - mFingerprintManager = (FingerprintManager)activity - .getSystemService(Context.FINGERPRINT_SERVICE); - mPowerManager = (PowerManager) activity.getSystemService(Context.POWER_SERVICE); - - mContentView = inflater.inflate(R.layout.fingerprint_enroll, null); - mTitleText = (TextView) mContentView.findViewById(R.id.fingerprint_enroll_title); - mMessageText = (TextView) mContentView.findViewById(R.id.fingerprint_enroll_message); - mProgressBar = (ProgressBar) mContentView.findViewById(R.id.fingerprint_progress_bar); - mFingerprintAnimator = (ImageView) mContentView.findViewById(R.id.fingerprint_animator); - - final int buttons[] = { - R.id.fingerprint_enroll_button_add, - R.id.fingerprint_enroll_button_next }; - for (int i = 0; i < buttons.length; i++) { - mContentView.findViewById(buttons[i]).setOnClickListener(this); - } - - if (mToken == null) { - mToken = getActivity().getIntent().getByteArrayExtra( - ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); - } - - if (mToken == null) { - // need to choose or confirm lock - updateStage(Stage.EnrollingOnboard); - } else if (ALWAYS_SHOW_FIND_SCREEN - || mFingerprintManager.getEnrolledFingerprints().size() == 0) { - updateStage(Stage.EnrollingFindSensor); - } else { - updateStage(Stage.EnrollingStart); - } - return mContentView; - } - - @Override - public void onSaveInstanceState(final Bundle outState) { - super.onSaveInstanceState(outState); - outState.putString(EXTRA_STAGE, mStage.toString()); - outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, - mToken); - if (mStage == Stage.EnrollingRepeat) { - outState.putInt(EXTRA_PROGRESS, mProgressBar.getProgress()); - } - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - if (savedInstanceState != null) { - mToken = savedInstanceState.getByteArray( - ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); - //probably orientation change - String stageSaved = savedInstanceState.getString(EXTRA_STAGE, null); - if (stageSaved != null) { - Stage stage = Stage.valueOf(stageSaved); - updateStage(stage); - if (stage == Stage.EnrollingRepeat) { - mProgressBar.setProgress(savedInstanceState.getInt(EXTRA_PROGRESS)); - } - } - } - } - - @Override - public void onClick(View v) { - switch(v.getId()) { - case R.id.fingerprint_enroll_button_add: - updateStage(Stage.EnrollingStart); - break; - case R.id.fingerprint_enroll_button_next: - if (mStage == Stage.EnrollingOnboard) { - launchChooseOrConfirmLock(); - } else if (mStage == Stage.EnrollingFindSensor) { - updateStage(Stage.EnrollingStart); - } else if (mStage == Stage.EnrollingFinish) { - getActivity().finish(); - } else { - Log.v(TAG, "No idea what to do next!"); - } - break; - } - } - - private void launchChooseOrConfirmLock() { - Intent intent = new Intent(); - long challenge = mFingerprintManager.preEnroll(); - ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(getActivity(), this); - if (!helper.launchConfirmationActivity(CONFIRM_REQUEST, null, - null, null, challenge)) { - intent.setClassName("com.android.settings", ChooseLockGeneric.class.getName()); - intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY, - DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); - intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true); - intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true); - intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge); - startActivityForResult(intent, CHOOSE_LOCK_GENERIC_REQUEST); - } - } - } -} diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java index 59816ac15..132281fa0 100644 --- a/src/com/android/settings/SecuritySettings.java +++ b/src/com/android/settings/SecuritySettings.java @@ -54,6 +54,9 @@ import android.util.Log; import com.android.internal.logging.MetricsLogger; import com.android.internal.widget.LockPatternUtils; import com.android.settings.TrustAgentUtils.TrustAgentComponentInfo; +import com.android.settings.fingerprint.FingerprintEnrollFindSensor; +import com.android.settings.fingerprint.FingerprintEnrollOnboard; +import com.android.settings.fingerprint.FingerprintSettings; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Index; import com.android.settings.search.Indexable; @@ -345,14 +348,19 @@ public class SecuritySettings extends SettingsPreferenceFragment final List<Fingerprint> items = fpm.getEnrolledFingerprints(); final int fingerprintCount = items != null ? items.size() : 0; final String clazz; + boolean hasPassword = mChooseLockSettingsHelper.utils().getActivePasswordQuality() + != DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; if (fingerprintCount > 0) { fingerprintPreference.setSummary(getResources().getQuantityString( R.plurals.security_settings_fingerprint_preference_summary, fingerprintCount, fingerprintCount)); clazz = FingerprintSettings.class.getName(); + } else if (!hasPassword) { + // No fingerprints registered, launch into enrollment wizard. + clazz = FingerprintEnrollOnboard.class.getName(); } else { - // No fingerprints registered, launch directly into enrollment wizard - clazz = FingerprintEnroll.class.getName(); + // Lock thingy is already set up, launch directly into find sensor step from wizard. + clazz = FingerprintEnrollFindSensor.class.getName(); } intent.setClassName("com.android.settings", clazz); fingerprintPreference.setIntent(intent); diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollBase.java b/src/com/android/settings/fingerprint/FingerprintEnrollBase.java new file mode 100644 index 000000000..9ef372a55 --- /dev/null +++ b/src/com/android/settings/fingerprint/FingerprintEnrollBase.java @@ -0,0 +1,120 @@ +/* + * 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 + */ + +package com.android.settings.fingerprint; + +import android.annotation.Nullable; +import android.app.Activity; +import android.content.Intent; +import android.graphics.Color; +import android.hardware.fingerprint.FingerprintManager; +import android.os.Bundle; +import android.view.View; +import android.view.WindowManager; +import android.widget.Button; + +import com.android.settings.ChooseLockSettingsHelper; +import com.android.settings.R; +import com.android.setupwizardlib.SetupWizardLayout; +import com.android.setupwizardlib.view.NavigationBar; + +/** + * Base activity for all fingerprint enrollment steps. + */ +public class FingerprintEnrollBase extends Activity implements View.OnClickListener { + + /** + * Used by the choose fingerprint wizard to indicate the wizard is + * finished, and each activity in the wizard should finish. + * <p> + * Previously, each activity in the wizard would finish itself after + * starting the next activity. However, this leads to broken 'Back' + * behavior. So, now an activity does not finish itself until it gets this + * result. + */ + protected static final int RESULT_FINISHED = RESULT_FIRST_USER; + + protected byte[] mToken; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setTheme(R.style.Theme_FingerprintEnroll); + mToken = getIntent().getByteArrayExtra( + ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); + if (savedInstanceState != null && mToken == null) { + mToken = savedInstanceState.getByteArray( + ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); + } + + @Override + protected void onPostCreate(@Nullable Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS | + WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | + WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR); + + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + + getWindow().setStatusBarColor(Color.TRANSPARENT); + getNavigationBar().setVisibility(View.GONE); + Button nextButton = getNextButton(); + if (nextButton != null) { + nextButton.setOnClickListener(this); + } + } + + protected NavigationBar getNavigationBar() { + return (NavigationBar) findViewById(R.id.suw_layout_navigation_bar); + } + + protected SetupWizardLayout getSetupWizardLayout() { + return (SetupWizardLayout) findViewById(R.id.setup_wizard_layout); + } + + protected void setHeaderText(int resId) { + getSetupWizardLayout().setHeaderText(getText(resId)); + } + + protected Button getNextButton() { + return (Button) findViewById(R.id.next_button); + } + + @Override + public void onClick(View v) { + if (v == getNextButton()) { + onNextButtonClick(); + } + } + + protected void onNextButtonClick() { + } + + protected Intent getEnrollingIntent() { + Intent intent = new Intent(); + intent.setClassName("com.android.settings", FingerprintEnrollEnrolling.class.getName()); + intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); + return intent; + } +} diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java new file mode 100644 index 000000000..56eee18e6 --- /dev/null +++ b/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java @@ -0,0 +1,187 @@ +/* + * 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 + */ + +package com.android.settings.fingerprint; + +import android.animation.Animator; +import android.animation.ObjectAnimator; +import android.content.Intent; +import android.hardware.fingerprint.FingerprintManager; +import android.os.Bundle; +import android.os.CancellationSignal; +import android.os.PowerManager; +import android.os.SystemClock; +import android.view.View; +import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import com.android.settings.ChooseLockSettingsHelper; +import com.android.settings.R; + +/** + * Activity which handles the actual enrolling for fingerprint. + */ +public class FingerprintEnrollEnrolling extends FingerprintEnrollBase { + + private static final int PROGRESS_BAR_MAX = 10000; + private static final int FINISH_DELAY = 250; + + private PowerManager mPowerManager; + private CancellationSignal mEnrollmentCancel = new CancellationSignal(); + private int mEnrollmentSteps; + private boolean mEnrolling; + private ProgressBar mProgressBar; + private ImageView mFingerprintAnimator; + private ObjectAnimator mProgressAnim; + private TextView mStartMessage; + private TextView mRepeatMessage; + private TextView mErrorText; + private Interpolator mFastOutSlowInInterpolator; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fingerprint_enroll_enrolling); + setHeaderText(R.string.security_settings_fingerprint_enroll_start_title); + mPowerManager = getSystemService(PowerManager.class); + mStartMessage = (TextView) findViewById(R.id.start_message); + mRepeatMessage = (TextView) findViewById(R.id.repeat_message); + mErrorText = (TextView) findViewById(R.id.error_text); + mProgressBar = (ProgressBar) findViewById(R.id.fingerprint_progress_bar); + mFingerprintAnimator = (ImageView) findViewById(R.id.fingerprint_animator); + mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator( + this, android.R.interpolator.fast_out_slow_in); + startEnrollment(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + cancelEnrollment(); + } + + private void startEnrollment() { + mEnrollmentSteps = -1; + getSystemService(FingerprintManager.class).enroll(mToken, mEnrollmentCancel, + mEnrollmentCallback, 0); + mProgressBar.setProgress(0); + mEnrolling = true; + } + + private void cancelEnrollment() { + if (mEnrolling) { + mEnrollmentCancel.cancel(); + mEnrolling = false; + } + } + + private void updateProgress(int progress) { + if (mProgressAnim != null) { + mProgressAnim.cancel(); + } + ObjectAnimator anim = ObjectAnimator.ofInt(mProgressBar, "progress", + mProgressBar.getProgress(), progress); + anim.addListener(mProgressAnimationListener); + anim.setInterpolator(mFastOutSlowInInterpolator); + anim.setDuration(250); + anim.start(); + mProgressAnim = anim; + } + + private void launchFinish(byte[] token) { + Intent intent = new Intent(); + intent.setClassName("com.android.settings", FingerprintEnrollFinish.class.getName()); + intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token); + startActivity(intent); + setResult(RESULT_FINISHED); + finish(); + } + + private void updateDescription() { + if (mEnrollmentSteps == -1) { + setHeaderText(R.string.security_settings_fingerprint_enroll_start_title); + mStartMessage.setVisibility(View.VISIBLE); + mRepeatMessage.setVisibility(View.INVISIBLE); + } else { + setHeaderText(R.string.security_settings_fingerprint_enroll_repeat_title); + mStartMessage.setVisibility(View.INVISIBLE); + mRepeatMessage.setVisibility(View.VISIBLE); + } + } + + private final Animator.AnimatorListener mProgressAnimationListener + = new Animator.AnimatorListener() { + + @Override + public void onAnimationStart(Animator animation) { } + + @Override + public void onAnimationRepeat(Animator animation) { } + + @Override + public void onAnimationEnd(Animator animation) { + if (mProgressBar.getProgress() >= PROGRESS_BAR_MAX) { + mProgressBar.postDelayed(mDelayedFinishRunnable, FINISH_DELAY); + } + } + + @Override + public void onAnimationCancel(Animator animation) { } + }; + + private FingerprintManager.EnrollmentCallback mEnrollmentCallback + = new FingerprintManager.EnrollmentCallback() { + + @Override + public void onEnrollmentProgress(int remaining) { + if (mEnrollmentSteps == -1) { + mEnrollmentSteps = remaining; + updateDescription(); + } + if (remaining >= 0) { + int progress = Math.max(0, mEnrollmentSteps + 1 - remaining); + updateProgress(PROGRESS_BAR_MAX * progress / (mEnrollmentSteps + 1)); + + // Treat fingerprint like a touch event + mPowerManager.userActivity(SystemClock.uptimeMillis(), + PowerManager.USER_ACTIVITY_EVENT_OTHER, + PowerManager.USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS); + } + mErrorText.setText(""); + } + + @Override + public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) { + mErrorText.setText(helpString); + } + + @Override + public void onEnrollmentError(int errMsgId, CharSequence errString) { + mErrorText.setText(errString); + } + }; + + // Give the user a chance to see progress completed before jumping to the next stage. + Runnable mDelayedFinishRunnable = new Runnable() { + @Override + public void run() { + launchFinish(mToken); + } + }; +} diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java new file mode 100644 index 000000000..d49fdb621 --- /dev/null +++ b/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java @@ -0,0 +1,79 @@ +/* + * 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 + */ + +package com.android.settings.fingerprint; + +import android.content.Intent; +import android.hardware.fingerprint.FingerprintManager; +import android.os.Bundle; + +import com.android.settings.ChooseLockSettingsHelper; +import com.android.settings.R; + +/** + * Activity explaining the fingerprint sensor location for fingerprint enrollment. + */ +public class FingerprintEnrollFindSensor extends FingerprintEnrollBase { + + private static final int CONFIRM_REQUEST = 1; + private static final int ENROLLING = 2; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fingerprint_enroll_find_sensor); + setHeaderText(R.string.security_settings_fingerprint_enroll_find_sensor_title); + if (mToken == null) { + launchConfirmLock(); + } + } + + @Override + protected void onNextButtonClick() { + startActivityForResult(getEnrollingIntent(), ENROLLING); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == CONFIRM_REQUEST) { + if (resultCode == RESULT_OK) { + mToken = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); + overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out); + } else { + finish(); + } + } else if (requestCode == ENROLLING) { + if (resultCode == RESULT_FINISHED) { + finish(); + } + } else { + super.onActivityResult(requestCode, resultCode, data); + } + } + + private void launchConfirmLock() { + long challenge = getSystemService(FingerprintManager.class).preEnroll(); + ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this); + if (!helper.launchConfirmationActivity(CONFIRM_REQUEST, + getString(R.string.security_settings_fingerprint_preference_title), + null, null, challenge)) { + + // This shouldn't happen, as we should only end up at this step if a lock thingy is + // already set. + finish(); + } + } +} diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/fingerprint/FingerprintEnrollFinish.java new file mode 100644 index 000000000..b87e02925 --- /dev/null +++ b/src/com/android/settings/fingerprint/FingerprintEnrollFinish.java @@ -0,0 +1,50 @@ +/* + * 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 + */ + +package com.android.settings.fingerprint; + +import android.os.Bundle; +import android.view.View; + +import com.android.settings.R; + +/** + * Activity which concludes fingerprint enrollment. + */ +public class FingerprintEnrollFinish extends FingerprintEnrollBase { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fingerprint_enroll_finish); + setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title); + findViewById(R.id.add_another_button).setOnClickListener(this); + } + + @Override + protected void onNextButtonClick() { + finish(); + } + + @Override + public void onClick(View v) { + if (v.getId() == R.id.add_another_button) { + finish(); + startActivity(getEnrollingIntent()); + } + super.onClick(v); + } +} diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollOnboard.java b/src/com/android/settings/fingerprint/FingerprintEnrollOnboard.java new file mode 100644 index 000000000..f9ad2bab8 --- /dev/null +++ b/src/com/android/settings/fingerprint/FingerprintEnrollOnboard.java @@ -0,0 +1,77 @@ +/* + * 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 + */ + +package com.android.settings.fingerprint; + +import android.app.admin.DevicePolicyManager; +import android.content.Intent; +import android.hardware.fingerprint.FingerprintManager; +import android.os.Bundle; + +import com.android.settings.ChooseLockGeneric; +import com.android.settings.ChooseLockSettingsHelper; +import com.android.settings.R; + +/** + * Onboarding activity for fingerprint enrollment. + */ +public class FingerprintEnrollOnboard extends FingerprintEnrollBase { + + private static final int CHOOSE_LOCK_GENERIC_REQUEST = 1; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.fingerprint_enroll_onboard); + setHeaderText(R.string.security_settings_fingerprint_enroll_onboard_title); + } + + @Override + protected void onNextButtonClick() { + launchChooseLock(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == CHOOSE_LOCK_GENERIC_REQUEST && resultCode == RESULT_FINISHED) { + byte[] token = data.getByteArrayExtra( + ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); + launchFindSensor(token); + } else { + super.onActivityResult(requestCode, resultCode, data); + } + } + + private void launchChooseLock() { + Intent intent = new Intent(); + long challenge = getSystemService(FingerprintManager.class).preEnroll(); + intent.setClassName("com.android.settings", ChooseLockGeneric.class.getName()); + intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY, + DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); + intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true); + intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true); + intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge); + startActivityForResult(intent, CHOOSE_LOCK_GENERIC_REQUEST); + } + + private void launchFindSensor(byte[] token) { + Intent intent = new Intent(); + intent.setClassName("com.android.settings", FingerprintEnrollFindSensor.class.getName()); + intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token); + startActivity(intent); + finish(); + } +} diff --git a/src/com/android/settings/FingerprintSettings.java b/src/com/android/settings/fingerprint/FingerprintSettings.java index 00f4b43ab..2469f7ec0 100644 --- a/src/com/android/settings/FingerprintSettings.java +++ b/src/com/android/settings/fingerprint/FingerprintSettings.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.settings; +package com.android.settings.fingerprint; import android.app.Activity; @@ -43,6 +43,12 @@ import android.widget.EditText; import android.widget.Toast; import com.android.internal.logging.MetricsLogger; +import com.android.settings.ChooseLockGeneric; +import com.android.settings.ChooseLockSettingsHelper; +import com.android.settings.R; +import com.android.settings.SettingsActivity; +import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.fingerprint.FingerprintEnrollEnrolling; import com.android.settings.search.Indexable; import java.util.List; @@ -323,7 +329,8 @@ public class FingerprintSettings extends SettingsActivity { final String key = pref.getKey(); if (KEY_FINGERPRINT_ADD.equals(key)) { Intent intent = new Intent(); - intent.setClassName("com.android.settings", FingerprintEnroll.class.getName()); + intent.setClassName("com.android.settings", + FingerprintEnrollEnrolling.class.getName()); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken); stopFingerprint(); startActivityForResult(intent, ADD_FINGERPRINT_REQUEST); @@ -410,9 +417,9 @@ public class FingerprintSettings extends SettingsActivity { Intent intent = new Intent(); long challenge = mFingerprintManager.preEnroll(); ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(getActivity(), this); - // TODO: update text or remove params from method - if (!helper.launchConfirmationActivity(CONFIRM_REQUEST, null, - null, null, challenge)) { + if (!helper.launchConfirmationActivity(CONFIRM_REQUEST, + getString(R.string.security_settings_fingerprint_preference_title), + null, null, challenge)) { intent.setClassName("com.android.settings", ChooseLockGeneric.class.getName()); intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING); diff --git a/src/com/android/settings/FingerprintUiHelper.java b/src/com/android/settings/fingerprint/FingerprintUiHelper.java index f4a027598..66ae69466 100644 --- a/src/com/android/settings/FingerprintUiHelper.java +++ b/src/com/android/settings/fingerprint/FingerprintUiHelper.java @@ -14,7 +14,7 @@ * limitations under the License */ -package com.android.settings; +package com.android.settings.fingerprint; import android.hardware.fingerprint.FingerprintManager; import android.os.CancellationSignal; @@ -23,6 +23,8 @@ import android.view.View; import android.widget.ImageView; import android.widget.TextView; +import com.android.settings.R; + /** * Small helper class to manage text/icon around fingerprint authentication UI. */ |