mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 14:15:30 +00:00
Bug 783092: LightweightTheme for BrowserApp. [r=mfinkle]
This commit is contained in:
parent
bce51456f9
commit
ec4308b4e9
@ -66,7 +66,8 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class AboutHomeContent extends ScrollView
|
||||
implements TabsAccessor.OnQueryTabsCompleteListener {
|
||||
implements TabsAccessor.OnQueryTabsCompleteListener,
|
||||
LightweightTheme.OnChangeListener {
|
||||
private static final String LOGTAG = "GeckoAboutHome";
|
||||
|
||||
private static final int NUMBER_OF_REMOTE_TABS = 5;
|
||||
@ -184,6 +185,18 @@ public class AboutHomeContent extends ScrollView
|
||||
setTopSitesConstants();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mActivity.getLightweightTheme().addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mActivity.getLightweightTheme().removeListener(this);
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
if (mAccountListener != null) {
|
||||
mAccountManager.removeOnAccountsUpdatedListener(mAccountListener);
|
||||
@ -568,6 +581,26 @@ public class AboutHomeContent extends ScrollView
|
||||
mRemoteTabs.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
final Drawable drawable = mActivity.getLightweightTheme().getDrawableWithAlpha(this, 255, 0);
|
||||
if (drawable == null)
|
||||
return;
|
||||
|
||||
setBackgroundDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
setBackgroundResource(R.drawable.abouthome_bg_repeat);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
onLightweightThemeChanged();
|
||||
}
|
||||
|
||||
public static class TopSitesGridView extends GridView {
|
||||
public TopSitesGridView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
@ -562,6 +562,8 @@ abstract public class BrowserApp extends GeckoApp
|
||||
mTabsPanel.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
|
||||
}
|
||||
|
||||
mBrowserToolbar.refreshBackground();
|
||||
|
||||
if (hasTabsSideBar())
|
||||
mBrowserToolbar.adjustTabsAnimation(true);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.LayoutInflater;
|
||||
@ -341,8 +342,11 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
|
||||
return mLayout;
|
||||
}
|
||||
|
||||
public void requestLayout() {
|
||||
mLayout.invalidate();
|
||||
public void refreshBackground() {
|
||||
mAddressBarBg.requestLayout();
|
||||
|
||||
if (mAwesomeBarRightEdge != null)
|
||||
mAwesomeBarRightEdge.requestLayout();
|
||||
}
|
||||
|
||||
public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
|
||||
@ -797,6 +801,60 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class RightEdge extends FrameLayout
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private BrowserApp mActivity;
|
||||
|
||||
public RightEdge(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mActivity = (BrowserApp) context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mActivity.getLightweightTheme().addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mActivity.getLightweightTheme().removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
Drawable drawable = mActivity.getLightweightTheme().getDrawable(this);
|
||||
if (drawable == null)
|
||||
return;
|
||||
|
||||
int[] padding = new int[] { getPaddingLeft(),
|
||||
getPaddingTop(),
|
||||
getPaddingRight(),
|
||||
getPaddingBottom()
|
||||
};
|
||||
setBackgroundDrawable(drawable);
|
||||
setPadding(padding[0], padding[1], padding[2], padding[3]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
int[] padding = new int[] { getPaddingLeft(),
|
||||
getPaddingTop(),
|
||||
getPaddingRight(),
|
||||
getPaddingBottom()
|
||||
};
|
||||
setBackgroundResource(R.drawable.address_bar_bg);
|
||||
setPadding(padding[0], padding[1], padding[2], padding[3]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
onLightweightThemeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
// MenuPopup holds the MenuPanel in Honeycomb/ICS devices with no hardware key
|
||||
public static class MenuPopup extends PopupWindow {
|
||||
private RelativeLayout mPanel;
|
||||
|
@ -5,23 +5,54 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
public class BrowserToolbarBackground extends LinearLayout
|
||||
implements CanvasDelegate.DrawManager {
|
||||
Path mPath;
|
||||
CanvasDelegate mCanvasDelegate;
|
||||
implements CanvasDelegate.DrawManager,
|
||||
LightweightTheme.OnChangeListener {
|
||||
private GeckoActivity mActivity;
|
||||
private Path mPath;
|
||||
private CurveTowards mSide;
|
||||
private CanvasDelegate mCanvasDelegate;
|
||||
|
||||
private enum CurveTowards { NONE, LEFT, RIGHT };
|
||||
|
||||
public BrowserToolbarBackground(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BrowserToolbarCurve);
|
||||
int curveTowards = a.getInt(R.styleable.BrowserToolbarCurve_curveTowards, 0x02);
|
||||
a.recycle();
|
||||
|
||||
if (curveTowards == 0x00)
|
||||
mSide = CurveTowards.NONE;
|
||||
else if (curveTowards == 0x01)
|
||||
mSide = CurveTowards.LEFT;
|
||||
else
|
||||
mSide = CurveTowards.RIGHT;
|
||||
|
||||
// Path is clipped.
|
||||
mPath = new Path();
|
||||
mCanvasDelegate = new CanvasDelegate(this, Mode.DST_OUT);
|
||||
mActivity = (GeckoActivity) context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mActivity.getLightweightTheme().addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mActivity.getLightweightTheme().removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,12 +64,22 @@ public class BrowserToolbarBackground extends LinearLayout
|
||||
float curve = height * 1.125f;
|
||||
|
||||
mPath.reset();
|
||||
mPath.moveTo(width, height);
|
||||
mPath.cubicTo((width - (curve * 0.75f)), height,
|
||||
(width - (curve * 0.25f)), 0,
|
||||
(width - curve), 0);
|
||||
mPath.lineTo(width, 0);
|
||||
mPath.lineTo(width, height);
|
||||
|
||||
if (mSide == CurveTowards.LEFT) {
|
||||
mPath.moveTo(0, height);
|
||||
mPath.cubicTo(curve * 0.75f, height,
|
||||
curve * 0.25f, 0,
|
||||
curve, 0);
|
||||
mPath.lineTo(0, 0);
|
||||
mPath.lineTo(0, height);
|
||||
} else if (mSide == CurveTowards.RIGHT) {
|
||||
mPath.moveTo(width, height);
|
||||
mPath.cubicTo((width - (curve * 0.75f)), height,
|
||||
(width - (curve * 0.25f)), 0,
|
||||
(width - curve), 0);
|
||||
mPath.lineTo(width, 0);
|
||||
mPath.lineTo(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,4 +91,36 @@ public class BrowserToolbarBackground extends LinearLayout
|
||||
public void defaultDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
Drawable drawable = mActivity.getLightweightTheme().getDrawable(this);
|
||||
if (drawable == null)
|
||||
return;
|
||||
|
||||
int[] padding = new int[] { getPaddingLeft(),
|
||||
getPaddingTop(),
|
||||
getPaddingRight(),
|
||||
getPaddingBottom()
|
||||
};
|
||||
setBackgroundDrawable(drawable);
|
||||
setPadding(padding[0], padding[1], padding[2], padding[3]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
int[] padding = new int[] { getPaddingLeft(),
|
||||
getPaddingTop(),
|
||||
getPaddingRight(),
|
||||
getPaddingBottom()
|
||||
};
|
||||
setBackgroundResource(R.drawable.address_bar_bg);
|
||||
setPadding(padding[0], padding[1], padding[2], padding[3]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
onLightweightThemeChanged();
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,8 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory {
|
||||
return new AwesomeBarTabs(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "BrowserToolbarBackground"))
|
||||
return new BrowserToolbarBackground(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "BrowserToolbar$RightEdge"))
|
||||
return new BrowserToolbar.RightEdge(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "FormAssistPopup"))
|
||||
return new FormAssistPopup(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "GeckoApp$MainLayout"))
|
||||
|
@ -5,9 +5,16 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.graphics.drawable.LevelListDrawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class MenuButton extends ShapedButton {
|
||||
@ -47,4 +54,30 @@ public class MenuButton extends ShapedButton {
|
||||
mPath.lineTo(width, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// The drawable is constructed as per @drawable/menu_button.
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
Drawable drawable = mActivity.getLightweightTheme().getDrawableWithAlpha(this, 34);
|
||||
if (drawable == null)
|
||||
return;
|
||||
|
||||
Resources resources = getContext().getResources();
|
||||
LayerDrawable layers = new LayerDrawable(new Drawable[] { new ColorDrawable(Color.BLACK), drawable });
|
||||
|
||||
StateListDrawable stateList = new StateListDrawable();
|
||||
stateList.addState(new int[] { android.R.attr.state_pressed }, resources.getDrawable(R.drawable.highlight));
|
||||
stateList.addState(new int[] {}, layers);
|
||||
|
||||
LevelListDrawable levelList = new LevelListDrawable();
|
||||
levelList.addLevel(0, 1, stateList);
|
||||
levelList.addLevel(2, 2, new ColorDrawable(Color.TRANSPARENT));
|
||||
|
||||
setBackgroundDrawable(levelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
setBackgroundResource(R.drawable.menu_button);
|
||||
}
|
||||
}
|
||||
|
@ -8,19 +8,26 @@ import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
public class ShapedButton extends ImageButton
|
||||
implements CanvasDelegate.DrawManager {
|
||||
public abstract class ShapedButton extends ImageButton
|
||||
implements CanvasDelegate.DrawManager,
|
||||
LightweightTheme.OnChangeListener {
|
||||
protected GeckoActivity mActivity;
|
||||
protected Path mPath;
|
||||
protected CurveTowards mSide;
|
||||
protected CanvasDelegate mCanvasDelegate;
|
||||
|
||||
protected enum CurveTowards { NONE, LEFT, RIGHT };
|
||||
|
||||
abstract public void onLightweightThemeChanged();
|
||||
abstract public void onLightweightThemeReset();
|
||||
|
||||
public ShapedButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mActivity = (GeckoActivity) context;
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BrowserToolbarCurve);
|
||||
int curveTowards = a.getInt(R.styleable.BrowserToolbarCurve_curveTowards, 0x02);
|
||||
@ -32,6 +39,20 @@ public class ShapedButton extends ImageButton
|
||||
mSide = CurveTowards.LEFT;
|
||||
else
|
||||
mSide = CurveTowards.RIGHT;
|
||||
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mActivity.getLightweightTheme().addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mActivity.getLightweightTheme().removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,4 +64,39 @@ public class ShapedButton extends ImageButton
|
||||
public void defaultDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundDrawable(Drawable drawable) {
|
||||
if (getBackground() == null || drawable == null) {
|
||||
super.setBackgroundDrawable(drawable);
|
||||
return;
|
||||
}
|
||||
|
||||
int[] padding = new int[] { getPaddingLeft(),
|
||||
getPaddingTop(),
|
||||
getPaddingRight(),
|
||||
getPaddingBottom()
|
||||
};
|
||||
drawable.setLevel(getBackground().getLevel());
|
||||
super.setBackgroundDrawable(drawable);
|
||||
|
||||
setPadding(padding[0], padding[1], padding[2], padding[3]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundResource(int resId) {
|
||||
if (getBackground() == null || resId == 0) {
|
||||
super.setBackgroundResource(resId);
|
||||
return;
|
||||
}
|
||||
|
||||
setBackgroundDrawable(getContext().getResources().getDrawable(resId));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
onLightweightThemeChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,17 +5,24 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.graphics.drawable.LevelListDrawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
||||
public class TabsButton extends ShapedButton {
|
||||
public class TabsButton extends ShapedButton {
|
||||
private Paint mPaint;
|
||||
|
||||
private Path mBackgroundPath;
|
||||
@ -23,6 +30,7 @@ public class TabsButton extends ShapedButton {
|
||||
private Path mRightCurve;
|
||||
|
||||
private boolean mCropped;
|
||||
private boolean mSideBar;
|
||||
|
||||
public TabsButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -31,6 +39,10 @@ public class TabsButton extends ShapedButton {
|
||||
mCropped = a.getBoolean(R.styleable.TabsButton_cropped, false);
|
||||
a.recycle();
|
||||
|
||||
a = context.obtainStyledAttributes(attrs, R.styleable.TabsPanel);
|
||||
mSideBar = a.getBoolean(R.styleable.TabsPanel_sidebar, false);
|
||||
a.recycle();
|
||||
|
||||
// Paint to draw the background.
|
||||
mPaint = new Paint();
|
||||
mPaint.setAntiAlias(true);
|
||||
@ -100,6 +112,8 @@ public class TabsButton extends ShapedButton {
|
||||
// Level 2: for phones: transparent.
|
||||
// for tablets: only one curve.
|
||||
Drawable background = getBackground();
|
||||
if (background == null)
|
||||
return;
|
||||
|
||||
if (!(background.getCurrent() instanceof ColorDrawable)) {
|
||||
if (background.getLevel() == 2) {
|
||||
@ -146,4 +160,35 @@ public class TabsButton extends ShapedButton {
|
||||
if (mCropped && background.getLevel() != 2)
|
||||
canvas.drawPath(mBackgroundPath, mPaint);
|
||||
}
|
||||
|
||||
// The drawable is constructed as per @drawable/tabs_button.
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
Drawable drawable = mActivity.getLightweightTheme().getDrawableWithAlpha(this, 34);
|
||||
if (drawable == null)
|
||||
return;
|
||||
|
||||
Resources resources = this.getContext().getResources();
|
||||
LayerDrawable layers = new LayerDrawable(new Drawable[] { resources.getDrawable(R.drawable.tabs_tray_bg_repeat), drawable });
|
||||
|
||||
StateListDrawable stateList = new StateListDrawable();
|
||||
stateList.addState(new int[] { android.R.attr.state_pressed }, resources.getDrawable(R.drawable.highlight));
|
||||
stateList.addState(new int[] {}, layers);
|
||||
|
||||
LevelListDrawable levelList = new LevelListDrawable();
|
||||
levelList.addLevel(0, 1, stateList);
|
||||
|
||||
// If there is a side bar, the expanded state will have a filled button.
|
||||
if (mSideBar)
|
||||
levelList.addLevel(2, 2, stateList);
|
||||
else
|
||||
levelList.addLevel(2, 2, new ColorDrawable(Color.TRANSPARENT));
|
||||
|
||||
setBackgroundDrawable(levelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
setBackgroundResource(R.drawable.tabs_button);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.mozilla.gecko.sync.setup.SyncAccounts;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -136,7 +137,10 @@ public class TabsPanel extends LinearLayout {
|
||||
}
|
||||
|
||||
// Tabs Panel Toolbar contains the Buttons
|
||||
public static class TabsPanelToolbar extends RelativeLayout {
|
||||
public static class TabsPanelToolbar extends RelativeLayout
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private BrowserApp mActivity;
|
||||
|
||||
public TabsPanelToolbar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
@ -151,6 +155,40 @@ public class TabsPanel extends LinearLayout {
|
||||
panelToolbarRes = R.layout.tabs_panel_toolbar;
|
||||
|
||||
LayoutInflater.from(context).inflate(panelToolbarRes, this);
|
||||
|
||||
mActivity = (BrowserApp) context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mActivity.getLightweightTheme().addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mActivity.getLightweightTheme().removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
Drawable drawable = mActivity.getLightweightTheme().getDrawableWithAlpha(this, 34);
|
||||
if (drawable == null)
|
||||
return;
|
||||
|
||||
setBackgroundDrawable(drawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
setBackgroundResource(R.drawable.tabs_tray_bg_repeat);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
onLightweightThemeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,13 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class TabsPanelButton extends ShapedButton {
|
||||
@ -47,4 +51,26 @@ public class TabsPanelButton extends ShapedButton {
|
||||
mPath.lineTo(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
// The drawable is constructed as per @drawable/tab_new_button.
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
Drawable drawable = mActivity.getLightweightTheme().getDrawableWithAlpha(this, 34);
|
||||
if (drawable == null)
|
||||
return;
|
||||
|
||||
Resources resources = getContext().getResources();
|
||||
LayerDrawable layers = new LayerDrawable(new Drawable[] { resources.getDrawable(R.drawable.tabs_tray_bg_repeat), drawable });
|
||||
|
||||
StateListDrawable stateList = new StateListDrawable();
|
||||
stateList.addState(new int[] { android.R.attr.state_pressed }, resources.getDrawable(R.drawable.highlight));
|
||||
stateList.addState(new int[] {}, layers);
|
||||
|
||||
setBackgroundDrawable(stateList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
setBackgroundResource(R.drawable.tab_new_button);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,8 @@
|
||||
android:layout_height="0dip"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/address_bar_bg"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="14dip"
|
||||
android:layout_alignParentTop="true"
|
||||
|
@ -25,7 +25,8 @@
|
||||
android:layout_height="0dip"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/address_bar_bg"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="50dip"
|
||||
android:layout_alignParentTop="true"
|
||||
|
@ -6,8 +6,7 @@
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -20,11 +20,6 @@
|
||||
android:paddingRight="10dip"
|
||||
android:enabled="false"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat"
|
||||
android:layout_marginRight="75dip"/>
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="15dip">
|
||||
|
@ -12,7 +12,8 @@
|
||||
<RelativeLayout android:id="@+id/address_bar"
|
||||
style="@style/AddressBar">
|
||||
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/address_bar_bg"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="75dip"
|
||||
android:layout_alignParentTop="true"
|
||||
|
@ -20,11 +20,6 @@
|
||||
android:paddingRight="14dip"
|
||||
android:enabled="false"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat"
|
||||
android:layout_marginRight="110dip"/>
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="28dip">
|
||||
|
@ -12,10 +12,11 @@
|
||||
<RelativeLayout android:id="@+id/address_bar"
|
||||
style="@style/AddressBar">
|
||||
|
||||
<ImageView android:id="@+id/address_bar_bg"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/address_bar_bg"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
gecko:curveTowards="left"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<org.mozilla.gecko.TabsButton android:id="@+id/tabs"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
@ -23,6 +24,7 @@
|
||||
android:layout_alignParentLeft="true"
|
||||
gecko:curveTowards="left"
|
||||
gecko:cropped="true"
|
||||
gecko:sidebar="true"
|
||||
android:background="@drawable/tabs_button"
|
||||
android:gravity="center_vertical"
|
||||
android:src="@drawable/tabs_level"
|
||||
@ -78,16 +80,16 @@
|
||||
android:focusable="false"
|
||||
android:background="@drawable/address_bar_url"/>
|
||||
|
||||
<FrameLayout android:id="@+id/awesome_bar_right_edge"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:duplicateParentState="true"
|
||||
android:background="@drawable/address_bar_bg">
|
||||
<view class="org.mozilla.gecko.BrowserToolbar$RightEdge"
|
||||
android:id="@+id/awesome_bar_right_edge"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:duplicateParentState="true">
|
||||
|
||||
<ImageView android:layout_width="50dp"
|
||||
android:layout_height="fill_parent"
|
||||
@ -98,7 +100,7 @@
|
||||
android:focusable="false"
|
||||
android:src="@drawable/address_bar_url"/>
|
||||
|
||||
</FrameLayout>
|
||||
</view>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -6,8 +6,7 @@
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<ImageButton android:id="@+id/add_tab"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
|
@ -25,7 +25,8 @@
|
||||
android:layout_height="0dip"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/address_bar_bg"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="17dip"
|
||||
android:layout_alignParentTop="true"
|
||||
|
@ -25,7 +25,8 @@
|
||||
android:layout_height="0dip"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/address_bar_bg"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="64dip"
|
||||
android:layout_alignParentTop="true"
|
||||
|
@ -8,7 +8,8 @@
|
||||
<view class="org.mozilla.gecko.TabsPanel$TabsPanelToolbar"
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/browser_toolbar_height"/>
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:background="@drawable/tabs_tray_bg_repeat"/>
|
||||
|
||||
<RelativeLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
@ -6,8 +6,7 @@
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -20,11 +20,6 @@
|
||||
android:paddingRight="12dip"
|
||||
android:enabled="false"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat"
|
||||
android:layout_marginRight="95dip"/>
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="22dip">
|
||||
|
Loading…
Reference in New Issue
Block a user