Java 类android.provider.ContactsContract.CommonDataKinds.Email 实例源码

项目:ntsync-android    文件:ContactOperations.java   
public ContactOperations addEvent(String event, int type, String label,
        boolean isPrimary, boolean isSuperPrimary) {
    mValues.clear();
    if (!TextUtils.isEmpty(event)) {
        mValues.put(Event.START_DATE, event);
        mValues.put(Event.TYPE, type);
        mValues.put(Event.MIMETYPE, Event.CONTENT_ITEM_TYPE);
        if (!TextUtils.isEmpty(label)) {
            mValues.put(Event.LABEL, label);
        }
        if (isSuperPrimary) {
            mValues.put(Email.IS_SUPER_PRIMARY, 1);
        }
        if (isPrimary) {
            mValues.put(Email.IS_PRIMARY, 1);
        }

        addInsertOp();
    }
    return this;
}
项目:q-mail    文件:ContactBadge.java   
@Override
public void onClick(View v) {
    // If contact has been assigned, extras should no longer be null, but do a null check
    // anyway just in case assignContactFromPhone or Email was called with a null bundle or
    // wasn't assigned previously.
    final Bundle extras = (this.extras == null) ? new Bundle() : this.extras;
    if (contactUri != null) {
        QuickContact.showQuickContact(getContext(), ContactBadge.this, contactUri,
                QuickContact.MODE_LARGE, null);
    } else if (contactEmail != null) {
        extras.putString(EXTRA_URI_CONTENT, contactEmail);
        queryHandler.startQuery(TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(contactEmail)),
                EMAIL_LOOKUP_PROJECTION, null, null, null);
    }
}
项目:q-mail    文件:RecipientLoader.java   
private void fillContactDataFromLookupKey(Uri lookupKeyUri, List<Recipient> recipients,
        Map<String, Recipient> recipientMap) {
    // We could use the contact id from the URI directly, but getting it from the lookup key is safer
    Uri contactContentUri = Contacts.lookupContact(contentResolver, lookupKeyUri);
    if (contactContentUri == null) {
        return;
    }

    String contactIdStr = getContactIdFromContactUri(contactContentUri);

    Cursor cursor = contentResolver.query(
            ContactsContract.CommonDataKinds.Email.CONTENT_URI,
            PROJECTION, ContactsContract.CommonDataKinds.Email.CONTACT_ID + "=?",
            new String[] { contactIdStr }, null);

    if (cursor == null) {
        return;
    }

    fillContactDataFromCursor(cursor, recipients, recipientMap);
}
项目:q-mail    文件:RecipientLoader.java   
private boolean fillContactDataFromNameAndEmail(String query, List<Recipient> recipients,
        Map<String, Recipient> recipientMap) {
    query = "%" + query + "%";

    Uri queryUri = Email.CONTENT_URI;

    String selection = Contacts.DISPLAY_NAME_PRIMARY + " LIKE ? " +
            " OR (" + Email.ADDRESS + " LIKE ? AND " + Data.MIMETYPE + " = '" + Email.CONTENT_ITEM_TYPE + "')";
    String[] selectionArgs = { query, query };
    Cursor cursor = contentResolver.query(queryUri, PROJECTION, selection, selectionArgs, SORT_ORDER);

    if (cursor == null) {
        return false;
    }

    fillContactDataFromCursor(cursor, recipients, recipientMap);

    return true;

}
项目:SOS-The-Healthcare-Companion    文件:ContactBadge.java   
@Override
public void onClick(View v) {
    // If contact has been assigned, mExtras should no longer be null, but do a null check
    // anyway just in case assignContactFromPhone or Email was called with a null bundle or
    // wasn't assigned previously.
    final Bundle extras = (mExtras == null) ? new Bundle() : mExtras;
    if (mContactUri != null) {
        QuickContact.showQuickContact(getContext(), ContactBadge.this, mContactUri, QuickContact.MODE_LARGE, mExcludeMimes);
    } else if (mContactEmail != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactEmail);
        mQueryHandler.startQuery(Constants.TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(mContactEmail)),
                EMAIL_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else if (mContactPhone != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactPhone);
        mQueryHandler.startQuery(Constants.TOKEN_PHONE_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, mContactPhone),
                PHONE_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else {
        // If a contact hasn't been assigned, don't react to click.
        return;
    }
}
项目:alerta-fraude    文件:ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getContactType(String string) {
    int type = CommonDataKinds.Email.TYPE_OTHER;
    if (string != null) {

        String lowerType = string.toLowerCase(Locale.getDefault());

        if ("home".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_HOME;
        }
        else if ("work".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_OTHER;
        }
        else if ("mobile".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_MOBILE;
        }
        return CommonDataKinds.Email.TYPE_CUSTOM;
    }
    return type;
}
项目:alerta-fraude    文件:ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getContactType(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.Email.TYPE_CUSTOM:
        stringType = "custom";
        break;
    case CommonDataKinds.Email.TYPE_HOME:
        stringType = "home";
        break;
    case CommonDataKinds.Email.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.Email.TYPE_MOBILE:
        stringType = "mobile";
        break;
    case CommonDataKinds.Email.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:alerta-fraude    文件:ContactAccessorSdk5.java   
/**
 * Converts a string from the W3C Contact API to it's Android int value.
 * @param string
 * @return Android int value
 */
private int getContactType(String string) {
    int type = CommonDataKinds.Email.TYPE_OTHER;
    if (string != null) {

        String lowerType = string.toLowerCase(Locale.getDefault());

        if ("home".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_HOME;
        }
        else if ("work".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_WORK;
        }
        else if ("other".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_OTHER;
        }
        else if ("mobile".equals(lowerType)) {
            return CommonDataKinds.Email.TYPE_MOBILE;
        }
        return CommonDataKinds.Email.TYPE_CUSTOM;
    }
    return type;
}
项目:alerta-fraude    文件:ContactAccessorSdk5.java   
/**
 * getPhoneType converts an Android phone type into a string
 * @param type
 * @return phone type as string.
 */
private String getContactType(int type) {
    String stringType;
    switch (type) {
    case CommonDataKinds.Email.TYPE_CUSTOM:
        stringType = "custom";
        break;
    case CommonDataKinds.Email.TYPE_HOME:
        stringType = "home";
        break;
    case CommonDataKinds.Email.TYPE_WORK:
        stringType = "work";
        break;
    case CommonDataKinds.Email.TYPE_MOBILE:
        stringType = "mobile";
        break;
    case CommonDataKinds.Email.TYPE_OTHER:
    default:
        stringType = "other";
        break;
    }
    return stringType;
}
项目:templated-messaging    文件:ContactBadge.java   
@Override
public void onClick(View v) {
    // If contact has been assigned, mExtras should no longer be null, but do a null check
    // anyway just in case assignContactFromPhone or Email was called with a null bundle or
    // wasn't assigned previously.
    final Bundle extras = (mExtras == null) ? new Bundle() : mExtras;
    if (mContactUri != null) {
        QuickContact.showQuickContact(getContext(), ContactBadge.this, mContactUri, QuickContact.MODE_LARGE, mExcludeMimes);
    } else if (mContactEmail != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactEmail);
        mQueryHandler.startQuery(Constants.TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(mContactEmail)),
                EMAIL_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else if (mContactPhone != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactPhone);
        mQueryHandler.startQuery(Constants.TOKEN_PHONE_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, mContactPhone),
                PHONE_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else {
        // If a contact hasn't been assigned, don't react to click.
        return;
    }
}
项目:K9-MailClient    文件:RecipientLoader.java   
private void fillContactDataFromLookupKey(Uri lookupKeyUri, List<Recipient> recipients,
        Map<String, Recipient> recipientMap) {
    // We could use the contact id from the URI directly, but getting it from the lookup key is safer
    Uri contactContentUri = Contacts.lookupContact(getContext().getContentResolver(), lookupKeyUri);
    if (contactContentUri == null) {
        return;
    }

    String contactIdStr = getContactIdFromContactUri(contactContentUri);

    Cursor cursor = getContext().getContentResolver().query(
            ContactsContract.CommonDataKinds.Email.CONTENT_URI,
            PROJECTION, ContactsContract.CommonDataKinds.Email.CONTACT_ID + "=?",
            new String[] { contactIdStr }, null);

    if (cursor == null) {
        return;
    }

    fillContactDataFromCursor(cursor, recipients, recipientMap);
}
项目:K9-MailClient    文件:RecipientLoader.java   
private void fillContactDataFromQuery(String query, List<Recipient> recipients,
        Map<String, Recipient> recipientMap) {

    ContentResolver contentResolver = getContext().getContentResolver();

    query = "%" + query + "%";
    Uri queryUri = ContactsContract.CommonDataKinds.Email.CONTENT_URI;
    String selection = Contacts.DISPLAY_NAME_PRIMARY + " LIKE ? " +
            " OR (" + Email.ADDRESS + " LIKE ? AND " + Data.MIMETYPE + " = '" + Email.CONTENT_ITEM_TYPE + "')";
    String[] selectionArgs = { query, query };
    Cursor cursor = contentResolver.query(queryUri, PROJECTION, selection, selectionArgs, SORT_ORDER);

    if (cursor == null) {
        return;
    }

    fillContactDataFromCursor(cursor, recipients, recipientMap);

    if (observerContact != null) {
        observerContact = new ForceLoadContentObserver();
        contentResolver.registerContentObserver(queryUri, false, observerContact);
    }
}
项目:Android-ContactPicker    文件:ContactBadge.java   
@Override
public void onClick(View v) {
    // If contact has been assigned, mExtras should no longer be null, but do a null check
    // anyway just in case assignContactFromPhone or Email was called with a null bundle or
    // wasn't assigned previously.
    final Bundle extras = (mExtras == null) ? new Bundle() : mExtras;
    if (mContactUri != null) {
        QuickContact.showQuickContact(getContext(), ContactBadge.this, mContactUri, QuickContact.MODE_LARGE, mExcludeMimes);
    } else if (mContactEmail != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactEmail);
        mQueryHandler.startQuery(Constants.TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(mContactEmail)),
                EMAIL_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else if (mContactPhone != null && mQueryHandler != null) {
        extras.putString(Constants.EXTRA_URI_CONTENT, mContactPhone);
        mQueryHandler.startQuery(Constants.TOKEN_PHONE_LOOKUP_AND_TRIGGER, extras,
                Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, mContactPhone),
                PHONE_LOOKUP_PROJECTION, null, null, null, mContactQueryHandlerCallback);
    } else {
        // If a contact hasn't been assigned, don't react to click.
        return;
    }
}
项目:FMTech    文件:bwi.java   
private final Cursor p()
{
  localhqr = new hqr(this.r);
  Uri localUri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Email.CONTENT_FILTER_URI, Uri.encode(this.s));
  Cursor localCursor = this.l.getContentResolver().query(localUri, v, null, null, null);
  if (localCursor == null) {
    return localhqr;
  }
  try
  {
    while (localCursor.moveToNext()) {
      if (!TextUtils.isEmpty(localCursor.getString(2))) {
        localhqr.a(b(localCursor));
      }
    }
    return localhqr;
  }
  finally
  {
    localCursor.close();
  }
}
项目:digits-android    文件:VCardBuilderTest.java   
@Test
public void testAppendNameProperties_phone() {
    final VCardBuilder builder = new VCardBuilder(VCardConfig.VCARD_TYPE_V30_GENERIC,
            VCardConfig.DEFAULT_EXPORT_CHARSET);
    final ContentValues cv = new ContentValues();
    final List<ContentValues> group = new ArrayList<>();

    cv.put(ContactsContract.Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
    cv.put(Email.IS_PRIMARY, 0);
    cv.put(Email.DATA1, "(123) 123-4567");

    group.add(cv);

    final String card = builder.appendPhones(group, null).toString();

    assertEquals(PHONE_CARD, card);
}
项目:digits-android    文件:VCardBuilderTest.java   
@Test
public void testAppendNameProperties_name() {
    final VCardBuilder builder = new VCardBuilder(VCardConfig.VCARD_TYPE_V30_GENERIC,
            VCardConfig.DEFAULT_EXPORT_CHARSET);
    final ContentValues cv = new ContentValues();
    final List<ContentValues> group = new ArrayList<>();

    cv.put(ContactsContract.Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
    cv.put(Email.DATA1, "Spruce Grouse");
    cv.put(Email.DATA2, "Spruce");
    cv.put(Email.DATA3, "Grouse");

    group.add(cv);

    final String card = builder.appendNameProperties(group).toString();

    assertEquals(NAME_CARD, card);
}
项目:contact    文件:PeopleDao.java   
/**
 * @param contentResolver
 * @param contactId
 */
private static String getEamilByContactId(ContentResolver contentResolver,
        String contactId) {
    Cursor emailCursor = null;
    String email = null;
    try {
        emailCursor = contentResolver
                .query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
                        new String[] { ContactsContract.CommonDataKinds.Email.DATA },
                        ContactsContract.CommonDataKinds.Email.CONTACT_ID
                                + "=?", new String[] { contactId }, null);
        if (emailCursor.moveToFirst()) {
            email = emailCursor
                    .getString(emailCursor
                            .getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (emailCursor != null) {
            emailCursor.close();
        }
    }
    return email;
}
项目:mc_backup    文件:ContactService.java   
private void initColumnNameConstantsMap() {
    if (mColumnNameConstantsMap != null) {
        return;
    }
    mColumnNameConstantsMap = new HashMap<String, String>();

    mColumnNameConstantsMap.put("name", StructuredName.DISPLAY_NAME);
    mColumnNameConstantsMap.put("givenname", StructuredName.GIVEN_NAME);
    mColumnNameConstantsMap.put("familyname", StructuredName.FAMILY_NAME);
    mColumnNameConstantsMap.put("honorificprefix", StructuredName.PREFIX);
    mColumnNameConstantsMap.put("honorificsuffix", StructuredName.SUFFIX);
    mColumnNameConstantsMap.put("additionalname", CUSTOM_DATA_COLUMN);
    mColumnNameConstantsMap.put("nickname", Nickname.NAME);
    mColumnNameConstantsMap.put("adr", StructuredPostal.STREET);
    mColumnNameConstantsMap.put("email", Email.ADDRESS);
    mColumnNameConstantsMap.put("url", Website.URL);
    mColumnNameConstantsMap.put("category", GroupMembership.GROUP_ROW_ID);
    mColumnNameConstantsMap.put("tel", Phone.NUMBER);
    mColumnNameConstantsMap.put("org", Organization.COMPANY);
    mColumnNameConstantsMap.put("jobTitle", Organization.TITLE);
    mColumnNameConstantsMap.put("note", Note.NOTE);
    mColumnNameConstantsMap.put("impp", Im.DATA);
    mColumnNameConstantsMap.put("sex", CUSTOM_DATA_COLUMN);
    mColumnNameConstantsMap.put("genderidentity", CUSTOM_DATA_COLUMN);
    mColumnNameConstantsMap.put("key", CUSTOM_DATA_COLUMN);
}
项目:mc_backup    文件:ContactService.java   
private void initMimeTypeConstantsMap() {
    if (mMimeTypeConstantsMap != null) {
        return;
    }
    mMimeTypeConstantsMap = new HashMap<String, String>();

    mMimeTypeConstantsMap.put("name", StructuredName.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("givenname", StructuredName.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("familyname", StructuredName.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("honorificprefix", StructuredName.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("honorificsuffix", StructuredName.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("additionalname", MIMETYPE_ADDITIONAL_NAME);
    mMimeTypeConstantsMap.put("nickname", Nickname.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("email", Email.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("url", Website.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("category", GroupMembership.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("tel", Phone.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("org", Organization.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("jobTitle", Organization.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("note", Note.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("impp", Im.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("sex", MIMETYPE_SEX);
    mMimeTypeConstantsMap.put("genderidentity", MIMETYPE_GENDER_IDENTITY);
    mMimeTypeConstantsMap.put("key", MIMETYPE_KEY);
}
项目:ntsync-android    文件:ContactOperations.java   
/**
 * Adds an email
 * 
 * @param the
 *            email address we're adding
 * @return instance of ContactOperations
 */
public ContactOperations addEmail(String email, int emailType,
        String label, boolean isPrimary, boolean isSuperPrimary) {
    mValues.clear();
    if (!TextUtils.isEmpty(email)) {
        mValues.put(Email.DATA, email);
        mValues.put(Email.TYPE, emailType);
        mValues.put(Email.MIMETYPE, Email.CONTENT_ITEM_TYPE);
        if (!TextUtils.isEmpty(label)) {
            mValues.put(Email.LABEL, label);
        }
        if (isSuperPrimary) {
            mValues.put(Email.IS_SUPER_PRIMARY, 1);
        }
        if (isPrimary) {
            mValues.put(Email.IS_PRIMARY, 1);
        }
        addInsertOp();
    }
    return this;
}
项目:ntsync-android    文件:ContactOperations.java   
/**
 * Adds a phone number
 * 
 * @param phone
 *            new phone number for the contact
 * @param phoneType
 *            the type: cell, home, etc.
 * @return instance of ContactOperations
 */
public ContactOperations addPhone(String phone, int phoneType,
        String label, boolean isPrimary, boolean isSuperPrimary) {
    mValues.clear();
    if (!TextUtils.isEmpty(phone)) {
        mValues.put(Phone.NUMBER, phone);
        mValues.put(Phone.TYPE, phoneType);
        mValues.put(Phone.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
        if (!TextUtils.isEmpty(label)) {
            mValues.put(Phone.LABEL, label);
        }
        if (isSuperPrimary) {
            mValues.put(Email.IS_SUPER_PRIMARY, 1);
        }
        if (isPrimary) {
            mValues.put(Email.IS_PRIMARY, 1);
        }

        addInsertOp();
    }
    return this;
}
项目:ntsync-android    文件:ContactOperations.java   
public ContactOperations addWebsite(String website, int type, String label,
        boolean isPrimary, boolean isSuperPrimary) {
    mValues.clear();
    if (!TextUtils.isEmpty(website)) {
        mValues.put(Website.URL, website);
        mValues.put(Website.TYPE, type);
        mValues.put(Website.MIMETYPE, Website.CONTENT_ITEM_TYPE);
        if (!TextUtils.isEmpty(label)) {
            mValues.put(Website.LABEL, label);
        }
        if (isSuperPrimary) {
            mValues.put(Email.IS_SUPER_PRIMARY, 1);
        }
        if (isPrimary) {
            mValues.put(Email.IS_PRIMARY, 1);
        }

        addInsertOp();
    }
    return this;
}
项目:ntsync-android    文件:ContactOperations.java   
public ContactOperations addNickname(String nickname, int type,
        String label, boolean isPrimary, boolean isSuperPrimary) {
    mValues.clear();
    if (!TextUtils.isEmpty(nickname)) {
        mValues.put(Nickname.NAME, nickname);
        mValues.put(Nickname.TYPE, type);
        mValues.put(Nickname.MIMETYPE, Nickname.CONTENT_ITEM_TYPE);
        if (!TextUtils.isEmpty(label)) {
            mValues.put(Nickname.LABEL, label);
        }
        if (isSuperPrimary) {
            mValues.put(Email.IS_SUPER_PRIMARY, 1);
        }
        if (isPrimary) {
            mValues.put(Email.IS_PRIMARY, 1);
        }

        addInsertOp();
    }
    return this;
}
项目:ntsync-android    文件:ContactOperations.java   
public ContactOperations addIm(String data, int type, String label,
        boolean isPrimary, boolean isSuperPrimary, int imProtocolType,
        String customProtocolName) {
    mValues.clear();
    if (!TextUtils.isEmpty(data)) {
        mValues.put(Im.DATA, data);
        mValues.put(Im.TYPE, type);
        mValues.put(Im.MIMETYPE, Im.CONTENT_ITEM_TYPE);
        if (!TextUtils.isEmpty(label)) {
            mValues.put(Im.LABEL, label);
        }
        if (isSuperPrimary) {
            mValues.put(Email.IS_SUPER_PRIMARY, 1);
        }
        if (isPrimary) {
            mValues.put(Email.IS_PRIMARY, 1);
        }
        mValues.put(Im.PROTOCOL, imProtocolType);
        if (!TextUtils.isEmpty(customProtocolName)) {
            mValues.put(Im.CUSTOM_PROTOCOL, customProtocolName);
        }

        addInsertOp();
    }
    return this;
}
项目:ntsync-android    文件:ContactOperations.java   
public ContactOperations addRelation(String data, int type, String label,
        boolean isPrimary, boolean isSuperPrimary) {
    mValues.clear();
    if (!TextUtils.isEmpty(data)) {
        mValues.put(Relation.DATA, data);
        mValues.put(Relation.TYPE, type);
        mValues.put(Relation.MIMETYPE, Relation.CONTENT_ITEM_TYPE);
        if (!TextUtils.isEmpty(label)) {
            mValues.put(Relation.LABEL, label);
        }
        if (isSuperPrimary) {
            mValues.put(Email.IS_SUPER_PRIMARY, 1);
        }
        if (isPrimary) {
            mValues.put(Email.IS_PRIMARY, 1);
        }
        addInsertOp();
    }
    return this;
}
项目:ntsync-android    文件:ContactManager.java   
public static int getAndroidEmailType(EmailType emailType) {
    switch (emailType) {
    case TYPE_CUSTOM:
        return Email.TYPE_CUSTOM;
    case TYPE_HOME:
        return Email.TYPE_HOME;
    case TYPE_MOBILE:
        return Email.TYPE_MOBILE;
    case TYPE_OTHER:
        return Email.TYPE_OTHER;
    case TYPE_WORK:
        return Email.TYPE_WORK;
    default:
        return Email.TYPE_OTHER;
    }
}
项目:ntsync-android    文件:ContactManager.java   
public static EmailType getEmailType(int androidEmailType) {
    switch (androidEmailType) {
    case Email.TYPE_CUSTOM:
        return EmailType.TYPE_CUSTOM;
    case Email.TYPE_OTHER:
        return EmailType.TYPE_OTHER;
    case Email.TYPE_HOME:
        return EmailType.TYPE_HOME;
    case Email.TYPE_WORK:
        return EmailType.TYPE_WORK;
    case Email.TYPE_MOBILE:
        return EmailType.TYPE_MOBILE;
    default:
        return EmailType.TYPE_OTHER;
    }
}
项目:CucumberSync    文件:LocalAddressBook.java   
protected void populateEmailAddresses(Contact c) throws RemoteException {
    @Cleanup Cursor cursor = providerClient.query(dataURI(), new String[] { Email.TYPE, Email.ADDRESS, Email.LABEL, Email.IS_SUPER_PRIMARY },
            Email.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
            new String[] { String.valueOf(c.getLocalID()), Email.CONTENT_ITEM_TYPE }, null);
    while (cursor != null && cursor.moveToNext()) {
        ezvcard.property.Email email = new ezvcard.property.Email(cursor.getString(1));
        switch (cursor.getInt(0)) {
        case Email.TYPE_HOME:
            email.addType(EmailType.HOME);
            break;
        case Email.TYPE_WORK:
            email.addType(EmailType.WORK);
            break;
        case Email.TYPE_MOBILE:
            email.addType(Contact.EMAIL_TYPE_MOBILE);
            break;
        case Email.TYPE_CUSTOM:
            String customType = cursor.getString(2);
            if (!StringUtils.isEmpty(customType))
                email.addType(EmailType.get(labelToXName(customType)));
        }
        if (cursor.getInt(3) != 0)  // IS_PRIMARY
            email.addType(EmailType.PREF);
        c.getEmails().add(email);
    }
}
项目:SafeSlinger-Android    文件:ContactAccessorApi5.java   
private boolean updateEmail(ContactMethod cmethod, String rawContactId, Context ctx) {

        // seek for raw contact + email = same
        String[] proj = new String[] {
                Email.RAW_CONTACT_ID, Data.MIMETYPE, Email.DATA
        };
        String where = Email.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=? AND " + Email.DATA
                + "=?";
        String[] args = new String[] {
                rawContactId, Email.CONTENT_ITEM_TYPE, cmethod.data
        };
        ContentValues values = valuesEmail(cmethod);
        values.put(Email.RAW_CONTACT_ID, rawContactId);

        return updateDataRow(ctx, proj, where, args, values);
    }
项目:sms_DualCard    文件:ComposeMessageActivity.java   
private Uri getContactUriForEmail(String emailAddress) {
    Cursor cursor = SqliteWrapper.query(
            this,
            getContentResolver(),
            Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI,
                    Uri.encode(emailAddress)), new String[] {
                    Email.CONTACT_ID, Contacts.DISPLAY_NAME }, null, null,
            null);

    if (cursor != null) {
        try {
            while (cursor.moveToNext()) {
                String name = cursor.getString(1);
                if (!TextUtils.isEmpty(name)) {
                    return ContentUris.withAppendedId(Contacts.CONTENT_URI,
                            cursor.getLong(0));
                }
            }
        } finally {
            cursor.close();
        }
    }
    return null;
}
项目:Calendar_lunar    文件:BaseEmailAddressAdapter.java   
@Override
protected FilterResults performFiltering(CharSequence constraint) {
    FilterResults results = new FilterResults();
    if (!TextUtils.isEmpty(constraint)) {
        Uri uri = Email.CONTENT_FILTER_URI.buildUpon()
                .appendPath(constraint.toString())
                .appendQueryParameter(DIRECTORY_PARAM_KEY, String.valueOf(mDirectoryId))
                .appendQueryParameter(LIMIT_PARAM_KEY,
                        String.valueOf(getLimit() + ALLOWANCE_FOR_DUPLICATES))
                .build();
        Cursor cursor = mContentResolver.query(
                uri, EmailQuery.PROJECTION, null, null, null);
        results.values = cursor;
    }
    return results;
}
项目:android-aosp-mms    文件:ComposeMessageActivity.java   
private Uri getContactUriForEmail(String emailAddress) {
    Cursor cursor = SqliteWrapper.query(this, getContentResolver(),
            Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(emailAddress)),
            new String[] { Email.CONTACT_ID, Contacts.DISPLAY_NAME }, null, null, null);

    if (cursor != null) {
        try {
            while (cursor.moveToNext()) {
                String name = cursor.getString(1);
                if (!TextUtils.isEmpty(name)) {
                    return ContentUris.withAppendedId(Contacts.CONTENT_URI, cursor.getLong(0));
                }
            }
        } finally {
            cursor.close();
        }
    }
    return null;
}
项目:q-mail    文件:RecipientLoader.java   
@SuppressWarnings("ConstantConditions")
private boolean fillContactDataFromNickname(String nickname, List<Recipient> recipients,
        Map<String, Recipient> recipientMap) {

    boolean hasContact = false;

    Uri queryUri = Email.CONTENT_URI;

    Cursor nicknameCursor = getNicknameCursor(nickname);

    if (nicknameCursor == null) {
        return hasContact;
    }

    try {
        while (nicknameCursor.moveToNext()) {
            String id = nicknameCursor.getString(INDEX_CONTACT_ID_FOR_NICKNAME);
            String selection = ContactsContract.Data.CONTACT_ID + " = ?";
            Cursor cursor = contentResolver
                    .query(queryUri, PROJECTION, selection, new String[] { id }, SORT_ORDER);

            String contactNickname = nicknameCursor.getString(INDEX_NICKNAME);
            fillContactDataFromCursor(cursor, recipients, recipientMap, contactNickname);

            hasContact = true;
        }
    } finally {
        nicknameCursor.close();
    }

    return hasContact;
}
项目:SmartChart    文件:CommonUtils.java   
/**
 * 往手机通讯录插入联系人
 *
 * @param ct
 * @param name
 * @param tel
 * @param email
 */
public static void insertContact(Context ct, String name, String tel, String email) {
    ContentValues values = new ContentValues();
    // 首先向RawContacts.CONTENT_URI执行一个空值插入,目的是获取系统返回的rawContactId
    Uri rawContactUri = ct.getContentResolver().insert(RawContacts.CONTENT_URI, values);
    long rawContactId = ContentUris.parseId(rawContactUri);
    // 往data表入姓名数据
    if (!TextUtils.isEmpty(tel)) {
        values.clear();
        values.put(Data.RAW_CONTACT_ID, rawContactId);
        values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);// 内容类型
        values.put(StructuredName.GIVEN_NAME, name);
        ct.getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);
    }
    // 往data表入电话数据
    if (!TextUtils.isEmpty(tel)) {
        values.clear();
        values.put(Data.RAW_CONTACT_ID, rawContactId);
        values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);// 内容类型
        values.put(Phone.NUMBER, tel);
        values.put(Phone.TYPE, Phone.TYPE_MOBILE);
        ct.getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);
    }
    // 往data表入Email数据
    if (!TextUtils.isEmpty(email)) {
        values.clear();
        values.put(Data.RAW_CONTACT_ID, rawContactId);
        values.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);// 内容类型
        values.put(Email.DATA, email);
        values.put(Email.TYPE, Email.TYPE_WORK);
        ct.getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);
    }
}
项目:contacts-search-android    文件:ContactFetcher.java   
public void matchContactEmails(Map<String, Contact> contactsMap) {
    // Get email
    final String[] emailProjection = new String[]{
            Email.DATA,
            Email.TYPE,
            Email.CONTACT_ID,
    };

    Cursor email = new CursorLoader(context,
            Email.CONTENT_URI,
            emailProjection,
            null,
            null,
            null).loadInBackground();

    if (email.moveToFirst()) {
        final int contactEmailColumnIndex = email.getColumnIndex(Email.DATA);
        final int contactTypeColumnIndex = email.getColumnIndex(Email.TYPE);
        final int contactIdColumnsIndex = email.getColumnIndex(Email.CONTACT_ID);

        while (!email.isAfterLast()) {
            final String address = email.getString(contactEmailColumnIndex);
            final String contactId = email.getString(contactIdColumnsIndex);
            final int type = email.getInt(contactTypeColumnIndex);
            String customLabel = "Custom";
            Contact contact = contactsMap.get(contactId);
            if (contact == null) {
                continue;
            }
            CharSequence emailType = ContactsContract.CommonDataKinds.Email.getTypeLabel(context.getResources(), type, customLabel);
            contact.addEmail(address, emailType.toString());
            email.moveToNext();
        }
    }

    email.close();
}
项目:alerta-fraude    文件:ContactAccessorSdk5.java   
/**
 * Add an email to a list of database actions to be performed
 *
 * @param ops the list of database actions
 * @param email the item to be inserted
 */
private void insertEmail(ArrayList<ContentProviderOperation> ops,
        JSONObject email) {
    ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
            .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
            .withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.Email.CONTENT_ITEM_TYPE)
            .withValue(CommonDataKinds.Email.DATA, getJsonString(email, "value"))
            .withValue(CommonDataKinds.Email.TYPE, getContactType(getJsonString(email, "type")))
            .withValue(CommonDataKinds.Email.LABEL, getJsonString(email, "type"))
            .build());
}
项目:alerta-fraude    文件:ContactAccessorSdk5.java   
/**
 * Add an email to a list of database actions to be performed
 *
 * @param ops the list of database actions
 * @param email the item to be inserted
 */
private void insertEmail(ArrayList<ContentProviderOperation> ops,
        JSONObject email) {
    ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
            .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
            .withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.Email.CONTENT_ITEM_TYPE)
            .withValue(CommonDataKinds.Email.DATA, getJsonString(email, "value"))
            .withValue(CommonDataKinds.Email.TYPE, getContactType(getJsonString(email, "type")))
            .withValue(CommonDataKinds.Email.LABEL, getJsonString(email, "type"))
            .build());
}