Search in sources :

Example 11 with Builder

use of android.net.Uri.Builder in project packages_apps_Contacts by AOKP.

the class EmailAddressListAdapter method configureLoader.

@Override
public void configureLoader(CursorLoader loader, long directoryId) {
    final Builder builder;
    if (isSearchMode()) {
        builder = Email.CONTENT_FILTER_URI.buildUpon();
        String query = getQueryString();
        builder.appendPath(TextUtils.isEmpty(query) ? "" : query);
    } else {
        builder = Email.CONTENT_URI.buildUpon();
        if (isSectionHeaderDisplayEnabled()) {
            builder.appendQueryParameter(Email.EXTRA_ADDRESS_BOOK_INDEX, "true");
        }
    }
    builder.appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId));
    builder.appendQueryParameter(ContactsContract.REMOVE_DUPLICATE_ENTRIES, "true");
    loader.setUri(builder.build());
    if (getContactNameDisplayOrder() == ContactsPreferences.DISPLAY_ORDER_PRIMARY) {
        loader.setProjection(EmailQuery.PROJECTION_PRIMARY);
    } else {
        loader.setProjection(EmailQuery.PROJECTION_ALTERNATIVE);
    }
    if (getSortOrder() == ContactsPreferences.SORT_ORDER_PRIMARY) {
        loader.setSortOrder(Email.SORT_KEY_PRIMARY);
    } else {
        loader.setSortOrder(Email.SORT_KEY_ALTERNATIVE);
    }
}
Also used : Builder(android.net.Uri.Builder)

Example 12 with Builder

use of android.net.Uri.Builder in project packages_apps_Contacts by AOKP.

the class MultiPickContactActivity method getUriToQuery.

private Uri getUriToQuery() {
    Uri uri;
    switch(mMode) {
        case MODE_DEFAULT_CONTACT:
            int operation = getIntent().getIntExtra(ADD_MOVE_GROUP_MEMBER_KEY, -1);
            long groupId = getIntent().getLongExtra(KEY_GROUP_ID, -1);
            String accountName = getIntent().getStringExtra(SimContactsConstants.ACCOUNT_NAME);
            String accountType = getIntent().getStringExtra(SimContactsConstants.ACCOUNT_TYPE);
            switch(operation) {
                case ACTION_ADD_GROUP_MEMBER:
                case ACTION_MOVE_GROUP_MEMBER:
                    Builder builder = Contacts.CONTENT_GROUP_URI.buildUpon();
                    builder.appendQueryParameter(ADD_GROUP_MEMBERS, String.valueOf(operation == ACTION_ADD_GROUP_MEMBER));
                    builder.appendQueryParameter(Groups._ID, String.valueOf(groupId));
                    builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
                    builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
                    uri = builder.build();
                    break;
                default:
                    uri = Contacts.CONTENT_URI;
                    break;
            }
            break;
        case MODE_SEARCH_CONTACT:
            uri = Contacts.CONTENT_URI;
            break;
        case MODE_DEFAULT_EMAIL:
        case MODE_SEARCH_EMAIL:
            uri = Email.CONTENT_URI;
            break;
        case MODE_DEFAULT_PHONE:
        case MODE_SEARCH_PHONE:
            uri = Phone.CONTENT_URI;
            break;
        case MODE_DEFAULT_CALL:
        case MODE_SEARCH_CALL:
            uri = Calls.CONTENT_URI_WITH_VOICEMAIL;
            break;
        case MODE_DEFAULT_SIM:
        case MODE_SEARCH_SIM:
            {
                mIntent = getIntent();
                int subscription = mIntent.getIntExtra(SimContactsConstants.SLOT_KEY, SimContactsConstants.SLOT1);
                uri = querySimContacts(subscription);
                break;
            }
        default:
            throw new IllegalArgumentException("getUriToQuery: Incorrect mode: " + mMode);
    }
    return uri.buildUpon().appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true").build();
}
Also used : Builder(android.net.Uri.Builder) Uri(android.net.Uri)

Example 13 with Builder

use of android.net.Uri.Builder in project packages_apps_Contacts by AOKP.

the class MultiPickContactActivity method showGroupSelectionList.

private void showGroupSelectionList(String accountType, long srcGroupId) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.label_groups));
    ContentResolver resolver = getContentResolver();
    String selection = Groups.ACCOUNT_TYPE + " =? AND " + Groups.DELETED + " != ?";
    ArrayList<String> items = new ArrayList<String>();
    mGroupIds.clear();
    items.clear();
    Cursor cursor = resolver.query(Groups.CONTENT_URI, new String[] { Groups._ID, Groups.TITLE }, selection, new String[] { accountType, "1" }, null);
    if (cursor == null || cursor.getCount() == 0) {
        Toast.makeText(mContext, R.string.message_can_not_move_members, Toast.LENGTH_LONG).show();
        return;
    } else {
        try {
            while (cursor.moveToNext()) {
                if (!cursor.getString(0).equals(String.valueOf(srcGroupId))) {
                    mGroupIds.add(cursor.getLong(0));
                    items.add(cursor.getString(1));
                }
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
    if (mGroupIds.size() == 0) {
        Toast.makeText(mContext, R.string.message_can_not_move_members, Toast.LENGTH_LONG).show();
        return;
    }
    String[] groupItem = new String[items.size()];
    for (int i = 0; i < items.size(); i++) {
        groupItem[i] = items.get(i);
    }
    builder.setItems(groupItem, new ChooseActionListener());
    builder.create().show();
}
Also used : AlertDialog(android.app.AlertDialog) Builder(android.net.Uri.Builder) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) ContentResolver(android.content.ContentResolver)

Example 14 with Builder

use of android.net.Uri.Builder in project packages_apps_Contacts by AOKP.

the class ConfirmAddDetailActivity method startDisambiguationQuery.

/**
 * Internal method to query for contacts with a given display name.
 *
 * @param contactDisplayName the display name to look for.
 */
private void startDisambiguationQuery(String contactDisplayName) {
    // Apply a limit of 1 result to the query because we only need to
    // determine whether or not at least one other contact has the same
    // name. We don't need to find ALL other contacts with the same name.
    final Builder builder = Contacts.CONTENT_URI.buildUpon();
    builder.appendQueryParameter("limit", String.valueOf(1));
    final Uri uri = builder.build();
    final String displayNameSelection;
    final String[] selectionArgs;
    if (TextUtils.isEmpty(contactDisplayName)) {
        displayNameSelection = Contacts.DISPLAY_NAME_PRIMARY + " IS NULL";
        selectionArgs = new String[] { String.valueOf(mContactId) };
    } else {
        displayNameSelection = Contacts.DISPLAY_NAME_PRIMARY + " = ?";
        selectionArgs = new String[] { contactDisplayName, String.valueOf(mContactId) };
    }
    mQueryHandler.startQuery(TOKEN_DISAMBIGUATION_QUERY, null, uri, new String[] { Contacts._ID }, /* unused projection but a valid one was needed */
    displayNameSelection + " AND " + Contacts.PHOTO_ID + " IS NULL AND " + Contacts._ID + " <> ?", selectionArgs, null);
}
Also used : Builder(android.net.Uri.Builder) Uri(android.net.Uri)

Example 15 with Builder

use of android.net.Uri.Builder in project packages_apps_Contacts by AOKP.

the class ContactsFragment method getUriToQuery.

private Uri getUriToQuery() {
    Uri uri;
    switch(mPickMode.getMode()) {
        case ContactsPickMode.MODE_DEFAULT_CONTACT:
        case ContactsPickMode.MODE_SEARCH_CONTACT:
            mIntent = mPickMode.getIntent();
            int operation = mIntent.getIntExtra(ADD_MOVE_GROUP_MEMBER_KEY, -1);
            long groupId = mIntent.getLongExtra(KEY_GROUP_ID, -1);
            String accountName = mIntent.getStringExtra(SimContactsConstants.ACCOUNT_NAME);
            String accountType = mIntent.getStringExtra(SimContactsConstants.ACCOUNT_TYPE);
            switch(operation) {
                case ACTION_ADD_GROUP_MEMBER:
                case ACTION_MOVE_GROUP_MEMBER:
                    Builder builder = Contacts.CONTENT_GROUP_URI.buildUpon();
                    builder.appendQueryParameter(ADD_GROUP_MEMBERS, String.valueOf(operation == ACTION_ADD_GROUP_MEMBER));
                    builder.appendQueryParameter(Groups._ID, String.valueOf(groupId));
                    builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
                    builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
                    uri = builder.build();
                    break;
                default:
                    uri = Contacts.CONTENT_URI;
                    break;
            }
            break;
        case ContactsPickMode.MODE_DEFAULT_EMAIL:
        case ContactsPickMode.MODE_SEARCH_EMAIL:
            uri = Email.CONTENT_URI;
            break;
        case ContactsPickMode.MODE_DEFAULT_PHONE:
        case ContactsPickMode.MODE_SEARCH_PHONE:
            uri = Phone.CONTENT_URI;
            uri = uri.buildUpon().appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(Directory.DEFAULT)).appendQueryParameter(ContactsContract.REMOVE_DUPLICATE_ENTRIES, "true").build();
            break;
        case ContactsPickMode.MODE_DEFAULT_SIM:
        case ContactsPickMode.MODE_SEARCH_SIM:
            {
                mIntent = mPickMode.getIntent();
                subscription = mIntent.getIntExtra(SimContactsConstants.SLOT_KEY, SimContactsConstants.SLOT1);
                uri = querySimContacts(subscription);
            }
            break;
        case ContactsPickMode.MODE_DEFAULT_CONTACT_INFO:
        case ContactsPickMode.MODE_SEARCH_CONTACT_INFO:
            uri = Data.CONTENT_URI;
            break;
        case ContactsPickMode.MODE_DEFAULT_CONTACT_VCARD:
        case ContactsPickMode.MODE_SEARCH_CONTACT_VCARD:
            uri = Contacts.CONTENT_URI;
            break;
        default:
            uri = Contacts.CONTENT_URI;
    }
    return uri.buildUpon().appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true").build();
}
Also used : Builder(android.net.Uri.Builder) SpannableString(android.text.SpannableString) Uri(android.net.Uri)

Aggregations

Builder (android.net.Uri.Builder)35 Uri (android.net.Uri)27 ContentValues (android.content.ContentValues)5 Cursor (android.database.Cursor)5 Intent (android.content.Intent)2 SpannableString (android.text.SpannableString)2 ContactListFilter (com.android.contacts.common.list.ContactListFilter)2 AlertDialog (android.app.AlertDialog)1 ContentResolver (android.content.ContentResolver)1 GeneralSecurityException (java.security.GeneralSecurityException)1 ArrayList (java.util.ArrayList)1 Contact (org.awesomeapp.messenger.model.Contact)1