android.provider.ContactsContract.CommonDataKinds.Im Java Examples

The following examples show how to use android.provider.ContactsContract.CommonDataKinds.Im. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContactsGetter.java    From AndroidContacts with MIT License 6 votes vote down vote up
private SparseArray<List<IMAddress>> getIMAddressesMap() {
    SparseArray<List<IMAddress>> idImAddressMap = new SparseArray<>();
    Cursor cur = getCursorFromContentType(new String[]{ID_KEY, MAIN_DATA_KEY, Im.PROTOCOL, Im.CUSTOM_PROTOCOL}, Im.CONTENT_ITEM_TYPE);
    if (cur != null) {
        while (cur.moveToNext()) {
            int id = cur.getInt(cur.getColumnIndex(ID_KEY));
            String data = cur.getString(cur.getColumnIndex(MAIN_DATA_KEY));
            int labelId = cur.getInt(cur.getColumnIndex(Im.PROTOCOL));
            String customLabel = cur.getString(cur.getColumnIndex(Im.CUSTOM_PROTOCOL));
            IMAddress current;
            if (customLabel == null)
                current = new IMAddress(mCtx, data, labelId);
            else
                current = new IMAddress(data, customLabel);
            List<IMAddress> currentWebsiteList = idImAddressMap.get(id);
            if (currentWebsiteList == null) {
                currentWebsiteList = new ArrayList<>();
                currentWebsiteList.add(current);
                idImAddressMap.put(id, currentWebsiteList);
            } else currentWebsiteList.add(current);
        }
        cur.close();
    }
    return idImAddressMap;
}
 
Example #2
Source File: ImMetadata.java    From ContactMerger with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieve the Protocol instance for a given raw database value.
 * @param id The raw database value.
 * @return The corresponding Protocol instance, or null.
 */
public static Protocol byProtocolId(int id) {
    switch(id) {
    case Im.PROTOCOL_CUSTOM: return CUSTOM;
    case Im.PROTOCOL_AIM: return AIM;
    case Im.PROTOCOL_MSN: return MSN;
    case Im.PROTOCOL_YAHOO: return YAHOO;
    case Im.PROTOCOL_SKYPE: return SKYPE;
    case Im.PROTOCOL_QQ: return QQ;
    case Im.PROTOCOL_GOOGLE_TALK: return GOOGLE_TALK;
    case Im.PROTOCOL_ICQ: return ICQ;
    case Im.PROTOCOL_JABBER: return JABBER;
    case Im.PROTOCOL_NETMEETING: return NETMEETING;
    }
    return null;
}
 
Example #3
Source File: InstantMessagingAddress.java    From react-native-paged-contacts with MIT License 5 votes vote down vote up
private String getProtocolName(String protocolId, String customProtocol) {
    if (protocolId == null) {
        throw new InvalidCursorTypeException();
    }
    switch (Integer.valueOf(protocolId)) {
        case Im.PROTOCOL_AIM:
            return "AIM";
        case Im.PROTOCOL_MSN:
            return "MSN";
        case Im.PROTOCOL_YAHOO:
            return "Yahoo";
        case Im.PROTOCOL_SKYPE:
            return "Skype";
        case Im.PROTOCOL_QQ:
            return "QQ";
        case Im.PROTOCOL_GOOGLE_TALK:
            return "Google Talk";
        case Im.PROTOCOL_ICQ:
            return "ICQ";
        case Im.PROTOCOL_JABBER:
            return "Jabber";
        case Im.PROTOCOL_NETMEETING:
            return "NetMeeting";
        case Im.PROTOCOL_CUSTOM:
            return customProtocol;
        default:
            return "Other";

    }
}
 
Example #4
Source File: ContactOperations.java    From tindroid with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a tinode im address
 *
 * @param tinode_id address we're adding
 * @return instance of ContactOperations
 */
@SuppressWarnings("unused")
ContactOperations addIm(final String tinode_id) {
    mValues.clear();
    if (!TextUtils.isEmpty(tinode_id)) {
        mValues.put(Im.DATA, tinode_id);
        mValues.put(Im.TYPE, Im.TYPE_OTHER);
        mValues.put(Im.MIMETYPE, Im.CONTENT_ITEM_TYPE);
        mValues.put(Im.PROTOCOL, Im.PROTOCOL_CUSTOM);
        mValues.put(Im.CUSTOM_PROTOCOL, Utils.TINODE_IM_PROTOCOL);
        addInsertOp();
    }
    return this;
}
 
Example #5
Source File: ImMetadata.java    From ContactMerger with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve a type instalce for a given database value, or null.
 * @param id The database value.
 * @return A corresponding Type instance, or null.
 */
private static Type byTypeId(int id) {
    switch(id) {
    case Im.TYPE_CUSTOM: return CUSTOM;
    case Im.TYPE_HOME: return HOME;
    case Im.TYPE_OTHER: return OTHER;
    case Im.TYPE_WORK: return WORK;
    }
    return null;
}
 
Example #6
Source File: InstantMessagingAddress.java    From react-native-paged-contacts with MIT License 4 votes vote down vote up
private void fillFromCursor() {
    data = getString(Im.DATA);
    final String protocolId = getString(Im.PROTOCOL);
    final String customProtocol = getString(Im.CUSTOM_PROTOCOL);
    protocol = getProtocolName(protocolId, customProtocol);
}