• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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.email.activity.setup;
18 
19 import com.android.email.R;
20 
21 import android.app.AlertDialog;
22 import android.app.Dialog;
23 import android.app.DialogFragment;
24 import android.content.Context;
25 import android.content.DialogInterface;
26 import android.os.Bundle;
27 
28 /**
29  * Dialog fragment to show "duplicate account" dialog
30  */
31 public class DuplicateAccountDialogFragment extends DialogFragment {
32     public final static String TAG = "DuplicateAccountDialogFragment";
33 
34     // Argument bundle keys
35     private final static String BUNDLE_KEY_ACCOUNT_NAME = "NoteDialogFragment.AccountName";
36 
37     // Public no-args constructor needed for fragment re-instantiation
DuplicateAccountDialogFragment()38     public DuplicateAccountDialogFragment() {}
39 
40     /**
41      * Create the dialog with parameters
42      */
newInstance(String note)43     public static DuplicateAccountDialogFragment newInstance(String note) {
44         DuplicateAccountDialogFragment f = new DuplicateAccountDialogFragment();
45         Bundle b = new Bundle();
46         b.putString(BUNDLE_KEY_ACCOUNT_NAME, note);
47         f.setArguments(b);
48         return f;
49     }
50 
51     @Override
onCreateDialog(Bundle savedInstanceState)52     public Dialog onCreateDialog(Bundle savedInstanceState) {
53         Context context = getActivity();
54         String accountName = getArguments().getString(BUNDLE_KEY_ACCOUNT_NAME);
55 
56         return new AlertDialog.Builder(context)
57             .setIconAttribute(android.R.attr.alertDialogIcon)
58             .setTitle(R.string.account_duplicate_dlg_title)
59             .setMessage(context.getString(
60                     R.string.account_duplicate_dlg_message_fmt, accountName))
61             .setPositiveButton(
62                     R.string.okay_action,
63                     new DialogInterface.OnClickListener() {
64                         @Override
65                         public void onClick(DialogInterface dialog, int which) {
66                             dismiss();
67                         }
68                     })
69             .create();
70     }
71 }
72