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.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.os.Bundle; 26 import android.support.annotation.NonNull; 27 28 import com.android.settings.R; 29 30 public class SetupSkipDialog extends DialogFragment implements DialogInterface.OnClickListener { 31 32 public static final String EXTRA_FRP_SUPPORTED = ":settings:frp_supported"; 33 34 private static final String ARG_FRP_SUPPORTED = "frp_supported"; 35 private static final String TAG_SKIP_DIALOG = "skip_dialog"; 36 private static final int RESULT_SKIP = Activity.RESULT_FIRST_USER + 10; 37 38 public static SetupSkipDialog newInstance(boolean isFrpSupported) { 39 SetupSkipDialog dialog = new SetupSkipDialog(); 40 Bundle args = new Bundle(); 41 args.putBoolean(ARG_FRP_SUPPORTED, isFrpSupported); 42 dialog.setArguments(args); 43 return dialog; 44 } 45 46 @Override 47 public Dialog onCreateDialog(Bundle savedInstanceState) { 48 return onCreateDialogBuilder().create(); 49 } 50 51 @NonNull 52 public AlertDialog.Builder onCreateDialogBuilder() { 53 Bundle args = getArguments(); 54 return new AlertDialog.Builder(getContext()) 55 .setPositiveButton(R.string.skip_anyway_button_label, this) 56 .setNegativeButton(R.string.go_back_button_label, this) 57 .setMessage(args.getBoolean(ARG_FRP_SUPPORTED) ? 58 R.string.lock_screen_intro_skip_dialog_text_frp : 59 R.string.lock_screen_intro_skip_dialog_text); 60 } 61 62 @Override 63 public void onClick(DialogInterface dialog, int button) { 64 switch (button) { 65 case DialogInterface.BUTTON_POSITIVE: 66 Activity activity = getActivity(); 67 activity.setResult(RESULT_SKIP); 68 activity.finish(); 69 break; 70 } 71 } 72 73 public void show(FragmentManager manager) { 74 show(manager, TAG_SKIP_DIALOG); 75 } 76 }