Search in sources :

Example 1 with Builder

use of android.net.Uri.Builder in project DroidPlugin by DroidPluginTeam.

the class AbstractContentProviderStub method buildNewUri.

private Uri buildNewUri(Uri uri, String targetAuthority) {
    Uri.Builder b = new Builder();
    b.scheme(uri.getScheme());
    b.authority(targetAuthority);
    b.path(uri.getPath());
    if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
        Set<String> names = uri.getQueryParameterNames();
        if (names != null && names.size() > 0) {
            for (String name : names) {
                if (!TextUtils.equals(name, Env.EXTRA_TARGET_AUTHORITY)) {
                    b.appendQueryParameter(name, uri.getQueryParameter(name));
                }
            }
        }
    } else {
        b.query(uri.getQuery());
    }
    b.fragment(uri.getFragment());
    return b.build();
}
Also used : Builder(android.net.Uri.Builder) Uri(android.net.Uri) Builder(android.net.Uri.Builder)

Example 2 with Builder

use of android.net.Uri.Builder in project android_packages_apps_Dialer by LineageOS.

the class DefaultContactListAdapter method configureLoader.

@Override
public void configureLoader(CursorLoader loader, long directoryId) {
    String sortOrder = null;
    if (isSearchMode()) {
        String query = getQueryString();
        if (query == null) {
            query = "";
        }
        query = query.trim();
        if (TextUtils.isEmpty(query)) {
            // Regardless of the directory, we don't want anything returned,
            // so let's just send a "nothing" query to the local directory.
            loader.setUri(Contacts.CONTENT_URI);
            loader.setProjection(getProjection(false));
            loader.setSelection("0");
        } else {
            final Builder builder = ContactsCompat.getContentUri().buildUpon();
            appendSearchParameters(builder, query, directoryId);
            loader.setUri(builder.build());
            loader.setProjection(getProjection(true));
        }
    } else {
        final ContactListFilter filter = getFilter();
        configureUri(loader, directoryId, filter);
        loader.setProjection(getProjection(false));
        configureSelection(loader, directoryId, filter);
    }
    if (getSortOrder() == ContactsPreferences.SORT_ORDER_PRIMARY) {
        if (sortOrder == null) {
            sortOrder = Contacts.SORT_KEY_PRIMARY;
        } else {
            sortOrder += ", " + Contacts.SORT_KEY_PRIMARY;
        }
    } else {
        if (sortOrder == null) {
            sortOrder = Contacts.SORT_KEY_ALTERNATIVE;
        } else {
            sortOrder += ", " + Contacts.SORT_KEY_ALTERNATIVE;
        }
    }
    loader.setSortOrder(sortOrder);
}
Also used : Builder(android.net.Uri.Builder)

Example 3 with Builder

use of android.net.Uri.Builder in project android_packages_apps_Dialer by LineageOS.

the class ContactPhotoManager method appendBusinessContactType.

/**
 * Adds a business contact type encoded fragment to the URL. Used to ensure photo URLS from Nearby
 * Places can be identified as business photo URLs rather than URLs for personal contact photos.
 *
 * @param photoUrl The photo URL to modify.
 * @return URL with the contact type parameter added and set to TYPE_BUSINESS.
 */
public static String appendBusinessContactType(String photoUrl) {
    Uri uri = Uri.parse(photoUrl);
    Builder builder = uri.buildUpon();
    builder.encodedFragment(String.valueOf(LetterTileDrawable.TYPE_BUSINESS));
    return builder.build().toString();
}
Also used : Builder(android.net.Uri.Builder) Uri(android.net.Uri)

Example 4 with Builder

use of android.net.Uri.Builder in project android_packages_apps_Dialer by LineageOS.

the class ContactPhotoManager method removeContactType.

/**
 * Removes the contact type information stored in the photo URI encoded fragment.
 *
 * @param photoUri The photo URI to remove the contact type from.
 * @return The photo URI with contact type removed.
 */
public static Uri removeContactType(Uri photoUri) {
    String encodedFragment = photoUri.getEncodedFragment();
    if (!TextUtils.isEmpty(encodedFragment)) {
        Builder builder = photoUri.buildUpon();
        builder.encodedFragment(null);
        return builder.build();
    }
    return photoUri;
}
Also used : Builder(android.net.Uri.Builder)

Example 5 with Builder

use of android.net.Uri.Builder in project devbricks by dailystudio.

the class ProviderUriBuilder method buildResultUri.

public static Uri buildResultUri(String authority, String database, int version, String table, long rowId) {
    if (authority == null || database == null || table == null) {
        return null;
    }
    Uri baseUri = Uri.parse("content://" + authority);
    if (baseUri == null) {
        return null;
    }
    Builder builder = baseUri.buildUpon();
    if (builder == null) {
        return null;
    }
    builder.appendPath(ProviderResultUriParser.BASE_RESULT);
    builder.appendPath(database);
    builder.appendPath(String.valueOf(version));
    builder.appendPath(table);
    if (rowId > 0) {
        builder.appendPath(String.valueOf(rowId));
    }
    return builder.build();
}
Also used : Builder(android.net.Uri.Builder) 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