Enroll fingerprint via SetupWizard [2/2]

Change-Id: Ieabfb0f3b789b02ddd1e17aba1eadfda52b21384
This commit is contained in:
d34d 2015-07-07 17:30:20 -07:00
parent a1c8217e77
commit b28f9c0a76
9 changed files with 264 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2015 The CyanogenMod 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="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#7ED321"
android:pathData="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
</vector>

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The CyanogenMod 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">
<include layout="@layout/header" />
<FrameLayout android:id="@+id/page"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/PageContent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/PageSummaryText"
android:textSize="16sp"
android:paddingLeft="@dimen/content_margin_left"
android:layout_marginBottom="@dimen/summary_margin_bottom"
android:paddingRight="@dimen/location_text_margin_right"
android:text="@string/fingerprint_setup_summary" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:paddingLeft="@dimen/content_margin_left"
android:paddingRight="@dimen/location_text_margin_right"
android:drawableStart="@drawable/ic_check_mark"
android:drawablePadding="24dp"
android:gravity="center_vertical"
android:textSize="16sp"
android:textStyle="bold"
android:text="@string/fingerprint_setup_backup_lock_method"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:paddingLeft="@dimen/content_margin_left"
android:paddingRight="@dimen/location_text_margin_right"
android:drawableStart="@drawable/ic_check_mark"
android:drawablePadding="24dp"
android:gravity="center_vertical"
android:textSize="16sp"
android:textStyle="bold"
android:text="@string/fingerprint_setup_add_fingerprint"/>
<TextView
android:id="@+id/setup_fingerprint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/content_margin_left"
android:paddingRight="@dimen/location_text_margin_right"
android:gravity="center_vertical"
android:textSize="16sp"
android:textAllCaps="true"
android:textColor="@color/fingerprint_setup_text_color"
android:text="@string/fingerprint_setup_screen_lock_setup"/>
</LinearLayout>
</ScrollView>
</FrameLayout>
</LinearLayout>

View File

@ -29,4 +29,5 @@
<color name="header_bg">@color/primary</color>
<color name="header_condensed_bg">@color/primary_dark</color>
<color name="button_bar_background">#e4e7e8</color>
<color name="fingerprint_setup_text_color">#356bc4</color>
</resources>

View File

@ -85,4 +85,13 @@
<string name="setup_require_cyanogen_label"><b>Require your Cyanogen OS account password</b> in order to use your device even after a factory reset.</string>
<string name="setup_device_locked_instructions"><i>To turn this feature off/on, please go to Settings > Security</i></string>
<string name="setup_warning_skip_anyway">Without a Cyanogen OS Account, you won\'t be able to:\n\nCustomize your phone with new icons, wallpapers and more in the Themes app\n\nLocate or remotely erase your phone if it\'s lost</string>
<!-- Fingerprint setup -->
<string name="settings_fingerprint_setup_title">Select backup screen lock type</string>
<string name="settings_fingerprint_setup_details">How would you like to lock your screen?</string>
<string name="fingerprint_setup_title">Fingerprint setup</string>
<string name="fingerprint_setup_summary">To use your fingerprint sensor to unlock your screen or confirm purchases, you\'ll need to:</string>
<string name="fingerprint_setup_backup_lock_method">Setup a backup screen lock method</string>
<string name="fingerprint_setup_add_fingerprint">Add your fingerprint</string>
<string name="fingerprint_setup_screen_lock_setup">Setup screen lock</string>
</resources>

View File

@ -40,6 +40,8 @@ public class SetupWizardApp extends Application {
public static final String ACTION_SETUP_WIFI = "com.android.net.wifi.SETUP_WIFI_NETWORK";
public static final String ACTION_VIEW_LEGAL = "cyanogenmod.intent.action.LEGALESE";
public static final String ACTION_SETUP_FINGERPRINT = "com.android.settings.SETUP_FINGERPRINT";
public static final String EXTRA_FIRST_RUN = "firstRun";
public static final String EXTRA_ALLOW_SKIP = "allowSkip";
public static final String EXTRA_AUTO_FINISH = "wifi_auto_finish_on_connect";
@ -49,6 +51,8 @@ public class SetupWizardApp extends Application {
public static final String EXTRA_MATERIAL_LIGHT = "material_light";
public static final String EXTRA_CKSOP = "cksOp";
public static final String EXTRA_LOGIN_FOR_KILL_SWITCH = "authCks";
public static final String EXTRA_TITLE = "title";
public static final String EXTRA_DETAILS = "details";
public static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled";
@ -65,6 +69,7 @@ public class SetupWizardApp extends Application {
public static final int REQUEST_CODE_SETUP_CAPTIVE_PORTAL= 4;
public static final int REQUEST_CODE_SETUP_BLUETOOTH= 5;
public static final int REQUEST_CODE_UNLOCK = 6;
public static final int REQUEST_CODE_SETUP_FINGERPRINT = 7;
public static final int RADIO_READY_TIMEOUT = 10 * 1000;

View File

@ -156,6 +156,7 @@ public class SetupStats {
public static final String VALUE = "value";
public static final String SLOT = "slot";
public static final String TOTAL_TIME = "total_time";
public static final String FINGERPRINT_SETUP = "fingerprint_setup";
}
}

View File

@ -50,6 +50,9 @@ public class CMSetupWizardData extends AbstractSetupData {
pages.add(new BluetoothSetupPage(mContext, this));
}
pages.add(new WelcomePage(mContext, this));
if (SetupWizardUtils.hasFingerprint(mContext) && SetupWizardUtils.isOwner()) {
pages.add(new FingerprintSetupPage(mContext, this));
}
pages.add(new WifiSetupPage(mContext, this));
if (SetupWizardUtils.hasTelephony(mContext)) {
pages.add(new SimCardMissingPage(mContext, this)

View File

@ -0,0 +1,123 @@
/*
* Copyright (C) 2013 The CyanogenMod 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.cyanogenmod.setupwizard.setup;
import android.app.Activity;
import android.app.ActivityOptions;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.android.internal.widget.LockPatternUtils;
import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
public class FingerprintSetupPage extends SetupPage {
private static final String TAG = "FingerprintSetupPage";
public FingerprintSetupPage(Context context, SetupDataCallbacks callbacks) {
super(context, callbacks);
}
@Override
public Fragment getFragment(FragmentManager fragmentManager, int action) {
Fragment fragment = fragmentManager.findFragmentByTag(getKey());
if (fragment == null) {
Bundle args = new Bundle();
args.putString(Page.KEY_PAGE_ARGUMENT, getKey());
args.putInt(Page.KEY_PAGE_ACTION, action);
fragment = new FingerprintSetupFragment();
fragment.setArguments(args);
}
return fragment;
}
@Override
public int getNextButtonTitleResId() {
return R.string.skip;
}
@Override
public String getKey() {
return TAG;
}
@Override
public int getTitleResId() {
return R.string.fingerprint_setup_title;
}
@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (SetupWizardApp.REQUEST_CODE_SETUP_FINGERPRINT == requestCode) {
if (resultCode == Activity.RESULT_OK) {
getCallbacks().onNextPage();
}
}
return true;
}
public static class FingerprintSetupFragment extends SetupPageFragment {
private TextView mSetupFingerprint;
@Override
protected void initializePage() {
mSetupFingerprint = (TextView) mRootView.findViewById(R.id.setup_fingerprint);
mSetupFingerprint.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
launchFingerprintSetup();
}
});
}
@Override
protected int getLayoutResource() {
return R.layout.setup_fingerprint;
}
private void launchFingerprintSetup() {
Intent intent = new Intent(SetupWizardApp.ACTION_SETUP_FINGERPRINT);
intent.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);
intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
intent.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
intent.putExtra(SetupWizardApp.EXTRA_THEME, SetupWizardApp.EXTRA_MATERIAL_LIGHT);
intent.putExtra(SetupWizardApp.EXTRA_AUTO_FINISH, false);
intent.putExtra(LockPatternUtils.LOCKSCREEN_FINGERPRINT_FALLBACK, true);
intent.putExtra(SetupWizardApp.EXTRA_TITLE,
getString(R.string.settings_fingerprint_setup_title));
intent.putExtra(SetupWizardApp.EXTRA_DETAILS,
getString(R.string.settings_fingerprint_setup_details));
ActivityOptions options =
ActivityOptions.makeCustomAnimation(getActivity(),
android.R.anim.fade_in,
android.R.anim.fade_out);
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
SetupStats.Label.PAGE, SetupStats.Label.FINGERPRINT_SETUP);
startActivityForResult(intent, SetupWizardApp.REQUEST_CODE_SETUP_FINGERPRINT,
options.toBundle());
}
}
}

View File

@ -36,6 +36,7 @@ import android.telephony.TelephonyManager;
import android.util.Log;
import com.android.internal.os.IKillSwitchService;
import com.android.internal.widget.LockPatternUtils;
import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.google.android.gms.common.ConnectionResult;
@ -267,6 +268,11 @@ public class SetupWizardUtils {
return packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
}
public static boolean hasFingerprint(Context context) {
LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
return lockPatternUtils.isFingerprintInstalled(context);
}
public static final ComponentName mTvwifisettingsActivity =
new ComponentName("com.android.tv.settings",
"com.android.tv.settings.connectivity.setup.WifiSetupActivity");