Java Code Examples for org.chromium.chrome.browser.tab.Tab#getThemeColor()

The following examples show how to use org.chromium.chrome.browser.tab.Tab#getThemeColor() . 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: LayoutManagerDocument.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = getTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = mTabCache.get(tabId);
    if (layoutTab == null) return;

    String url = tab.getUrl();
    boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);
    int themeColor = tab.getThemeColor();
    boolean canUseLiveTexture =
            tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage;
    layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(), canUseLiveTexture,
            themeColor, ColorUtils.getTextBoxColorForToolbarBackground(
                                mContext.getResources(), tab, themeColor),
            ColorUtils.getTextBoxAlphaForToolbarBackground(tab));

    mHost.requestRender();
}
 
Example 2
Source File: ColorUtils.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @return Alpha for the textbox given a Tab.
 */
public static float getTextBoxAlphaForToolbarBackground(Tab tab) {
    int color = tab.getThemeColor();
    if (tab.getNativePage() instanceof NewTabPage) {
        if (((NewTabPage) tab.getNativePage()).isLocationBarShownInNTP()) return 0f;
    }
    return shouldUseOpaqueTextboxBackground(color)
            ? 1f : LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
}
 
Example 3
Source File: LayoutManagerDocument.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = getTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = mTabCache.get(tabId);
    if (layoutTab == null) return;

    String url = tab.getUrl();
    boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);
    int themeColor = tab.getThemeColor();
    // TODO(xingliu): Remove this override themeColor for Blimp tabs. See crbug.com/644774.
    if (tab.isBlimpTab() && tab.getBlimpContents() != null) {
        themeColor = tab.getBlimpContents().getThemeColor();
    }

    boolean canUseLiveTexture = tab.isBlimpTab()
            || tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage;

    boolean needsUpdate = layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(),
            canUseLiveTexture, themeColor, ColorUtils.getTextBoxColorForToolbarBackground(
                                mContext.getResources(), tab, themeColor),
            ColorUtils.getTextBoxAlphaForToolbarBackground(tab));
    if (needsUpdate) requestUpdate();

    mHost.requestRender();
}
 
Example 4
Source File: ColorUtils.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return Alpha for the textbox given a Tab.
 */
public static float getTextBoxAlphaForToolbarBackground(Tab tab) {
    int color = tab.getThemeColor();
    if (tab.getNativePage() instanceof NewTabPage) {
        if (((NewTabPage) tab.getNativePage()).isLocationBarShownInNTP()) return 0f;
    }
    return shouldUseOpaqueTextboxBackground(color)
            ? 1f : LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
}
 
Example 5
Source File: LayoutManagerDocument.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void initLayoutTabFromHost(final int tabId) {
    if (getTabModelSelector() == null || getActiveLayout() == null) return;

    TabModelSelector selector = getTabModelSelector();
    Tab tab = selector.getTabById(tabId);
    if (tab == null) return;

    LayoutTab layoutTab = mTabCache.get(tabId);
    if (layoutTab == null) return;

    String url = tab.getUrl();
    boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX);
    int themeColor = tab.getThemeColor();

    boolean canUseLiveTexture =
            tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage;

    boolean isNtp = tab.getNativePage() instanceof NewTabPage;
    boolean needsUpdate = layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(),
            canUseLiveTexture, themeColor,
            ColorUtils.getTextBoxColorForToolbarBackground(
                    mContext.getResources(), isNtp, themeColor),
            ColorUtils.getTextBoxAlphaForToolbarBackground(tab));
    if (needsUpdate) requestUpdate();

    mHost.requestRender();
}
 
Example 6
Source File: ColorUtils.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return Alpha for the textbox given a Tab.
 */
public static float getTextBoxAlphaForToolbarBackground(Tab tab) {
    int color = tab.getThemeColor();
    if (tab.getNativePage() instanceof NewTabPage) {
        if (((NewTabPage) tab.getNativePage()).isLocationBarShownInNTP()) return 0f;
    }
    return shouldUseOpaqueTextboxBackground(color)
            ? 1f : LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
}