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.app.Activity;
     20 import android.app.AlertDialog;
     21 import android.app.Dialog;
     22 import android.app.DialogFragment;
     23 import android.app.FragmentManager;
     24 import android.content.DialogInterface;
     25 import android.content.Intent;
     26 import android.content.res.Resources;
     27 import android.os.Bundle;
     28 import android.view.View;
     29 import android.widget.Button;
     30 
     31 import com.android.internal.logging.MetricsProto.MetricsEvent;
     32 import com.android.settings.R;
     33 import com.android.settings.SetupWizardUtils;
     34 import com.android.setupwizardlib.util.SystemBarHelper;
     35 import com.android.setupwizardlib.view.NavigationBar;
     36 
     37 public class SetupFingerprintEnrollEnrolling extends FingerprintEnrollEnrolling
     38         implements NavigationBar.NavigationBarListener {
     39 
     40     private static final String TAG_DIALOG = "dialog";
     41 
     42     @Override
     43     protected Intent getFinishIntent() {
     44         final Intent intent = new Intent(this, SetupFingerprintEnrollFinish.class);
     45         SetupWizardUtils.copySetupExtras(getIntent(), intent);
     46         return intent;
     47     }
     48 
     49     @Override
     50     protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
     51         resid = SetupWizardUtils.getTheme(getIntent());
     52         super.onApplyThemeResource(theme, resid, first);
     53     }
     54 
     55     @Override
     56     protected void initViews() {
     57         SetupWizardUtils.setImmersiveMode(this);
     58 
     59         final View buttonBar = findViewById(R.id.button_bar);
     60         if (buttonBar != null) {
     61             buttonBar.setVisibility(View.GONE);
     62         }
     63 
     64         final NavigationBar navigationBar = getNavigationBar();
     65         navigationBar.setNavigationBarListener(this);
     66         navigationBar.getNextButton().setText(R.string.skip_label);
     67         navigationBar.getBackButton().setVisibility(View.GONE);
     68     }
     69 
     70     @Override
     71     protected Button getNextButton() {
     72         return getNavigationBar().getNextButton();
     73     }
     74 
     75     @Override
     76     public void onNavigateBack() {
     77         onBackPressed();
     78     }
     79 
     80     @Override
     81     public void onNavigateNext() {
     82         new SkipDialog().show(getFragmentManager(), TAG_DIALOG);
     83     }
     84 
     85     @Override
     86     protected int getMetricsCategory() {
     87         return MetricsEvent.FINGERPRINT_ENROLLING_SETUP;
     88     }
     89 
     90     public static class SkipDialog extends DialogFragment {
     91 
     92         @Override
     93         public void show(FragmentManager manager, String tag) {
     94             if (manager.findFragmentByTag(tag) == null) {
     95                 super.show(manager, tag);
     96             }
     97         }
     98 
     99         public SkipDialog() {
    100             // no-arg constructor for fragment
    101         }
    102 
    103         @Override
    104         public Dialog onCreateDialog(Bundle savedInstanceState) {
    105             final AlertDialog dialog = new AlertDialog.Builder(getActivity())
    106                     .setTitle(R.string.setup_fingerprint_enroll_enrolling_skip_title)
    107                     .setMessage(R.string.setup_fingerprint_enroll_enrolling_skip_message)
    108                     .setCancelable(false)
    109                     .setPositiveButton(R.string.wifi_skip_anyway,
    110                             new DialogInterface.OnClickListener() {
    111                                 @Override
    112                                 public void onClick(DialogInterface dialog, int id) {
    113                                     Activity activity = getActivity();
    114                                     if (activity != null) {
    115                                         activity.setResult(RESULT_SKIP);
    116                                         activity.finish();
    117                                     }
    118                                 }
    119                             })
    120                     .setNegativeButton(R.string.wifi_dont_skip,
    121                             new DialogInterface.OnClickListener() {
    122                                 @Override
    123                                 public void onClick(DialogInterface dialog, int id) {
    124                                 }
    125                             })
    126                     .create();
    127             SystemBarHelper.hideSystemBars(dialog);
    128             return dialog;
    129         }
    130     }
    131 }
    132