Home | History | Annotate | Download | only in quickcontact
      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.quickcontact;
     18 
     19 import android.content.ContentValues;
     20 import android.content.Context;
     21 import android.content.Intent;
     22 import android.provider.ContactsContract.Directory;
     23 import android.widget.Toast;
     24 
     25 import com.android.contacts.ContactSaveService;
     26 import com.android.contacts.R;
     27 import com.android.contacts.model.Contact;
     28 import com.android.contacts.model.account.AccountWithDataSet;
     29 
     30 import 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  */
     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 
     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