blob: 422897172cc2d62de719c7c5df25c2ae0cdd75f2 [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
Brian Attwelld28851f2014-06-10 13:25:07 -070019import android.content.ContentValues;
20import android.content.Context;
21import android.content.Intent;
22import android.provider.ContactsContract.Directory;
23import android.widget.Toast;
24
Gary Mai0a49afa2016-12-05 15:53:58 -080025import com.android.contacts.ContactSaveService;
26import com.android.contacts.R;
27import com.android.contacts.model.Contact;
28import com.android.contacts.model.account.AccountWithDataSet;
29
Brian Attwelld28851f2014-06-10 13:25:07 -070030import 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}