Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/document/BrandColorUtils.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/document/BrandColorUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/document/BrandColorUtils.java |
| index 1333ed4059e856a2de49b490dfa09ab0385e8dc8..2e41fe7bd10826f0dfe7c14061b08c01cc4c44f0 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/document/BrandColorUtils.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/document/BrandColorUtils.java |
| @@ -12,6 +12,7 @@ import android.graphics.Color; |
| public class BrandColorUtils { |
| private static final float CONTRAST_LIGHT_TEXT_THRESHOLD = 3f; |
| private static final float LIGHTNESS_OPAQUE_BOX_THRESHOLD = 0.82f; |
| + private static final float LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA = 0.2f; |
| /** Percentage to darken the brand color by when setting the status bar color. */ |
| private static final float DARKEN_COLOR_FRACTION = 0.6f; |
| @@ -44,6 +45,25 @@ public class BrandColorUtils { |
| } |
| /** |
| + * @return The base color for the textbox given a toolbar background color. |
| + */ |
| + public static int getTextBoxColorForToolbarBackground(int color) { |
| + boolean shouldUseOpaqueTextboxBackground = shouldUseOpaqueTextboxBackground(color); |
| + if (shouldUseOpaqueTextboxBackground) return Color.WHITE; |
| + return getColorWithOverlay(Color.WHITE, color, LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA); |
| + } |
| + |
| + private static int getColorWithOverlay(int baseColor, int overlayColor, float overlayAlpha) { |
|
David Trainor- moved to gerrit
2015/08/03 20:12:44
cache 1.f - overlayAlpha to baseAlpha IMO.
|
| + return Color.rgb( |
| + (int) (overlayAlpha * Color.red(baseColor) |
| + + (1f - overlayAlpha) * Color.red(overlayColor)), |
| + (int) (overlayAlpha * Color.green(baseColor) |
| + + (1f - overlayAlpha) * Color.green(overlayColor)), |
| + (int) (overlayAlpha * Color.blue(baseColor) |
| + + (1f - overlayAlpha) * Color.blue(overlayColor))); |
| + } |
| + |
| + /** |
| * Darkens the given color to use on the status bar. |
| * @param color Brand color of the website. |
| * @return Color that should be used for Android status bar. |