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 17package com.android.contacts.quickcontact; 18 19import com.android.contacts.ContactSaveService; 20import com.android.contacts.R; 21import com.android.contacts.common.model.Contact; 22import com.android.contacts.common.model.account.AccountWithDataSet; 23 24import android.content.ContentValues; 25import android.content.Context; 26import android.content.Intent; 27import android.provider.ContactsContract.Directory; 28import android.widget.Toast; 29 30import java.util.ArrayList; 31 32/** 33 * Utility class to support adding directory contacts. 34 * 35 * This class is coupled with {@link QuickContactActivity}, but is left out of 36 * QuickContactActivity.java to avoid ballooning the size of the file. 37 */ 38public class DirectoryContactUtil { 39 40 public static boolean isDirectoryContact(Contact contactData) { 41 // Not a directory contact? Nothing to fix here 42 if (contactData == null || !contactData.isDirectoryEntry()) return false; 43 44 // No export support? Too bad 45 return contactData.getDirectoryExportSupport() != Directory.EXPORT_SUPPORT_NONE; 46 } 47 48 public static void createCopy( 49 ArrayList<ContentValues> values, AccountWithDataSet account, 50 Context context) { 51 Toast.makeText(context, R.string.toast_making_personal_copy, 52 Toast.LENGTH_LONG).show(); 53 Intent serviceIntent = ContactSaveService.createNewRawContactIntent( 54 context, values, account, 55 QuickContactActivity.class, Intent.ACTION_VIEW); 56 context.startService(serviceIntent); 57 } 58} 59