blob: c4969cc6d19a6ca23ac9a86e6a57e0cfcb7b0bf7 [file] [log] [blame]
Walter Jang055c66d2015-03-12 10:47:53 -07001/*
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
Brian Attwelld28851f2014-06-10 13:25:07 -070017package com.android.contacts.quickcontact;
18
19import com.android.contacts.ContactSaveService;
20import com.android.contacts.R;
Brian Attwelld28851f2014-06-10 13:25:07 -070021import com.android.contacts.common.model.Contact;
22import com.android.contacts.common.model.account.AccountWithDataSet;
Brian Attwelld28851f2014-06-10 13:25:07 -070023
Brian Attwelld28851f2014-06-10 13:25:07 -070024import 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;
Brian Attwelld28851f2014-06-10 13:25:07 -070031
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
Brian Attwelld28851f2014-06-10 13:25:07 -070048 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}