gecko/mobile/android/base/toolbar/BackButton.java

91 lines
3.1 KiB
Java
Raw Normal View History

/* 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 BackButton extends ShapedButton {
private Path mPath;
private Path mBorderPath;
private Paint mBorderPaint;
private final float mBorderWidth;
public BackButton(Context context, AttributeSet attrs) {
super(context, attrs);
mBorderWidth = getResources().getDimension(R.dimen.nav_button_border_width);
// Paint to draw the border.
mBorderPaint = new Paint();
mBorderPaint.setAntiAlias(true);
mBorderPaint.setStrokeWidth(mBorderWidth);
mBorderPaint.setStyle(Paint.Style.STROKE);
// Path is masked.
mPath = new Path();
mBorderPath = new Path();
setPrivateMode(false);
}
@Override
public void setPrivateMode(boolean isPrivate) {
super.setPrivateMode(isPrivate);
mBorderPaint.setColor(isPrivate ? 0xFF363B40 : 0xFFB5B5B5);
}
@Override
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
super.onSizeChanged(width, height, oldWidth, oldHeight);
mPath.reset();
mPath.addCircle(width/2, height/2, width/2 - mBorderWidth, Path.Direction.CW);
mBorderPath.reset();
mBorderPath.addCircle(width/2, height/2, (width/2) - mBorderWidth, Path.Direction.CW);
}
@Override
public void draw(Canvas canvas) {
mCanvasDelegate.draw(canvas, mPath, getWidth(), getHeight());
// Draw the border on top.
canvas.drawPath(mBorderPath, mBorderPaint);
}
Bug 871645 - Consolidate naming of URL bar variables and resources. r=lucasr * * * Bug 871645 - (Part 1) Rename "awesome" things "url" things in BrowserToolbar * * * Bug 871645 - (Part 2) Rename ic_awesomebar_* icon resources * * * Bug 871645 - (Part 3) Rename shouldDelayAwesomebarUpdate * * * Bug 871645 - (Part 4) Rename favicon dimensions that affect generic favicons * * * Bug 871645 - (Part 5) Rename awesome_* string entities * * * Bug 871645 - (Part 6) Rename color resources * * * Bug 871645 - (Part 7) Rename address_bar things * * * Bug 871645 - (Part 8) Rename addressBar things in BrowserToolbar * * * Bug 871645 - (Part 9) Rename AddressBar styles --HG-- rename : mobile/android/base/resources/color/awesome_bar_title.xml => mobile/android/base/resources/color/url_bar_title.xml rename : mobile/android/base/resources/color/awesome_bar_title_hint.xml => mobile/android/base/resources/color/url_bar_title_hint.xml rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_go.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_go.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_reader.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_reader.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_search.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_search.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_star.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_star.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_tab.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_tab.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_bg_shadow.png => mobile/android/base/resources/drawable-hdpi/url_bar_bg_shadow.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_default.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_default.9.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_default_pb.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_default_pb.9.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_pressed.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_pressed.9.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_pressed_pb.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_pressed_pb.9.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_go.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_go.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_reader.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_reader.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_search.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_search.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_star.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_star.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_tab.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_tab.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_bg_shadow.png => mobile/android/base/resources/drawable-mdpi/url_bar_bg_shadow.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_default.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_default.9.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_default_pb.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_default_pb.9.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_pressed.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_pressed.9.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_pressed_pb.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_pressed_pb.9.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_go.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_go.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_reader.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_reader.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_search.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_search.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_star.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_star.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_tab.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_tab.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_bg_shadow.png => mobile/android/base/resources/drawable-xhdpi/url_bar_bg_shadow.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_default.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_default.9.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_default_pb.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_default_pb.9.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_pressed.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_pressed.9.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_pressed_pb.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_pressed_pb.9.png rename : mobile/android/base/resources/drawable/address_bar_bg.xml => mobile/android/base/resources/drawable/url_bar_bg.xml rename : mobile/android/base/resources/drawable/address_bar_bg_shadow_repeat.xml => mobile/android/base/resources/drawable/url_bar_bg_shadow_repeat.xml rename : mobile/android/base/resources/drawable/address_bar_url.xml => mobile/android/base/resources/drawable/url_bar_entry.xml rename : mobile/android/base/resources/drawable/address_bar_nav_button.xml => mobile/android/base/resources/drawable/url_bar_nav_button.xml rename : mobile/android/base/resources/drawable/address_bar_right_edge.xml => mobile/android/base/resources/drawable/url_bar_right_edge.xml
2013-05-28 08:48:27 -07:00
// 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() {
Bug 871645 - Consolidate naming of URL bar variables and resources. r=lucasr * * * Bug 871645 - (Part 1) Rename "awesome" things "url" things in BrowserToolbar * * * Bug 871645 - (Part 2) Rename ic_awesomebar_* icon resources * * * Bug 871645 - (Part 3) Rename shouldDelayAwesomebarUpdate * * * Bug 871645 - (Part 4) Rename favicon dimensions that affect generic favicons * * * Bug 871645 - (Part 5) Rename awesome_* string entities * * * Bug 871645 - (Part 6) Rename color resources * * * Bug 871645 - (Part 7) Rename address_bar things * * * Bug 871645 - (Part 8) Rename addressBar things in BrowserToolbar * * * Bug 871645 - (Part 9) Rename AddressBar styles --HG-- rename : mobile/android/base/resources/color/awesome_bar_title.xml => mobile/android/base/resources/color/url_bar_title.xml rename : mobile/android/base/resources/color/awesome_bar_title_hint.xml => mobile/android/base/resources/color/url_bar_title_hint.xml rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_go.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_go.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_reader.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_reader.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_search.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_search.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_star.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_star.png rename : mobile/android/base/resources/drawable-hdpi/ic_awesomebar_tab.png => mobile/android/base/resources/drawable-hdpi/ic_url_bar_tab.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_bg_shadow.png => mobile/android/base/resources/drawable-hdpi/url_bar_bg_shadow.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_default.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_default.9.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_default_pb.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_default_pb.9.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_pressed.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_pressed.9.png rename : mobile/android/base/resources/drawable-hdpi/address_bar_url_pressed_pb.9.png => mobile/android/base/resources/drawable-hdpi/url_bar_entry_pressed_pb.9.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_go.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_go.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_reader.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_reader.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_search.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_search.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_star.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_star.png rename : mobile/android/base/resources/drawable-mdpi/ic_awesomebar_tab.png => mobile/android/base/resources/drawable-mdpi/ic_url_bar_tab.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_bg_shadow.png => mobile/android/base/resources/drawable-mdpi/url_bar_bg_shadow.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_default.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_default.9.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_default_pb.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_default_pb.9.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_pressed.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_pressed.9.png rename : mobile/android/base/resources/drawable-mdpi/address_bar_url_pressed_pb.9.png => mobile/android/base/resources/drawable-mdpi/url_bar_entry_pressed_pb.9.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_go.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_go.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_reader.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_reader.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_search.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_search.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_star.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_star.png rename : mobile/android/base/resources/drawable-xhdpi/ic_awesomebar_tab.png => mobile/android/base/resources/drawable-xhdpi/ic_url_bar_tab.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_bg_shadow.png => mobile/android/base/resources/drawable-xhdpi/url_bar_bg_shadow.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_default.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_default.9.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_default_pb.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_default_pb.9.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_pressed.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_pressed.9.png rename : mobile/android/base/resources/drawable-xhdpi/address_bar_url_pressed_pb.9.png => mobile/android/base/resources/drawable-xhdpi/url_bar_entry_pressed_pb.9.png rename : mobile/android/base/resources/drawable/address_bar_bg.xml => mobile/android/base/resources/drawable/url_bar_bg.xml rename : mobile/android/base/resources/drawable/address_bar_bg_shadow_repeat.xml => mobile/android/base/resources/drawable/url_bar_bg_shadow_repeat.xml rename : mobile/android/base/resources/drawable/address_bar_url.xml => mobile/android/base/resources/drawable/url_bar_entry.xml rename : mobile/android/base/resources/drawable/address_bar_nav_button.xml => mobile/android/base/resources/drawable/url_bar_nav_button.xml rename : mobile/android/base/resources/drawable/address_bar_right_edge.xml => mobile/android/base/resources/drawable/url_bar_right_edge.xml
2013-05-28 08:48:27 -07:00
setBackgroundResource(R.drawable.url_bar_nav_button);
}
}