Java Code Examples for org.chromium.base.ApiCompatibilityUtils#setCompoundDrawablesRelativeWithIntrinsicBounds()

The following examples show how to use org.chromium.base.ApiCompatibilityUtils#setCompoundDrawablesRelativeWithIntrinsicBounds() . 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: BookmarkFolderSelectActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Sets compound drawables (icons) for different kinds of list entries,
 * i.e. New Folder, Normal and Selected.
 */
private void setUpIcons(FolderListEntry entry, TextView textView) {
    int iconId = 0;
    if (entry.mType == FolderListEntry.TYPE_NORMAL) {
        iconId = R.drawable.bookmark_folder;
    } else if (entry.mType == FolderListEntry.TYPE_NEW_FOLDER) {
        // For new folder, start_icon is different.
        iconId = R.drawable.bookmark_add_folder;
    }

    Drawable drawableStart = TintedDrawable.constructTintedDrawable(textView.getResources(),
            iconId);
    // Selected entry has an end_icon, a blue check mark.
    Drawable drawableEnd = entry.mIsSelected ? ApiCompatibilityUtils.getDrawable(
            textView.getResources(), R.drawable.bookmark_check_blue) : null;
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(textView,
            drawableStart, null, drawableEnd, null);
}
 
Example 2
Source File: RecentTabsRowAdapter.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
void configureChildView(int childPosition, ViewHolder viewHolder) {
    if (isMoreButton(childPosition)) {
        Resources resources = mActivity.getResources();
        String text = resources.getString(R.string.recent_tabs_show_more);
        viewHolder.textView.setText(text);
        Drawable drawable =  ApiCompatibilityUtils.getDrawable(
                resources, R.drawable.more_horiz);
        ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
                viewHolder.textView, drawable, null, null, null);
    } else {
        CurrentlyOpenTab openTab = getChild(childPosition);
        viewHolder.textView.setText(TextUtils.isEmpty(openTab.getTitle()) ? openTab.getUrl()
                : openTab.getTitle());
        loadLocalFavicon(viewHolder, openTab.getUrl());
    }
}
 
Example 3
Source File: BookmarkFolderSelectActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Sets compound drawables (icons) for different kinds of list entries,
 * i.e. New Folder, Normal and Selected.
 */
private void setUpIcons(FolderListEntry entry, TextView textView) {
    int iconId = 0;
    if (entry.mType == FolderListEntry.TYPE_NORMAL) {
        iconId = R.drawable.bookmark_folder;
    } else if (entry.mType == FolderListEntry.TYPE_NEW_FOLDER) {
        // For new folder, start_icon is different.
        iconId = R.drawable.bookmark_add_folder;
    }

    Drawable drawableStart = TintedDrawable.constructTintedDrawable(textView.getResources(),
            iconId);
    // Selected entry has an end_icon, a blue check mark.
    Drawable drawableEnd = entry.mIsSelected ? ApiCompatibilityUtils.getDrawable(
            textView.getResources(), R.drawable.ic_check_googblue_24dp) : null;
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(textView,
            drawableStart, null, drawableEnd, null);
}
 
Example 4
Source File: PaymentRequestHeader.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the title and origin on the header.
 *
 * @param title         The title to display on the header.
 * @param origin        The origin to display on the header.
 * @param securityLevel The security level of the page that invoked PaymentRequest.
 */
public void setTitleAndOrigin(String title, String origin, int securityLevel) {
    ((TextView) findViewById(R.id.page_title)).setText(title);

    TextView hostName = (TextView) findViewById(R.id.hostname);
    Spannable url = new SpannableStringBuilder(origin);
    OmniboxUrlEmphasizer.emphasizeUrl(url, mContext.getResources(),
            Profile.getLastUsedProfile(), securityLevel, false /* isInternalPage */,
            true /* useDarkColors */, true /* emphasizeHttpsScheme */);
    hostName.setText(url);

    if (origin.startsWith(UrlConstants.HTTPS_URL_PREFIX)) {
        // Add a lock icon.
        ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(hostName,
                TintedDrawable.constructTintedDrawable(mContext.getResources(),
                        R.drawable.omnibox_https_valid, R.color.google_green_700),
                null, null, null);

        // Remove left padding to align left compound drawable with the title. Note that the
        // left compound drawable has transparent boundary.
        hostName.setPaddingRelative(0, 0, 0, 0);
    }
}
 
Example 5
Source File: BookmarkFolderSelectActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Sets compound drawables (icons) for different kinds of list entries,
 * i.e. New Folder, Normal and Selected.
 */
private void setUpIcons(FolderListEntry entry, TextView textView) {
    int iconId = 0;
    if (entry.mType == FolderListEntry.TYPE_NORMAL) {
        iconId = R.drawable.bookmark_folder;
    } else if (entry.mType == FolderListEntry.TYPE_NEW_FOLDER) {
        // For new folder, start_icon is different.
        iconId = R.drawable.bookmark_add_folder;
    }

    Drawable drawableStart = TintedDrawable.constructTintedDrawable(textView.getResources(),
            iconId);
    // Selected entry has an end_icon, a blue check mark.
    Drawable drawableEnd = entry.mIsSelected ? ApiCompatibilityUtils.getDrawable(
            textView.getResources(), R.drawable.ic_check_googblue_24dp) : null;
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(textView,
            drawableStart, null, drawableEnd, null);
}
 
Example 6
Source File: RecentTabsRowAdapter.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
void configureChildView(int childPosition, ViewHolder viewHolder) {
    if (isMoreButton(childPosition)) {
        Resources resources = mActivity.getResources();
        String text = resources.getString(R.string.recent_tabs_show_more);
        viewHolder.textView.setText(text);
        Drawable drawable =  ApiCompatibilityUtils.getDrawable(
                resources, R.drawable.more_horiz);
        ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
                viewHolder.textView, drawable, null, null, null);
    } else {
        CurrentlyOpenTab openTab = getChild(childPosition);
        viewHolder.textView.setText(TextUtils.isEmpty(openTab.getTitle()) ? openTab.getUrl()
                : openTab.getTitle());
        loadLocalFavicon(viewHolder, openTab.getUrl());
    }
}
 
Example 7
Source File: WebappUrlBar.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void updateSecurityIcon(int securityLevel) {
    boolean isSmallDevice = !DeviceFormFactor.isTablet();
    mCurrentIconResource =
            LocationBarLayout.getSecurityIconResource(securityLevel, isSmallDevice, false);

    if (mCurrentIconResource != 0 && mIconResourceWidths.get(mCurrentIconResource, -1) == -1) {
        Drawable icon = ApiCompatibilityUtils.getDrawable(getResources(), mCurrentIconResource);
        mIconResourceWidths.put(mCurrentIconResource, icon.getIntrinsicWidth());
    }

    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mUrlBar,
            mCurrentIconResource, 0, 0, 0);
}
 
Example 8
Source File: BookmarkDrawerListItemView.java    From delion with Apache License 2.0 5 votes vote down vote up
void setIcon(int iconDrawableId) {
    if (iconDrawableId == 0) {
        setCompoundDrawablePadding(0);
    } else {
        setCompoundDrawablePadding(getResources().getDimensionPixelSize(
                R.dimen.bookmark_drawer_drawable_padding));
    }

    Drawable drawable = TintedDrawable.constructTintedDrawable(getResources(), iconDrawableId);
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
            this, drawable, null, null, null);
}
 
Example 9
Source File: RecentTabsRowAdapter.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void loadSyncedFavicon(final ViewHolder viewHolder, final String url) {
    Drawable image = mFaviconCache.getSyncedFaviconImage(url);
    if (image == null) {
        image = faviconDrawable(mRecentTabsManager.getSyncedFaviconImageForURL(url));
        image = (image == null) ? mDefaultFavicon : image;
        mFaviconCache.putSycnedFaviconImage(url, image);
    }
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(viewHolder.textView,
            image, null, null, null);
}
 
Example 10
Source File: RecentTabsRowAdapter.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void configureChildView(int childPosition, ViewHolder viewHolder) {
    if (isHistoryLink(childPosition)) {
        viewHolder.textView.setText(R.string.show_full_history);
        ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
                viewHolder.textView, R.drawable.history_favicon, 0, 0, 0);
    } else {
        RecentlyClosedTab tab = getChild(childPosition);
        String title = TitleUtil.getTitleForDisplay(tab.title, tab.url);
        viewHolder.textView.setText(title);
        loadLocalFavicon(viewHolder, tab.url);
    }
}
 
Example 11
Source File: WebappUrlBar.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void updateSecurityIcon(int securityLevel) {
    boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext());
    mCurrentIconResource =
            LocationBarLayout.getSecurityIconResource(securityLevel, isSmallDevice, false);

    if (mCurrentIconResource != 0 && mIconResourceWidths.get(mCurrentIconResource, -1) == -1) {
        Drawable icon = ApiCompatibilityUtils.getDrawable(getResources(), mCurrentIconResource);
        mIconResourceWidths.put(mCurrentIconResource, icon.getIntrinsicWidth());
    }

    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mUrlBar,
            mCurrentIconResource, 0, 0, 0);
}
 
Example 12
Source File: RecentTabsRowAdapter.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void loadSyncedFavicon(final ViewHolder viewHolder, final String url) {
    Drawable image = mFaviconCache.getSyncedFaviconImage(url);
    if (image == null) {
        image = faviconDrawable(mRecentTabsManager.getSyncedFaviconImageForURL(url));
        image = (image == null) ? mDefaultFavicon : image;
        mFaviconCache.putSycnedFaviconImage(url, image);
    }
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(viewHolder.textView,
            image, null, null, null);
}
 
Example 13
Source File: RecentTabsRowAdapter.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void configureChildView(int childPosition, ViewHolder viewHolder) {
    if (isHistoryLink(childPosition)) {
        viewHolder.textView.setText(R.string.show_full_history);
        ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
                viewHolder.textView, R.drawable.history_favicon, 0, 0, 0);
    } else {
        RecentlyClosedTab tab = getChild(childPosition);
        String title = TitleUtil.getTitleForDisplay(tab.title, tab.url);
        viewHolder.textView.setText(title);
        loadLocalFavicon(viewHolder, tab.url);
    }
}
 
Example 14
Source File: NewTabPageToolbar.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private ViewGroup initButton(int buttonId, int drawableId) {
    ViewGroup button = (ViewGroup) findViewById(buttonId);
    TextView textView = (TextView) button.getChildAt(0);

    TintedDrawable icon = TintedDrawable.constructTintedDrawable(getResources(), drawableId);
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
            textView, icon, null, null, null);

    return button;
}
 
Example 15
Source File: BookmarkDrawerListItemView.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
void setIcon(int iconDrawableId) {
    if (iconDrawableId == 0) {
        setCompoundDrawablePadding(0);
    } else {
        setCompoundDrawablePadding(getResources().getDimensionPixelSize(
                R.dimen.bookmark_drawer_drawable_padding));
    }

    Drawable drawable = TintedDrawable.constructTintedDrawable(getResources(), iconDrawableId);
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
            this, drawable, null, null, null);
}
 
Example 16
Source File: WebappUrlBar.java    From delion with Apache License 2.0 5 votes vote down vote up
private void updateSecurityIcon(int securityLevel) {
    boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext());
    mCurrentIconResource =
            LocationBarLayout.getSecurityIconResource(securityLevel, isSmallDevice);

    if (mCurrentIconResource != 0 && mIconResourceWidths.get(mCurrentIconResource, -1) == -1) {
        Drawable icon = ApiCompatibilityUtils.getDrawable(getResources(), mCurrentIconResource);
        mIconResourceWidths.put(mCurrentIconResource, icon.getIntrinsicWidth());
    }

    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mUrlBar,
            mCurrentIconResource, 0, 0, 0);
}
 
Example 17
Source File: RecentTabsRowAdapter.java    From delion with Apache License 2.0 5 votes vote down vote up
private void loadSyncedFavicon(final ViewHolder viewHolder, final String url) {
    Drawable image = mFaviconCache.getSyncedFaviconImage(url);
    if (image == null) {
        image = faviconDrawable(mRecentTabsManager.getSyncedFaviconImageForURL(url));
        image = (image == null) ? mDefaultFavicon : image;
        mFaviconCache.putSycnedFaviconImage(url, image);
    }
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(viewHolder.textView,
            image, null, null, null);
}
 
Example 18
Source File: RecentTabsRowAdapter.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void configureChildView(int childPosition, ViewHolder viewHolder) {
    if (isHistoryLink(childPosition)) {
        viewHolder.textView.setText(R.string.show_full_history);
        ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
                viewHolder.textView, R.drawable.history_favicon, 0, 0, 0);
    } else {
        RecentlyClosedTab tab = getChild(childPosition);
        String title = NewTabPageView.getTitleForDisplay(tab.title, tab.url);
        viewHolder.textView.setText(title);
        loadLocalFavicon(viewHolder, tab.url);
    }
}
 
Example 19
Source File: NewTabPageToolbar.java    From delion with Apache License 2.0 5 votes vote down vote up
private ViewGroup initButton(int buttonId, int drawableId) {
    ViewGroup button = (ViewGroup) findViewById(buttonId);
    TextView textView = (TextView) button.getChildAt(0);

    TintedDrawable icon = TintedDrawable.constructTintedDrawable(getResources(), drawableId);
    ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
            textView, icon, null, null, null);

    return button;
}