Home | History | Annotate | Download | only in fingerprint
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License
     15  */
     16 
     17 package com.android.settings.fingerprint;
     18 
     19 import android.content.Intent;
     20 import android.content.res.Resources;
     21 import android.os.UserHandle;
     22 import android.widget.Button;
     23 
     24 import com.android.internal.logging.MetricsProto.MetricsEvent;
     25 import com.android.internal.widget.LockPatternUtils;
     26 import com.android.settings.R;
     27 import com.android.settings.SetupChooseLockGeneric;
     28 import com.android.settings.SetupWizardUtils;
     29 import com.android.setupwizardlib.SetupWizardRecyclerLayout;
     30 import com.android.setupwizardlib.items.Item;
     31 import com.android.setupwizardlib.items.RecyclerItemAdapter;
     32 import com.android.setupwizardlib.view.NavigationBar;
     33 
     34 public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntroduction
     35         implements NavigationBar.NavigationBarListener {
     36 
     37     @Override
     38     protected Intent getChooseLockIntent() {
     39         Intent intent = new Intent(this, SetupChooseLockGeneric.class);
     40         SetupWizardUtils.copySetupExtras(getIntent(), intent);
     41         return intent;
     42     }
     43 
     44     @Override
     45     protected Intent getFindSensorIntent() {
     46         final Intent intent = new Intent(this, SetupFingerprintEnrollFindSensor.class);
     47         SetupWizardUtils.copySetupExtras(getIntent(), intent);
     48         return intent;
     49     }
     50 
     51     @Override
     52     protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
     53         resid = SetupWizardUtils.getTheme(getIntent());
     54         super.onApplyThemeResource(theme, resid, first);
     55     }
     56 
     57     @Override
     58     protected void initViews() {
     59         final SetupWizardRecyclerLayout layout =
     60                 (SetupWizardRecyclerLayout) findViewById(R.id.setup_wizard_layout);
     61         final RecyclerItemAdapter adapter = (RecyclerItemAdapter) layout.getAdapter();
     62         final Item nextItem = (Item) adapter.findItemById(R.id.next_button);
     63         nextItem.setTitle(
     64                 getText(R.string.security_settings_fingerprint_enroll_introduction_continue_setup));
     65 
     66         final Item cancelItem = (Item) adapter.findItemById(R.id.cancel_button);
     67         cancelItem.setTitle(
     68                 getText(R.string.security_settings_fingerprint_enroll_introduction_cancel_setup));
     69 
     70         SetupWizardUtils.setImmersiveMode(this);
     71         getNavigationBar().setNavigationBarListener(this);
     72         Button nextButton = getNavigationBar().getNextButton();
     73         nextButton.setText(null);
     74         nextButton.setEnabled(false);
     75         layout.setDividerInset(getResources().getDimensionPixelSize(
     76                 R.dimen.suw_items_icon_divider_inset));
     77     }
     78 
     79     @Override
     80     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     81         if (requestCode == FINGERPRINT_FIND_SENSOR_REQUEST) {
     82             if (data == null) {
     83                 data = new Intent();
     84             }
     85             LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
     86             data.putExtra(SetupChooseLockGeneric.
     87                     SetupChooseLockGenericFragment.EXTRA_PASSWORD_QUALITY,
     88                     lockPatternUtils.getKeyguardStoredPasswordQuality(UserHandle.myUserId()));
     89         }
     90         super.onActivityResult(requestCode, resultCode, data);
     91     }
     92 
     93     @Override
     94     protected void onCancelButtonClick() {
     95         SetupSkipDialog dialog = SetupSkipDialog.newInstance(
     96                 getIntent().getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
     97         dialog.show(getFragmentManager());
     98     }
     99 
    100     @Override
    101     public void onNavigateBack() {
    102         onBackPressed();
    103     }
    104 
    105     @Override
    106     public void onNavigateNext() {
    107         // next is handled via the onNextButtonClick method in FingerprintEnrollIntroduction
    108     }
    109 
    110     @Override
    111     protected int getMetricsCategory() {
    112         return MetricsEvent.FINGERPRINT_ENROLL_INTRO_SETUP;
    113     }
    114 }
    115