mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
0151a54be9
--HG-- rename : mobile/android/base/AutocompleteHandler.java => mobile/android/base/toolbar/AutocompleteHandler.java rename : mobile/android/base/BackButton.java => mobile/android/base/toolbar/BackButton.java rename : mobile/android/base/BrowserToolbar.java => mobile/android/base/toolbar/BrowserToolbar.java rename : mobile/android/base/BrowserToolbarBackground.java => mobile/android/base/toolbar/BrowserToolbarBackground.java rename : mobile/android/base/CanvasDelegate.java => mobile/android/base/toolbar/CanvasDelegate.java rename : mobile/android/base/ForwardButton.java => mobile/android/base/toolbar/ForwardButton.java rename : mobile/android/base/PageActionLayout.java => mobile/android/base/toolbar/PageActionLayout.java rename : mobile/android/base/ShapedButton.java => mobile/android/base/toolbar/ShapedButton.java rename : mobile/android/base/TabCounter.java => mobile/android/base/toolbar/TabCounter.java
92 lines
3.4 KiB
Java
92 lines
3.4 KiB
Java
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.gecko.toolbar;
|
|
|
|
import org.mozilla.gecko.R;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.LinearGradient;
|
|
import android.graphics.Paint;
|
|
import android.graphics.Path;
|
|
import android.graphics.Shader;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.graphics.drawable.StateListDrawable;
|
|
import android.util.AttributeSet;
|
|
|
|
public class ForwardButton extends ShapedButton {
|
|
private Path mBorderPath;
|
|
private Paint mBorderPaint;
|
|
private Paint mBorderPrivatePaint;
|
|
|
|
public ForwardButton(Context context, AttributeSet attrs) {
|
|
super(context, attrs);
|
|
|
|
// Paint to draw the border.
|
|
mBorderPaint = new Paint();
|
|
mBorderPaint.setAntiAlias(true);
|
|
mBorderPaint.setColor(0xFF000000);
|
|
mBorderPaint.setStyle(Paint.Style.STROKE);
|
|
|
|
mBorderPrivatePaint = new Paint(mBorderPaint);
|
|
|
|
mBorderPath = new Path();
|
|
}
|
|
|
|
@Override
|
|
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
|
|
super.onSizeChanged(width, height, oldWidth, oldHeight);
|
|
|
|
float borderWidth = getContext().getResources().getDimension(R.dimen.nav_button_border_width);
|
|
mBorderPaint.setStrokeWidth(borderWidth);
|
|
mBorderPrivatePaint.setStrokeWidth(borderWidth);
|
|
|
|
mBorderPath.reset();
|
|
mBorderPath.moveTo(width - borderWidth, 0);
|
|
mBorderPath.lineTo(width - borderWidth, height);
|
|
|
|
mBorderPaint.setShader(new LinearGradient(0, 0,
|
|
0, height,
|
|
0xFFB5BBC1, 0xFFFAFBFC,
|
|
Shader.TileMode.CLAMP));
|
|
|
|
mBorderPrivatePaint.setShader(new LinearGradient(0, 0,
|
|
0, height,
|
|
0xFF040607, 0xFF0B0D0E,
|
|
Shader.TileMode.CLAMP));
|
|
}
|
|
|
|
@Override
|
|
public void draw(Canvas canvas) {
|
|
super.draw(canvas);
|
|
|
|
// Draw the border on top.
|
|
canvas.drawPath(mBorderPath, isPrivateMode() ? mBorderPrivatePaint : mBorderPaint);
|
|
}
|
|
|
|
// The drawable is constructed as per @drawable/url_bar_nav_button.
|
|
@Override
|
|
public void onLightweightThemeChanged() {
|
|
final Drawable drawable = mTheme.getDrawable(this);
|
|
if (drawable == null)
|
|
return;
|
|
|
|
final StateListDrawable stateList = new StateListDrawable();
|
|
stateList.addState(PRIVATE_PRESSED_STATE_SET, getColorDrawable(R.color.highlight_nav_pb));
|
|
stateList.addState(PRESSED_ENABLED_STATE_SET, getColorDrawable(R.color.highlight_nav));
|
|
stateList.addState(PRIVATE_FOCUSED_STATE_SET, getColorDrawable(R.color.highlight_nav_focused_pb));
|
|
stateList.addState(FOCUSED_STATE_SET, getColorDrawable(R.color.highlight_nav_focused));
|
|
stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.background_private));
|
|
stateList.addState(EMPTY_STATE_SET, drawable);
|
|
|
|
setBackgroundDrawable(stateList);
|
|
}
|
|
|
|
@Override
|
|
public void onLightweightThemeReset() {
|
|
setBackgroundResource(R.drawable.url_bar_nav_button);
|
|
}
|
|
}
|