Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarPhone.java

Issue 2683653007: Show a Google "G" in the omnibox on the New Tab Page. (Closed)
Patch Set: comment Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarPhone.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarPhone.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarPhone.java
index 30093bb7ecf5c9a2f557ce8796223a4a12efdc66..d60cb415ad4b94464e4c5b4eb71bb20b7bd7a90d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarPhone.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarPhone.java
@@ -12,6 +12,7 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
+import android.support.v4.view.animation.FastOutLinearInInterpolator;
import android.text.Selection;
import android.util.AttributeSet;
import android.view.KeyEvent;
@@ -20,15 +21,19 @@ import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
+import android.view.animation.Interpolator;
+import android.widget.FrameLayout;
import android.widget.ImageView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.WindowDelegate;
import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper;
import org.chromium.chrome.browser.tab.Tab;
+import org.chromium.chrome.browser.util.MathUtils;
import org.chromium.chrome.browser.widget.TintedImageButton;
import org.chromium.ui.UiUtils;
@@ -41,13 +46,20 @@ public class LocationBarPhone extends LocationBarLayout {
private static final int ACTION_BUTTON_TOUCH_OVERFLOW_LEFT = 15;
+ private static final Interpolator GOOGLE_G_FADE_INTERPOLATOR =
+ new FastOutLinearInInterpolator();
+
private View mFirstVisibleFocusedView;
private View mIncognitoBadge;
+ private View mGoogleGContainer;
+ private View mGoogleG;
private View mUrlActionsContainer;
private TintedImageButton mMenuButton;
private ImageView mMenuBadge;
private View mMenuButtonWrapper;
private int mIncognitoBadgePadding;
+ private int mGoogleGWidth;
+ private int mGoogleGMargin;
private float mUrlFocusChangePercent;
private Runnable mKeyboardResizeModeTask;
private ObjectAnimator mOmniboxBackgroundAnimator;
@@ -72,6 +84,11 @@ public class LocationBarPhone extends LocationBarLayout {
mIncognitoBadgePadding =
getResources().getDimensionPixelSize(R.dimen.location_bar_incognito_badge_padding);
+ mGoogleGContainer = findViewById(R.id.google_g_container);
+ mGoogleG = findViewById(R.id.google_g);
+ mGoogleGWidth = getResources().getDimensionPixelSize(R.dimen.location_bar_google_g_width);
+ mGoogleGMargin = getResources().getDimensionPixelSize(R.dimen.location_bar_google_g_margin);
+
mUrlActionsContainer = findViewById(R.id.url_action_container);
Rect delegateArea = new Rect();
mUrlActionsContainer.getHitRect(delegateArea);
@@ -113,18 +130,6 @@ public class LocationBarPhone extends LocationBarLayout {
return mMenuButton;
}
- @Override
- public void getContentRect(Rect outRect) {
- super.getContentRect(outRect);
- if (mIncognitoBadge.getVisibility() == View.GONE) return;
-
- if (!ApiCompatibilityUtils.isLayoutRtl(this)) {
- outRect.left += mIncognitoBadge.getWidth();
- } else {
- outRect.right -= mIncognitoBadge.getWidth();
- }
- }
-
/**
* @return The first view visible when the location bar is focused.
*/
@@ -270,7 +275,35 @@ public class LocationBarPhone extends LocationBarLayout {
@Override
protected void updateButtonVisibility() {
updateDeleteButtonVisibility();
- updateMicButtonVisiblity(mUrlFocusChangePercent);
+ updateMicButtonVisibility(mUrlFocusChangePercent);
+ updateGoogleG();
+ }
+
+ private void updateGoogleG() {
+ NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab();
+
+ // If the default search engine is not Google, isLocationBarShownInNTP() will return false.
+ if (ntp == null || !ntp.isLocationBarShownInNTP()
+ || !ChromeFeatureList.isEnabled(ChromeFeatureList.NTP_SHOW_GOOGLE_G_IN_OMNIBOX)) {
+ mGoogleGContainer.setVisibility(View.GONE);
+ return;
+ }
+
+ mGoogleGContainer.setVisibility(View.VISIBLE);
+ float animationProgress =
+ GOOGLE_G_FADE_INTERPOLATOR.getInterpolation(mUrlFocusChangePercent);
+ mGoogleG.setAlpha(1 - animationProgress);
+
+ // Shrink the width down to zero, and the end margin down to half of its starting value.
+ FrameLayout.LayoutParams layoutParams =
+ (FrameLayout.LayoutParams) mGoogleG.getLayoutParams();
+ layoutParams.width = Math.round(mGoogleGWidth * (1 - animationProgress));
+ ApiCompatibilityUtils.setMarginEnd(
+ layoutParams, Math.round(MathUtils.interpolate(
+ mGoogleGMargin, mGoogleGMargin / 2f, animationProgress)));
+
+ // Just calling requestLayout() would not resolve the end margin.
+ mGoogleG.setLayoutParams(layoutParams);
}
@Override

Powered by Google App Engine
This is Rietveld 408576698