From dad2cec69f545dc9ee305411c396eb9710cf51ee Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 18 Aug 2014 10:40:07 +0100 Subject: [PATCH] Bug 1019035 - Rounded top-left corner on the toolbar while in display mode (r=mcomella) --- .../android/base/toolbar/BrowserToolbar.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/mobile/android/base/toolbar/BrowserToolbar.java b/mobile/android/base/toolbar/BrowserToolbar.java index 04180241b72b..a9ead2defb09 100644 --- a/mobile/android/base/toolbar/BrowserToolbar.java +++ b/mobile/android/base/toolbar/BrowserToolbar.java @@ -40,8 +40,11 @@ import org.mozilla.gecko.widget.ThemedRelativeLayout; import android.content.Context; import android.content.res.Resources; +import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.graphics.drawable.StateListDrawable; +import android.graphics.Paint; +import android.graphics.Path; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; @@ -160,6 +163,9 @@ public class BrowserToolbar extends ThemedRelativeLayout private int urlBarViewOffset; private int defaultForwardMargin; + private Path roundCornerShape; + private Paint roundCornerPaint; + private static final Interpolator buttonsInterpolator = new AccelerateInterpolator(); private static final int FORWARD_ANIMATION_DURATION = 450; @@ -173,6 +179,8 @@ public class BrowserToolbar extends ThemedRelativeLayout public BrowserToolbar(Context context, AttributeSet attrs) { super(context, attrs); + setWillNotDraw(false); + theme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme(); // BrowserToolbar is attached to BrowserApp only. @@ -245,6 +253,19 @@ public class BrowserToolbar extends ThemedRelativeLayout focusOrder.addAll(Arrays.asList(tabsButton, menuButton)); } + if (!HardwareUtils.isTablet()) { + roundCornerShape = new Path(); + roundCornerShape.moveTo(0, 0); + roundCornerShape.lineTo(30, 0); + roundCornerShape.cubicTo(0, 0, 0, 0, 0, 30); + roundCornerShape.lineTo(0, 0); + + roundCornerPaint = new Paint(); + roundCornerPaint.setAntiAlias(true); + roundCornerPaint.setColor(res.getColor(R.color.background_tabs)); + roundCornerPaint.setStrokeWidth(0.0f); + } + setUIMode(UIMode.DISPLAY); // Create these listeners here, once, to avoid constructing new listeners @@ -478,6 +499,15 @@ public class BrowserToolbar extends ThemedRelativeLayout prefs.close(); } + @Override + public void draw(Canvas canvas) { + super.draw(canvas); + + if (!HardwareUtils.isTablet() && uiMode == UIMode.DISPLAY) { + canvas.drawPath(roundCornerShape, roundCornerPaint); + } + } + public void setProgressBar(ToolbarProgressView progressBar) { this.progressBar = progressBar; }