mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 932967: Cleanup LWT to not use Activity, but use Application. [r=mfinkle]
--HG-- extra : rebase_source : aceef27c2fd841965f614f4c0157cdcbccf152e7
This commit is contained in:
parent
cc780d71aa
commit
abb2cad8d6
@ -5,14 +5,11 @@
|
|||||||
package org.mozilla.gecko;
|
package org.mozilla.gecko;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.LinearGradient;
|
import android.graphics.LinearGradient;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.graphics.PorterDuff.Mode;
|
|
||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.StateListDrawable;
|
import android.graphics.drawable.StateListDrawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@ -37,7 +34,6 @@ public class BackButton extends ShapedButton {
|
|||||||
// Path is masked.
|
// Path is masked.
|
||||||
mPath = new Path();
|
mPath = new Path();
|
||||||
mBorderPath = new Path();
|
mBorderPath = new Path();
|
||||||
mCanvasDelegate = new CanvasDelegate(this, Mode.DST_IN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -76,19 +72,17 @@ public class BackButton extends ShapedButton {
|
|||||||
// The drawable is constructed as per @drawable/url_bar_nav_button.
|
// The drawable is constructed as per @drawable/url_bar_nav_button.
|
||||||
@Override
|
@Override
|
||||||
public void onLightweightThemeChanged() {
|
public void onLightweightThemeChanged() {
|
||||||
Drawable drawable = mActivity.getLightweightTheme().getDrawable(this);
|
final Drawable drawable = mTheme.getDrawable(this);
|
||||||
if (drawable == null)
|
if (drawable == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Resources resources = getContext().getResources();
|
final StateListDrawable stateList = new StateListDrawable();
|
||||||
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(new int[] { R.attr.state_private, android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_nav_pb)));
|
stateList.addState(PRIVATE_FOCUSED_STATE_SET, getColorDrawable(R.color.highlight_nav_focused_pb));
|
||||||
stateList.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_nav)));
|
stateList.addState(FOCUSED_STATE_SET, getColorDrawable(R.color.highlight_nav_focused));
|
||||||
stateList.addState(new int[] { R.attr.state_private, android.R.attr.state_focused }, new ColorDrawable(resources.getColor(R.color.highlight_nav_focused_pb)));
|
stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.background_private));
|
||||||
stateList.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(resources.getColor(R.color.highlight_nav_focused)));
|
stateList.addState(EMPTY_STATE_SET, drawable);
|
||||||
stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_private)));
|
|
||||||
stateList.addState(new int[] {}, drawable);
|
|
||||||
|
|
||||||
setBackgroundDrawable(stateList);
|
setBackgroundDrawable(stateList);
|
||||||
}
|
}
|
||||||
|
@ -7,32 +7,27 @@ package org.mozilla.gecko;
|
|||||||
import org.mozilla.gecko.widget.GeckoLinearLayout;
|
import org.mozilla.gecko.widget.GeckoLinearLayout;
|
||||||
|
|
||||||
import android.content.Context;
|
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.ColorDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.StateListDrawable;
|
import android.graphics.drawable.StateListDrawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
public class BrowserToolbarBackground extends GeckoLinearLayout {
|
public class BrowserToolbarBackground extends GeckoLinearLayout {
|
||||||
private GeckoActivity mActivity;
|
private final LightweightTheme mTheme;
|
||||||
|
|
||||||
public BrowserToolbarBackground(Context context, AttributeSet attrs) {
|
public BrowserToolbarBackground(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mActivity = (GeckoActivity) context;
|
mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLightweightThemeChanged() {
|
public void onLightweightThemeChanged() {
|
||||||
Drawable drawable = mActivity.getLightweightTheme().getDrawable(this);
|
final Drawable drawable = mTheme.getDrawable(this);
|
||||||
if (drawable == null)
|
if (drawable == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StateListDrawable stateList = new StateListDrawable();
|
final StateListDrawable stateList = new StateListDrawable();
|
||||||
stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(mActivity.getResources().getColor(R.color.background_private)));
|
stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.background_private));
|
||||||
stateList.addState(new int[] {}, drawable);
|
stateList.addState(EMPTY_STATE_SET, drawable);
|
||||||
|
|
||||||
setBackgroundDrawable(stateList);
|
setBackgroundDrawable(stateList);
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,11 @@
|
|||||||
package org.mozilla.gecko;
|
package org.mozilla.gecko;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.LinearGradient;
|
import android.graphics.LinearGradient;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.StateListDrawable;
|
import android.graphics.drawable.StateListDrawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@ -69,20 +67,18 @@ public class ForwardButton extends ShapedButton {
|
|||||||
// The drawable is constructed as per @drawable/url_bar_nav_button.
|
// The drawable is constructed as per @drawable/url_bar_nav_button.
|
||||||
@Override
|
@Override
|
||||||
public void onLightweightThemeChanged() {
|
public void onLightweightThemeChanged() {
|
||||||
Drawable drawable = mActivity.getLightweightTheme().getDrawable(this);
|
final Drawable drawable = mTheme.getDrawable(this);
|
||||||
if (drawable == null)
|
if (drawable == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Resources resources = getContext().getResources();
|
final StateListDrawable stateList = new StateListDrawable();
|
||||||
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(new int[] { R.attr.state_private, android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_nav_pb)));
|
stateList.addState(PRIVATE_FOCUSED_STATE_SET, getColorDrawable(R.color.highlight_nav_focused_pb));
|
||||||
stateList.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_nav)));
|
stateList.addState(FOCUSED_STATE_SET, getColorDrawable(R.color.highlight_nav_focused));
|
||||||
stateList.addState(new int[] { R.attr.state_private, android.R.attr.state_focused }, new ColorDrawable(resources.getColor(R.color.highlight_nav_focused_pb)));
|
stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.background_private));
|
||||||
stateList.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(resources.getColor(R.color.highlight_nav_focused)));
|
stateList.addState(EMPTY_STATE_SET, drawable);
|
||||||
stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_private)));
|
|
||||||
stateList.addState(new int[] {}, drawable);
|
|
||||||
|
|
||||||
setBackgroundDrawable(stateList);
|
setBackgroundDrawable(stateList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +93,4 @@ public class GeckoActivity extends FragmentActivity implements GeckoActivityStat
|
|||||||
MemoryMonitor.getInstance().onTrimMemory(level);
|
MemoryMonitor.getInstance().onTrimMemory(level);
|
||||||
super.onTrimMemory(level);
|
super.onTrimMemory(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LightweightTheme getLightweightTheme() {
|
|
||||||
return ((GeckoApplication) getApplication()).getLightweightTheme();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,30 +7,28 @@ package org.mozilla.gecko;
|
|||||||
import org.mozilla.gecko.widget.GeckoImageButton;
|
import org.mozilla.gecko.widget.GeckoImageButton;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.graphics.PorterDuff.Mode;
|
import android.graphics.PorterDuff.Mode;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.StateListDrawable;
|
import android.graphics.drawable.StateListDrawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
public class ShapedButton extends GeckoImageButton
|
public class ShapedButton extends GeckoImageButton
|
||||||
implements CanvasDelegate.DrawManager {
|
implements CanvasDelegate.DrawManager {
|
||||||
protected GeckoActivity mActivity;
|
protected final LightweightTheme mTheme;
|
||||||
|
|
||||||
private Path mPath;
|
private final Path mPath;
|
||||||
private CurveTowards mSide;
|
private final CurveTowards mSide;
|
||||||
|
|
||||||
protected CanvasDelegate mCanvasDelegate;
|
protected final CanvasDelegate mCanvasDelegate;
|
||||||
|
|
||||||
private enum CurveTowards { NONE, LEFT, RIGHT };
|
private enum CurveTowards { NONE, LEFT, RIGHT };
|
||||||
|
|
||||||
public ShapedButton(Context context, AttributeSet attrs) {
|
public ShapedButton(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mActivity = (GeckoActivity) context;
|
mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();
|
||||||
|
|
||||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BrowserToolbarCurve);
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BrowserToolbarCurve);
|
||||||
int curveTowards = a.getInt(R.styleable.BrowserToolbarCurve_curveTowards, 0x00);
|
int curveTowards = a.getInt(R.styleable.BrowserToolbarCurve_curveTowards, 0x00);
|
||||||
@ -57,9 +55,9 @@ public class ShapedButton extends GeckoImageButton
|
|||||||
if (mSide == CurveTowards.NONE)
|
if (mSide == CurveTowards.NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int width = getMeasuredWidth();
|
final int width = getMeasuredWidth();
|
||||||
int height = getMeasuredHeight();
|
final int height = getMeasuredHeight();
|
||||||
int curve = (int) (height * 1.125f);
|
final int curve = (int) (height * 1.125f);
|
||||||
|
|
||||||
mPath.reset();
|
mPath.reset();
|
||||||
|
|
||||||
@ -97,20 +95,19 @@ public class ShapedButton extends GeckoImageButton
|
|||||||
// The drawable is constructed as per @drawable/shaped_button.
|
// The drawable is constructed as per @drawable/shaped_button.
|
||||||
@Override
|
@Override
|
||||||
public void onLightweightThemeChanged() {
|
public void onLightweightThemeChanged() {
|
||||||
int background = mActivity.getResources().getColor(R.color.background_tabs);
|
final int background = getResources().getColor(R.color.background_tabs);
|
||||||
LightweightThemeDrawable lightWeight = mActivity.getLightweightTheme().getColorDrawable(this, background);
|
final LightweightThemeDrawable lightWeight = mTheme.getColorDrawable(this, background);
|
||||||
|
|
||||||
if (lightWeight == null)
|
if (lightWeight == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lightWeight.setAlpha(34, 34);
|
lightWeight.setAlpha(34, 34);
|
||||||
|
|
||||||
Resources resources = this.getContext().getResources();
|
final StateListDrawable stateList = new StateListDrawable();
|
||||||
StateListDrawable stateList = new StateListDrawable();
|
stateList.addState(PRESSED_ENABLED_STATE_SET, getColorDrawable(R.color.highlight_shaped));
|
||||||
stateList.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(resources.getColor(R.color.highlight_shaped)));
|
stateList.addState(FOCUSED_STATE_SET, getColorDrawable(R.color.highlight_shaped_focused));
|
||||||
stateList.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(resources.getColor(R.color.highlight_shaped_focused)));
|
stateList.addState(PRIVATE_STATE_SET, getColorDrawable(R.color.background_tabs));
|
||||||
stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(resources.getColor(R.color.background_tabs)));
|
stateList.addState(EMPTY_STATE_SET, lightWeight);
|
||||||
stateList.addState(new int[] {}, lightWeight);
|
|
||||||
|
|
||||||
setBackgroundDrawable(stateList);
|
setBackgroundDrawable(stateList);
|
||||||
}
|
}
|
||||||
@ -140,11 +137,6 @@ public class ShapedButton extends GeckoImageButton
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBackgroundResource(int resId) {
|
public void setBackgroundResource(int resId) {
|
||||||
if (getBackground() == null || resId == 0) {
|
setBackgroundDrawable(getResources().getDrawable(resId));
|
||||||
super.setBackgroundResource(resId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setBackgroundDrawable(getContext().getResources().getDrawable(resId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,8 @@ public class TabsPanel extends LinearLayout
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private GeckoApp mActivity;
|
private final GeckoApp mActivity;
|
||||||
|
private final LightweightTheme mTheme;
|
||||||
private RelativeLayout mHeader;
|
private RelativeLayout mHeader;
|
||||||
private TabsListContainer mTabsContainer;
|
private TabsListContainer mTabsContainer;
|
||||||
private PanelView mPanel;
|
private PanelView mPanel;
|
||||||
@ -68,6 +69,7 @@ public class TabsPanel extends LinearLayout
|
|||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mActivity = (GeckoApp) context;
|
mActivity = (GeckoApp) context;
|
||||||
|
mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();
|
||||||
|
|
||||||
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
|
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
|
||||||
LinearLayout.LayoutParams.FILL_PARENT));
|
LinearLayout.LayoutParams.FILL_PARENT));
|
||||||
@ -161,19 +163,19 @@ public class TabsPanel extends LinearLayout
|
|||||||
@Override
|
@Override
|
||||||
public void onAttachedToWindow() {
|
public void onAttachedToWindow() {
|
||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
mActivity.getLightweightTheme().addListener(this);
|
mTheme.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDetachedFromWindow() {
|
public void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
mActivity.getLightweightTheme().removeListener(this);
|
mTheme.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLightweightThemeChanged() {
|
public void onLightweightThemeChanged() {
|
||||||
int background = mActivity.getResources().getColor(R.color.background_tabs);
|
final int background = getResources().getColor(R.color.background_tabs);
|
||||||
LightweightThemeDrawable drawable = mActivity.getLightweightTheme().getColorDrawable(this, background, true);
|
final LightweightThemeDrawable drawable = mTheme.getColorDrawable(this, background, true);
|
||||||
if (drawable == null)
|
if (drawable == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -194,11 +196,8 @@ public class TabsPanel extends LinearLayout
|
|||||||
|
|
||||||
// Tabs List Container holds the ListView
|
// Tabs List Container holds the ListView
|
||||||
public static class TabsListContainer extends FrameLayout {
|
public static class TabsListContainer extends FrameLayout {
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
public TabsListContainer(Context context, AttributeSet attrs) {
|
public TabsListContainer(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mContext = context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PanelView getCurrentPanelView() {
|
public PanelView getCurrentPanelView() {
|
||||||
@ -229,11 +228,11 @@ public class TabsPanel extends LinearLayout
|
|||||||
// Tabs Panel Toolbar contains the Buttons
|
// Tabs Panel Toolbar contains the Buttons
|
||||||
public static class TabsPanelToolbar extends LinearLayout
|
public static class TabsPanelToolbar extends LinearLayout
|
||||||
implements LightweightTheme.OnChangeListener {
|
implements LightweightTheme.OnChangeListener {
|
||||||
private BrowserApp mActivity;
|
private final LightweightTheme mTheme;
|
||||||
|
|
||||||
public TabsPanelToolbar(Context context, AttributeSet attrs) {
|
public TabsPanelToolbar(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mActivity = (BrowserApp) context;
|
mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();
|
||||||
|
|
||||||
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
|
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
|
||||||
(int) context.getResources().getDimension(R.dimen.browser_toolbar_height)));
|
(int) context.getResources().getDimension(R.dimen.browser_toolbar_height)));
|
||||||
@ -244,19 +243,19 @@ public class TabsPanel extends LinearLayout
|
|||||||
@Override
|
@Override
|
||||||
public void onAttachedToWindow() {
|
public void onAttachedToWindow() {
|
||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
mActivity.getLightweightTheme().addListener(this);
|
mTheme.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDetachedFromWindow() {
|
public void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
mActivity.getLightweightTheme().removeListener(this);
|
mTheme.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLightweightThemeChanged() {
|
public void onLightweightThemeChanged() {
|
||||||
int background = mActivity.getResources().getColor(R.color.background_tabs);
|
final int background = getResources().getColor(R.color.background_tabs);
|
||||||
LightweightThemeDrawable drawable = mActivity.getLightweightTheme().getColorDrawable(this, background);
|
final LightweightThemeDrawable drawable = mTheme.getColorDrawable(this, background);
|
||||||
if (drawable == null)
|
if (drawable == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -4,22 +4,28 @@
|
|||||||
|
|
||||||
package org.mozilla.gecko.widget;
|
package org.mozilla.gecko.widget;
|
||||||
|
|
||||||
import org.mozilla.gecko.GeckoActivity;
|
import org.mozilla.gecko.GeckoApplication;
|
||||||
import org.mozilla.gecko.LightweightTheme;
|
import org.mozilla.gecko.LightweightTheme;
|
||||||
import org.mozilla.gecko.R;
|
import org.mozilla.gecko.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.@VIEWTYPE@;
|
import android.widget.@VIEWTYPE@;
|
||||||
|
|
||||||
public class Gecko@VIEWTYPE@ extends @VIEWTYPE@
|
public class Gecko@VIEWTYPE@ extends @VIEWTYPE@
|
||||||
implements LightweightTheme.OnChangeListener {
|
implements LightweightTheme.OnChangeListener {
|
||||||
private GeckoActivity mActivity;
|
private final LightweightTheme mTheme;
|
||||||
|
|
||||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||||
private static final int[] STATE_DARK = { R.attr.state_dark };
|
private static final int[] STATE_DARK = { R.attr.state_dark };
|
||||||
|
|
||||||
|
protected static final int[] PRIVATE_PRESSED_STATE_SET = { R.attr.state_private, android.R.attr.state_pressed };
|
||||||
|
protected static final int[] PRIVATE_FOCUSED_STATE_SET = { R.attr.state_private, android.R.attr.state_focused };
|
||||||
|
protected static final int[] PRIVATE_STATE_SET = { R.attr.state_private };
|
||||||
|
|
||||||
private boolean mIsPrivate = false;
|
private boolean mIsPrivate = false;
|
||||||
private boolean mIsLight = false;
|
private boolean mIsLight = false;
|
||||||
private boolean mIsDark = false;
|
private boolean mIsDark = false;
|
||||||
@ -27,7 +33,7 @@ public class Gecko@VIEWTYPE@ extends @VIEWTYPE@
|
|||||||
|
|
||||||
public Gecko@VIEWTYPE@(Context context, AttributeSet attrs) {
|
public Gecko@VIEWTYPE@(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mActivity = (GeckoActivity) context;
|
mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();
|
||||||
|
|
||||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||||
mAutoUpdateTheme = a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
mAutoUpdateTheme = a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||||
@ -39,7 +45,7 @@ public class Gecko@VIEWTYPE@ extends @VIEWTYPE@
|
|||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
|
|
||||||
if (mAutoUpdateTheme)
|
if (mAutoUpdateTheme)
|
||||||
mActivity.getLightweightTheme().addListener(this);
|
mTheme.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,7 +53,7 @@ public class Gecko@VIEWTYPE@ extends @VIEWTYPE@
|
|||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
|
|
||||||
if (mAutoUpdateTheme)
|
if (mAutoUpdateTheme)
|
||||||
mActivity.getLightweightTheme().removeListener(this);
|
mTheme.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,8 +72,8 @@ public class Gecko@VIEWTYPE@ extends @VIEWTYPE@
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLightweightThemeChanged() {
|
public void onLightweightThemeChanged() {
|
||||||
if (mAutoUpdateTheme && mActivity.getLightweightTheme().isEnabled())
|
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||||
setTheme(mActivity.getLightweightTheme().isLightTheme());
|
setTheme(mTheme.isLightTheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -122,9 +128,13 @@ public class Gecko@VIEWTYPE@ extends @VIEWTYPE@
|
|||||||
mAutoUpdateTheme = autoUpdateTheme;
|
mAutoUpdateTheme = autoUpdateTheme;
|
||||||
|
|
||||||
if (mAutoUpdateTheme)
|
if (mAutoUpdateTheme)
|
||||||
mActivity.getLightweightTheme().addListener(this);
|
mTheme.addListener(this);
|
||||||
else
|
else
|
||||||
mActivity.getLightweightTheme().removeListener(this);
|
mTheme.removeListener(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ColorDrawable getColorDrawable(int id) {
|
||||||
|
return new ColorDrawable(getResources().getColor(id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user