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 a8ccf0f355f2eebd2f65e20bda8a5c853d89dd58..afc7d6b5ad0fe5eb34a26b4c13ad75cb7705eb76 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 |
| @@ -8,7 +8,12 @@ import android.animation.ObjectAnimator; |
| import android.annotation.SuppressLint; |
| import android.content.Context; |
| import android.content.res.ColorStateList; |
| +import android.graphics.Bitmap; |
| +import android.graphics.BitmapFactory; |
| import android.graphics.Canvas; |
| +import android.graphics.Paint; |
| +import android.graphics.PorterDuff; |
| +import android.graphics.PorterDuffXfermode; |
| import android.graphics.Rect; |
| import android.text.Selection; |
| import android.text.TextUtils; |
| @@ -19,6 +24,7 @@ import android.view.TouchDelegate; |
| import android.view.View; |
| import android.view.ViewGroup; |
| import android.view.WindowManager; |
| +import android.widget.ImageView; |
| import org.chromium.base.ApiCompatibilityUtils; |
| import org.chromium.chrome.R; |
| @@ -44,6 +50,8 @@ public class LocationBarPhone extends LocationBarLayout { |
| private View mIncognitoBadge; |
| private View mUrlActionsContainer; |
| private TintedImageButton mMenuButton; |
| + private ImageView mMenuBadge; |
| + private View mMenuButtonWrapper; |
| private int mIncognitoBadgePadding; |
| private boolean mVoiceSearchEnabled; |
| private boolean mUrlFocusChangeInProgress; |
| @@ -76,10 +84,12 @@ public class LocationBarPhone extends LocationBarLayout { |
| setTouchDelegate(touchDelegate); |
| mMenuButton = (TintedImageButton) findViewById(R.id.document_menu_button); |
| + mMenuBadge = (ImageView) findViewById(R.id.document_menu_badge); |
| + mMenuButtonWrapper = findViewById(R.id.document_menu_btn_wrapper); |
| if (hasVisibleViewsAfterUrlBarWhenUnfocused()) mUrlActionsContainer.setVisibility(VISIBLE); |
| if (!showMenuButtonInOmnibox()) { |
| - ((ViewGroup) mMenuButton.getParent()).removeView(mMenuButton); |
| + ((ViewGroup) mMenuButtonWrapper.getParent()).removeView(mMenuButtonWrapper); |
| } |
| } |
| @@ -164,7 +174,7 @@ public class LocationBarPhone extends LocationBarLayout { |
| mDeleteButton.setAlpha(percent); |
| mMicButton.setAlpha(percent); |
| - if (showMenuButtonInOmnibox()) mMenuButton.setAlpha(1f - percent); |
| + if (showMenuButtonInOmnibox()) mMenuButtonWrapper.setAlpha(1f - percent); |
| updateDeleteButtonVisibility(); |
| } |
| @@ -368,4 +378,39 @@ public class LocationBarPhone extends LocationBarLayout { |
| super.setLayoutDirection(layoutDirection); |
| updateIncognitoBadgePadding(); |
| } |
| + |
| + /** |
| + * Displays the update app menu badge. |
| + */ |
| + public void showAppMenuBadge() { |
|
gone
2015/12/08 22:24:24
showAppMenuUpdateBadge?
Theresa
2015/12/10 03:53:18
Done.
|
| + mMenuBadge.setVisibility(View.VISIBLE); |
| + |
| + // Punch a hole in the app menu button to create the illusion of a 1dp transparent border |
| + // around the update badge. |
| + // Load btn_menu bitmap and use it to initialize a canvas. |
| + BitmapFactory.Options opts = new BitmapFactory.Options(); |
| + opts.inMutable = true; |
| + Bitmap menuButtonBitmap = BitmapFactory.decodeResource(getResources(), |
| + R.drawable.btn_menu, opts); |
| + Canvas canvas = new Canvas(); |
| + canvas.setBitmap(menuButtonBitmap); |
| + |
| + // Calculate the dimensions and offsets for the update badge. |
| + float menuBadgeBackgroundSize = getResources().getDimension( |
| + R.dimen.menu_badge_background_size); |
| + float radius = menuBadgeBackgroundSize / 2.f; |
| + // TODO(twellington): don't hard-code 11.5 and 19, calculate them based on something |
| + // (not sure what yet - 19 is almost 3/4 of the icon height (24dp); 11 doesn't relate to |
| + // the icon width (14dp) very well). |
| + float xPos = 11.f * getResources().getDisplayMetrics().density; |
| + float yPos = 19.f * getResources().getDisplayMetrics().density; |
| + |
| + // Draw a transparent circle on top of the bitmap, creating a hole. |
| + Paint paint = new Paint(); |
| + paint.setFlags(Paint.ANTI_ALIAS_FLAG); |
| + paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); |
| + canvas.drawCircle(xPos, yPos, radius, paint); |
| + |
| + mMenuButton.setImageBitmap(menuButtonBitmap); |
| + } |
| } |