mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1188198 - Remove the m prefix from the ThemedView.java.frag template and regenerate the output files. r=mcomella
This commit is contained in:
parent
b8afc16863
commit
7c19fbb085
@ -21,7 +21,7 @@ import android.util.AttributeSet;
|
||||
|
||||
public class ThemedEditText extends android.widget.EditText
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private LightweightTheme mTheme;
|
||||
private LightweightTheme theme;
|
||||
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
@ -31,12 +31,12 @@ public class ThemedEditText extends android.widget.EditText
|
||||
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;
|
||||
private boolean mIsLight;
|
||||
private boolean mIsDark;
|
||||
private boolean mAutoUpdateTheme; // always false if there's no theme.
|
||||
private boolean isPrivate;
|
||||
private boolean isLight;
|
||||
private boolean isDark;
|
||||
private boolean autoUpdateTheme; // always false if there's no theme.
|
||||
|
||||
private ColorStateList mDrawableColors;
|
||||
private ColorStateList drawableColors;
|
||||
|
||||
public ThemedEditText(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -53,11 +53,11 @@ public class ThemedEditText extends android.widget.EditText
|
||||
// might be instantiating this View in an IDE, with no ambient GeckoApplication.
|
||||
final Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof GeckoApplication) {
|
||||
mTheme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
theme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
}
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||
mAutoUpdateTheme = mTheme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
autoUpdateTheme = theme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@ -65,27 +65,27 @@ public class ThemedEditText extends android.widget.EditText
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.removeListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
if (isPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
else if (isLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
else if (isDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
@ -93,13 +93,13 @@ public class ThemedEditText extends android.widget.EditText
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||
setTheme(mTheme.isLightTheme());
|
||||
if (autoUpdateTheme && theme.isEnabled())
|
||||
setTheme(theme.isLightTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
if (mAutoUpdateTheme)
|
||||
if (autoUpdateTheme)
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
@ -110,12 +110,12 @@ public class ThemedEditText extends android.widget.EditText
|
||||
}
|
||||
|
||||
public boolean isPrivateMode() {
|
||||
return mIsPrivate;
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
if (this.isPrivate != isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
@ -123,14 +123,14 @@ public class ThemedEditText extends android.widget.EditText
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if ((isLight && this.isLight != isLight) ||
|
||||
(!isLight && this.isDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
this.isLight = true;
|
||||
this.isDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
this.isLight = false;
|
||||
this.isDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
@ -139,26 +139,26 @@ public class ThemedEditText extends android.widget.EditText
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
if (isLight || isDark) {
|
||||
isLight = false;
|
||||
isDark = false;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoUpdateTheme(boolean autoUpdateTheme) {
|
||||
if (mTheme == null) {
|
||||
if (theme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoUpdateTheme != autoUpdateTheme) {
|
||||
mAutoUpdateTheme = autoUpdateTheme;
|
||||
if (this.autoUpdateTheme != autoUpdateTheme) {
|
||||
this.autoUpdateTheme = autoUpdateTheme;
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
else
|
||||
mTheme.removeListener(this);
|
||||
theme.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,6 +167,6 @@ public class ThemedEditText extends android.widget.EditText
|
||||
}
|
||||
|
||||
protected LightweightTheme getTheme() {
|
||||
return mTheme;
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import android.util.AttributeSet;
|
||||
|
||||
public class ThemedFrameLayout extends android.widget.FrameLayout
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private LightweightTheme mTheme;
|
||||
private LightweightTheme theme;
|
||||
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
@ -31,12 +31,12 @@ public class ThemedFrameLayout extends android.widget.FrameLayout
|
||||
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;
|
||||
private boolean mIsLight;
|
||||
private boolean mIsDark;
|
||||
private boolean mAutoUpdateTheme; // always false if there's no theme.
|
||||
private boolean isPrivate;
|
||||
private boolean isLight;
|
||||
private boolean isDark;
|
||||
private boolean autoUpdateTheme; // always false if there's no theme.
|
||||
|
||||
private ColorStateList mDrawableColors;
|
||||
private ColorStateList drawableColors;
|
||||
|
||||
public ThemedFrameLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -53,11 +53,11 @@ public class ThemedFrameLayout extends android.widget.FrameLayout
|
||||
// might be instantiating this View in an IDE, with no ambient GeckoApplication.
|
||||
final Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof GeckoApplication) {
|
||||
mTheme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
theme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
}
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||
mAutoUpdateTheme = mTheme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
autoUpdateTheme = theme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@ -65,27 +65,27 @@ public class ThemedFrameLayout extends android.widget.FrameLayout
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.removeListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
if (isPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
else if (isLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
else if (isDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
@ -93,13 +93,13 @@ public class ThemedFrameLayout extends android.widget.FrameLayout
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||
setTheme(mTheme.isLightTheme());
|
||||
if (autoUpdateTheme && theme.isEnabled())
|
||||
setTheme(theme.isLightTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
if (mAutoUpdateTheme)
|
||||
if (autoUpdateTheme)
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
@ -110,12 +110,12 @@ public class ThemedFrameLayout extends android.widget.FrameLayout
|
||||
}
|
||||
|
||||
public boolean isPrivateMode() {
|
||||
return mIsPrivate;
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
if (this.isPrivate != isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
@ -123,14 +123,14 @@ public class ThemedFrameLayout extends android.widget.FrameLayout
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if ((isLight && this.isLight != isLight) ||
|
||||
(!isLight && this.isDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
this.isLight = true;
|
||||
this.isDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
this.isLight = false;
|
||||
this.isDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
@ -139,26 +139,26 @@ public class ThemedFrameLayout extends android.widget.FrameLayout
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
if (isLight || isDark) {
|
||||
isLight = false;
|
||||
isDark = false;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoUpdateTheme(boolean autoUpdateTheme) {
|
||||
if (mTheme == null) {
|
||||
if (theme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoUpdateTheme != autoUpdateTheme) {
|
||||
mAutoUpdateTheme = autoUpdateTheme;
|
||||
if (this.autoUpdateTheme != autoUpdateTheme) {
|
||||
this.autoUpdateTheme = autoUpdateTheme;
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
else
|
||||
mTheme.removeListener(this);
|
||||
theme.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,6 +167,6 @@ public class ThemedFrameLayout extends android.widget.FrameLayout
|
||||
}
|
||||
|
||||
protected LightweightTheme getTheme() {
|
||||
return mTheme;
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import android.util.AttributeSet;
|
||||
|
||||
public class ThemedImageButton extends android.widget.ImageButton
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private LightweightTheme mTheme;
|
||||
private LightweightTheme theme;
|
||||
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
@ -31,12 +31,12 @@ public class ThemedImageButton extends android.widget.ImageButton
|
||||
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;
|
||||
private boolean mIsLight;
|
||||
private boolean mIsDark;
|
||||
private boolean mAutoUpdateTheme; // always false if there's no theme.
|
||||
private boolean isPrivate;
|
||||
private boolean isLight;
|
||||
private boolean isDark;
|
||||
private boolean autoUpdateTheme; // always false if there's no theme.
|
||||
|
||||
private ColorStateList mDrawableColors;
|
||||
private ColorStateList drawableColors;
|
||||
|
||||
public ThemedImageButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -53,15 +53,15 @@ public class ThemedImageButton extends android.widget.ImageButton
|
||||
// might be instantiating this View in an IDE, with no ambient GeckoApplication.
|
||||
final Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof GeckoApplication) {
|
||||
mTheme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
theme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
}
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||
mAutoUpdateTheme = mTheme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
autoUpdateTheme = theme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
a.recycle();
|
||||
|
||||
final TypedArray themedA = context.obtainStyledAttributes(attrs, R.styleable.ThemedView, defStyle, 0);
|
||||
mDrawableColors = themedA.getColorStateList(R.styleable.ThemedView_drawableTintList);
|
||||
drawableColors = themedA.getColorStateList(R.styleable.ThemedView_drawableTintList);
|
||||
themedA.recycle();
|
||||
|
||||
// Apply the tint initially - the Drawable is
|
||||
@ -73,27 +73,27 @@ public class ThemedImageButton extends android.widget.ImageButton
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.removeListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
if (isPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
else if (isLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
else if (isDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
@ -101,13 +101,13 @@ public class ThemedImageButton extends android.widget.ImageButton
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||
setTheme(mTheme.isLightTheme());
|
||||
if (autoUpdateTheme && theme.isEnabled())
|
||||
setTheme(theme.isLightTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
if (mAutoUpdateTheme)
|
||||
if (autoUpdateTheme)
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
@ -118,12 +118,12 @@ public class ThemedImageButton extends android.widget.ImageButton
|
||||
}
|
||||
|
||||
public boolean isPrivateMode() {
|
||||
return mIsPrivate;
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
if (this.isPrivate != isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
@ -131,14 +131,14 @@ public class ThemedImageButton extends android.widget.ImageButton
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if ((isLight && this.isLight != isLight) ||
|
||||
(!isLight && this.isDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
this.isLight = true;
|
||||
this.isDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
this.isLight = false;
|
||||
this.isDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
@ -147,26 +147,26 @@ public class ThemedImageButton extends android.widget.ImageButton
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
if (isLight || isDark) {
|
||||
isLight = false;
|
||||
isDark = false;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoUpdateTheme(boolean autoUpdateTheme) {
|
||||
if (mTheme == null) {
|
||||
if (theme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoUpdateTheme != autoUpdateTheme) {
|
||||
mAutoUpdateTheme = autoUpdateTheme;
|
||||
if (this.autoUpdateTheme != autoUpdateTheme) {
|
||||
this.autoUpdateTheme = autoUpdateTheme;
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
else
|
||||
mTheme.removeListener(this);
|
||||
theme.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,14 +177,14 @@ public class ThemedImageButton extends android.widget.ImageButton
|
||||
|
||||
private void setTintedImageDrawable(final Drawable drawable) {
|
||||
final Drawable tintedDrawable;
|
||||
if (mDrawableColors == null) {
|
||||
if (drawableColors == null) {
|
||||
// If we tint a drawable with a null ColorStateList, it will override
|
||||
// any existing colorFilters and tint... so don't!
|
||||
tintedDrawable = drawable;
|
||||
} else if (drawable == null) {
|
||||
tintedDrawable = null;
|
||||
} else {
|
||||
tintedDrawable = DrawableUtil.tintDrawableWithStateList(drawable, mDrawableColors);
|
||||
tintedDrawable = DrawableUtil.tintDrawableWithStateList(drawable, drawableColors);
|
||||
}
|
||||
super.setImageDrawable(tintedDrawable);
|
||||
}
|
||||
@ -194,6 +194,6 @@ public class ThemedImageButton extends android.widget.ImageButton
|
||||
}
|
||||
|
||||
protected LightweightTheme getTheme() {
|
||||
return mTheme;
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import android.util.AttributeSet;
|
||||
|
||||
public class ThemedImageView extends android.widget.ImageView
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private LightweightTheme mTheme;
|
||||
private LightweightTheme theme;
|
||||
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
@ -31,12 +31,12 @@ public class ThemedImageView extends android.widget.ImageView
|
||||
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;
|
||||
private boolean mIsLight;
|
||||
private boolean mIsDark;
|
||||
private boolean mAutoUpdateTheme; // always false if there's no theme.
|
||||
private boolean isPrivate;
|
||||
private boolean isLight;
|
||||
private boolean isDark;
|
||||
private boolean autoUpdateTheme; // always false if there's no theme.
|
||||
|
||||
private ColorStateList mDrawableColors;
|
||||
private ColorStateList drawableColors;
|
||||
|
||||
public ThemedImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -53,15 +53,15 @@ public class ThemedImageView extends android.widget.ImageView
|
||||
// might be instantiating this View in an IDE, with no ambient GeckoApplication.
|
||||
final Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof GeckoApplication) {
|
||||
mTheme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
theme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
}
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||
mAutoUpdateTheme = mTheme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
autoUpdateTheme = theme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
a.recycle();
|
||||
|
||||
final TypedArray themedA = context.obtainStyledAttributes(attrs, R.styleable.ThemedView, defStyle, 0);
|
||||
mDrawableColors = themedA.getColorStateList(R.styleable.ThemedView_drawableTintList);
|
||||
drawableColors = themedA.getColorStateList(R.styleable.ThemedView_drawableTintList);
|
||||
themedA.recycle();
|
||||
|
||||
// Apply the tint initially - the Drawable is
|
||||
@ -73,27 +73,27 @@ public class ThemedImageView extends android.widget.ImageView
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.removeListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
if (isPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
else if (isLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
else if (isDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
@ -101,13 +101,13 @@ public class ThemedImageView extends android.widget.ImageView
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||
setTheme(mTheme.isLightTheme());
|
||||
if (autoUpdateTheme && theme.isEnabled())
|
||||
setTheme(theme.isLightTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
if (mAutoUpdateTheme)
|
||||
if (autoUpdateTheme)
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
@ -118,12 +118,12 @@ public class ThemedImageView extends android.widget.ImageView
|
||||
}
|
||||
|
||||
public boolean isPrivateMode() {
|
||||
return mIsPrivate;
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
if (this.isPrivate != isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
@ -131,14 +131,14 @@ public class ThemedImageView extends android.widget.ImageView
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if ((isLight && this.isLight != isLight) ||
|
||||
(!isLight && this.isDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
this.isLight = true;
|
||||
this.isDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
this.isLight = false;
|
||||
this.isDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
@ -147,26 +147,26 @@ public class ThemedImageView extends android.widget.ImageView
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
if (isLight || isDark) {
|
||||
isLight = false;
|
||||
isDark = false;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoUpdateTheme(boolean autoUpdateTheme) {
|
||||
if (mTheme == null) {
|
||||
if (theme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoUpdateTheme != autoUpdateTheme) {
|
||||
mAutoUpdateTheme = autoUpdateTheme;
|
||||
if (this.autoUpdateTheme != autoUpdateTheme) {
|
||||
this.autoUpdateTheme = autoUpdateTheme;
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
else
|
||||
mTheme.removeListener(this);
|
||||
theme.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,14 +177,14 @@ public class ThemedImageView extends android.widget.ImageView
|
||||
|
||||
private void setTintedImageDrawable(final Drawable drawable) {
|
||||
final Drawable tintedDrawable;
|
||||
if (mDrawableColors == null) {
|
||||
if (drawableColors == null) {
|
||||
// If we tint a drawable with a null ColorStateList, it will override
|
||||
// any existing colorFilters and tint... so don't!
|
||||
tintedDrawable = drawable;
|
||||
} else if (drawable == null) {
|
||||
tintedDrawable = null;
|
||||
} else {
|
||||
tintedDrawable = DrawableUtil.tintDrawableWithStateList(drawable, mDrawableColors);
|
||||
tintedDrawable = DrawableUtil.tintDrawableWithStateList(drawable, drawableColors);
|
||||
}
|
||||
super.setImageDrawable(tintedDrawable);
|
||||
}
|
||||
@ -194,6 +194,6 @@ public class ThemedImageView extends android.widget.ImageView
|
||||
}
|
||||
|
||||
protected LightweightTheme getTheme() {
|
||||
return mTheme;
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import android.util.AttributeSet;
|
||||
|
||||
public class ThemedLinearLayout extends android.widget.LinearLayout
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private LightweightTheme mTheme;
|
||||
private LightweightTheme theme;
|
||||
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
@ -31,12 +31,12 @@ public class ThemedLinearLayout extends android.widget.LinearLayout
|
||||
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;
|
||||
private boolean mIsLight;
|
||||
private boolean mIsDark;
|
||||
private boolean mAutoUpdateTheme; // always false if there's no theme.
|
||||
private boolean isPrivate;
|
||||
private boolean isLight;
|
||||
private boolean isDark;
|
||||
private boolean autoUpdateTheme; // always false if there's no theme.
|
||||
|
||||
private ColorStateList mDrawableColors;
|
||||
private ColorStateList drawableColors;
|
||||
|
||||
public ThemedLinearLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -48,11 +48,11 @@ public class ThemedLinearLayout extends android.widget.LinearLayout
|
||||
// might be instantiating this View in an IDE, with no ambient GeckoApplication.
|
||||
final Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof GeckoApplication) {
|
||||
mTheme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
theme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
}
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||
mAutoUpdateTheme = mTheme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
autoUpdateTheme = theme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@ -60,27 +60,27 @@ public class ThemedLinearLayout extends android.widget.LinearLayout
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.removeListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
if (isPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
else if (isLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
else if (isDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
@ -88,13 +88,13 @@ public class ThemedLinearLayout extends android.widget.LinearLayout
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||
setTheme(mTheme.isLightTheme());
|
||||
if (autoUpdateTheme && theme.isEnabled())
|
||||
setTheme(theme.isLightTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
if (mAutoUpdateTheme)
|
||||
if (autoUpdateTheme)
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
@ -105,12 +105,12 @@ public class ThemedLinearLayout extends android.widget.LinearLayout
|
||||
}
|
||||
|
||||
public boolean isPrivateMode() {
|
||||
return mIsPrivate;
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
if (this.isPrivate != isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
@ -118,14 +118,14 @@ public class ThemedLinearLayout extends android.widget.LinearLayout
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if ((isLight && this.isLight != isLight) ||
|
||||
(!isLight && this.isDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
this.isLight = true;
|
||||
this.isDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
this.isLight = false;
|
||||
this.isDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
@ -134,26 +134,26 @@ public class ThemedLinearLayout extends android.widget.LinearLayout
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
if (isLight || isDark) {
|
||||
isLight = false;
|
||||
isDark = false;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoUpdateTheme(boolean autoUpdateTheme) {
|
||||
if (mTheme == null) {
|
||||
if (theme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoUpdateTheme != autoUpdateTheme) {
|
||||
mAutoUpdateTheme = autoUpdateTheme;
|
||||
if (this.autoUpdateTheme != autoUpdateTheme) {
|
||||
this.autoUpdateTheme = autoUpdateTheme;
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
else
|
||||
mTheme.removeListener(this);
|
||||
theme.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,6 +162,6 @@ public class ThemedLinearLayout extends android.widget.LinearLayout
|
||||
}
|
||||
|
||||
protected LightweightTheme getTheme() {
|
||||
return mTheme;
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import android.util.AttributeSet;
|
||||
|
||||
public class ThemedRelativeLayout extends android.widget.RelativeLayout
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private LightweightTheme mTheme;
|
||||
private LightweightTheme theme;
|
||||
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
@ -31,12 +31,12 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout
|
||||
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;
|
||||
private boolean mIsLight;
|
||||
private boolean mIsDark;
|
||||
private boolean mAutoUpdateTheme; // always false if there's no theme.
|
||||
private boolean isPrivate;
|
||||
private boolean isLight;
|
||||
private boolean isDark;
|
||||
private boolean autoUpdateTheme; // always false if there's no theme.
|
||||
|
||||
private ColorStateList mDrawableColors;
|
||||
private ColorStateList drawableColors;
|
||||
|
||||
public ThemedRelativeLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -53,11 +53,11 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout
|
||||
// might be instantiating this View in an IDE, with no ambient GeckoApplication.
|
||||
final Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof GeckoApplication) {
|
||||
mTheme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
theme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
}
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||
mAutoUpdateTheme = mTheme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
autoUpdateTheme = theme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@ -65,27 +65,27 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.removeListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
if (isPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
else if (isLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
else if (isDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
@ -93,13 +93,13 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||
setTheme(mTheme.isLightTheme());
|
||||
if (autoUpdateTheme && theme.isEnabled())
|
||||
setTheme(theme.isLightTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
if (mAutoUpdateTheme)
|
||||
if (autoUpdateTheme)
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
@ -110,12 +110,12 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout
|
||||
}
|
||||
|
||||
public boolean isPrivateMode() {
|
||||
return mIsPrivate;
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
if (this.isPrivate != isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
@ -123,14 +123,14 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if ((isLight && this.isLight != isLight) ||
|
||||
(!isLight && this.isDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
this.isLight = true;
|
||||
this.isDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
this.isLight = false;
|
||||
this.isDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
@ -139,26 +139,26 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
if (isLight || isDark) {
|
||||
isLight = false;
|
||||
isDark = false;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoUpdateTheme(boolean autoUpdateTheme) {
|
||||
if (mTheme == null) {
|
||||
if (theme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoUpdateTheme != autoUpdateTheme) {
|
||||
mAutoUpdateTheme = autoUpdateTheme;
|
||||
if (this.autoUpdateTheme != autoUpdateTheme) {
|
||||
this.autoUpdateTheme = autoUpdateTheme;
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
else
|
||||
mTheme.removeListener(this);
|
||||
theme.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,6 +167,6 @@ public class ThemedRelativeLayout extends android.widget.RelativeLayout
|
||||
}
|
||||
|
||||
protected LightweightTheme getTheme() {
|
||||
return mTheme;
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import android.util.AttributeSet;
|
||||
|
||||
public class ThemedTextSwitcher extends android.widget.TextSwitcher
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private LightweightTheme mTheme;
|
||||
private LightweightTheme theme;
|
||||
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
@ -31,12 +31,12 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher
|
||||
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;
|
||||
private boolean mIsLight;
|
||||
private boolean mIsDark;
|
||||
private boolean mAutoUpdateTheme; // always false if there's no theme.
|
||||
private boolean isPrivate;
|
||||
private boolean isLight;
|
||||
private boolean isDark;
|
||||
private boolean autoUpdateTheme; // always false if there's no theme.
|
||||
|
||||
private ColorStateList mDrawableColors;
|
||||
private ColorStateList drawableColors;
|
||||
|
||||
public ThemedTextSwitcher(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -48,11 +48,11 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher
|
||||
// might be instantiating this View in an IDE, with no ambient GeckoApplication.
|
||||
final Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof GeckoApplication) {
|
||||
mTheme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
theme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
}
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||
mAutoUpdateTheme = mTheme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
autoUpdateTheme = theme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@ -60,27 +60,27 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.removeListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
if (isPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
else if (isLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
else if (isDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
@ -88,13 +88,13 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||
setTheme(mTheme.isLightTheme());
|
||||
if (autoUpdateTheme && theme.isEnabled())
|
||||
setTheme(theme.isLightTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
if (mAutoUpdateTheme)
|
||||
if (autoUpdateTheme)
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
@ -105,12 +105,12 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher
|
||||
}
|
||||
|
||||
public boolean isPrivateMode() {
|
||||
return mIsPrivate;
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
if (this.isPrivate != isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
@ -118,14 +118,14 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if ((isLight && this.isLight != isLight) ||
|
||||
(!isLight && this.isDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
this.isLight = true;
|
||||
this.isDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
this.isLight = false;
|
||||
this.isDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
@ -134,26 +134,26 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
if (isLight || isDark) {
|
||||
isLight = false;
|
||||
isDark = false;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoUpdateTheme(boolean autoUpdateTheme) {
|
||||
if (mTheme == null) {
|
||||
if (theme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoUpdateTheme != autoUpdateTheme) {
|
||||
mAutoUpdateTheme = autoUpdateTheme;
|
||||
if (this.autoUpdateTheme != autoUpdateTheme) {
|
||||
this.autoUpdateTheme = autoUpdateTheme;
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
else
|
||||
mTheme.removeListener(this);
|
||||
theme.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,6 +162,6 @@ public class ThemedTextSwitcher extends android.widget.TextSwitcher
|
||||
}
|
||||
|
||||
protected LightweightTheme getTheme() {
|
||||
return mTheme;
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import android.util.AttributeSet;
|
||||
|
||||
public class ThemedTextView extends android.widget.TextView
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private LightweightTheme mTheme;
|
||||
private LightweightTheme theme;
|
||||
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
@ -31,12 +31,12 @@ public class ThemedTextView extends android.widget.TextView
|
||||
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;
|
||||
private boolean mIsLight;
|
||||
private boolean mIsDark;
|
||||
private boolean mAutoUpdateTheme; // always false if there's no theme.
|
||||
private boolean isPrivate;
|
||||
private boolean isLight;
|
||||
private boolean isDark;
|
||||
private boolean autoUpdateTheme; // always false if there's no theme.
|
||||
|
||||
private ColorStateList mDrawableColors;
|
||||
private ColorStateList drawableColors;
|
||||
|
||||
public ThemedTextView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -53,11 +53,11 @@ public class ThemedTextView extends android.widget.TextView
|
||||
// might be instantiating this View in an IDE, with no ambient GeckoApplication.
|
||||
final Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof GeckoApplication) {
|
||||
mTheme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
theme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
}
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||
mAutoUpdateTheme = mTheme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
autoUpdateTheme = theme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@ -65,27 +65,27 @@ public class ThemedTextView extends android.widget.TextView
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.removeListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
if (isPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
else if (isLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
else if (isDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
@ -93,13 +93,13 @@ public class ThemedTextView extends android.widget.TextView
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||
setTheme(mTheme.isLightTheme());
|
||||
if (autoUpdateTheme && theme.isEnabled())
|
||||
setTheme(theme.isLightTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
if (mAutoUpdateTheme)
|
||||
if (autoUpdateTheme)
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
@ -110,12 +110,12 @@ public class ThemedTextView extends android.widget.TextView
|
||||
}
|
||||
|
||||
public boolean isPrivateMode() {
|
||||
return mIsPrivate;
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
if (this.isPrivate != isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
@ -123,14 +123,14 @@ public class ThemedTextView extends android.widget.TextView
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if ((isLight && this.isLight != isLight) ||
|
||||
(!isLight && this.isDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
this.isLight = true;
|
||||
this.isDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
this.isLight = false;
|
||||
this.isDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
@ -139,26 +139,26 @@ public class ThemedTextView extends android.widget.TextView
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
if (isLight || isDark) {
|
||||
isLight = false;
|
||||
isDark = false;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoUpdateTheme(boolean autoUpdateTheme) {
|
||||
if (mTheme == null) {
|
||||
if (theme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoUpdateTheme != autoUpdateTheme) {
|
||||
mAutoUpdateTheme = autoUpdateTheme;
|
||||
if (this.autoUpdateTheme != autoUpdateTheme) {
|
||||
this.autoUpdateTheme = autoUpdateTheme;
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
else
|
||||
mTheme.removeListener(this);
|
||||
theme.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,6 +167,6 @@ public class ThemedTextView extends android.widget.TextView
|
||||
}
|
||||
|
||||
protected LightweightTheme getTheme() {
|
||||
return mTheme;
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import android.util.AttributeSet;
|
||||
|
||||
public class ThemedView extends android.view.View
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private LightweightTheme mTheme;
|
||||
private LightweightTheme theme;
|
||||
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
@ -31,12 +31,12 @@ public class ThemedView extends android.view.View
|
||||
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;
|
||||
private boolean mIsLight;
|
||||
private boolean mIsDark;
|
||||
private boolean mAutoUpdateTheme; // always false if there's no theme.
|
||||
private boolean isPrivate;
|
||||
private boolean isLight;
|
||||
private boolean isDark;
|
||||
private boolean autoUpdateTheme; // always false if there's no theme.
|
||||
|
||||
private ColorStateList mDrawableColors;
|
||||
private ColorStateList drawableColors;
|
||||
|
||||
public ThemedView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -53,11 +53,11 @@ public class ThemedView extends android.view.View
|
||||
// might be instantiating this View in an IDE, with no ambient GeckoApplication.
|
||||
final Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof GeckoApplication) {
|
||||
mTheme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
theme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
}
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||
mAutoUpdateTheme = mTheme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
autoUpdateTheme = theme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@ -65,27 +65,27 @@ public class ThemedView extends android.view.View
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.removeListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
if (isPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
else if (isLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
else if (isDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
@ -93,13 +93,13 @@ public class ThemedView extends android.view.View
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||
setTheme(mTheme.isLightTheme());
|
||||
if (autoUpdateTheme && theme.isEnabled())
|
||||
setTheme(theme.isLightTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
if (mAutoUpdateTheme)
|
||||
if (autoUpdateTheme)
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
@ -110,12 +110,12 @@ public class ThemedView extends android.view.View
|
||||
}
|
||||
|
||||
public boolean isPrivateMode() {
|
||||
return mIsPrivate;
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
if (this.isPrivate != isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
@ -123,14 +123,14 @@ public class ThemedView extends android.view.View
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if ((isLight && this.isLight != isLight) ||
|
||||
(!isLight && this.isDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
this.isLight = true;
|
||||
this.isDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
this.isLight = false;
|
||||
this.isDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
@ -139,26 +139,26 @@ public class ThemedView extends android.view.View
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
if (isLight || isDark) {
|
||||
isLight = false;
|
||||
isDark = false;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoUpdateTheme(boolean autoUpdateTheme) {
|
||||
if (mTheme == null) {
|
||||
if (theme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoUpdateTheme != autoUpdateTheme) {
|
||||
mAutoUpdateTheme = autoUpdateTheme;
|
||||
if (this.autoUpdateTheme != autoUpdateTheme) {
|
||||
this.autoUpdateTheme = autoUpdateTheme;
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
else
|
||||
mTheme.removeListener(this);
|
||||
theme.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,6 +167,6 @@ public class ThemedView extends android.view.View
|
||||
}
|
||||
|
||||
protected LightweightTheme getTheme() {
|
||||
return mTheme;
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import android.util.AttributeSet;
|
||||
|
||||
public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private LightweightTheme mTheme;
|
||||
private LightweightTheme theme;
|
||||
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
private static final int[] STATE_LIGHT = { R.attr.state_light };
|
||||
@ -32,12 +32,12 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@
|
||||
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;
|
||||
private boolean mIsLight;
|
||||
private boolean mIsDark;
|
||||
private boolean mAutoUpdateTheme; // always false if there's no theme.
|
||||
private boolean isPrivate;
|
||||
private boolean isLight;
|
||||
private boolean isDark;
|
||||
private boolean autoUpdateTheme; // always false if there's no theme.
|
||||
|
||||
private ColorStateList mDrawableColors;
|
||||
private ColorStateList drawableColors;
|
||||
|
||||
public Themed@VIEW_NAME_SUFFIX@(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@ -56,16 +56,16 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@
|
||||
// might be instantiating this View in an IDE, with no ambient GeckoApplication.
|
||||
final Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof GeckoApplication) {
|
||||
mTheme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
theme = ((GeckoApplication) applicationContext).getLightweightTheme();
|
||||
}
|
||||
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LightweightTheme);
|
||||
mAutoUpdateTheme = mTheme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
autoUpdateTheme = theme != null && a.getBoolean(R.styleable.LightweightTheme_autoUpdateTheme, true);
|
||||
a.recycle();
|
||||
//#if TINT_FOREGROUND_DRAWABLE
|
||||
|
||||
final TypedArray themedA = context.obtainStyledAttributes(attrs, R.styleable.ThemedView, defStyle, 0);
|
||||
mDrawableColors = themedA.getColorStateList(R.styleable.ThemedView_drawableTintList);
|
||||
drawableColors = themedA.getColorStateList(R.styleable.ThemedView_drawableTintList);
|
||||
themedA.recycle();
|
||||
|
||||
// Apply the tint initially - the Drawable is
|
||||
@ -78,27 +78,27 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.removeListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
if (isPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
else if (mIsLight)
|
||||
else if (isLight)
|
||||
mergeDrawableStates(drawableState, STATE_LIGHT);
|
||||
else if (mIsDark)
|
||||
else if (isDark)
|
||||
mergeDrawableStates(drawableState, STATE_DARK);
|
||||
|
||||
return drawableState;
|
||||
@ -106,13 +106,13 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeChanged() {
|
||||
if (mAutoUpdateTheme && mTheme.isEnabled())
|
||||
setTheme(mTheme.isLightTheme());
|
||||
if (autoUpdateTheme && theme.isEnabled())
|
||||
setTheme(theme.isLightTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightweightThemeReset() {
|
||||
if (mAutoUpdateTheme)
|
||||
if (autoUpdateTheme)
|
||||
resetTheme();
|
||||
}
|
||||
|
||||
@ -123,12 +123,12 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@
|
||||
}
|
||||
|
||||
public boolean isPrivateMode() {
|
||||
return mIsPrivate;
|
||||
return isPrivate;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
if (this.isPrivate != isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
@ -136,14 +136,14 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@
|
||||
|
||||
public void setTheme(boolean isLight) {
|
||||
// Set the theme only if it is different from existing theme.
|
||||
if ((isLight && mIsLight != isLight) ||
|
||||
(!isLight && mIsDark == isLight)) {
|
||||
if ((isLight && this.isLight != isLight) ||
|
||||
(!isLight && this.isDark == isLight)) {
|
||||
if (isLight) {
|
||||
mIsLight = true;
|
||||
mIsDark = false;
|
||||
this.isLight = true;
|
||||
this.isDark = false;
|
||||
} else {
|
||||
mIsLight = false;
|
||||
mIsDark = true;
|
||||
this.isLight = false;
|
||||
this.isDark = true;
|
||||
}
|
||||
|
||||
refreshDrawableState();
|
||||
@ -152,26 +152,26 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@
|
||||
}
|
||||
|
||||
public void resetTheme() {
|
||||
if (mIsLight || mIsDark) {
|
||||
mIsLight = false;
|
||||
mIsDark = false;
|
||||
if (isLight || isDark) {
|
||||
isLight = false;
|
||||
isDark = false;
|
||||
refreshDrawableState();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoUpdateTheme(boolean autoUpdateTheme) {
|
||||
if (mTheme == null) {
|
||||
if (theme == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoUpdateTheme != autoUpdateTheme) {
|
||||
mAutoUpdateTheme = autoUpdateTheme;
|
||||
if (this.autoUpdateTheme != autoUpdateTheme) {
|
||||
this.autoUpdateTheme = autoUpdateTheme;
|
||||
|
||||
if (mAutoUpdateTheme)
|
||||
mTheme.addListener(this);
|
||||
if (autoUpdateTheme)
|
||||
theme.addListener(this);
|
||||
else
|
||||
mTheme.removeListener(this);
|
||||
theme.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,14 +183,14 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@
|
||||
|
||||
private void setTintedImageDrawable(final Drawable drawable) {
|
||||
final Drawable tintedDrawable;
|
||||
if (mDrawableColors == null) {
|
||||
if (drawableColors == null) {
|
||||
// If we tint a drawable with a null ColorStateList, it will override
|
||||
// any existing colorFilters and tint... so don't!
|
||||
tintedDrawable = drawable;
|
||||
} else if (drawable == null) {
|
||||
tintedDrawable = null;
|
||||
} else {
|
||||
tintedDrawable = DrawableUtil.tintDrawableWithStateList(drawable, mDrawableColors);
|
||||
tintedDrawable = DrawableUtil.tintDrawableWithStateList(drawable, drawableColors);
|
||||
}
|
||||
super.setImageDrawable(tintedDrawable);
|
||||
}
|
||||
@ -201,6 +201,6 @@ public class Themed@VIEW_NAME_SUFFIX@ extends @BASE_TYPE@
|
||||
}
|
||||
|
||||
protected LightweightTheme getTheme() {
|
||||
return mTheme;
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user