Commit a59a4ff3 authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

Visually scale down the size of the Google G logo in the omnibox

Bug: 1020774
Change-Id: I48b32fdfbcf4dc2a20ba047ee3f93783f4fa2a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1918047
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718931}
parent 86496e9c
...@@ -312,6 +312,7 @@ ...@@ -312,6 +312,7 @@
<dimen name="sei_location_bar_icon_end_padding_focused">16dp</dimen> <dimen name="sei_location_bar_icon_end_padding_focused">16dp</dimen>
<dimen name="sei_location_bar_verbose_start_padding_verbose_text">4dp</dimen> <dimen name="sei_location_bar_verbose_start_padding_verbose_text">4dp</dimen>
<dimen name="sei_location_bar_status_extra_padding_width">4dp</dimen> <dimen name="sei_location_bar_status_extra_padding_width">4dp</dimen>
<dimen name="sei_google_g_size">20dp</dimen>
<dimen name="tablet_toolbar_start_padding">4dp</dimen> <dimen name="tablet_toolbar_start_padding">4dp</dimen>
<dimen name="tablet_toolbar_end_padding">6dp</dimen> <dimen name="tablet_toolbar_end_padding">6dp</dimen>
......
...@@ -8,6 +8,10 @@ import static org.chromium.chrome.browser.toolbar.top.ToolbarPhone.URL_FOCUS_CHA ...@@ -8,6 +8,10 @@ import static org.chromium.chrome.browser.toolbar.top.ToolbarPhone.URL_FOCUS_CHA
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
...@@ -73,6 +77,8 @@ public class StatusView extends LinearLayout { ...@@ -73,6 +77,8 @@ public class StatusView extends LinearLayout {
private @StringRes int mAccessibilityToast; private @StringRes int mAccessibilityToast;
private Bitmap mIconBitmap; private Bitmap mIconBitmap;
private Bitmap mCachedGoogleG;
private Paint mPaint;
private TouchDelegate mTouchDelegate; private TouchDelegate mTouchDelegate;
private CompositeTouchDelegate mCompositeTouchDelegate; private CompositeTouchDelegate mCompositeTouchDelegate;
...@@ -113,6 +119,8 @@ public class StatusView extends LinearLayout { ...@@ -113,6 +119,8 @@ public class StatusView extends LinearLayout {
if (mToolbarCommonPropertiesModel != null if (mToolbarCommonPropertiesModel != null
&& mDelegate.shouldShowSearchEngineLogo( && mDelegate.shouldShowSearchEngineLogo(
mToolbarCommonPropertiesModel.isIncognito())) { mToolbarCommonPropertiesModel.isIncognito())) {
if (isSearchEngineGoogle) mPaint = new Paint();
LinearLayout.LayoutParams layoutParams = LinearLayout.LayoutParams layoutParams =
new LinearLayout.LayoutParams(mIconView.getLayoutParams()); new LinearLayout.LayoutParams(mIconView.getLayoutParams());
layoutParams.setMarginEnd(0); layoutParams.setMarginEnd(0);
...@@ -317,6 +325,36 @@ public class StatusView extends LinearLayout { ...@@ -317,6 +325,36 @@ public class StatusView extends LinearLayout {
// mIconRes and mIconBitmap are mutually exclusive and therefore when one is set, the other // mIconRes and mIconBitmap are mutually exclusive and therefore when one is set, the other
// should be unset. // should be unset.
mIconBitmap = null; mIconBitmap = null;
// Temporary workaround for M79 which makes the google g 20dp instead of 24dp.
// TODO(wylieb): Remove this code for M80 and replace it with the larger solution.
if (mDelegate != null && mToolbarCommonPropertiesModel != null
&& mDelegate.shouldShowSearchEngineLogo(mToolbarCommonPropertiesModel.isIncognito())
&& mIconRes == R.drawable.ic_logo_googleg_24dp) {
if (mCachedGoogleG == null) {
// Note: we use these constants more than once.
int outlineSize = getResources().getDimensionPixelSize(
R.dimen.location_bar_status_icon_width);
int googleGSize = getResources().getDimensionPixelSize(R.dimen.sei_google_g_size);
// Note: this bitmap will be sized to location_bar_status_icon_width in
// {@link StatusView#animateStatusIcon} when passed into LayerDrawable.LayerState.
// To avoid this, we must compose the 20dp icon inside the 24dp icon.
assert mPaint
!= null : "Paint should be initialized when the search engine is Google.";
mCachedGoogleG =
Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(),
R.drawable.ic_logo_googleg_24dp),
googleGSize, googleGSize, false);
Bitmap bitmap = Bitmap.createBitmap(outlineSize, outlineSize, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(mCachedGoogleG, (outlineSize - googleGSize) / 2f,
(outlineSize - googleGSize) / 2f, mPaint);
mCachedGoogleG = bitmap;
}
mIconBitmap = mCachedGoogleG;
mIconRes = 0;
}
animateStatusIcon(); animateStatusIcon();
} }
......
...@@ -35,6 +35,7 @@ import org.chromium.chrome.browser.toolbar.LocationBarModel; ...@@ -35,6 +35,7 @@ import org.chromium.chrome.browser.toolbar.LocationBarModel;
import org.chromium.chrome.browser.ui.widget.CompositeTouchDelegate; import org.chromium.chrome.browser.ui.widget.CompositeTouchDelegate;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ui.DummyUiActivityTestCase; import org.chromium.chrome.test.ui.DummyUiActivityTestCase;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor; import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
import org.chromium.ui.test.util.UiRestriction; import org.chromium.ui.test.util.UiRestriction;
...@@ -141,6 +142,7 @@ public class StatusViewTest extends DummyUiActivityTestCase { ...@@ -141,6 +142,7 @@ public class StatusViewTest extends DummyUiActivityTestCase {
@MediumTest @MediumTest
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) @Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
@Feature({"Omnibox"}) @Feature({"Omnibox"})
@EnableFeatures("OmniboxSearchEngineLogo")
public void testSearchEngineLogo_noIncognitoPadding() { public void testSearchEngineLogo_noIncognitoPadding() {
// Set incognito badge visible. // Set incognito badge visible.
runOnUiThreadBlocking( runOnUiThreadBlocking(
......
6b1298f352e2fd819cba056417008a8ecbffeec6 1860cf581fd842be14469fb5e7c47f276c2ee323
\ No newline at end of file \ No newline at end of file
88ded67364374371bad308486f1a37e9e1a31e88 e3bb3035a4eb4aaddac847ef90ad2693014e1e72
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment