• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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.cts.verifier.nfc;
18 
19 import android.app.AlertDialog;
20 import android.content.Context;
21 import android.content.DialogInterface;
22 import android.content.Intent;
23 import android.provider.Settings;
24 
25 import com.android.cts.verifier.R;
26 
27 /** Class containing methods to create common dialogs for NFC activities. */
28 public class NfcDialogs {
29 
createNotEnabledDialog(final Context context)30     static AlertDialog createNotEnabledDialog(final Context context) {
31         return new AlertDialog.Builder(context)
32                 .setIcon(android.R.drawable.ic_dialog_alert)
33                 .setTitle(R.string.nfc_not_enabled)
34                 .setMessage(R.string.nfc_not_enabled_message)
35                 .setPositiveButton(R.string.nfc_settings, new DialogInterface.OnClickListener() {
36                     @Override
37                     public void onClick(DialogInterface dialog, int which) {
38                         Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS);
39                         context.startActivity(intent);
40                     }
41                 })
42                 .create();
43     }
44 
45     public static AlertDialog createHceTapReaderDialog(final Context context, String message) {
46         String baseString = context.getString(R.string.nfc_hce_tap_reader_message);
47         return new AlertDialog.Builder(context)
48                 .setIcon(android.R.drawable.ic_dialog_alert)
49                 .setTitle(R.string.nfc_hce_tap_reader_title)
50                 .setMessage(message != null ? message + "\n\n" + baseString : baseString)
51                 .setPositiveButton("OK", null)
52                 .create();
53     }
54 
55     public static AlertDialog createChangeForegroundDialog(final Context context) {
56         return new AlertDialog.Builder(context)
57                 .setIcon(android.R.drawable.ic_dialog_alert)
58                 .setTitle(R.string.nfc_hce_tap_reader_title)
59                 .setMessage(context.getString(R.string.nfc_hce_change_favor_foreground))
60                 .setPositiveButton("OK", new DialogInterface.OnClickListener() {
61                     @Override
62                     public void onClick(DialogInterface dialog, int which) {
63                         Intent intent = new Intent(Settings.ACTION_NFC_PAYMENT_SETTINGS);
64                         context.startActivity(intent);
65                     }
66                 })
67                 .create();
68     }
69 
70     /**
71      * SecureNfcEnabled dialog
72      */
73     public static AlertDialog createSecureNfcEnabledDialog(final Context context) {
74         return new AlertDialog.Builder(context)
75                 .setIcon(android.R.drawable.ic_dialog_alert)
76                 .setTitle(R.string.secure_nfc_enabled)
77                 .setMessage(R.string.secure_nfc_enabled_message)
78                 .setPositiveButton(R.string.nfc_settings, new DialogInterface.OnClickListener() {
79                     @Override
80                     public void onClick(DialogInterface dialog, int which) {
81                         Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS);
82                         context.startActivity(intent);
83                     }
84                 })
85                 .create();
86     }
87 
88 
89     private NfcDialogs() {
90     }
91 }
92