ThemeManager singleton

This commit is contained in:
Moez Bhatti
2015-12-25 14:23:14 -05:00
parent 6b7d7a56cd
commit 2f4e3b5525
35 changed files with 337 additions and 325 deletions
@@ -89,26 +89,26 @@ public class FontManager {
// Colors and font weight // Colors and font weight
switch (type) { switch (type) {
case FontManager.TEXT_TYPE_PRIMARY: case FontManager.TEXT_TYPE_PRIMARY:
boolean isNight = ThemeManager.getTheme() == ThemeManager.Theme.GREY || boolean isNight = ThemeManager.getInstance().getTheme() == ThemeManager.Theme.GREY ||
ThemeManager.getTheme() == ThemeManager.Theme.BLACK; ThemeManager.getInstance().getTheme() == ThemeManager.Theme.BLACK;
int id = isNight ? R.color.text_primary_dark : R.color.text_primary_light; int id = isNight ? R.color.text_primary_dark : R.color.text_primary_light;
return context.getResources().getColorStateList(id); return context.getResources().getColorStateList(id);
case FontManager.TEXT_TYPE_SECONDARY: case FontManager.TEXT_TYPE_SECONDARY:
return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary()); return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundSecondary());
case FontManager.TEXT_TYPE_TERTIARY: case FontManager.TEXT_TYPE_TERTIARY:
return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary()); return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundSecondary());
case FontManager.TEXT_TYPE_CATEGORY: case FontManager.TEXT_TYPE_CATEGORY:
return ColorStateList.valueOf(ThemeManager.getColor()); return ColorStateList.valueOf(ThemeManager.getInstance().getColor());
case FontManager.TEXT_TYPE_DIALOG_TITLE: case FontManager.TEXT_TYPE_DIALOG_TITLE:
return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary()); return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundPrimary());
case FontManager.TEXT_TYPE_DIALOG_MESSAGE: case FontManager.TEXT_TYPE_DIALOG_MESSAGE:
return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary()); return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundSecondary());
case FontManager.TEXT_TYPE_DIALOG_BUTTON: case FontManager.TEXT_TYPE_DIALOG_BUTTON:
return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary()); return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundPrimary());
case FontManager.TEXT_TYPE_TOOLBAR: case FontManager.TEXT_TYPE_TOOLBAR:
return ColorStateList.valueOf(ThemeManager.getTextOnColorPrimary()); return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnColorPrimary());
} }
return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary()); return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundPrimary());
} }
public static int getFontWeight(Context context, boolean heavy) { public static int getFontWeight(Context context, boolean heavy) {
@@ -20,9 +20,9 @@ public class ListviewHelper {
try { try {
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.scrollbar); Drawable drawable = ContextCompat.getDrawable(context, R.drawable.scrollbar);
drawable.setColorFilter(Color.argb(64, drawable.setColorFilter(Color.argb(64,
Color.red(ThemeManager.getTextOnBackgroundSecondary()), Color.red(ThemeManager.getInstance().getTextOnBackgroundSecondary()),
Color.green(ThemeManager.getTextOnBackgroundSecondary()), Color.green(ThemeManager.getInstance().getTextOnBackgroundSecondary()),
Color.blue(ThemeManager.getTextOnBackgroundSecondary())), Color.blue(ThemeManager.getInstance().getTextOnBackgroundSecondary())),
PorterDuff.Mode.SRC_ATOP); PorterDuff.Mode.SRC_ATOP);
Field mScrollCacheField = View.class.getDeclaredField("mScrollCache"); Field mScrollCacheField = View.class.getDeclaredField("mScrollCache");
@@ -197,7 +197,7 @@ public class ContactHelper {
int length = Units.dpToPx(context, 64); int length = Units.dpToPx(context, 64);
Bitmap bitmap = Bitmap.createBitmap(length, length, Bitmap.Config.ARGB_8888); Bitmap bitmap = Bitmap.createBitmap(length, length, Bitmap.Config.ARGB_8888);
bitmap.eraseColor(ThemeManager.getColor()); bitmap.eraseColor(ThemeManager.getInstance().getColor());
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
@@ -19,7 +19,7 @@ public class NightModeAutoReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
ThemeManager.loadThemeProperties(context); ThemeManager.getInstance().loadThemeProperties(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean(SettingsFragment.NIGHT_AUTO, false)) { if (prefs.getBoolean(SettingsFragment.NIGHT_AUTO, false)) {
@@ -42,11 +42,11 @@ public class NightModeAutoReceiver extends BroadcastReceiver {
(calendar.get(Calendar.HOUR_OF_DAY) == day.get(Calendar.HOUR_OF_DAY) && calendar.get(Calendar.MINUTE) <= day.get(Calendar.MINUTE))) { (calendar.get(Calendar.HOUR_OF_DAY) == day.get(Calendar.HOUR_OF_DAY) && calendar.get(Calendar.MINUTE) <= day.get(Calendar.MINUTE))) {
Log.i(TAG, "Switching to night mode"); Log.i(TAG, "Switching to night mode");
prefs.edit().putString(SettingsFragment.BACKGROUND, ThemeManager.Theme.PREF_GREY).apply(); prefs.edit().putString(SettingsFragment.BACKGROUND, ThemeManager.Theme.PREF_GREY).apply();
ThemeManager.setTheme(ThemeManager.Theme.GREY); ThemeManager.getInstance().setTheme(ThemeManager.Theme.GREY);
} else { } else {
Log.i(TAG, "Switching to day mode"); Log.i(TAG, "Switching to day mode");
prefs.edit().putString(SettingsFragment.BACKGROUND, ThemeManager.Theme.PREF_OFFWHITE).apply(); prefs.edit().putString(SettingsFragment.BACKGROUND, ThemeManager.Theme.PREF_OFFWHITE).apply();
ThemeManager.setTheme(ThemeManager.Theme.OFFWHITE); ThemeManager.getInstance().setTheme(ThemeManager.Theme.OFFWHITE);
} }
} }
} }
@@ -56,7 +56,7 @@ public class WearableIntentReceiver extends BroadcastReceiver {
background = Bitmap.createBitmap(640, 400, Bitmap.Config.ARGB_8888); background = Bitmap.createBitmap(640, 400, Bitmap.Config.ARGB_8888);
// We can't use ThemeManager here because it might not be initialized // We can't use ThemeManager here because it might not be initialized
background.eraseColor(Integer.parseInt(prefs.getString(SettingsFragment.THEME, "" + ThemeManager.DEFAULT_COLOR))); background.eraseColor(Integer.parseInt(prefs.getString(SettingsFragment.THEME, "" + ThemeManager.getInstance().DEFAULT_COLOR)));
} }
wearableExtender.setBackground(background); wearableExtender.setBackground(background);
@@ -680,7 +680,7 @@ public class NotificationManager {
.setContentIntent(composePI) .setContentIntent(composePI)
.setSmallIcon(R.drawable.ic_compose) .setSmallIcon(R.drawable.ic_compose)
.setPriority(NotificationCompat.PRIORITY_MIN) .setPriority(NotificationCompat.PRIORITY_MIN)
.setColor(ThemeManager.getColor()); .setColor(ThemeManager.getInstance().getColor());
NotificationManager.notify(context, NOTIFICATION_ID_QUICKCOMPOSE, builder.build()); NotificationManager.notify(context, NOTIFICATION_ID_QUICKCOMPOSE, builder.build());
} else { } else {
@@ -648,9 +648,9 @@ public class MainActivity extends QKActivity implements LiveView, SlidingMenu.Sl
public void refresh() { public void refresh() {
// Update the background color. This code is important during the welcome screen setup, when the activity // Update the background color. This code is important during the welcome screen setup, when the activity
// in the ThemeManager isn't the MainActivity // in the ThemeManager isn't the MainActivity
findViewById(R.id.menu_frame).getRootView().setBackgroundColor(ThemeManager.getBackgroundColor()); findViewById(R.id.menu_frame).getRootView().setBackgroundColor(ThemeManager.getInstance().getBackgroundColor());
findViewById(R.id.menu_frame).setBackgroundColor(ThemeManager.getBackgroundColor()); findViewById(R.id.menu_frame).setBackgroundColor(ThemeManager.getInstance().getBackgroundColor());
findViewById(R.id.content_frame).setBackgroundColor(ThemeManager.getBackgroundColor()); findViewById(R.id.content_frame).setBackgroundColor(ThemeManager.getInstance().getBackgroundColor());
} }
public static class DeleteThreadListener implements DialogInterface.OnClickListener { public static class DeleteThreadListener implements DialogInterface.OnClickListener {
@@ -71,35 +71,6 @@ public class ThemeManager {
} }
} }
private static int sColor;
private static int sActiveColor;
private static int sBackgroundColor;
private static Theme sTheme;
private static int sTextOnColorPrimary;
private static int sTextOnColorSecondary;
private static int sTextOnBackgroundPrimary;
private static int sTextOnBackgroundSecondary;
private static int sSentBubbleRes;
private static int sSentBubbleAltRes;
private static boolean sSentBubbleColored;
private static int sSentBubbleColor;
private static int sReceivedBubbleRes;
private static int sReceivedBubbleAltRes;
private static boolean sReceivedBubbleColored;
private static int sReceivedBubbleColor;
private static Drawable sRippleBackground;
private static Resources sResources;
private static SharedPreferences sPrefs;
private static boolean sStatusTintEnabled = false;
private static boolean sNavigationTintEnabled = false;
private static QKActivity mActivity;
private static Context mContext;
private static Window mWindow;
// Colours copied from http://www.google.com/design/spec/style/color.html#color-ui-color-palette // Colours copied from http://www.google.com/design/spec/style/color.html#color-ui-color-palette
private static final int[][] COLOURS = {{ private static final int[][] COLOURS = {{
// Red // Red
@@ -249,45 +220,86 @@ public class ThemeManager {
0, 0, 0, 1, 1, 1, 1, 1, 1, 1 0, 0, 0, 1, 1, 1, 1, 1, 1, 1
}}; }};
private int mColor;
private int mActiveColor;
private int mBackgroundColor;
private Theme mTheme;
private int mTextOnColorPrimary;
private int mTextOnColorSecondary;
private int mTextOnBackgroundPrimary;
private int mtextOnBackgroundSecondary;
private int mSentBubbleRes;
private int mSentBubbleAltRes;
private boolean mSentBubbleColored;
private int mReceivedBubbleRes;
private int mReceivedBubbleAltRes;
private boolean mReceivedBubbleColored;
private Drawable mRippleBackground;
private Resources mResources;
private SharedPreferences mPrefs;
private boolean mStatusTintEnabled = false;
private boolean mNavigationTintEnabled = false;
private QKActivity mActivity;
private Context mContext;
private Window mWindow;
private static ThemeManager sInstance;
public static ThemeManager getInstance() {
if (sInstance == null) {
sInstance = new ThemeManager();
}
return sInstance;
}
private ThemeManager() {
}
/** /**
* Loads all theme properties. Should be called during onCreate * Loads all theme properties. Should be called during onCreate
* of each activity that contains fragments that use ThemeManager * of each activity that contains fragments that use ThemeManager
*/ */
public static void loadThemeProperties(Context context) { public void loadThemeProperties(Context context) {
sPrefs = PreferenceManager.getDefaultSharedPreferences(context); mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
sResources = context.getResources(); mResources = context.getResources();
mContext = context; mContext = context;
sColor = Integer.parseInt(sPrefs.getString(SettingsFragment.THEME, "" + ThemeManager.DEFAULT_COLOR)); mColor = Integer.parseInt(mPrefs.getString(SettingsFragment.THEME, "" + ThemeManager.getInstance().DEFAULT_COLOR));
sActiveColor = sColor; mActiveColor = mColor;
if (context instanceof QKActivity) { if (context instanceof QKActivity) {
mActivity = (QKActivity) context; mActivity = (QKActivity) context;
mActivity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(sColor)); mActivity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(mColor));
mWindow = mActivity.getWindow(); mWindow = mActivity.getWindow();
} }
initializeTheme(Theme.fromString(sPrefs.getString(SettingsFragment.BACKGROUND, "offwhite"))); initializeTheme(Theme.fromString(mPrefs.getString(SettingsFragment.BACKGROUND, "offwhite")));
sStatusTintEnabled = sPrefs.getBoolean(SettingsFragment.STATUS_TINT, true) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; mStatusTintEnabled = mPrefs.getBoolean(SettingsFragment.STATUS_TINT, true) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
sNavigationTintEnabled = sPrefs.getBoolean(SettingsFragment.NAVIGATION_TINT, false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; mNavigationTintEnabled = mPrefs.getBoolean(SettingsFragment.NAVIGATION_TINT, false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
if (mActivity != null && sStatusTintEnabled) { if (mActivity != null && mStatusTintEnabled) {
if (sStatusTintEnabled) { if (mStatusTintEnabled) {
mWindow.setStatusBarColor(ColorUtils.darken(sColor)); mWindow.setStatusBarColor(ColorUtils.darken(mColor));
} }
if (sNavigationTintEnabled) { if (mNavigationTintEnabled) {
mWindow.setNavigationBarColor(ColorUtils.darken(sColor)); mWindow.setNavigationBarColor(ColorUtils.darken(mColor));
} }
} }
} }
public static void setTheme(Theme theme) { public void setTheme(Theme theme) {
int startColor = sBackgroundColor; int startColor = mBackgroundColor;
initializeTheme(theme); initializeTheme(theme);
int endColor = sBackgroundColor; int endColor = mBackgroundColor;
if (mActivity instanceof MainActivity) { if (mActivity instanceof MainActivity) {
final View background = mActivity.findViewById(R.id.menu_frame).getRootView(); final View background = mActivity.findViewById(R.id.menu_frame).getRootView();
@@ -331,70 +343,70 @@ public class ThemeManager {
} }
} }
public static void initializeTheme(Theme theme) { public void initializeTheme(Theme theme) {
sTheme = theme; mTheme = theme;
switch (theme) { switch (theme) {
case WHITE: case WHITE:
sBackgroundColor = sResources.getColor(R.color.white_pure); mBackgroundColor = mResources.getColor(R.color.white_pure);
if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ? if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ?
R.style.AppThemeWhite : R.style.AppThemeWhiteDialog); R.style.AppThemeWhite : R.style.AppThemeWhiteDialog);
break; break;
case OFFWHITE: case OFFWHITE:
sBackgroundColor = sResources.getColor(R.color.grey_light_mega_ultra); mBackgroundColor = mResources.getColor(R.color.grey_light_mega_ultra);
if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ? if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ?
R.style.AppThemeLight : R.style.AppThemeLightDialog); R.style.AppThemeLight : R.style.AppThemeLightDialog);
break; break;
case GREY: case GREY:
sBackgroundColor = sResources.getColor(R.color.grey_material); mBackgroundColor = mResources.getColor(R.color.grey_material);
if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ? if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ?
R.style.AppThemeDark : R.style.AppThemeDarkDialog); R.style.AppThemeDark : R.style.AppThemeDarkDialog);
break; break;
case BLACK: case BLACK:
sBackgroundColor = sResources.getColor(R.color.black); mBackgroundColor = mResources.getColor(R.color.black);
if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ? if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ?
R.style.AppThemeDarkAmoled : R.style.AppThemeDarkAmoledDialog); R.style.AppThemeDarkAmoled : R.style.AppThemeDarkAmoledDialog);
break; break;
} }
switch (sTheme) { switch (mTheme) {
case WHITE: case WHITE:
case OFFWHITE: case OFFWHITE:
sTextOnBackgroundPrimary = sResources.getColor(R.color.theme_light_text_primary); mTextOnBackgroundPrimary = mResources.getColor(R.color.theme_light_text_primary);
sTextOnBackgroundSecondary = sResources.getColor(R.color.theme_light_text_secondary); mtextOnBackgroundSecondary = mResources.getColor(R.color.theme_light_text_secondary);
sRippleBackground = sResources.getDrawable(R.drawable.button_background_transparent); mRippleBackground = mResources.getDrawable(R.drawable.button_background_transparent);
if (mActivity != null) { if (mActivity != null) {
mActivity.getToolbar().setPopupTheme(R.style.PopupThemeLight); mActivity.getToolbar().setPopupTheme(R.style.PopupThemeLight);
} }
break; break;
case GREY: case GREY:
case BLACK: case BLACK:
sTextOnBackgroundPrimary = sResources.getColor(R.color.theme_dark_text_primary); mTextOnBackgroundPrimary = mResources.getColor(R.color.theme_dark_text_primary);
sTextOnBackgroundSecondary = sResources.getColor(R.color.theme_dark_text_secondary); mtextOnBackgroundSecondary = mResources.getColor(R.color.theme_dark_text_secondary);
sRippleBackground = sResources.getDrawable(R.drawable.button_background_transparent_light); mRippleBackground = mResources.getDrawable(R.drawable.button_background_transparent_light);
if (mActivity != null) { if (mActivity != null) {
mActivity.getToolbar().setPopupTheme(R.style.PopupTheme); mActivity.getToolbar().setPopupTheme(R.style.PopupTheme);
} }
break; break;
} }
sTextOnColorPrimary = sResources.getColor(isColorDarkEnough(sColor) ? mTextOnColorPrimary = mResources.getColor(isColorDarkEnough(mColor) ?
R.color.theme_dark_text_primary : R.color.theme_light_text_primary); R.color.theme_dark_text_primary : R.color.theme_light_text_primary);
sTextOnColorSecondary = sResources.getColor(isColorDarkEnough(sColor) ? mTextOnColorSecondary = mResources.getColor(isColorDarkEnough(mColor) ?
R.color.theme_dark_text_secondary : R.color.theme_light_text_secondary); R.color.theme_dark_text_secondary : R.color.theme_light_text_secondary);
setSentBubbleColored(sPrefs.getBoolean(SettingsFragment.COLOUR_SENT, true)); setSentBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOUR_SENT, true));
setReceivedBubbleColored(sPrefs.getBoolean(SettingsFragment.COLOUR_RECEIVED, false)); setReceivedBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOUR_RECEIVED, false));
setBubbleStyleNew(sPrefs.getBoolean(SettingsFragment.BUBBLES_NEW, true)); setBubbleStyleNew(mPrefs.getBoolean(SettingsFragment.BUBBLES_NEW, true));
if (mActivity != null) { if (mActivity != null) {
// We need to set this here because the title bar is initialized before the ThemeManager, // We need to set this here because the title bar is initialized before the ThemeManager,
// so it's not using the correct color yet // so it's not using the correct color yet
((QKTextView) mActivity.findViewById(R.id.toolbar_title)).setTextColor(sTextOnColorPrimary); ((QKTextView) mActivity.findViewById(R.id.toolbar_title)).setTextColor(mTextOnColorPrimary);
} }
} }
public static void setIcon(final QKActivity context) { public void setIcon(final QKActivity context) {
new QKDialog() new QKDialog()
.setContext(context) .setContext(context)
.setTitle(R.string.update_icon_title) .setTitle(R.string.update_icon_title)
@@ -420,7 +432,7 @@ public class ThemeManager {
// Save the enabled component so we can kill the app with this one when // Save the enabled component so we can kill the app with this one when
// it's all done. // it's all done.
if (getSwatchColour(sColor) == PALETTE[i]) { if (getSwatchColour(mColor) == PALETTE[i]) {
enabledComponent = componentClassName; enabledComponent = componentClassName;
} else { } else {
@@ -447,106 +459,106 @@ public class ThemeManager {
.show(); .show();
} }
public static int getBackgroundColor() { public int getBackgroundColor() {
return sBackgroundColor; return mBackgroundColor;
} }
public static int getTextOnColorPrimary() { public int getTextOnColorPrimary() {
return sTextOnColorPrimary; return mTextOnColorPrimary;
} }
public static int getTextOnColorSecondary() { public int getTextOnColorSecondary() {
return sTextOnColorSecondary; return mTextOnColorSecondary;
} }
public static int getTextOnBackgroundPrimary() { public int getTextOnBackgroundPrimary() {
return sTextOnBackgroundPrimary; return mTextOnBackgroundPrimary;
} }
public static int getTextOnBackgroundSecondary() { public int getTextOnBackgroundSecondary() {
return sTextOnBackgroundSecondary; return mtextOnBackgroundSecondary;
} }
public static int getSentBubbleRes() { public int getSentBubbleRes() {
return sSentBubbleRes; return mSentBubbleRes;
} }
public static int getSentBubbleAltRes() { public int getSentBubbleAltRes() {
return sSentBubbleAltRes; return mSentBubbleAltRes;
} }
public static int getSentBubbleColor() { public int getSentBubbleColor() {
return sSentBubbleColored ? sActiveColor : getNeutralBubbleColor(); return mSentBubbleColored ? mActiveColor : getNeutralBubbleColor();
} }
public static int getReceivedBubbleRes() { public int getReceivedBubbleRes() {
return sReceivedBubbleRes; return mReceivedBubbleRes;
} }
public static int getReceivedBubbleAltRes() { public int getReceivedBubbleAltRes() {
return sReceivedBubbleAltRes; return mReceivedBubbleAltRes;
} }
public static int getReceivedBubbleColor() { public int getReceivedBubbleColor() {
return sReceivedBubbleColored ? sActiveColor : getNeutralBubbleColor(); return mReceivedBubbleColored ? mActiveColor : getNeutralBubbleColor();
} }
public static void setBubbleStyleNew(boolean styleNew) { public void setBubbleStyleNew(boolean styleNew) {
sSentBubbleRes = styleNew ? R.drawable.message_sent_2 : R.drawable.message_sent; mSentBubbleRes = styleNew ? R.drawable.message_sent_2 : R.drawable.message_sent;
sSentBubbleAltRes = styleNew ? R.drawable.message_sent_alt_2 : R.drawable.message_sent_alt; mSentBubbleAltRes = styleNew ? R.drawable.message_sent_alt_2 : R.drawable.message_sent_alt;
sReceivedBubbleRes = styleNew ? R.drawable.message_received_2 : R.drawable.message_received; mReceivedBubbleRes = styleNew ? R.drawable.message_received_2 : R.drawable.message_received;
sReceivedBubbleAltRes = styleNew ? R.drawable.message_received_alt_2 : R.drawable.message_received_alt; mReceivedBubbleAltRes = styleNew ? R.drawable.message_received_alt_2 : R.drawable.message_received_alt;
} }
public static void setSentBubbleColored(boolean colored) { public void setSentBubbleColored(boolean colored) {
sSentBubbleColored = colored; mSentBubbleColored = colored;
} }
public static void setReceivedBubbleColored(boolean colored) { public void setReceivedBubbleColored(boolean colored) {
sReceivedBubbleColored = colored; mReceivedBubbleColored = colored;
} }
public static int getNeutralBubbleColor() { public int getNeutralBubbleColor() {
if (sTheme == null) { if (mTheme == null) {
return 0xeeeeee; return 0xeeeeee;
} }
switch (sTheme) { switch (mTheme) {
case WHITE: case WHITE:
return sResources.getColor(R.color.grey_light_mega_ultra); return mResources.getColor(R.color.grey_light_mega_ultra);
case OFFWHITE: case OFFWHITE:
return sResources.getColor(R.color.white_pure); return mResources.getColor(R.color.white_pure);
case GREY: case GREY:
return sResources.getColor(R.color.grey_dark); return mResources.getColor(R.color.grey_dark);
default: default:
return sResources.getColor(R.color.grey_material); return mResources.getColor(R.color.grey_material);
} }
} }
public static Drawable getRippleBackground() { public Drawable getRippleBackground() {
return sRippleBackground; return mRippleBackground;
} }
public static int getColor() { public int getColor() {
return sActiveColor; return mActiveColor;
} }
public static int getThemeColor() { public int getThemeColor() {
return sColor; return mColor;
} }
public static Theme getTheme() { public Theme getTheme() {
return sTheme; return mTheme;
} }
public static boolean isNightMode() { public boolean isNightMode() {
return sTheme == Theme.GREY || sTheme == Theme.BLACK; return mTheme == Theme.GREY || mTheme == Theme.BLACK;
} }
public static void showColourSwatchesDialog(final QKActivity context) { public void showColourSwatchesDialog(final QKActivity context) {
final QKDialog dialog = new QKDialog(); final QKDialog dialog = new QKDialog();
ColorPickerPalette palette = new ColorPickerPalette(context); ColorPickerPalette palette = new ColorPickerPalette(context);
@@ -556,7 +568,7 @@ public class ThemeManager {
dialog.dismiss(); dialog.dismiss();
}); });
palette.drawPalette(PALETTE, getSwatchColour(sColor)); palette.drawPalette(PALETTE, getSwatchColour(mColor));
dialog.setContext(context) dialog.setContext(context)
.setTitle(R.string.pref_theme) .setTitle(R.string.pref_theme)
@@ -566,7 +578,7 @@ public class ThemeManager {
dialog.show(); dialog.show();
} }
private static void showColourPickerDialog(final QKActivity context, int swatchColour) { private void showColourPickerDialog(final QKActivity context, int swatchColour) {
final QKDialog dialog = new QKDialog(); final QKDialog dialog = new QKDialog();
ColorPickerPalette palette = new ColorPickerPalette(context); ColorPickerPalette palette = new ColorPickerPalette(context);
@@ -576,7 +588,7 @@ public class ThemeManager {
dialog.dismiss(); dialog.dismiss();
}); });
palette.drawPalette(getSwatch(swatchColour), sColor); palette.drawPalette(getSwatch(swatchColour), mColor);
dialog.setContext(context) dialog.setContext(context)
.setTitle(R.string.pref_theme) .setTitle(R.string.pref_theme)
@@ -586,11 +598,11 @@ public class ThemeManager {
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setStatusBarTintEnabled(boolean enabled) { public void setStatusBarTintEnabled(boolean enabled) {
if (sStatusTintEnabled != enabled) { if (mStatusTintEnabled != enabled) {
sStatusTintEnabled = enabled; mStatusTintEnabled = enabled;
int colorFrom = enabled ? sResources.getColor(R.color.black) : sColor; int colorFrom = enabled ? mResources.getColor(R.color.black) : mColor;
int colorTo = enabled ? sColor : sResources.getColor(R.color.black); int colorTo = enabled ? mColor : mResources.getColor(R.color.black);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
colorAnimation.setDuration(TRANSITION_LENGTH); colorAnimation.setDuration(TRANSITION_LENGTH);
@@ -602,11 +614,11 @@ public class ThemeManager {
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setNavigationBarTintEnabled(boolean enabled) { public void setNavigationBarTintEnabled(boolean enabled) {
if (sNavigationTintEnabled != enabled) { if (mNavigationTintEnabled != enabled) {
sNavigationTintEnabled = enabled; mNavigationTintEnabled = enabled;
int colorFrom = enabled ? sResources.getColor(R.color.black) : sColor; int colorFrom = enabled ? mResources.getColor(R.color.black) : mColor;
int colorTo = enabled ? sColor : sResources.getColor(R.color.black); int colorTo = enabled ? mColor : mResources.getColor(R.color.black);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
colorAnimation.setDuration(TRANSITION_LENGTH); colorAnimation.setDuration(TRANSITION_LENGTH);
@@ -617,11 +629,11 @@ public class ThemeManager {
} }
} }
public static String getColorString(int color) { public String getColorString(int color) {
return String.format("#%08x", color).toUpperCase(); return String.format("#%08x", color).toUpperCase();
} }
public static void setColour(int color) { public void setColour(int color) {
AnalyticsManager.getInstance().sendEvent( AnalyticsManager.getInstance().sendEvent(
AnalyticsManager.CATEGORY_PREFERENCE_CHANGE, AnalyticsManager.CATEGORY_PREFERENCE_CHANGE,
@@ -629,17 +641,17 @@ public class ThemeManager {
getColorString(color) getColorString(color)
); );
int colourFrom = sColor; int colourFrom = mColor;
sColor = color; mColor = color;
sActiveColor = color; mActiveColor = color;
sPrefs.edit().putString(SettingsFragment.THEME, "" + color).apply(); mPrefs.edit().putString(SettingsFragment.THEME, "" + color).apply();
setSentBubbleColored(sPrefs.getBoolean(SettingsFragment.COLOUR_SENT, true)); setSentBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOUR_SENT, true));
setReceivedBubbleColored(sPrefs.getBoolean(SettingsFragment.COLOUR_RECEIVED, false)); setReceivedBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOUR_RECEIVED, false));
sTextOnColorPrimary = sResources.getColor(isColorDarkEnough(sColor) ? mTextOnColorPrimary = mResources.getColor(isColorDarkEnough(mColor) ?
R.color.theme_dark_text_primary : R.color.theme_light_text_primary); R.color.theme_dark_text_primary : R.color.theme_light_text_primary);
sTextOnColorSecondary = sResources.getColor(isColorDarkEnough(sColor) ? mTextOnColorSecondary = mResources.getColor(isColorDarkEnough(mColor) ?
R.color.theme_dark_text_secondary : R.color.theme_light_text_secondary); R.color.theme_dark_text_secondary : R.color.theme_light_text_secondary);
// Some views are updated every frame of the animation; get these views here. We // Some views are updated every frame of the animation; get these views here. We
@@ -663,10 +675,10 @@ public class ThemeManager {
} }
} }
if (sStatusTintEnabled) { if (mStatusTintEnabled) {
mWindow.setStatusBarColor(ColorUtils.darken(color1)); mWindow.setStatusBarColor(ColorUtils.darken(color1));
} }
if (sNavigationTintEnabled) { if (mNavigationTintEnabled) {
mWindow.setNavigationBarColor(ColorUtils.darken(color1)); mWindow.setNavigationBarColor(ColorUtils.darken(color1));
} }
}); });
@@ -684,8 +696,8 @@ public class ThemeManager {
//final Toolbar toolbar = (Toolbar) mActivity.findViewById(R.id.title); //final Toolbar toolbar = (Toolbar) mActivity.findViewById(R.id.title);
final QKTextView title = (QKTextView) mActivity.findViewById(R.id.toolbar_title); final QKTextView title = (QKTextView) mActivity.findViewById(R.id.toolbar_title);
if (title.getCurrentTextColor() != ThemeManager.sTextOnColorPrimary) { if (title.getCurrentTextColor() != mTextOnColorPrimary) {
ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), title.getCurrentTextColor(), ThemeManager.sTextOnColorPrimary); ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), title.getCurrentTextColor(), mTextOnColorPrimary);
titleColorAnimation.setDuration(TRANSITION_LENGTH); titleColorAnimation.setDuration(TRANSITION_LENGTH);
titleColorAnimation.setInterpolator(new DecelerateInterpolator()); titleColorAnimation.setInterpolator(new DecelerateInterpolator());
titleColorAnimation.addUpdateListener(animation -> { titleColorAnimation.addUpdateListener(animation -> {
@@ -698,18 +710,18 @@ public class ThemeManager {
} }
} }
public static void setActiveColor(int color) { public void setActiveColor(int color) {
sActiveColor = color; mActiveColor = color;
if (mActivity != null) { if (mActivity != null) {
if (mActivity.getSupportActionBar() != null) { if (mActivity.getSupportActionBar() != null) {
mActivity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color)); mActivity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
} }
} }
if (sStatusTintEnabled) { if (mStatusTintEnabled) {
mWindow.setStatusBarColor(ColorUtils.darken(color)); mWindow.setStatusBarColor(ColorUtils.darken(color));
} }
if (sNavigationTintEnabled) { if (mNavigationTintEnabled) {
mWindow.setNavigationBarColor(ColorUtils.darken(color)); mWindow.setNavigationBarColor(ColorUtils.darken(color));
} }
@@ -718,7 +730,7 @@ public class ThemeManager {
} }
} }
private static boolean isColorDarkEnough(int color) { private boolean isColorDarkEnough(int color) {
for (int i = 0; i < COLOURS.length; i++) { for (int i = 0; i < COLOURS.length; i++) {
for (int j = 0; j < COLOURS[i].length; j++) { for (int j = 0; j < COLOURS[i].length; j++) {
if (color == COLOURS[i][j]) { if (color == COLOURS[i][j]) {
@@ -730,7 +742,7 @@ public class ThemeManager {
return true; return true;
} }
public static int getSwatchColour(int colour) { public int getSwatchColour(int colour) {
for (int i = 0; i < COLOURS.length; i++) { for (int i = 0; i < COLOURS.length; i++) {
for (int j = 0; j < COLOURS[i].length; j++) { for (int j = 0; j < COLOURS[i].length; j++) {
if (colour == COLOURS[i][j]) { if (colour == COLOURS[i][j]) {
@@ -742,7 +754,7 @@ public class ThemeManager {
return colour; return colour;
} }
private static int[] getSwatch(int colour) { private int[] getSwatch(int colour) {
for (int[] swatch : COLOURS) { for (int[] swatch : COLOURS) {
for (int swatchColor : swatch) { for (int swatchColor : swatch) {
if (colour == swatchColor) { if (colour == swatchColor) {
@@ -72,7 +72,7 @@ public abstract class QKActivity extends ActionBarActivity {
setSupportActionBar(mToolbar); setSupportActionBar(mToolbar);
} }
ThemeManager.loadThemeProperties(this); ThemeManager.getInstance().loadThemeProperties(this);
} }
protected void showBackButton(boolean show) { protected void showBackButton(boolean show) {
@@ -173,7 +173,7 @@ public abstract class QKActivity extends ActionBarActivity {
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
// Save a reference to the menu so that we can quickly access menu icons later. // Save a reference to the menu so that we can quickly access menu icons later.
mMenu = menu; mMenu = menu;
colorMenuIcons(mMenu, ThemeManager.getTextOnColorPrimary()); colorMenuIcons(mMenu, ThemeManager.getInstance().getTextOnColorPrimary());
return true; return true;
} }
@@ -102,7 +102,7 @@ public abstract class QKContentFragment extends QKFragment implements LiveView,
public void refresh() { public void refresh() {
View view = getView(); View view = getView();
if (view != null) { if (view != null) {
view.setBackgroundColor(ThemeManager.getBackgroundColor()); view.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor());
} }
} }
} }
@@ -37,7 +37,7 @@ public class QKFragment extends Fragment implements LiveView {
@Override @Override
public void refresh() { public void refresh() {
if (getView() != null) { if (getView() != null) {
getView().setBackgroundColor(ThemeManager.getBackgroundColor()); getView().setBackgroundColor(ThemeManager.getInstance().getBackgroundColor());
} }
} }
} }
@@ -29,9 +29,9 @@ public abstract class QKPopupActivity extends QKActivity {
setFinishOnTouchOutside(mPrefs.getBoolean(SettingsFragment.QUICKREPLY_TAP_DISMISS, true)); setFinishOnTouchOutside(mPrefs.getBoolean(SettingsFragment.QUICKREPLY_TAP_DISMISS, true));
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
setContentView(getLayoutResource()); setContentView(getLayoutResource());
ThemeManager.loadThemeProperties(this); ThemeManager.getInstance().loadThemeProperties(this);
((QKLinearLayout) findViewById(R.id.popup)).setBackgroundTint(ThemeManager.getBackgroundColor()); ((QKLinearLayout) findViewById(R.id.popup)).setBackgroundTint(ThemeManager.getInstance().getBackgroundColor());
View title = findViewById(R.id.title); View title = findViewById(R.id.title);
if (title != null && title instanceof AppCompatTextView) { if (title != null && title instanceof AppCompatTextView) {
@@ -80,23 +80,23 @@ public class ConversationListAdapter extends RecyclerCursorAdapter<ConversationL
if (conversation.hasUnreadMessages()) { if (conversation.hasUnreadMessages()) {
holder.unreadView.setVisibility(View.VISIBLE); holder.unreadView.setVisibility(View.VISIBLE);
holder.snippetView.setTextColor(ThemeManager.getTextOnBackgroundPrimary()); holder.snippetView.setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary());
holder.dateView.setTextColor(ThemeManager.getColor()); holder.dateView.setTextColor(ThemeManager.getInstance().getColor());
} else { } else {
holder.unreadView.setVisibility(View.GONE); holder.unreadView.setVisibility(View.GONE);
holder.snippetView.setTextColor(ThemeManager.getTextOnBackgroundSecondary()); holder.snippetView.setTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary());
holder.dateView.setTextColor(ThemeManager.getTextOnBackgroundSecondary()); holder.dateView.setTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary());
} }
if (isInMultiSelectMode()) { if (isInMultiSelectMode()) {
holder.mSelected.setVisibility(View.VISIBLE); holder.mSelected.setVisibility(View.VISIBLE);
if (isSelected(conversation.getThreadId())) { if (isSelected(conversation.getThreadId())) {
holder.mSelected.setImageResource(R.drawable.ic_selected); holder.mSelected.setImageResource(R.drawable.ic_selected);
holder.mSelected.setColorFilter(ThemeManager.getColor()); holder.mSelected.setColorFilter(ThemeManager.getInstance().getColor());
holder.mSelected.setAlpha(1f); holder.mSelected.setAlpha(1f);
} else { } else {
holder.mSelected.setImageResource(R.drawable.ic_unselected); holder.mSelected.setImageResource(R.drawable.ic_unselected);
holder.mSelected.setColorFilter(ThemeManager.getTextOnBackgroundSecondary()); holder.mSelected.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary());
holder.mSelected.setAlpha(0.5f); holder.mSelected.setAlpha(0.5f);
} }
} else { } else {
@@ -127,9 +127,9 @@ public class ConversationListAdapter extends RecyclerCursorAdapter<ConversationL
@Override @Override
public void refresh() { public void refresh() {
mMuted.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP); mMuted.setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP);
mUnread.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP); mUnread.setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP);
mError.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP); mError.setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP);
notifyDataSetChanged(); notifyDataSetChanged();
} }
} }
@@ -88,16 +88,16 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
View view = inflater.inflate(R.layout.fragment_conversations, null); View view = inflater.inflate(R.layout.fragment_conversations, null);
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
mEmptyStateIcon.setColorFilter(ThemeManager.getTextOnBackgroundPrimary()); mEmptyStateIcon.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundPrimary());
mRecyclerView.setHasFixedSize(true); mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mAdapter); mRecyclerView.setAdapter(mAdapter);
mFab.setColorNormal(ThemeManager.getColor()); mFab.setColorNormal(ThemeManager.getInstance().getColor());
mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getColor())); mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getInstance().getColor()));
mFab.attachToRecyclerView(mRecyclerView); mFab.attachToRecyclerView(mRecyclerView);
mFab.setColorFilter(ThemeManager.getTextOnColorPrimary()); mFab.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary());
mFab.setOnClickListener(v -> { mFab.setOnClickListener(v -> {
if (mAdapter.isInMultiSelectMode()) { if (mAdapter.isInMultiSelectMode()) {
mAdapter.disableMultiSelectMode(true); mAdapter.disableMultiSelectMode(true);
@@ -307,11 +307,11 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
return; return;
} }
mFab.setColorNormal(ThemeManager.getColor()); mFab.setColorNormal(ThemeManager.getInstance().getColor());
mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getColor())); mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getInstance().getColor()));
mFab.getDrawable().setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mFab.getDrawable().setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mEmptyStateIcon.setColorFilter(ThemeManager.getTextOnBackgroundPrimary()); mEmptyStateIcon.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundPrimary());
} }
@Override @Override
@@ -110,7 +110,7 @@ public class ConversationListViewHolder extends ClickyViewHolder<Conversation> i
buf.append(mContext.getResources().getString(R.string.draft_separator)); buf.append(mContext.getResources().getString(R.string.draft_separator));
int before = buf.length(); int before = buf.length();
buf.append(mContext.getResources().getString(R.string.has_draft)); buf.append(mContext.getResources().getString(R.string.has_draft));
buf.setSpan(new ForegroundColorSpan(ThemeManager.getColor()), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); buf.setSpan(new ForegroundColorSpan(ThemeManager.getInstance().getColor()), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
} }
return buf; return buf;
@@ -27,24 +27,24 @@ public class BubblePreferenceDialog extends QKDialog {
View view = mContext.getLayoutInflater().inflate(R.layout.dialog_bubbles, null); View view = mContext.getLayoutInflater().inflate(R.layout.dialog_bubbles, null);
final QKTextView in1 = (QKTextView) view.findViewById(R.id.in_1); final QKTextView in1 = (QKTextView) view.findViewById(R.id.in_1);
in1.setBackgroundResource(ThemeManager.getReceivedBubbleRes()); in1.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleRes());
in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in1.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); in1.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor());
final QKTextView in2 = (QKTextView) view.findViewById(R.id.in_2); final QKTextView in2 = (QKTextView) view.findViewById(R.id.in_2);
in2.setBackgroundResource(ThemeManager.getReceivedBubbleAltRes()); in2.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleAltRes());
in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in2.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); in2.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor());
final QKTextView out1 = (QKTextView) view.findViewById(R.id.out_1); final QKTextView out1 = (QKTextView) view.findViewById(R.id.out_1);
out1.setBackgroundResource(ThemeManager.getSentBubbleRes()); out1.setBackgroundResource(ThemeManager.getInstance().getSentBubbleRes());
out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out1.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); out1.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor());
final QKTextView out2 = (QKTextView) view.findViewById(R.id.out_2); final QKTextView out2 = (QKTextView) view.findViewById(R.id.out_2);
out2.setBackgroundResource(ThemeManager.getSentBubbleAltRes()); out2.setBackgroundResource(ThemeManager.getInstance().getSentBubbleAltRes());
out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out2.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); out2.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor());
Preference.OnPreferenceClickListener onPreferenceClickListener = new Preference.OnPreferenceClickListener() { Preference.OnPreferenceClickListener onPreferenceClickListener = new Preference.OnPreferenceClickListener() {
@Override @Override
@@ -52,38 +52,38 @@ public class BubblePreferenceDialog extends QKDialog {
Log.d(TAG, preference.getKey()); Log.d(TAG, preference.getKey());
switch (preference.getKey()) { switch (preference.getKey()) {
case SettingsFragment.BUBBLES_NEW: case SettingsFragment.BUBBLES_NEW:
ThemeManager.setBubbleStyleNew(((QKSwitchPreference) preference).isChecked()); ThemeManager.getInstance().setBubbleStyleNew(((QKSwitchPreference) preference).isChecked());
in1.setBackgroundResource(ThemeManager.getReceivedBubbleRes()); in1.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleRes());
in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in1.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); in1.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor());
in2.setBackgroundResource(ThemeManager.getReceivedBubbleAltRes()); in2.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleAltRes());
in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in2.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); in2.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor());
out1.setBackgroundResource(ThemeManager.getSentBubbleRes()); out1.setBackgroundResource(ThemeManager.getInstance().getSentBubbleRes());
out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out1.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); out1.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor());
out2.setBackgroundResource(ThemeManager.getSentBubbleAltRes()); out2.setBackgroundResource(ThemeManager.getInstance().getSentBubbleAltRes());
out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out2.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); out2.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor());
return true; return true;
case SettingsFragment.COLOUR_RECEIVED: case SettingsFragment.COLOUR_RECEIVED:
ThemeManager.setReceivedBubbleColored(((QKSwitchPreference) preference).isChecked()); ThemeManager.getInstance().setReceivedBubbleColored(((QKSwitchPreference) preference).isChecked());
in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in1.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); in1.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor());
in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in2.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); in2.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor());
return true; return true;
case SettingsFragment.COLOUR_SENT: case SettingsFragment.COLOUR_SENT:
ThemeManager.setSentBubbleColored(((QKSwitchPreference) preference).isChecked()); ThemeManager.getInstance().setSentBubbleColored(((QKSwitchPreference) preference).isChecked());
out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out1.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); out1.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor());
out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out2.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); out2.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor());
return true; return true;
} }
return false; return false;
@@ -45,7 +45,7 @@ public class DefaultSmsHelper implements ActionClickListener {
.type(getSnackBarType()) .type(getSnackBarType())
.text(mMessage) .text(mMessage)
.duration(duration) .duration(duration)
.actionColor(ThemeManager.getColor()) .actionColor(ThemeManager.getInstance().getColor())
.actionLabel(R.string.upgrade_now) .actionLabel(R.string.upgrade_now)
.actionListener(this); .actionListener(this);
@@ -130,7 +130,7 @@ public class QKDialog extends DialogFragment {
mPositiveButtonView = (QKTextView) view.findViewById(R.id.buttonPositive); mPositiveButtonView = (QKTextView) view.findViewById(R.id.buttonPositive);
mPositiveButtonView.setVisibility(View.VISIBLE); mPositiveButtonView.setVisibility(View.VISIBLE);
mPositiveButtonView.setText(mPositiveButtonText); mPositiveButtonView.setText(mPositiveButtonText);
mPositiveButtonView.setTextColor(ThemeManager.getColor()); mPositiveButtonView.setTextColor(ThemeManager.getInstance().getColor());
mPositiveButtonView.setOnClickListener(mPositiveButtonClickListener); mPositiveButtonView.setOnClickListener(mPositiveButtonClickListener);
} }
@@ -443,11 +443,11 @@ public class QKDialog extends DialogFragment {
} }
QKTextView title = (QKTextView) convertView.findViewById(R.id.list_item_title); QKTextView title = (QKTextView) convertView.findViewById(R.id.list_item_title);
title.setTextColor(ThemeManager.getColor()); title.setTextColor(ThemeManager.getInstance().getColor());
title.setText(getItem(position).title); title.setText(getItem(position).title);
QKTextView subtitle = (QKTextView) convertView.findViewById(R.id.list_item_subtitle); QKTextView subtitle = (QKTextView) convertView.findViewById(R.id.list_item_subtitle);
subtitle.setTextColor(ThemeManager.getTextOnBackgroundPrimary()); subtitle.setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary());
subtitle.setText(getItem(position).subtitle); subtitle.setText(getItem(position).subtitle);
((QKTextView) convertView.findViewById(R.id.list_item_body)) ((QKTextView) convertView.findViewById(R.id.list_item_body))
@@ -190,7 +190,7 @@ public class MMSDialogFragment extends DialogFragment {
mPositiveButtonView = (QKTextView) view.findViewById(R.id.buttonPositive); mPositiveButtonView = (QKTextView) view.findViewById(R.id.buttonPositive);
mPositiveButtonView.setVisibility(View.VISIBLE); mPositiveButtonView.setVisibility(View.VISIBLE);
mPositiveButtonView.setText(mPositiveButtonText); mPositiveButtonView.setText(mPositiveButtonText);
mPositiveButtonView.setTextColor(ThemeManager.getColor()); mPositiveButtonView.setTextColor(ThemeManager.getInstance().getColor());
mPositiveButtonView.setOnClickListener(new View.OnClickListener() { mPositiveButtonView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@@ -465,11 +465,11 @@ public class MMSDialogFragment extends DialogFragment {
} }
QKTextView title = (QKTextView) convertView.findViewById(R.id.list_item_title); QKTextView title = (QKTextView) convertView.findViewById(R.id.list_item_title);
title.setTextColor(ThemeManager.getColor()); title.setTextColor(ThemeManager.getInstance().getColor());
title.setText(getItem(position).title); title.setText(getItem(position).title);
QKTextView subtitle = (QKTextView) convertView.findViewById(R.id.list_item_subtitle); QKTextView subtitle = (QKTextView) convertView.findViewById(R.id.list_item_subtitle);
subtitle.setTextColor(ThemeManager.getTextOnBackgroundPrimary()); subtitle.setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary());
subtitle.setText(getItem(position).subtitle); subtitle.setText(getItem(position).subtitle);
((QKTextView) convertView.findViewById(R.id.list_item_body)) ((QKTextView) convertView.findViewById(R.id.list_item_body))
@@ -130,10 +130,10 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
if (sent) { if (sent) {
// set up colors // set up colors
holder.mBodyTextView.setOnColorBackground(ThemeManager.getSentBubbleColor() != ThemeManager.getNeutralBubbleColor()); holder.mBodyTextView.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() != ThemeManager.getInstance().getNeutralBubbleColor());
holder.mDateView.setOnColorBackground(false); holder.mDateView.setOnColorBackground(false);
holder.mDeliveredIndicator.setColorFilter(ThemeManager.getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); holder.mDeliveredIndicator.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP);
holder.mLockedIndicator.setColorFilter(ThemeManager.getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); holder.mLockedIndicator.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP);
// set up avatar // set up avatar
holder.mAvatarView.setImageDrawable(Contact.getMe(true).getAvatar(mContext, null)); holder.mAvatarView.setImageDrawable(Contact.getMe(true).getAvatar(mContext, null));
@@ -145,10 +145,10 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
} }
} else { } else {
// set up colors // set up colors
holder.mBodyTextView.setOnColorBackground(ThemeManager.getReceivedBubbleColor() != ThemeManager.getNeutralBubbleColor()); holder.mBodyTextView.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() != ThemeManager.getInstance().getNeutralBubbleColor());
holder.mDateView.setOnColorBackground(false); holder.mDateView.setOnColorBackground(false);
holder.mDeliveredIndicator.setColorFilter(ThemeManager.getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); holder.mDeliveredIndicator.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP);
holder.mLockedIndicator.setColorFilter(ThemeManager.getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); holder.mLockedIndicator.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP);
// set up avatar // set up avatar
if (mPrefs.getBoolean(SettingsFragment.HIDE_AVATAR_RECEIVED, false)) { if (mPrefs.getBoolean(SettingsFragment.HIDE_AVATAR_RECEIVED, false)) {
@@ -302,15 +302,15 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
holder.mDateView.setVisibility(showTimestamp ? View.VISIBLE : View.GONE); holder.mDateView.setVisibility(showTimestamp ? View.VISIBLE : View.GONE);
holder.mSpace.setVisibility(showAvatar ? View.VISIBLE : View.GONE); holder.mSpace.setVisibility(showAvatar ? View.VISIBLE : View.GONE);
holder.mBodyTextView.setBackgroundResource(showAvatar ? (messageItem.isMe() ? ThemeManager.getSentBubbleRes() : holder.mBodyTextView.setBackgroundResource(showAvatar ? (messageItem.isMe() ? ThemeManager.getInstance().getSentBubbleRes() :
ThemeManager.getReceivedBubbleRes()) : (messageItem.isMe() ? ThemeManager.getInstance().getReceivedBubbleRes()) : (messageItem.isMe() ?
ThemeManager.getSentBubbleAltRes() : ThemeManager.getReceivedBubbleAltRes())); ThemeManager.getInstance().getSentBubbleAltRes() : ThemeManager.getInstance().getReceivedBubbleAltRes()));
holder.setLiveViewCallback(() -> { holder.setLiveViewCallback(() -> {
if (messageItem.isMe()) { if (messageItem.isMe()) {
holder.mBodyTextView.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); holder.mBodyTextView.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
} else { } else {
holder.mBodyTextView.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); holder.mBodyTextView.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
} }
}); });
holder.refresh(); holder.refresh();
@@ -762,7 +762,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
mSensorManager.registerListener(this, mProxSensor, SensorManager.SENSOR_DELAY_NORMAL); mSensorManager.registerListener(this, mProxSensor, SensorManager.SENSOR_DELAY_NORMAL);
} }
ThemeManager.setActiveColor(mConversationPrefs.getColor()); ThemeManager.getInstance().setActiveColor(mConversationPrefs.getColor());
} }
@Override @Override
@@ -787,14 +787,14 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
} }
} }
ThemeManager.setActiveColor(ThemeManager.getThemeColor()); ThemeManager.getInstance().setActiveColor(ThemeManager.getInstance().getThemeColor());
} }
@Override @Override
public void onMenuChanging(float percentOpen) { public void onMenuChanging(float percentOpen) {
if (mConversationPrefs != null) { if (mConversationPrefs != null) {
ThemeManager.setActiveColor((int) mArgbEvaluator.evaluate( ThemeManager.getInstance().setActiveColor((int) mArgbEvaluator.evaluate(
percentOpen, 0xFF000000 | mConversationPrefs.getColor(), 0xFF000000 | ThemeManager.getThemeColor())); percentOpen, 0xFF000000 | mConversationPrefs.getColor(), 0xFF000000 | ThemeManager.getInstance().getThemeColor()));
} }
} }
@@ -381,7 +381,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
String valueString = newValue == null ? "null" : newValue.toString(); String valueString = newValue == null ? "null" : newValue.toString();
if (key.equals(NOTIFICATION_LED_COLOR)) { if (key.equals(NOTIFICATION_LED_COLOR)) {
// Format the color as a nice string if it's the LED color. // Format the color as a nice string if it's the LED color.
valueString = ThemeManager.getColorString(Integer.parseInt(valueString)); valueString = ThemeManager.getInstance().getColorString(Integer.parseInt(valueString));
} }
Log.d(TAG, "onPreferenceChange key:" + key + " newValue: " + valueString); Log.d(TAG, "onPreferenceChange key:" + key + " newValue: " + valueString);
@@ -393,13 +393,13 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
switch (key) { switch (key) {
case BACKGROUND: case BACKGROUND:
ThemeManager.setTheme(ThemeManager.Theme.fromString((String) newValue)); ThemeManager.getInstance().setTheme(ThemeManager.Theme.fromString((String) newValue));
break; break;
case STATUS_TINT: case STATUS_TINT:
ThemeManager.setStatusBarTintEnabled((Boolean) newValue); ThemeManager.getInstance().setStatusBarTintEnabled((Boolean) newValue);
break; break;
case NAVIGATION_TINT: case NAVIGATION_TINT:
ThemeManager.setNavigationBarTintEnabled((Boolean) newValue); ThemeManager.getInstance().setNavigationBarTintEnabled((Boolean) newValue);
break; break;
case FONT_FAMILY: case FONT_FAMILY:
preference.setSummary(mFontFamilies[Integer.parseInt("" + newValue)]); preference.setSummary(mFontFamilies[Integer.parseInt("" + newValue)]);
@@ -412,10 +412,10 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
preference.setSummary(mFontWeights[i == 2 ? 0 : 1]); preference.setSummary(mFontWeights[i == 2 ? 0 : 1]);
break; break;
case COLOUR_SENT: case COLOUR_SENT:
ThemeManager.setSentBubbleColored((Boolean) newValue); ThemeManager.getInstance().setSentBubbleColored((Boolean) newValue);
break; break;
case COLOUR_RECEIVED: case COLOUR_RECEIVED:
ThemeManager.setReceivedBubbleColored((Boolean) newValue); ThemeManager.getInstance().setReceivedBubbleColored((Boolean) newValue);
break; break;
case NIGHT_AUTO: case NIGHT_AUTO:
updateAlarmManager(mContext, (Boolean) newValue); updateAlarmManager(mContext, (Boolean) newValue);
@@ -519,13 +519,13 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
switch (key) { switch (key) {
case THEME: case THEME:
ThemeManager.showColourSwatchesDialog(mContext); ThemeManager.getInstance().showColourSwatchesDialog(mContext);
break; break;
case BUBBLES: case BUBBLES:
new BubblePreferenceDialog().setContext(mContext).show(); new BubblePreferenceDialog().setContext(mContext).show();
break; break;
case ICON: case ICON:
ThemeManager.setIcon(mContext); ThemeManager.getInstance().setIcon(mContext);
break; break;
case BLOCKED_FUTURE: case BLOCKED_FUTURE:
BlockedNumberDialog.showDialog(mContext); BlockedNumberDialog.showDialog(mContext);
@@ -701,7 +701,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
View view = getView(); View view = getView();
if (view != null) { if (view != null) {
view.setBackgroundColor(ThemeManager.getBackgroundColor()); view.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor());
} }
} }
@@ -61,8 +61,8 @@ public class AutoCompleteContactView extends RecipientEditTextView implements Li
FontManager.getFontWeight(mContext, false))); FontManager.getFontWeight(mContext, false)));
setTextSize(TypedValue.COMPLEX_UNIT_SP, FontManager.getTextSize(mContext, FontManager.TEXT_TYPE_PRIMARY)); setTextSize(TypedValue.COMPLEX_UNIT_SP, FontManager.getTextSize(mContext, FontManager.TEXT_TYPE_PRIMARY));
setTextColor(ThemeManager.getTextOnBackgroundPrimary()); setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary());
setHintTextColor(ThemeManager.getTextOnBackgroundSecondary()); setHintTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary());
if (mAdapter != null) { if (mAdapter != null) {
SharedPreferences prefs = mContext.getPrefs(); SharedPreferences prefs = mContext.getPrefs();
@@ -261,7 +261,7 @@ public class AvatarView extends ImageView implements View.OnClickListener, LiveV
getBackground().setColorFilter(0x00000000, PorterDuff.Mode.SRC_ATOP); getBackground().setColorFilter(0x00000000, PorterDuff.Mode.SRC_ATOP);
} else { } else {
super.setImageDrawable(TextUtils.isEmpty(mInitial) ? mDefaultDrawable : null); super.setImageDrawable(TextUtils.isEmpty(mInitial) ? mDefaultDrawable : null);
getBackground().setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP); getBackground().setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP);
} }
} }
} }
@@ -279,13 +279,13 @@ public class AvatarView extends ImageView implements View.OnClickListener, LiveV
@Override @Override
public void refresh() { public void refresh() {
mPaint.setColor(ThemeManager.getTextOnColorPrimary()); mPaint.setColor(ThemeManager.getInstance().getTextOnColorPrimary());
mDefaultDrawable.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mDefaultDrawable.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
if (getBackground() == null) { if (getBackground() == null) {
setBackgroundResource(R.drawable.circle); setBackgroundResource(R.drawable.circle);
} }
getBackground().setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP); getBackground().setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP);
} }
private class QueryHandler extends AsyncQueryHandler { private class QueryHandler extends AsyncQueryHandler {
@@ -951,24 +951,24 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L
@Override @Override
public void refresh() { public void refresh() {
mButtonBackground.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP); mButtonBackground.setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP);
mButtonBar1.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mButtonBar1.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mButtonBar2.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mButtonBar2.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mAttachmentPanel.setBackgroundColor(ThemeManager.getColor()); mAttachmentPanel.setBackgroundColor(ThemeManager.getInstance().getColor());
mAttach.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mAttach.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mCamera.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mCamera.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
updateDelayButton(); updateDelayButton();
mProgress.setUnfinishedStrokeColor(ThemeManager.getTextOnColorSecondary()); mProgress.setUnfinishedStrokeColor(ThemeManager.getInstance().getTextOnColorSecondary());
mProgress.setFinishedStrokeColor(ThemeManager.getTextOnColorPrimary()); mProgress.setFinishedStrokeColor(ThemeManager.getInstance().getTextOnColorPrimary());
if (ThemeManager.getSentBubbleRes() != 0) mReplyText.setBackgroundResource(ThemeManager.getSentBubbleRes()); if (ThemeManager.getInstance().getSentBubbleRes() != 0) mReplyText.setBackgroundResource(ThemeManager.getInstance().getSentBubbleRes());
mReplyText.getBackground().setColorFilter(ThemeManager.getNeutralBubbleColor(), PorterDuff.Mode.SRC_ATOP); mReplyText.getBackground().setColorFilter(ThemeManager.getInstance().getNeutralBubbleColor(), PorterDuff.Mode.SRC_ATOP);
mReplyText.refresh(); mReplyText.refresh();
getBackground().setColorFilter(ThemeManager.getBackgroundColor(), PorterDuff.Mode.SRC_ATOP); getBackground().setColorFilter(ThemeManager.getInstance().getBackgroundColor(), PorterDuff.Mode.SRC_ATOP);
} }
private void updateDelayButton() { private void updateDelayButton() {
mDelay.setColorFilter(mDelayedMessagingEnabled ? mDelay.setColorFilter(mDelayedMessagingEnabled ?
ThemeManager.getTextOnColorPrimary() : ThemeManager.getTextOnColorSecondary(), ThemeManager.getInstance().getTextOnColorPrimary() : ThemeManager.getInstance().getTextOnColorSecondary(),
PorterDuff.Mode.SRC_ATOP); PorterDuff.Mode.SRC_ATOP);
} }
} }
@@ -99,8 +99,8 @@ public class QKEditText extends android.widget.EditText implements LiveView {
int fontWeight = FontManager.getFontWeight(mContext, false); int fontWeight = FontManager.getFontWeight(mContext, false);
setTypeface(TypefaceManager.obtainTypeface(mContext, fontFamily, fontWeight setTypeface(TypefaceManager.obtainTypeface(mContext, fontFamily, fontWeight
)); ));
setTextColor(ThemeManager.getTextOnBackgroundPrimary()); setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary());
setHintTextColor(ThemeManager.getTextOnBackgroundSecondary()); setHintTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary());
// Text size // Text size
int sp = FontManager.getTextSize(mContext, FontManager.TEXT_TYPE_PRIMARY); int sp = FontManager.getTextSize(mContext, FontManager.TEXT_TYPE_PRIMARY);
@@ -44,7 +44,7 @@ public class QKImageView extends ImageView implements LiveView {
mDrawable = drawable; mDrawable = drawable;
if (mDrawable != null) { if (mDrawable != null) {
mDrawable.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP); mDrawable.setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP);
super.setImageDrawable(drawable); super.setImageDrawable(drawable);
} }
} }
@@ -50,16 +50,16 @@ public class QKSwitch extends SwitchCompat implements LiveView {
// Disabled state // Disabled state
states[0] = new int[]{-android.R.attr.state_enabled}; states[0] = new int[]{-android.R.attr.state_enabled};
colors[0] = mRes.getColor(ThemeManager.isNightMode() ? colors[0] = mRes.getColor(ThemeManager.getInstance().isNightMode() ?
R.color.switch_thumb_disabled_dark : R.color.switch_thumb_disabled_light); R.color.switch_thumb_disabled_dark : R.color.switch_thumb_disabled_light);
// Checked state // Checked state
states[1] = new int[]{android.R.attr.state_checked}; states[1] = new int[]{android.R.attr.state_checked};
colors[1] = ThemeManager.getColor(); colors[1] = ThemeManager.getInstance().getColor();
// Unchecked enabled state state // Unchecked enabled state state
states[2] = new int[0]; states[2] = new int[0];
colors[2] = mRes.getColor(ThemeManager.isNightMode() ? colors[2] = mRes.getColor(ThemeManager.getInstance().isNightMode() ?
R.color.switch_thumb_enabled_dark : R.color.switch_thumb_enabled_light); R.color.switch_thumb_enabled_dark : R.color.switch_thumb_enabled_light);
return new ColorStateList(states, colors); return new ColorStateList(states, colors);
@@ -71,19 +71,19 @@ public class QKSwitch extends SwitchCompat implements LiveView {
// Disabled state // Disabled state
states[0] = new int[]{-android.R.attr.state_enabled}; states[0] = new int[]{-android.R.attr.state_enabled};
colors[0] = mRes.getColor(ThemeManager.isNightMode() ? colors[0] = mRes.getColor(ThemeManager.getInstance().isNightMode() ?
R.color.switch_track_disabled_dark : R.color.switch_track_disabled_light); R.color.switch_track_disabled_dark : R.color.switch_track_disabled_light);
// Checked state // Checked state
states[1] = new int[]{android.R.attr.state_checked}; states[1] = new int[]{android.R.attr.state_checked};
colors[1] = Color.argb(0x4D, // 30% alpha colors[1] = Color.argb(0x4D, // 30% alpha
Color.red(ThemeManager.getColor()), Color.red(ThemeManager.getInstance().getColor()),
Color.green(ThemeManager.getColor()), Color.green(ThemeManager.getInstance().getColor()),
Color.blue(ThemeManager.getColor())); Color.blue(ThemeManager.getInstance().getColor()));
// Unchecked enabled state state // Unchecked enabled state state
states[2] = new int[0]; states[2] = new int[0];
colors[2] = mRes.getColor(ThemeManager.isNightMode() ? colors[2] = mRes.getColor(ThemeManager.getInstance().isNightMode() ?
R.color.switch_track_enabled_dark : R.color.switch_track_enabled_light); R.color.switch_track_enabled_dark : R.color.switch_track_enabled_light);
return new ColorStateList(states, colors); return new ColorStateList(states, colors);
@@ -106,19 +106,19 @@ public class QKTextView extends TextView implements LiveView {
if (onColorBackground) { if (onColorBackground) {
if (mType == FontManager.TEXT_TYPE_PRIMARY) { if (mType == FontManager.TEXT_TYPE_PRIMARY) {
setTextColor(ThemeManager.getTextOnColorPrimary()); setTextColor(ThemeManager.getInstance().getTextOnColorPrimary());
setLinkTextColor(ThemeManager.getTextOnColorPrimary()); setLinkTextColor(ThemeManager.getInstance().getTextOnColorPrimary());
} else if (mType == FontManager.TEXT_TYPE_SECONDARY || } else if (mType == FontManager.TEXT_TYPE_SECONDARY ||
mType == FontManager.TEXT_TYPE_TERTIARY) { mType == FontManager.TEXT_TYPE_TERTIARY) {
setTextColor(ThemeManager.getTextOnColorSecondary()); setTextColor(ThemeManager.getInstance().getTextOnColorSecondary());
} }
} else { } else {
if (mType == FontManager.TEXT_TYPE_PRIMARY) { if (mType == FontManager.TEXT_TYPE_PRIMARY) {
setTextColor(ThemeManager.getTextOnBackgroundPrimary()); setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary());
setLinkTextColor(ThemeManager.getColor()); setLinkTextColor(ThemeManager.getInstance().getColor());
} else if (mType == FontManager.TEXT_TYPE_SECONDARY || } else if (mType == FontManager.TEXT_TYPE_SECONDARY ||
mType == FontManager.TEXT_TYPE_TERTIARY) { mType == FontManager.TEXT_TYPE_TERTIARY) {
setTextColor(ThemeManager.getTextOnBackgroundSecondary()); setTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary());
} }
} }
} }
@@ -58,7 +58,7 @@ public class StarredContactsView extends LinearLayout implements LoaderManager.L
super.onFinishInflate(); super.onFinishInflate();
mFavoritesBackground = (LinearLayout) findViewById(R.id.starred_contacts); mFavoritesBackground = (LinearLayout) findViewById(R.id.starred_contacts);
mFavoritesBackground.setBackgroundColor(ThemeManager.getBackgroundColor()); mFavoritesBackground.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor());
mTitle = (QKTextView) findViewById(R.id.title); mTitle = (QKTextView) findViewById(R.id.title);
@@ -154,13 +154,13 @@ public class StarredContactsView extends LinearLayout implements LoaderManager.L
} }
public void expand() { public void expand() {
mTitle.setTextColor(ThemeManager.getTextOnBackgroundPrimary()); mTitle.setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary());
mFavorites.setVisibility(View.VISIBLE); mFavorites.setVisibility(View.VISIBLE);
mIndicator.setRotation(0f); mIndicator.setRotation(0f);
} }
public void collapse() { public void collapse() {
mTitle.setTextColor(ThemeManager.getTextOnBackgroundSecondary()); mTitle.setTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary());
mFavorites.setVisibility(View.GONE); mFavorites.setVisibility(View.GONE);
mIndicator.setRotation(90f); mIndicator.setRotation(90f);
} }
@@ -176,7 +176,7 @@ public class StarredContactsView extends LinearLayout implements LoaderManager.L
@Override @Override
public void refresh() { public void refresh() {
mIndicator.setColorFilter(ThemeManager.getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); mIndicator.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP);
mFavoritesBackground.setBackgroundColor(ThemeManager.getBackgroundColor()); mFavoritesBackground.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor());
} }
} }
@@ -38,7 +38,7 @@ public class WelcomeActivity extends QKActivity implements ViewPager.OnPageChang
getSupportActionBar().hide(); getSupportActionBar().hide();
mBackground = findViewById(R.id.welcome); mBackground = findViewById(R.id.welcome);
mBackground.setBackgroundColor(ThemeManager.getColor()); mBackground.setBackgroundColor(ThemeManager.getInstance().getColor());
mPrevious = (ImageView) findViewById(R.id.welcome_previous); mPrevious = (ImageView) findViewById(R.id.welcome_previous);
mPrevious.setOnClickListener(this); mPrevious.setOnClickListener(this);
@@ -63,8 +63,8 @@ public class WelcomeActivity extends QKActivity implements ViewPager.OnPageChang
} }
public void setColor(int color) { public void setColor(int color) {
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), ThemeManager.getColor(), color); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), ThemeManager.getInstance().getColor(), color);
colorAnimation.setDuration(ThemeManager.TRANSITION_LENGTH); colorAnimation.setDuration(ThemeManager.getInstance().TRANSITION_LENGTH);
colorAnimation.setInterpolator(new DecelerateInterpolator()); colorAnimation.setInterpolator(new DecelerateInterpolator());
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override @Override
@@ -74,7 +74,7 @@ public class WelcomeActivity extends QKActivity implements ViewPager.OnPageChang
}); });
colorAnimation.start(); colorAnimation.start();
ThemeManager.setColour(color); ThemeManager.getInstance().setColour(color);
} }
public void setColorBackground(int color) { public void setColorBackground(int color) {
@@ -43,8 +43,8 @@ public class WelcomeNightFragment extends BaseWelcomeFragment implements BaseWel
@Override @Override
public void onScrollOffsetChanged(WelcomeActivity activity, float offset) { public void onScrollOffsetChanged(WelcomeActivity activity, float offset) {
int colorBackground = (Integer) mArgbEvaluator.evaluate(Math.abs(offset), ThemeManager.getBackgroundColor(), ThemeManager.getColor()); int colorBackground = (Integer) mArgbEvaluator.evaluate(Math.abs(offset), ThemeManager.getInstance().getBackgroundColor(), ThemeManager.getInstance().getColor());
int colorAccent = (Integer) mArgbEvaluator.evaluate(1 - Math.abs(offset), 0xFFFFFFFF, ThemeManager.getColor()); int colorAccent = (Integer) mArgbEvaluator.evaluate(1 - Math.abs(offset), 0xFFFFFFFF, ThemeManager.getInstance().getColor());
activity.setColorBackground(colorBackground); activity.setColorBackground(colorBackground);
activity.tintIndicators(colorAccent); activity.tintIndicators(colorAccent);
@@ -66,14 +66,14 @@ public class WelcomeNightFragment extends BaseWelcomeFragment implements BaseWel
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (v.getId() == R.id.welcome_night_hint) { if (v.getId() == R.id.welcome_night_hint) {
boolean night = ThemeManager.getTheme() == ThemeManager.Theme.OFFWHITE; boolean night = ThemeManager.getInstance().getTheme() == ThemeManager.Theme.OFFWHITE;
int backgroundColor = mContext.getResources().getColor(night ? R.color.grey_light_mega_ultra : R.color.grey_material); int backgroundColor = mContext.getResources().getColor(night ? R.color.grey_light_mega_ultra : R.color.grey_material);
int newBackgroundColor = mContext.getResources().getColor(night ? R.color.grey_material : R.color.grey_light_mega_ultra); int newBackgroundColor = mContext.getResources().getColor(night ? R.color.grey_material : R.color.grey_light_mega_ultra);
ThemeManager.setTheme(night ? ThemeManager.Theme.GREY : ThemeManager.Theme.OFFWHITE); ThemeManager.getInstance().setTheme(night ? ThemeManager.Theme.GREY : ThemeManager.Theme.OFFWHITE);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), backgroundColor, newBackgroundColor); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), backgroundColor, newBackgroundColor);
colorAnimation.setDuration(ThemeManager.TRANSITION_LENGTH); colorAnimation.setDuration(ThemeManager.getInstance().TRANSITION_LENGTH);
colorAnimation.setInterpolator(new DecelerateInterpolator()); colorAnimation.setInterpolator(new DecelerateInterpolator());
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override @Override
@@ -21,7 +21,7 @@ public class WelcomeThemeFragment extends BaseWelcomeFragment implements ColorPi
mPallette = (ColorPickerPalette) view.findViewById(R.id.welcome_themes); mPallette = (ColorPickerPalette) view.findViewById(R.id.welcome_themes);
mPallette.init(19, 4, this); mPallette.init(19, 4, this);
mPallette.drawPalette(ThemeManager.PALETTE, ThemeManager.getColor()); mPallette.drawPalette(ThemeManager.getInstance().PALETTE, ThemeManager.getInstance().getColor());
return view; return view;
} }
@@ -29,7 +29,7 @@ public class WelcomeThemeFragment extends BaseWelcomeFragment implements ColorPi
@Override @Override
public void onColorSelected(int color) { public void onColorSelected(int color) {
((WelcomeActivity) getActivity()).setColor(color); ((WelcomeActivity) getActivity()).setColor(color);
mPallette.drawPalette(ThemeManager.PALETTE, color); mPallette.drawPalette(ThemeManager.getInstance().PALETTE, color);
} }
@Override @Override
@@ -45,7 +45,7 @@ public class WidgetProvider extends AppWidgetProvider {
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds); super.onUpdate(context, appWidgetManager, appWidgetIds);
ThemeManager.loadThemeProperties(context); ThemeManager.getInstance().loadThemeProperties(context);
for (int appWidgetId : appWidgetIds) { for (int appWidgetId : appWidgetIds) {
updateWidget(context, appWidgetId, isSmallWidget(appWidgetManager, appWidgetId)); updateWidget(context, appWidgetId, isSmallWidget(appWidgetManager, appWidgetId));
@@ -118,10 +118,10 @@ public class WidgetProvider extends AppWidgetProvider {
remoteViews.setRemoteAdapter(R.id.conversation_list, intent); remoteViews.setRemoteAdapter(R.id.conversation_list, intent);
remoteViews.setTextViewText(R.id.widget_label, context.getString(R.string.title_conversation_list)); remoteViews.setTextViewText(R.id.widget_label, context.getString(R.string.title_conversation_list));
remoteViews.setTextColor(R.id.widget_label, ThemeManager.getTextOnColorPrimary()); remoteViews.setTextColor(R.id.widget_label, ThemeManager.getInstance().getTextOnColorPrimary());
remoteViews.setInt(R.id.conversation_list_background, "setColorFilter", ThemeManager.getBackgroundColor()); remoteViews.setInt(R.id.conversation_list_background, "setColorFilter", ThemeManager.getInstance().getBackgroundColor());
remoteViews.setInt(R.id.header_background, "setColorFilter", ThemeManager.getColor()); remoteViews.setInt(R.id.header_background, "setColorFilter", ThemeManager.getInstance().getColor());
// Open Mms's app conversation list when click on header // Open Mms's app conversation list when click on header
final Intent convIntent = new Intent(context, MainActivity.class); final Intent convIntent = new Intent(context, MainActivity.class);
@@ -224,9 +224,9 @@ public class WidgetService extends RemoteViewsService {
} }
private void bindIndicators(RemoteViews remoteViews, Conversation conversation) { private void bindIndicators(RemoteViews remoteViews, Conversation conversation) {
remoteViews.setInt(R.id.muted, "setColorFilter", ThemeManager.getColor()); remoteViews.setInt(R.id.muted, "setColorFilter", ThemeManager.getInstance().getColor());
remoteViews.setInt(R.id.error, "setColorFilter", ThemeManager.getColor()); remoteViews.setInt(R.id.error, "setColorFilter", ThemeManager.getInstance().getColor());
remoteViews.setInt(R.id.unread, "setColorFilter", ThemeManager.getColor()); remoteViews.setInt(R.id.unread, "setColorFilter", ThemeManager.getInstance().getColor());
remoteViews.setViewVisibility(R.id.muted, new ConversationPrefsHelper(mContext, conversation.getThreadId()) remoteViews.setViewVisibility(R.id.muted, new ConversationPrefsHelper(mContext, conversation.getThreadId())
.getNotificationsEnabled() ? View.GONE : View.VISIBLE); .getNotificationsEnabled() ? View.GONE : View.VISIBLE);
remoteViews.setViewVisibility(R.id.error, conversation.hasError() ? View.VISIBLE : View.GONE); remoteViews.setViewVisibility(R.id.error, conversation.hasError() ? View.VISIBLE : View.GONE);
@@ -234,15 +234,15 @@ public class WidgetService extends RemoteViewsService {
} }
private void bindName(RemoteViews remoteViews, Conversation conversation) { private void bindName(RemoteViews remoteViews, Conversation conversation) {
SpannableStringBuilder from = addColor(conversation.getRecipients().formatNames(", "), ThemeManager.getTextOnBackgroundPrimary()); SpannableStringBuilder from = addColor(conversation.getRecipients().formatNames(", "), ThemeManager.getInstance().getTextOnBackgroundPrimary());
if (conversation.hasDraft()) { if (conversation.hasDraft()) {
from.append(mContext.getResources().getString(R.string.draft_separator)); from.append(mContext.getResources().getString(R.string.draft_separator));
int before = from.length(); int before = from.length();
from.append(mContext.getResources().getString(R.string.has_draft)); from.append(mContext.getResources().getString(R.string.has_draft));
from.setSpan(new TextAppearanceSpan(mContext, android.R.style.TextAppearance_Small, from.setSpan(new TextAppearanceSpan(mContext, android.R.style.TextAppearance_Small,
ThemeManager.getTextOnBackgroundPrimary()), before, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); ThemeManager.getInstance().getTextOnBackgroundPrimary()), before, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
from.setSpan(new ForegroundColorSpan(ThemeManager.getColor()), before, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); from.setSpan(new ForegroundColorSpan(ThemeManager.getInstance().getColor()), before, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
} }
remoteViews.setTextViewText(R.id.name, from); remoteViews.setTextViewText(R.id.name, from);
@@ -250,12 +250,12 @@ public class WidgetService extends RemoteViewsService {
private void bindDate(RemoteViews remoteViews, Conversation conversation) { private void bindDate(RemoteViews remoteViews, Conversation conversation) {
remoteViews.setTextViewText(R.id.date, addColor(MessageUtils.formatTimeStampString(mContext, conversation.getDate()), remoteViews.setTextViewText(R.id.date, addColor(MessageUtils.formatTimeStampString(mContext, conversation.getDate()),
conversation.hasUnreadMessages() ? ThemeManager.getColor() : ThemeManager.getTextOnBackgroundSecondary())); conversation.hasUnreadMessages() ? ThemeManager.getInstance().getColor() : ThemeManager.getInstance().getTextOnBackgroundSecondary()));
} }
private void bindSnippet(RemoteViews remoteViews, Conversation conversation) { private void bindSnippet(RemoteViews remoteViews, Conversation conversation) {
remoteViews.setTextViewText(R.id.snippet, addColor(conversation.getSnippet(), conversation.hasUnreadMessages() ? remoteViews.setTextViewText(R.id.snippet, addColor(conversation.getSnippet(), conversation.hasUnreadMessages() ?
ThemeManager.getTextOnBackgroundPrimary() : ThemeManager.getTextOnBackgroundSecondary())); ThemeManager.getInstance().getTextOnBackgroundPrimary() : ThemeManager.getInstance().getTextOnBackgroundSecondary()));
} }
/** /**