Bug 1019035 - Rounded top-left corner on the toolbar while in display mode (r=mcomella)

This commit is contained in:
Lucas Rocha 2014-08-15 18:23:18 +01:00
Родитель 0ff90b5957
Коммит 6bb8f975a1
1 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -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;
}