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
17package com.android.email.activity.setup;
18
19import com.android.email.R;
20
21import android.app.AlertDialog;
22import android.app.Dialog;
23import android.app.DialogFragment;
24import android.content.Context;
25import android.content.DialogInterface;
26import android.os.Bundle;
27
28/**
29 * Dialog fragment to show "duplicate account" dialog
30 */
31public 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    /**
38     * Create the dialog with parameters
39     */
40    public static DuplicateAccountDialogFragment newInstance(String note) {
41        DuplicateAccountDialogFragment f = new DuplicateAccountDialogFragment();
42        Bundle b = new Bundle();
43        b.putString(BUNDLE_KEY_ACCOUNT_NAME, note);
44        f.setArguments(b);
45        return f;
46    }
47
48    @Override
49    public Dialog onCreateDialog(Bundle savedInstanceState) {
50        Context context = getActivity();
51        String accountName = getArguments().getString(BUNDLE_KEY_ACCOUNT_NAME);
52
53        return new AlertDialog.Builder(context)
54            .setIconAttribute(android.R.attr.alertDialogIcon)
55            .setTitle(R.string.account_duplicate_dlg_title)
56            .setMessage(context.getString(
57                    R.string.account_duplicate_dlg_message_fmt, accountName))
58            .setPositiveButton(
59                    R.string.okay_action,
60                    new DialogInterface.OnClickListener() {
61                        public void onClick(DialogInterface dialog, int which) {
62                            dismiss();
63                        }
64                    })
65            .create();
66    }
67}
68