• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
35 public class SetupFingerprintEnrollEnrolling extends FingerprintEnrollEnrolling {
36 
37     private static final String TAG_DIALOG = "dialog";
38 
39     @Override
getFinishIntent()40     protected Intent getFinishIntent() {
41         final Intent intent = new Intent(this, SetupFingerprintEnrollFinish.class);
42         SetupWizardUtils.copySetupExtras(getIntent(), intent);
43         return intent;
44     }
45 
46     @Override
onApplyThemeResource(Resources.Theme theme, int resid, boolean first)47     protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
48         resid = SetupWizardUtils.getTheme(getIntent());
49         super.onApplyThemeResource(theme, resid, first);
50     }
51 
52     @Override
initViews()53     protected void initViews() {
54         super.initViews();
55         final Button skipButton = (Button) findViewById(R.id.skip_button);
56         skipButton.setVisibility(View.VISIBLE);
57         skipButton.setOnClickListener(this);
58     }
59 
60     @Override
onClick(View v)61     public void onClick(View v) {
62         switch (v.getId()) {
63             case R.id.skip_button:
64                 new SkipDialog().show(getFragmentManager(), TAG_DIALOG);
65                 break;
66             default:
67                 super.onClick(v);
68         }
69     }
70 
71     @Override
getMetricsCategory()72     protected int getMetricsCategory() {
73         return MetricsEvent.FINGERPRINT_ENROLLING_SETUP;
74     }
75 
76     public static class SkipDialog extends DialogFragment {
77 
78         @Override
show(FragmentManager manager, String tag)79         public void show(FragmentManager manager, String tag) {
80             if (manager.findFragmentByTag(tag) == null) {
81                 super.show(manager, tag);
82             }
83         }
84 
SkipDialog()85         public SkipDialog() {
86             // no-arg constructor for fragment
87         }
88 
89         @Override
onCreateDialog(Bundle savedInstanceState)90         public Dialog onCreateDialog(Bundle savedInstanceState) {
91             return new AlertDialog.Builder(getActivity())
92                     .setTitle(R.string.setup_fingerprint_enroll_enrolling_skip_title)
93                     .setMessage(R.string.setup_fingerprint_enroll_enrolling_skip_message)
94                     .setCancelable(false)
95                     .setPositiveButton(R.string.wifi_skip_anyway,
96                             new DialogInterface.OnClickListener() {
97                                 @Override
98                                 public void onClick(DialogInterface dialog, int id) {
99                                     Activity activity = getActivity();
100                                     if (activity != null) {
101                                         activity.setResult(RESULT_SKIP);
102                                         activity.finish();
103                                     }
104                                 }
105                             })
106                     .setNegativeButton(R.string.wifi_dont_skip,
107                             new DialogInterface.OnClickListener() {
108                                 @Override
109                                 public void onClick(DialogInterface dialog, int id) {
110                                 }
111                             })
112                     .create();
113         }
114     }
115 }
116