Java Code Examples for org.chromium.chrome.browser.util.ColorUtils#shouldUseLightForegroundOnBackground()

The following examples show how to use org.chromium.chrome.browser.util.ColorUtils#shouldUseLightForegroundOnBackground() . 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: LocationBarLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Checks the current specs and updates {@link LocationBar#mUseDarkColors} if necessary.
 * @return Whether {@link LocationBar#mUseDarkColors} has been updated.
 */
private boolean updateUseDarkColors() {
    Tab tab = getCurrentTab();
    boolean brandColorNeedsLightText = false;
    if (getToolbarDataProvider().isUsingBrandColor() && !mUrlHasFocus) {
        int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
        brandColorNeedsLightText =
                ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor);
    }

    boolean useDarkColors = tab == null || !(tab.isIncognito() || brandColorNeedsLightText);
    boolean hasChanged = useDarkColors != mUseDarkColors;
    mUseDarkColors = useDarkColors;

    return hasChanged;
}
 
Example 2
Source File: LocationBarLayout.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Checks the current specs and updates {@link LocationBar#mUseDarkColors} if necessary.
 * @return Whether {@link LocationBar#mUseDarkColors} has been updated.
 */
private boolean updateUseDarkColors() {
    Tab tab = getCurrentTab();
    boolean brandColorNeedsLightText = false;
    if (getToolbarDataProvider().isUsingBrandColor() && !mUrlHasFocus) {
        int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
        brandColorNeedsLightText =
                ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor);
    }

    boolean useDarkColors =
            (mToolbarDataProvider == null || !mToolbarDataProvider.isIncognito())
            && (tab == null || !(tab.isIncognito() || brandColorNeedsLightText));
    boolean hasChanged = useDarkColors != mUseDarkColors;
    mUseDarkColors = useDarkColors;

    return hasChanged;
}
 
Example 3
Source File: LocationBarLayout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Checks the current specs and updates {@link LocationBar#mUseDarkColors} if necessary.
 * @return Whether {@link LocationBar#mUseDarkColors} has been updated.
 */
private boolean updateUseDarkColors() {
    Tab tab = getCurrentTab();
    boolean brandColorNeedsLightText = false;
    if (getToolbarDataProvider().isUsingBrandColor() && !mUrlHasFocus) {
        int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
        brandColorNeedsLightText =
                ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor);
    }

    boolean useDarkColors = tab == null || !(tab.isIncognito() || brandColorNeedsLightText);
    boolean hasChanged = useDarkColors != mUseDarkColors;
    mUseDarkColors = useDarkColors;

    return hasChanged;
}
 
Example 4
Source File: ToolbarProgressBar.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Color the progress bar based on the toolbar theme color.
 * @param color The Android color the toolbar is using.
 */
public void setThemeColor(int color, boolean isIncognito) {
    mThemeColor = color;

    // The default toolbar has specific colors to use.
    if ((ColorUtils.isUsingDefaultToolbarColor(getResources(), color)
            || !ColorUtils.isValidThemeColor(color)) && !isIncognito) {
        setForegroundColor(ApiCompatibilityUtils.getColor(getResources(),
                R.color.progress_bar_foreground));
        setBackgroundColor(ApiCompatibilityUtils.getColor(getResources(),
                R.color.progress_bar_background));
        return;
    }

    setForegroundColor(ColorUtils.getThemedAssetColor(color, isIncognito));

    if (mAnimatingView != null
            && (ColorUtils.shouldUseLightForegroundOnBackground(color) || isIncognito)) {
        mAnimatingView.setColor(ColorUtils.getColorWithOverlay(color, Color.WHITE,
                ANIMATION_WHITE_FRACTION));
    }

    setBackgroundColor(ColorUtils.getColorWithOverlay(color, Color.WHITE,
            THEMED_BACKGROUND_WHITE_FRACTION));
}
 
Example 5
Source File: ToolbarProgressBar.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Color the progress bar based on the toolbar theme color.
 * @param color The Android color the toolbar is using.
 */
public void setThemeColor(int color, boolean isIncognito) {
    mThemeColor = color;
    boolean isDefaultTheme = ColorUtils.isUsingDefaultToolbarColor(getResources(), color);

    // All colors use a single path if using the status bar color as the background.
    if (mUseStatusBarColorAsBackground) {
        if (isDefaultTheme) color = Color.BLACK;
        setForegroundColor(
                ApiCompatibilityUtils.getColor(getResources(), R.color.white_alpha_70));
        setBackgroundColor(ColorUtils.getDarkenedColorForStatusBar(color));
        return;
    }

    // The default toolbar has specific colors to use.
    if ((isDefaultTheme || !ColorUtils.isValidThemeColor(color)) && !isIncognito) {
        setForegroundColor(ApiCompatibilityUtils.getColor(getResources(),
                R.color.progress_bar_foreground));
        setBackgroundColor(ApiCompatibilityUtils.getColor(getResources(),
                R.color.progress_bar_background));
        return;
    }

    setForegroundColor(ColorUtils.getThemedAssetColor(color, isIncognito));

    if (mAnimatingView != null
            && (ColorUtils.shouldUseLightForegroundOnBackground(color) || isIncognito)) {
        mAnimatingView.setColor(ColorUtils.getColorWithOverlay(color, Color.WHITE,
                ANIMATION_WHITE_FRACTION));
    }

    setBackgroundColor(ColorUtils.getColorWithOverlay(color, Color.WHITE,
            THEMED_BACKGROUND_WHITE_FRACTION));
}
 
Example 6
Source File: LayerTitleCache.java    From delion with Apache License 2.0 5 votes vote down vote up
private String getUpdatedTitleInternal(Tab tab, String titleString,
        boolean fetchFaviconFromHistory) {
    final int tabId = tab.getId();
    Bitmap originalFavicon = tab.getFavicon();

    boolean isDarkTheme = tab.isIncognito();
    // If theme colors are enabled in the tab switcher, the theme might require lighter text.
    if (FeatureUtilities.areTabSwitcherThemeColorsEnabled()
            && !DeviceFormFactor.isTablet(mContext)) {
        isDarkTheme |= ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor());
    }

    ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor());
    boolean isRtl = tab.isTitleDirectionRtl();
    TitleBitmapFactory titleBitmapFactory = isDarkTheme
            ? mDarkTitleBitmapFactory : mStandardTitleBitmapFactory;

    Title title = mTitles.get(tabId);
    if (title == null) {
        title = new Title();
        mTitles.put(tabId, title);
        title.register();
    }

    title.set(titleBitmapFactory.getTitleBitmap(mContext, titleString),
            titleBitmapFactory.getFaviconBitmap(mContext, originalFavicon),
            fetchFaviconFromHistory);

    if (mNativeLayerTitleCache != 0) {
        nativeUpdateLayer(mNativeLayerTitleCache, tabId, title.getTitleResId(),
                title.getFaviconResId(), isDarkTheme, isRtl);
    }
    return titleString;
}
 
Example 7
Source File: ToolbarPhone.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void setUseLightDrawablesForTextureCapture() {
    int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
    mUseLightDrawablesForTextureCapture =
            isIncognito()
            || (currentPrimaryColor != 0
                       && ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor));
}
 
Example 8
Source File: ToolbarPhone.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateTabCountVisuals(int numberOfTabs) {
    if (mHomeButton != null) mHomeButton.setEnabled(true);

    if (mToggleTabStackButton == null) return;

    mToggleTabStackButton.setEnabled(numberOfTabs >= 1);
    mToggleTabStackButton.setContentDescription(
            getResources().getQuantityString(
                    R.plurals.accessibility_toolbar_btn_tabswitcher_toggle,
                    numberOfTabs, numberOfTabs));
    mTabSwitcherButtonDrawableLight.updateForTabCount(numberOfTabs, isIncognito());
    mTabSwitcherButtonDrawable.updateForTabCount(numberOfTabs, isIncognito());

    boolean useTabStackDrawableLight = isIncognito()
            || ColorUtils.shouldUseLightForegroundOnBackground(getTabThemeColor());
    if (mTabSwitcherAnimationTabStackDrawable == null
            || mIsOverlayTabStackDrawableLight != useTabStackDrawableLight) {
        mTabSwitcherAnimationTabStackDrawable =
                TabSwitcherDrawable.createTabSwitcherDrawable(
                        getResources(), useTabStackDrawableLight);
        int[] stateSet = {android.R.attr.state_enabled};
        mTabSwitcherAnimationTabStackDrawable.setState(stateSet);
        mTabSwitcherAnimationTabStackDrawable.setBounds(
                mToggleTabStackButton.getDrawable().getBounds());
        mIsOverlayTabStackDrawableLight = useTabStackDrawableLight;
    }

    if (mTabSwitcherAnimationTabStackDrawable != null) {
        mTabSwitcherAnimationTabStackDrawable.updateForTabCount(
                numberOfTabs, isIncognito());
    }
}
 
Example 9
Source File: LayerTitleCache.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private String getUpdatedTitleInternal(Tab tab, String titleString,
        boolean fetchFaviconFromHistory) {
    final int tabId = tab.getId();
    Bitmap originalFavicon = tab.getFavicon();

    boolean isDarkTheme = tab.isIncognito();
    // The theme might require lighter text.
    if (!DeviceFormFactor.isTablet()) {
        isDarkTheme |= ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor());
    }

    ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor());
    boolean isRtl = tab.isTitleDirectionRtl();
    TitleBitmapFactory titleBitmapFactory = isDarkTheme
            ? mDarkTitleBitmapFactory : mStandardTitleBitmapFactory;

    Title title = mTitles.get(tabId);
    if (title == null) {
        title = new Title();
        mTitles.put(tabId, title);
        title.register();
    }

    title.set(titleBitmapFactory.getTitleBitmap(mContext, titleString),
            titleBitmapFactory.getFaviconBitmap(mContext, originalFavicon),
            fetchFaviconFromHistory);

    if (mNativeLayerTitleCache != 0) {
        nativeUpdateLayer(mNativeLayerTitleCache, tabId, title.getTitleResId(),
                title.getFaviconResId(), isDarkTheme, isRtl);
    }
    return titleString;
}
 
Example 10
Source File: ToolbarPhone.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void setUseLightDrawablesForTextureCapture() {
    int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
    mUseLightDrawablesForTextureCapture =
            isIncognito()
            || (currentPrimaryColor != 0
                       && ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor));
}
 
Example 11
Source File: LayerTitleCache.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private String getUpdatedTitleInternal(Tab tab, String titleString,
        boolean fetchFaviconFromHistory) {
    final int tabId = tab.getId();
    Bitmap originalFavicon = tab.getFavicon();

    boolean isDarkTheme = tab.isIncognito();
    // The theme might require lighter text.
    if (!DeviceFormFactor.isTablet(mContext)) {
        isDarkTheme |= ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor());
    }

    ColorUtils.shouldUseLightForegroundOnBackground(tab.getThemeColor());
    boolean isRtl = tab.isTitleDirectionRtl();
    TitleBitmapFactory titleBitmapFactory = isDarkTheme
            ? mDarkTitleBitmapFactory : mStandardTitleBitmapFactory;

    Title title = mTitles.get(tabId);
    if (title == null) {
        title = new Title();
        mTitles.put(tabId, title);
        title.register();
    }

    title.set(titleBitmapFactory.getTitleBitmap(mContext, titleString),
            titleBitmapFactory.getFaviconBitmap(mContext, originalFavicon),
            fetchFaviconFromHistory);

    if (mNativeLayerTitleCache != 0) {
        nativeUpdateLayer(mNativeLayerTitleCache, tabId, title.getTitleResId(),
                title.getFaviconResId(), isDarkTheme, isRtl);
    }
    return titleString;
}
 
Example 12
Source File: ToolbarProgressBar.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Color the progress bar based on the toolbar theme color.
 * @param color The Android color the toolbar is using.
 */
public void setThemeColor(int color, boolean isIncognito) {
    mThemeColor = color;

    // The default toolbar has specific colors to use.
    if (ColorUtils.isUsingDefaultToolbarColor(getResources(), color) && !isIncognito) {
        setForegroundColor(ApiCompatibilityUtils.getColor(getResources(),
                R.color.progress_bar_foreground));
        setBackgroundColor(ApiCompatibilityUtils.getColor(getResources(),
                R.color.progress_bar_background));
        return;
    }

    // All other theme colors are computed.
    if (!ColorUtils.shouldUseLightForegroundOnBackground(color) && !isIncognito) {
        // Light theme.
        setForegroundColor(ColorUtils.getColorWithOverlay(color, Color.BLACK,
                THEMED_FOREGROUND_BLACK_FRACTION));
    } else {
        // Dark theme.
        setForegroundColor(Color.WHITE);
        if (mAnimatingView != null) {
            mAnimatingView.setColor(ColorUtils.getColorWithOverlay(color, Color.WHITE,
                    ANIMATION_WHITE_FRACTION));
        }
    }

    setBackgroundColor(ColorUtils.getColorWithOverlay(color, Color.WHITE,
            THEMED_BACKGROUND_WHITE_FRACTION));
}
 
Example 13
Source File: ToolbarPhone.java    From delion with Apache License 2.0 5 votes vote down vote up
private void setUseLightDrawablesForTextureCapture() {
    int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
    mUseLightDrawablesForTextureCapture =
            isIncognito()
            || (currentPrimaryColor != 0
                       && ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor));
}
 
Example 14
Source File: LocationBarPhone.java    From delion with Apache License 2.0 5 votes vote down vote up
private boolean shouldUseLightDrawables() {
    Tab tab = getCurrentTab();
    boolean isIncognito = tab != null && tab.isIncognito();
    boolean useLightDrawables = isIncognito;
    if (getToolbarDataProvider().isUsingBrandColor()) {
        int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
        useLightDrawables |=
                ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor);
    }
    return useLightDrawables;
}
 
Example 15
Source File: ToolbarPhone.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
protected void updateTabCountVisuals(int numberOfTabs) {
    if (mHomeButton != null) mHomeButton.setEnabled(true);

    if (mToggleTabStackButton == null) return;

    mToggleTabStackButton.setEnabled(numberOfTabs >= 1);
    mToggleTabStackButton.setContentDescription(
            getResources().getQuantityString(
                    R.plurals.accessibility_toolbar_btn_tabswitcher_toggle,
                    numberOfTabs, numberOfTabs));
    mTabSwitcherButtonDrawableLight.updateForTabCount(numberOfTabs, isIncognito());
    mTabSwitcherButtonDrawable.updateForTabCount(numberOfTabs, isIncognito());

    int themeColor;
    if (getToolbarDataProvider() != null) {
        themeColor = getToolbarDataProvider().getPrimaryColor();
    } else {
        themeColor = getToolbarColorForVisualState(
                isIncognito() ? VisualState.INCOGNITO : VisualState.NORMAL);
    }

    boolean useTabStackDrawableLight = isIncognito()
            || ColorUtils.shouldUseLightForegroundOnBackground(themeColor);
    if (mTabSwitcherAnimationTabStackDrawable == null
            || mIsOverlayTabStackDrawableLight != useTabStackDrawableLight) {
        mTabSwitcherAnimationTabStackDrawable =
                TabSwitcherDrawable.createTabSwitcherDrawable(
                        getResources(), useTabStackDrawableLight);
        int[] stateSet = {android.R.attr.state_enabled};
        mTabSwitcherAnimationTabStackDrawable.setState(stateSet);
        mTabSwitcherAnimationTabStackDrawable.setBounds(
                mToggleTabStackButton.getDrawable().getBounds());
        mIsOverlayTabStackDrawableLight = useTabStackDrawableLight;
    }

    if (mTabSwitcherAnimationTabStackDrawable != null) {
        mTabSwitcherAnimationTabStackDrawable.updateForTabCount(
                numberOfTabs, isIncognito());
    }
}
 
Example 16
Source File: WebappActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
protected void initializeSplashScreenWidgets(int backgroundColor, Bitmap splashImage) {
    Bitmap displayIcon = splashImage == null ? mWebappInfo.icon() : splashImage;
    int minimiumSizeThreshold = getResources().getDimensionPixelSize(
            R.dimen.webapp_splash_image_size_minimum);
    int bigThreshold = getResources().getDimensionPixelSize(
            R.dimen.webapp_splash_image_size_threshold);

    // Inflate the correct layout for the image.
    int layoutId;
    if (displayIcon == null || displayIcon.getWidth() < minimiumSizeThreshold
            || (displayIcon == mWebappInfo.icon() && mWebappInfo.isIconGenerated())) {
        mWebappUma.recordSplashscreenIconType(WebappUma.SPLASHSCREEN_ICON_TYPE_NONE);
        layoutId = R.layout.webapp_splash_screen_no_icon;
    } else {
        // The size of the splash screen image determines which layout to use.
        boolean isUsingSmallSplashImage = displayIcon.getWidth() <= bigThreshold
                || displayIcon.getHeight() <= bigThreshold;
        if (isUsingSmallSplashImage) {
            layoutId = R.layout.webapp_splash_screen_small;
        } else {
            layoutId = R.layout.webapp_splash_screen_large;
        }

        // Record stats about the splash screen.
        int splashScreenIconType;
        if (splashImage == null) {
            splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_FALLBACK;
        } else if (isUsingSmallSplashImage) {
            splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM_SMALL;
        } else {
            splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM;
        }
        mWebappUma.recordSplashscreenIconType(splashScreenIconType);
        mWebappUma.recordSplashscreenIconSize(
                Math.round(displayIcon.getWidth()
                        / getResources().getDisplayMetrics().density));
    }

    ViewGroup subLayout = (ViewGroup) LayoutInflater.from(WebappActivity.this)
            .inflate(layoutId, mSplashScreen, true);

    // Set up the elements of the splash screen.
    TextView appNameView = (TextView) subLayout.findViewById(
            R.id.webapp_splash_screen_name);
    ImageView splashIconView = (ImageView) subLayout.findViewById(
            R.id.webapp_splash_screen_icon);
    appNameView.setText(mWebappInfo.name());
    if (splashIconView != null) splashIconView.setImageBitmap(displayIcon);

    if (ColorUtils.shouldUseLightForegroundOnBackground(backgroundColor)) {
        appNameView.setTextColor(ApiCompatibilityUtils.getColor(getResources(),
                R.color.webapp_splash_title_light));
    }
}
 
Example 17
Source File: WebappActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
protected void initializeSplashScreenWidgets(int backgroundColor, Bitmap splashImage) {
    Bitmap displayIcon = splashImage == null ? mWebappInfo.icon() : splashImage;
    int minimiumSizeThreshold = getResources().getDimensionPixelSize(
            R.dimen.webapp_splash_image_size_minimum);
    int bigThreshold = getResources().getDimensionPixelSize(
            R.dimen.webapp_splash_image_size_threshold);

    // Inflate the correct layout for the image.
    int layoutId;
    if (displayIcon == null || displayIcon.getWidth() < minimiumSizeThreshold
            || (displayIcon == mWebappInfo.icon() && mWebappInfo.isIconGenerated())) {
        mWebappUma.recordSplashscreenIconType(WebappUma.SPLASHSCREEN_ICON_TYPE_NONE);
        layoutId = R.layout.webapp_splash_screen_no_icon;
    } else {
        // The size of the splash screen image determines which layout to use.
        boolean isUsingSmallSplashImage = displayIcon.getWidth() <= bigThreshold
                || displayIcon.getHeight() <= bigThreshold;
        if (isUsingSmallSplashImage) {
            layoutId = R.layout.webapp_splash_screen_small;
        } else {
            layoutId = R.layout.webapp_splash_screen_large;
        }

        // Record stats about the splash screen.
        int splashScreenIconType;
        if (splashImage == null) {
            splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_FALLBACK;
        } else if (isUsingSmallSplashImage) {
            splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM_SMALL;
        } else {
            splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM;
        }
        mWebappUma.recordSplashscreenIconType(splashScreenIconType);
        mWebappUma.recordSplashscreenIconSize(
                Math.round(displayIcon.getWidth()
                        / getResources().getDisplayMetrics().density));
    }

    ViewGroup subLayout = (ViewGroup) LayoutInflater.from(WebappActivity.this)
            .inflate(layoutId, mSplashScreen, true);

    // Set up the elements of the splash screen.
    TextView appNameView = (TextView) subLayout.findViewById(
            R.id.webapp_splash_screen_name);
    ImageView splashIconView = (ImageView) subLayout.findViewById(
            R.id.webapp_splash_screen_icon);
    appNameView.setText(mWebappInfo.name());
    if (splashIconView != null) splashIconView.setImageBitmap(displayIcon);

    if (ColorUtils.shouldUseLightForegroundOnBackground(backgroundColor)) {
        appNameView.setTextColor(ApiCompatibilityUtils.getColor(getResources(),
                R.color.webapp_splash_title_light));
    }
}
 
Example 18
Source File: BottomToolbarPhone.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return Whether or not the toolbar is currently using a light theme color.
 */
public boolean isLightTheme() {
    return !ColorUtils.shouldUseLightForegroundOnBackground(getTabThemeColor());
}
 
Example 19
Source File: WebappActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
protected void initializeSplashScreenWidgets(int backgroundColor, Bitmap splashImage) {
    Bitmap displayIcon = splashImage == null ? mWebappInfo.icon() : splashImage;
    int minimiumSizeThreshold = getResources().getDimensionPixelSize(
            R.dimen.webapp_splash_image_size_minimum);
    int bigThreshold = getResources().getDimensionPixelSize(
            R.dimen.webapp_splash_image_size_threshold);

    // Inflate the correct layout for the image.
    int layoutId;
    if (displayIcon == null || displayIcon.getWidth() < minimiumSizeThreshold
            || (displayIcon == mWebappInfo.icon() && mWebappInfo.isIconGenerated())) {
        mWebappUma.recordSplashscreenIconType(WebappUma.SPLASHSCREEN_ICON_TYPE_NONE);
        layoutId = R.layout.webapp_splash_screen_no_icon;
    } else {
        // The size of the splash screen image determines which layout to use.
        boolean isUsingSmallSplashImage = displayIcon.getWidth() <= bigThreshold
                || displayIcon.getHeight() <= bigThreshold;
        if (isUsingSmallSplashImage) {
            layoutId = R.layout.webapp_splash_screen_small;
        } else {
            layoutId = R.layout.webapp_splash_screen_large;
        }

        // Record stats about the splash screen.
        int splashScreenIconType;
        if (splashImage == null) {
            splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_FALLBACK;
        } else if (isUsingSmallSplashImage) {
            splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM_SMALL;
        } else {
            splashScreenIconType = WebappUma.SPLASHSCREEN_ICON_TYPE_CUSTOM;
        }
        mWebappUma.recordSplashscreenIconType(splashScreenIconType);
        mWebappUma.recordSplashscreenIconSize(
                Math.round(displayIcon.getWidth()
                        / getResources().getDisplayMetrics().density));
    }

    ViewGroup subLayout = (ViewGroup) LayoutInflater.from(WebappActivity.this)
            .inflate(layoutId, mSplashScreen, true);

    // Set up the elements of the splash screen.
    TextView appNameView = (TextView) subLayout.findViewById(
            R.id.webapp_splash_screen_name);
    ImageView splashIconView = (ImageView) subLayout.findViewById(
            R.id.webapp_splash_screen_icon);
    appNameView.setText(mWebappInfo.name());
    if (splashIconView != null) splashIconView.setImageBitmap(displayIcon);

    if (ColorUtils.shouldUseLightForegroundOnBackground(backgroundColor)) {
        appNameView.setTextColor(ApiCompatibilityUtils.getColor(getResources(),
                R.color.webapp_splash_title_light));
    }
}