Walter Jang | 055c66d | 2015-03-12 10:47:53 -0700 | [diff] [blame] | 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 | |
Brian Attwell | d28851f | 2014-06-10 13:25:07 -0700 | [diff] [blame] | 17 | package com.android.contacts.quickcontact; |
| 18 | |
| 19 | import com.android.contacts.ContactSaveService; |
| 20 | import com.android.contacts.R; |
Brian Attwell | d28851f | 2014-06-10 13:25:07 -0700 | [diff] [blame] | 21 | import com.android.contacts.common.model.Contact; |
| 22 | import com.android.contacts.common.model.account.AccountWithDataSet; |
Brian Attwell | d28851f | 2014-06-10 13:25:07 -0700 | [diff] [blame] | 23 | |
Brian Attwell | d28851f | 2014-06-10 13:25:07 -0700 | [diff] [blame] | 24 | import android.content.ContentValues; |
| 25 | import android.content.Context; |
| 26 | import android.content.Intent; |
| 27 | import android.provider.ContactsContract.Directory; |
| 28 | import android.widget.Toast; |
| 29 | |
| 30 | import java.util.ArrayList; |
Brian Attwell | d28851f | 2014-06-10 13:25:07 -0700 | [diff] [blame] | 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 | */ |
| 38 | public 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 Attwell | d28851f | 2014-06-10 13:25:07 -0700 | [diff] [blame] | 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 | } |