1 /* 2 * Copyright (C) 2016 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.password; 18 19 import android.app.Activity; 20 import android.app.AlertDialog; 21 import android.app.Dialog; 22 import android.app.FragmentManager; 23 import android.content.DialogInterface; 24 import android.os.Bundle; 25 import android.support.annotation.NonNull; 26 27 import com.android.internal.logging.nano.MetricsProto; 28 import com.android.settings.R; 29 import com.android.settings.core.instrumentation.InstrumentedDialogFragment; 30 31 public class SetupSkipDialog extends InstrumentedDialogFragment 32 implements DialogInterface.OnClickListener { 33 34 public static final String EXTRA_FRP_SUPPORTED = ":settings:frp_supported"; 35 36 private static final String ARG_FRP_SUPPORTED = "frp_supported"; 37 private static final String TAG_SKIP_DIALOG = "skip_dialog"; 38 public static final int RESULT_SKIP = Activity.RESULT_FIRST_USER + 10; 39 40 public static SetupSkipDialog newInstance(boolean isFrpSupported) { 41 SetupSkipDialog dialog = new SetupSkipDialog(); 42 Bundle args = new Bundle(); 43 args.putBoolean(ARG_FRP_SUPPORTED, isFrpSupported); 44 dialog.setArguments(args); 45 return dialog; 46 } 47 48 @Override 49 public int getMetricsCategory() { 50 return MetricsProto.MetricsEvent.DIALOG_FINGERPRINT_SKIP_SETUP; 51 } 52 53 @Override 54 public Dialog onCreateDialog(Bundle savedInstanceState) { 55 return onCreateDialogBuilder().create(); 56 } 57 58 @NonNull 59 public AlertDialog.Builder onCreateDialogBuilder() { 60 Bundle args = getArguments(); 61 return new AlertDialog.Builder(getContext()) 62 .setPositiveButton(R.string.skip_anyway_button_label, this) 63 .setNegativeButton(R.string.go_back_button_label, this) 64 .setTitle(R.string.lock_screen_intro_skip_title) 65 .setMessage(args.getBoolean(ARG_FRP_SUPPORTED) ? 66 R.string.lock_screen_intro_skip_dialog_text_frp : 67 R.string.lock_screen_intro_skip_dialog_text); 68 } 69 70 @Override 71 public void onClick(DialogInterface dialog, int button) { 72 switch (button) { 73 case DialogInterface.BUTTON_POSITIVE: 74 Activity activity = getActivity(); 75 activity.setResult(RESULT_SKIP); 76 activity.finish(); 77 break; 78 } 79 } 80 81 public void show(FragmentManager manager) { 82 show(manager, TAG_SKIP_DIALOG); 83 } 84 }