1 /* 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 17 package com.android.contacts.editor; 18 19 import com.android.contacts.R; 20 21 import android.app.AlertDialog; 22 import android.app.Dialog; 23 import android.app.DialogFragment; 24 import android.content.DialogInterface; 25 import android.os.Bundle; 26 27 public class JoinSuggestedContactDialogFragment extends DialogFragment { 28 29 private static final String ARG_RAW_CONTACT_IDS = "rawContactIds"; 30 show(ContactEditorBaseFragment fragment, long[] rawContactIds)31 public static void show(ContactEditorBaseFragment fragment, long[] rawContactIds) { 32 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 onCreateDialog(Bundle savedInstanceState)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) { 50 ContactEditorBaseFragment targetFragment = 51 (ContactEditorBaseFragment) getTargetFragment(); 52 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 } 61 }