package com.ae.apps.common.utils;

import java.util.List;

/**
 * Helper methods for Contact
 */
public class ContactUtils {
    /**
     * Checks whether the numberToCheck is present in the supplied list. Adds the number to the list if it doesn't exist
     * and returns false
     *
     * @param phoneNumbers  phone numbers
     * @param numberToCheck number to check
     */
    public static boolean checkIfPhoneNumberExists(final List<String> phoneNumbers, final String numberToCheck) {
        // Remove spaces, hyphens and + symbols from the phone number for comparison
        String unformattedNumber = numberToCheck.replaceAll("\\s+", "")
                .replaceAll("\\+", "")
                .replaceAll("-", "")
                .replaceAll("\\(", "")
                .replaceAll("\\)", "")
                .trim();
        if (phoneNumbers.contains(unformattedNumber)) {
            return true;
        } else {
            phoneNumbers.add(unformattedNumber);
            return false;
        }
    }
}

@@ -39,22 +39,201 @@
 ort 
-java.util.List
+android.content.Context;%0Aimport android.content.Intent;%0Aimport android.net.Uri;%0Aimport android.provider.ContactsContract;%0A%0Aimport java.util.List;%0A%0Aimport static android.net.Uri.withAppendedPath
 ;%0A%0A/
@@ -1190,11 +1190,490 @@
  %7D%0A    %7D
+%0A%0A    /**%0A     * Shows this contact in the Android's Contact Manager%0A     *%0A     * @param contactId contactId%0A     */%0A    public static void showContactInAddressBook(Context context, String contactId) %7B%0A        if (null != contactId) %7B%0A            Intent intent = new Intent(Intent.ACTION_VIEW);%0A%0A            Uri uri = withAppendedPath(ContactsContract.Contacts.CONTENT_URI, contactId);%0A            intent.setData(uri);%0A%0A            context.startActivity(intent);%0A        %7D%0A    %7D
 %0A%7D%0A

add contact utility method