blob: 8f8b56a9934667cea04d9cf918162411b1531527 [file] [log] [blame]
Walter Jang3e9a6242015-02-05 13:41:43 -08001/*
2 * Copyright (C) 2015 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.contacts.editor;
18
19import com.android.contacts.R;
20
21import android.app.AlertDialog;
22import android.app.Dialog;
23import android.app.DialogFragment;
24import android.content.DialogInterface;
25import android.os.Bundle;
26
27public class JoinSuggestedContactDialogFragment extends DialogFragment {
28
29 private static final String ARG_RAW_CONTACT_IDS = "rawContactIds";
30
Gary Mai363af602016-09-28 10:01:23 -070031 public static void show(ContactEditorFragment fragment, long[] rawContactIds) {
Walter Jang3e9a6242015-02-05 13:41:43 -080032 final Bundle args = new Bundle();
33 args.putLongArray(ARG_RAW_CONTACT_IDS, rawContactIds);
34
35 final JoinSuggestedContactDialogFragment dialog = new JoinSuggestedContactDialogFragment();
36 dialog.setArguments(args);
37 dialog.setTargetFragment(fragment, 0);
38 dialog.show(fragment.getFragmentManager(), "join");
39 }
40
41 @Override
42 public Dialog onCreateDialog(Bundle savedInstanceState) {
43 return new AlertDialog.Builder(getActivity())
44 .setIconAttribute(android.R.attr.alertDialogIcon)
45 .setMessage(R.string.aggregation_suggestion_join_dialog_message)
46 .setPositiveButton(android.R.string.yes,
47 new DialogInterface.OnClickListener() {
48 @Override
49 public void onClick(DialogInterface dialog, int whichButton) {
Gary Mai363af602016-09-28 10:01:23 -070050 ContactEditorFragment targetFragment =
51 (ContactEditorFragment) getTargetFragment();
Walter Jang3e9a6242015-02-05 13:41:43 -080052 long rawContactIds[] =
53 getArguments().getLongArray(ARG_RAW_CONTACT_IDS);
54 targetFragment.doJoinSuggestedContact(rawContactIds);
55 }
56 }
57 )
58 .setNegativeButton(android.R.string.no, null)
59 .create();
60 }
Walter Jang7b0970f2016-09-01 10:40:19 -070061}