Chromium Code Reviews| 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 b18fc189647bff9ba367d4a7c13a730c42ce863d..ba12899df680616c49a4c7fdc8270d93aba1f605 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,6 +21,8 @@ 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; |
| @@ -29,6 +32,7 @@ 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 +45,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 +83,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 +129,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 +274,29 @@ public class LocationBarPhone extends LocationBarLayout { |
| @Override |
| protected void updateButtonVisibility() { |
| updateDeleteButtonVisibility(); |
| - updateMicButtonVisiblity(mUrlFocusChangePercent); |
| + updateMicButtonVisibility(mUrlFocusChangePercent); |
| + |
| + NewTabPage ntp = getToolbarDataProvider().getNewTabPageForCurrentTab(); |
|
mdjones
2017/02/11 00:32:57
Can we isolate all this new logic into a function
Bernhard Bauer
2017/02/13 17:18:01
Done.
|
| + if (ntp == null || !ntp.isLocationBarShownInNTP()) { |
| + 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 |