Commit 6cac8097 authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

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

This is a reland of a59a4ff3

Original change's description:
> 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: Theresa  <twellington@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#718931}

Bug: 1020774
Change-Id: I27aa92db055e39570f8ba0099d5c54bf22236194
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1946849Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarEnder <ender@google.com>
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721728}
parent 3777a417
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M18.098,19.039C19.816,17.439 20.906,15.056 20.906,12C20.906,11.445 20.855,10.85 20.728,10.281L12.005,10.281L12.005,13.867L17.022,13.867C16.77,15.131 16.084,16.095 15.103,16.719L15.103,17.184L17.548,19.039L18.098,19.039Z"
android:fillColor="#4285F4"/>
<path
android:pathData="M6.739,13.734C7.464,15.948 9.539,17.541 11.998,17.541C13.2,17.541 14.261,17.255 15.105,16.72L18.098,19.041C16.462,20.563 14.283,21.375 11.998,21.375C8.294,21.375 5.114,19.25 3.594,16.147L3.698,15.512L6.238,13.734L6.739,13.734Z"
android:fillColor="#34A853"/>
<path
android:pathData="M6.742,10.256C6.557,10.819 6.463,11.408 6.463,12C6.463,12.609 6.561,13.195 6.742,13.744L3.597,16.153C2.983,14.903 2.638,13.494 2.638,12C2.638,10.506 2.983,9.097 3.597,7.847L4.22,7.713L6.602,9.572L6.742,10.256L6.742,10.256Z"
android:fillColor="#FBBC05"/>
<path
android:pathData="M11.998,6.461C13.319,6.461 14.511,6.93 15.447,7.697L18.172,4.969C16.511,3.52 14.381,2.625 11.997,2.625C8.294,2.625 5.114,4.748 3.594,7.85L6.741,10.258C7.469,8.048 9.541,6.461 11.998,6.461Z"
android:fillColor="#EA4335"/>
</vector>
......@@ -518,7 +518,7 @@ class StatusMediator {
} else if (mIsSearchEngineGoogle) {
int icon = mDelegate.shouldShowSearchLoupeEverywhere(isIncognito)
? R.drawable.ic_search
: R.drawable.ic_logo_googleg_24dp;
: R.drawable.ic_logo_googleg_20dp;
mModel.set(StatusProperties.STATUS_ICON_RES, icon);
callback.onResult(icon);
} else {
......@@ -542,7 +542,7 @@ class StatusMediator {
@VisibleForTesting
int getSecurityIconTintForSearchEngineIcon(int icon) {
int tint;
if (icon == 0 || icon == R.drawable.ic_logo_googleg_24dp) {
if (icon == 0 || icon == R.drawable.ic_logo_googleg_20dp) {
tint = 0;
} else {
tint = mDarkTheme ? R.color.default_icon_color_secondary_list
......
......@@ -8,6 +8,8 @@ import static org.chromium.chrome.browser.toolbar.top.ToolbarPhone.URL_FOCUS_CHA
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
......@@ -21,13 +23,11 @@ import android.view.ViewStub;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.omnibox.SearchEngineLogoUtils;
......@@ -73,6 +73,7 @@ public class StatusView extends LinearLayout {
private @StringRes int mAccessibilityToast;
private Bitmap mIconBitmap;
private Bitmap mCachedGoogleG;
private TouchDelegate mTouchDelegate;
private CompositeTouchDelegate mCompositeTouchDelegate;
......@@ -317,6 +318,29 @@ public class StatusView extends LinearLayout {
// mIconRes and mIconBitmap are mutually exclusive and therefore when one is set, the other
// should be unset.
mIconBitmap = null;
// Note: To workaround for TransitionDrawable resizing mismatching layers (see
// {@link StatusView#animateStatusIcon} when passed into LayerDrawable.LayerState), a 20dp
// google g is loaded and drawn on a R.dimen.location_bar_status_icon_width sized background
if (mDelegate != null && mToolbarCommonPropertiesModel != null
&& mDelegate.shouldShowSearchEngineLogo(mToolbarCommonPropertiesModel.isIncognito())
&& mIconRes == R.drawable.ic_logo_googleg_20dp) {
if (mCachedGoogleG == null) {
int outlineSize = getResources().getDimensionPixelSize(
R.dimen.location_bar_status_icon_width);
Drawable googleGDrawable = AppCompatResources.getDrawable(
getContext(), R.drawable.ic_logo_googleg_20dp);
mCachedGoogleG = Bitmap.createBitmap(outlineSize, outlineSize, Config.ARGB_8888);
Canvas canvas = new Canvas(mCachedGoogleG);
canvas.translate((outlineSize - googleGDrawable.getIntrinsicWidth()) / 2f,
(outlineSize - googleGDrawable.getIntrinsicHeight()) / 2f);
googleGDrawable.setBounds(0, 0, googleGDrawable.getIntrinsicWidth(),
googleGDrawable.getIntrinsicHeight());
googleGDrawable.draw(canvas);
}
mIconBitmap = mCachedGoogleG;
mIconRes = 0;
}
animateStatusIcon();
}
......
......@@ -110,7 +110,7 @@ public class StatusViewRenderTest extends DummyUiActivityTestCase {
mStatusModel.set(StatusProperties.STATUS_ALPHA, 1f);
mStatusModel.set(StatusProperties.SHOW_STATUS_ICON, true);
mStatusModel.set(StatusProperties.STATUS_ICON_RES,
org.chromium.chrome.R.drawable.ic_logo_googleg_24dp);
org.chromium.chrome.R.drawable.ic_logo_googleg_20dp);
mStatusModel.set(StatusProperties.STATUS_ICON_TINT_RES, 0);
});
......
......@@ -35,6 +35,7 @@ import org.chromium.chrome.browser.toolbar.LocationBarModel;
import org.chromium.chrome.browser.ui.widget.CompositeTouchDelegate;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
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.PropertyModelChangeProcessor;
import org.chromium.ui.test.util.UiRestriction;
......@@ -131,7 +132,7 @@ public class StatusViewTest extends DummyUiActivityTestCase {
onView(withId(R.id.location_bar_incognito_badge)).check(matches(isCompletelyDisplayed()));
runOnUiThreadBlocking(() -> {
mStatusModel.set(StatusProperties.STATUS_ICON_RES, R.drawable.ic_logo_googleg_24dp);
mStatusModel.set(StatusProperties.STATUS_ICON_RES, R.drawable.ic_logo_googleg_20dp);
});
onView(withId(R.id.location_bar_status_icon))
.check((view, e) -> assertNotNull(mStatusView.getTouchDelegateForTesting()));
......@@ -141,6 +142,7 @@ public class StatusViewTest extends DummyUiActivityTestCase {
@MediumTest
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
@Feature({"Omnibox"})
@EnableFeatures("OmniboxSearchEngineLogo")
public void testSearchEngineLogo_noIncognitoPadding() {
// Set incognito badge visible.
runOnUiThreadBlocking(
......@@ -148,7 +150,7 @@ public class StatusViewTest extends DummyUiActivityTestCase {
onView(withId(R.id.location_bar_incognito_badge)).check(matches(isCompletelyDisplayed()));
runOnUiThreadBlocking(() -> {
mStatusModel.set(StatusProperties.STATUS_ICON_RES, R.drawable.ic_logo_googleg_24dp);
mStatusModel.set(StatusProperties.STATUS_ICON_RES, R.drawable.ic_logo_googleg_20dp);
});
onView(withId(R.id.location_bar_incognito_badge)).check((view, e) -> {
ViewGroup.MarginLayoutParams params =
......
......@@ -84,7 +84,7 @@ public final class StatusMediatorUnitTest {
mMediator.setShowIconsWhenUrlFocused(true);
mMediator.updateSearchEngineStatusIcon(true, true, TEST_SEARCH_URL);
Assert.assertEquals(
R.drawable.ic_logo_googleg_24dp, mModel.get(StatusProperties.STATUS_ICON_RES));
R.drawable.ic_logo_googleg_20dp, mModel.get(StatusProperties.STATUS_ICON_RES));
}
@Test
......@@ -136,7 +136,7 @@ public final class StatusMediatorUnitTest {
mMediator.setUrlFocusChangePercent(1f);
mMediator.updateSearchEngineStatusIcon(true, true, TEST_SEARCH_URL);
Assert.assertEquals(
R.drawable.ic_logo_googleg_24dp, mModel.get(StatusProperties.STATUS_ICON_RES));
R.drawable.ic_logo_googleg_20dp, mModel.get(StatusProperties.STATUS_ICON_RES));
Assert.assertTrue(mModel.get(StatusProperties.SHOW_STATUS_ICON));
}
......@@ -267,7 +267,7 @@ public final class StatusMediatorUnitTest {
Assert.assertTrue(mMediator.maybeUpdateStatusIconForSearchEngineIcon());
Assert.assertEquals(
R.drawable.ic_logo_googleg_24dp, mModel.get(StatusProperties.STATUS_ICON_RES));
R.drawable.ic_logo_googleg_20dp, mModel.get(StatusProperties.STATUS_ICON_RES));
}
@Test
......@@ -289,11 +289,11 @@ public final class StatusMediatorUnitTest {
mMediator.setUseDarkColors(false);
Assert.assertEquals(0, mMediator.getSecurityIconTintForSearchEngineIcon(0));
Assert.assertEquals(0,
mMediator.getSecurityIconTintForSearchEngineIcon(R.drawable.ic_logo_googleg_24dp));
mMediator.getSecurityIconTintForSearchEngineIcon(R.drawable.ic_logo_googleg_20dp));
mMediator.setUseDarkColors(true);
Assert.assertEquals(0, mMediator.getSecurityIconTintForSearchEngineIcon(0));
Assert.assertEquals(0,
mMediator.getSecurityIconTintForSearchEngineIcon(R.drawable.ic_logo_googleg_24dp));
mMediator.getSecurityIconTintForSearchEngineIcon(R.drawable.ic_logo_googleg_20dp));
}
@Test
......
6b1298f352e2fd819cba056417008a8ecbffeec6
\ No newline at end of file
ad7cde95affb6d160c8510d07755f81ae2be2c1d
\ No newline at end of file
88ded67364374371bad308486f1a37e9e1a31e88
\ No newline at end of file
e53ccabd6a719e511d703f960d1e9081554a5df0
\ 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