Search in sources :

Example 1 with ContactListFilter

use of com.android.contacts.common.list.ContactListFilter in project packages_apps_Contacts by AOKP.

the class MultiPickContactActivity method startQuery.

public void startQuery() {
    Uri uri = getUriToQuery();
    ContactListFilter filter = (ContactListFilter) getIntent().getParcelableExtra(AccountFilterActivity.KEY_EXTRA_CONTACT_LIST_FILTER);
    if (filter != null) {
        if (filter.filterType == ContactListFilter.FILTER_TYPE_ACCOUNT) {
            // We should exclude the invisiable contacts.
            uri = uri.buildUpon().appendQueryParameter(RawContacts.ACCOUNT_NAME, filter.accountName).appendQueryParameter(RawContacts.ACCOUNT_TYPE, filter.accountType).appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, ContactsContract.Directory.DEFAULT + "").build();
        } else if (filter.filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS) {
            // Do not query sim contacts in airplane mode.
            if (!isShowSIM()) {
                uri = uri.buildUpon().appendQueryParameter(RawContacts.ACCOUNT_TYPE, SimAccountType.ACCOUNT_TYPE).appendQueryParameter(SimContactsConstants.WITHOUT_SIM_FLAG, "true").build();
            }
        }
    }
    String[] projection = getProjectionForQuery();
    String selection = getSelectionForQuery();
    String[] selectionArgs = getSelectionArgsForQuery();
    mQueryHandler.startQuery(QUERY_TOKEN, null, uri, projection, selection, selectionArgs, getSortOrder(projection));
}
Also used : Uri(android.net.Uri) ContactListFilter(com.android.contacts.common.list.ContactListFilter)

Example 2 with ContactListFilter

use of com.android.contacts.common.list.ContactListFilter in project packages_apps_Contacts by AOKP.

the class MultiPickContactActivity method getContactsFilterUri.

/**
 * Just get the uri we need to query contacts.
 *
 * @return uri with account info parameter if explicit request contacts fit
 *         current account, else just search contacts fit specified keyword.
 */
private Uri getContactsFilterUri() {
    Uri filterUri = Contacts.CONTENT_FILTER_URI;
    // To confirm if the search rule must contain account limitation.
    Intent intent = getIntent();
    ContactListFilter filter = (ContactListFilter) intent.getParcelableExtra(AccountFilterActivity.KEY_EXTRA_CONTACT_LIST_FILTER);
    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_FILTER_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);
            return builder.build();
    }
    if (filter != null && filter.filterType == ContactListFilter.FILTER_TYPE_ACCOUNT) {
        // Need consider account info limitation, construct the uri with
        // account info query parameter.
        Builder builder = filterUri.buildUpon();
        filter.addAccountQueryParameterToUrl(builder);
        return builder.build();
    }
    if (!isShowSIM()) {
        filterUri = filterUri.buildUpon().appendQueryParameter(RawContacts.ACCOUNT_TYPE, SimAccountType.ACCOUNT_TYPE).appendQueryParameter(SimContactsConstants.WITHOUT_SIM_FLAG, "true").build();
    }
    // with "filter" path.
    return filterUri;
}
Also used : Builder(android.net.Uri.Builder) Intent(android.content.Intent) Uri(android.net.Uri) ContactListFilter(com.android.contacts.common.list.ContactListFilter)

Example 3 with ContactListFilter

use of com.android.contacts.common.list.ContactListFilter in project packages_apps_Contacts by AOKP.

the class PeopleActivity method configureFragments.

private void configureFragments(boolean fromRequest) {
    if (fromRequest) {
        ContactListFilter filter = null;
        int actionCode = mRequest.getActionCode();
        boolean searchMode = mRequest.isSearchMode();
        final int tabToOpen;
        switch(actionCode) {
            case ContactsRequest.ACTION_ALL_CONTACTS:
                filter = ContactListFilter.createFilterWithType(ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS);
                tabToOpen = TabState.ALL;
                break;
            case ContactsRequest.ACTION_CONTACTS_WITH_PHONES:
                filter = ContactListFilter.createFilterWithType(ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY);
                tabToOpen = TabState.ALL;
                break;
            case ContactsRequest.ACTION_FREQUENT:
            case ContactsRequest.ACTION_STREQUENT:
            case ContactsRequest.ACTION_STARRED:
                tabToOpen = TabState.FAVORITES;
                break;
            case ContactsRequest.ACTION_VIEW_CONTACT:
                tabToOpen = TabState.ALL;
                break;
            case ContactsRequest.ACTION_GROUP:
                tabToOpen = TabState.GROUPS;
                break;
            default:
                tabToOpen = -1;
                break;
        }
        if (tabToOpen != -1) {
            mActionBarAdapter.setCurrentTab(tabToOpen);
        }
        if (filter != null) {
            mContactListFilterController.setContactListFilter(filter, false);
            searchMode = false;
        }
        if (mRequest.getContactUri() != null) {
            searchMode = false;
        }
        mActionBarAdapter.setSearchMode(searchMode);
        configureContactListFragmentForRequest();
    }
    configureContactListFragment();
    configureGroupListFragment();
    invalidateOptionsMenuIfNeeded();
}
Also used : ContactListFilter(com.android.contacts.common.list.ContactListFilter)

Example 4 with ContactListFilter

use of com.android.contacts.common.list.ContactListFilter in project packages_apps_Contacts by AOKP.

the class ContactsFragment method getContactsFilterUri.

/**
 * Just get the uri we need to query contacts.
 *
 * @return uri with account info parameter if explicit request contacts fit current account,
 *         else just search contacts fit specified keyword.
 */
private Uri getContactsFilterUri() {
    Uri filterUri = Contacts.CONTENT_FILTER_URI;
    // To confirm if the search rule must contain account limitation.
    Intent intent = mPickMode.getIntent();
    ContactListFilter filter = (ContactListFilter) intent.getParcelableExtra(AccountFilterActivity.KEY_EXTRA_CONTACT_LIST_FILTER);
    int operation = intent.getIntExtra(ADD_MOVE_GROUP_MEMBER_KEY, -1);
    long groupId = intent.getLongExtra(KEY_GROUP_ID, -1);
    String accountName = intent.getStringExtra(SimContactsConstants.ACCOUNT_NAME);
    String accountType = intent.getStringExtra(SimContactsConstants.ACCOUNT_TYPE);
    switch(operation) {
        case ACTION_ADD_GROUP_MEMBER:
        case ACTION_MOVE_GROUP_MEMBER:
            Builder builder = Contacts.CONTENT_FILTER_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);
            return builder.build();
    }
    if (filter != null && filter.filterType == ContactListFilter.FILTER_TYPE_ACCOUNT) {
        // Need consider account info limitation, construct the uri with
        // account info query parameter.
        Builder builder = filterUri.buildUpon();
        filter.addAccountQueryParameterToUrl(builder);
        return builder.build();
    }
    if (!isShowSIM()) {
        filterUri = filterUri.buildUpon().appendQueryParameter(RawContacts.ACCOUNT_TYPE, SimAccountType.ACCOUNT_TYPE).appendQueryParameter(SimContactsConstants.WITHOUT_SIM_FLAG, "true").build();
    }
    // with "filter" path.
    return filterUri;
}
Also used : Builder(android.net.Uri.Builder) Intent(android.content.Intent) SpannableString(android.text.SpannableString) Uri(android.net.Uri) ContactListFilter(com.android.contacts.common.list.ContactListFilter)

Example 5 with ContactListFilter

use of com.android.contacts.common.list.ContactListFilter in project packages_apps_Contacts by AOKP.

the class ContactsFragment method startQuery.

public void startQuery() {
    Uri uri = getUriToQuery();
    if (uri == null)
        return;
    ContactListFilter filter = (ContactListFilter) mPickMode.getIntent().getParcelableExtra(AccountFilterActivity.KEY_EXTRA_CONTACT_LIST_FILTER);
    if (filter != null) {
        if (filter.filterType == ContactListFilter.FILTER_TYPE_ACCOUNT) {
            // We should exclude the invisiable contacts.
            uri = uri.buildUpon().appendQueryParameter(RawContacts.ACCOUNT_NAME, filter.accountName).appendQueryParameter(RawContacts.ACCOUNT_TYPE, filter.accountType).appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, ContactsContract.Directory.DEFAULT + "").build();
        } else if (filter.filterType == ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS) {
            // Do not query sim contacts in airplane mode.
            if (!isShowSIM()) {
                uri = uri.buildUpon().appendQueryParameter(RawContacts.ACCOUNT_TYPE, SimAccountType.ACCOUNT_TYPE).appendQueryParameter(SimContactsConstants.WITHOUT_SIM_FLAG, "true").build();
            }
        }
    }
    String[] projection = getProjectionForQuery();
    String selection = getSelectionForQuery();
    String[] selectionArgs = getSelectionArgsForQuery();
    mQueryHandler.startQuery(QUERY_TOKEN, null, uri, projection, selection, selectionArgs, getSortOrder(projection));
}
Also used : SpannableString(android.text.SpannableString) Uri(android.net.Uri) ContactListFilter(com.android.contacts.common.list.ContactListFilter)

Aggregations

ContactListFilter (com.android.contacts.common.list.ContactListFilter)6 Uri (android.net.Uri)4 Intent (android.content.Intent)2 Builder (android.net.Uri.Builder)2 SpannableString (android.text.SpannableString)2