From 2f4e3b5525ce51b170790b12fbe3d83d205649b7 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Fri, 25 Dec 2015 14:23:14 -0500 Subject: [PATCH] ThemeManager singleton --- .../com/moez/QKSMS/common/FontManager.java | 20 +- .../com/moez/QKSMS/common/ListviewHelper.java | 6 +- .../com/moez/QKSMS/data/ContactHelper.java | 2 +- .../QKSMS/receiver/NightModeAutoReceiver.java | 6 +- .../receiver/WearableIntentReceiver.java | 2 +- .../transaction/NotificationManager.java | 2 +- .../java/com/moez/QKSMS/ui/MainActivity.java | 6 +- .../java/com/moez/QKSMS/ui/ThemeManager.java | 312 +++++++++--------- .../com/moez/QKSMS/ui/base/QKActivity.java | 4 +- .../moez/QKSMS/ui/base/QKContentFragment.java | 2 +- .../com/moez/QKSMS/ui/base/QKFragment.java | 2 +- .../moez/QKSMS/ui/base/QKPopupActivity.java | 4 +- .../ConversationListAdapter.java | 18 +- .../ConversationListFragment.java | 16 +- .../ConversationListViewHolder.java | 2 +- .../ui/dialog/BubblePreferenceDialog.java | 70 ++-- .../QKSMS/ui/dialog/DefaultSmsHelper.java | 2 +- .../com/moez/QKSMS/ui/dialog/QKDialog.java | 6 +- .../ui/dialog/mms/MMSDialogFragment.java | 6 +- .../ui/messagelist/MessageListAdapter.java | 22 +- .../ui/messagelist/MessageListFragment.java | 8 +- .../QKSMS/ui/settings/SettingsFragment.java | 18 +- .../ui/view/AutoCompleteContactView.java | 4 +- .../com/moez/QKSMS/ui/view/AvatarView.java | 8 +- .../com/moez/QKSMS/ui/view/ComposeView.java | 24 +- .../com/moez/QKSMS/ui/view/QKEditText.java | 4 +- .../com/moez/QKSMS/ui/view/QKImageView.java | 2 +- .../java/com/moez/QKSMS/ui/view/QKSwitch.java | 16 +- .../com/moez/QKSMS/ui/view/QKTextView.java | 12 +- .../QKSMS/ui/view/StarredContactsView.java | 10 +- .../QKSMS/ui/welcome/WelcomeActivity.java | 8 +- .../ui/welcome/WelcomeNightFragment.java | 10 +- .../ui/welcome/WelcomeThemeFragment.java | 4 +- .../moez/QKSMS/ui/widget/WidgetProvider.java | 8 +- .../moez/QKSMS/ui/widget/WidgetService.java | 16 +- 35 files changed, 337 insertions(+), 325 deletions(-) diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/FontManager.java b/QKSMS/src/main/java/com/moez/QKSMS/common/FontManager.java index 8c8c1fd5..b0ecccad 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/FontManager.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/FontManager.java @@ -89,26 +89,26 @@ public class FontManager { // Colors and font weight switch (type) { case FontManager.TEXT_TYPE_PRIMARY: - boolean isNight = ThemeManager.getTheme() == ThemeManager.Theme.GREY || - ThemeManager.getTheme() == ThemeManager.Theme.BLACK; + boolean isNight = ThemeManager.getInstance().getTheme() == ThemeManager.Theme.GREY || + ThemeManager.getInstance().getTheme() == ThemeManager.Theme.BLACK; int id = isNight ? R.color.text_primary_dark : R.color.text_primary_light; return context.getResources().getColorStateList(id); case FontManager.TEXT_TYPE_SECONDARY: - return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary()); + return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundSecondary()); case FontManager.TEXT_TYPE_TERTIARY: - return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary()); + return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundSecondary()); case FontManager.TEXT_TYPE_CATEGORY: - return ColorStateList.valueOf(ThemeManager.getColor()); + return ColorStateList.valueOf(ThemeManager.getInstance().getColor()); case FontManager.TEXT_TYPE_DIALOG_TITLE: - return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary()); + return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundPrimary()); case FontManager.TEXT_TYPE_DIALOG_MESSAGE: - return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary()); + return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundSecondary()); case FontManager.TEXT_TYPE_DIALOG_BUTTON: - return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary()); + return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundPrimary()); 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) { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/common/ListviewHelper.java b/QKSMS/src/main/java/com/moez/QKSMS/common/ListviewHelper.java index 1e614697..bb196dd6 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/common/ListviewHelper.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/common/ListviewHelper.java @@ -20,9 +20,9 @@ public class ListviewHelper { try { Drawable drawable = ContextCompat.getDrawable(context, R.drawable.scrollbar); drawable.setColorFilter(Color.argb(64, - Color.red(ThemeManager.getTextOnBackgroundSecondary()), - Color.green(ThemeManager.getTextOnBackgroundSecondary()), - Color.blue(ThemeManager.getTextOnBackgroundSecondary())), + Color.red(ThemeManager.getInstance().getTextOnBackgroundSecondary()), + Color.green(ThemeManager.getInstance().getTextOnBackgroundSecondary()), + Color.blue(ThemeManager.getInstance().getTextOnBackgroundSecondary())), PorterDuff.Mode.SRC_ATOP); Field mScrollCacheField = View.class.getDeclaredField("mScrollCache"); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java b/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java index ea7fff1c..9f279d72 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/data/ContactHelper.java @@ -197,7 +197,7 @@ public class ContactHelper { int length = Units.dpToPx(context, 64); Bitmap bitmap = Bitmap.createBitmap(length, length, Bitmap.Config.ARGB_8888); - bitmap.eraseColor(ThemeManager.getColor()); + bitmap.eraseColor(ThemeManager.getInstance().getColor()); Canvas canvas = new Canvas(bitmap); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/receiver/NightModeAutoReceiver.java b/QKSMS/src/main/java/com/moez/QKSMS/receiver/NightModeAutoReceiver.java index cfcb5758..351c468a 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/receiver/NightModeAutoReceiver.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/receiver/NightModeAutoReceiver.java @@ -19,7 +19,7 @@ public class NightModeAutoReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - ThemeManager.loadThemeProperties(context); + ThemeManager.getInstance().loadThemeProperties(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); 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))) { Log.i(TAG, "Switching to night mode"); prefs.edit().putString(SettingsFragment.BACKGROUND, ThemeManager.Theme.PREF_GREY).apply(); - ThemeManager.setTheme(ThemeManager.Theme.GREY); + ThemeManager.getInstance().setTheme(ThemeManager.Theme.GREY); } else { Log.i(TAG, "Switching to day mode"); prefs.edit().putString(SettingsFragment.BACKGROUND, ThemeManager.Theme.PREF_OFFWHITE).apply(); - ThemeManager.setTheme(ThemeManager.Theme.OFFWHITE); + ThemeManager.getInstance().setTheme(ThemeManager.Theme.OFFWHITE); } } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/receiver/WearableIntentReceiver.java b/QKSMS/src/main/java/com/moez/QKSMS/receiver/WearableIntentReceiver.java index f152b28a..96f94479 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/receiver/WearableIntentReceiver.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/receiver/WearableIntentReceiver.java @@ -56,7 +56,7 @@ public class WearableIntentReceiver extends BroadcastReceiver { background = Bitmap.createBitmap(640, 400, Bitmap.Config.ARGB_8888); // 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); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java b/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java index ee788e2b..e1154788 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/transaction/NotificationManager.java @@ -680,7 +680,7 @@ public class NotificationManager { .setContentIntent(composePI) .setSmallIcon(R.drawable.ic_compose) .setPriority(NotificationCompat.PRIORITY_MIN) - .setColor(ThemeManager.getColor()); + .setColor(ThemeManager.getInstance().getColor()); NotificationManager.notify(context, NOTIFICATION_ID_QUICKCOMPOSE, builder.build()); } else { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/MainActivity.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/MainActivity.java index 2612051a..0018d3e0 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/MainActivity.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/MainActivity.java @@ -648,9 +648,9 @@ public class MainActivity extends QKActivity implements LiveView, SlidingMenu.Sl public void refresh() { // Update the background color. This code is important during the welcome screen setup, when the activity // in the ThemeManager isn't the MainActivity - findViewById(R.id.menu_frame).getRootView().setBackgroundColor(ThemeManager.getBackgroundColor()); - findViewById(R.id.menu_frame).setBackgroundColor(ThemeManager.getBackgroundColor()); - findViewById(R.id.content_frame).setBackgroundColor(ThemeManager.getBackgroundColor()); + findViewById(R.id.menu_frame).getRootView().setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); + findViewById(R.id.menu_frame).setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); + findViewById(R.id.content_frame).setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); } public static class DeleteThreadListener implements DialogInterface.OnClickListener { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java index cd252f0f..f995097c 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/ThemeManager.java @@ -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 private static final int[][] COLOURS = {{ // Red @@ -249,45 +220,86 @@ public class ThemeManager { 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 * of each activity that contains fragments that use ThemeManager */ - public static void loadThemeProperties(Context context) { - sPrefs = PreferenceManager.getDefaultSharedPreferences(context); - sResources = context.getResources(); + public void loadThemeProperties(Context context) { + mPrefs = PreferenceManager.getDefaultSharedPreferences(context); + mResources = context.getResources(); mContext = context; - sColor = Integer.parseInt(sPrefs.getString(SettingsFragment.THEME, "" + ThemeManager.DEFAULT_COLOR)); - sActiveColor = sColor; + mColor = Integer.parseInt(mPrefs.getString(SettingsFragment.THEME, "" + ThemeManager.getInstance().DEFAULT_COLOR)); + mActiveColor = mColor; if (context instanceof QKActivity) { mActivity = (QKActivity) context; - mActivity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(sColor)); + mActivity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(mColor)); 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; - sNavigationTintEnabled = sPrefs.getBoolean(SettingsFragment.NAVIGATION_TINT, false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; + mStatusTintEnabled = mPrefs.getBoolean(SettingsFragment.STATUS_TINT, true) && 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 (sStatusTintEnabled) { - mWindow.setStatusBarColor(ColorUtils.darken(sColor)); + if (mActivity != null && mStatusTintEnabled) { + if (mStatusTintEnabled) { + mWindow.setStatusBarColor(ColorUtils.darken(mColor)); } - if (sNavigationTintEnabled) { - mWindow.setNavigationBarColor(ColorUtils.darken(sColor)); + if (mNavigationTintEnabled) { + mWindow.setNavigationBarColor(ColorUtils.darken(mColor)); } } } - public static void setTheme(Theme theme) { - int startColor = sBackgroundColor; + public void setTheme(Theme theme) { + int startColor = mBackgroundColor; initializeTheme(theme); - int endColor = sBackgroundColor; + int endColor = mBackgroundColor; if (mActivity instanceof MainActivity) { final View background = mActivity.findViewById(R.id.menu_frame).getRootView(); @@ -331,70 +343,70 @@ public class ThemeManager { } } - public static void initializeTheme(Theme theme) { - sTheme = theme; + public void initializeTheme(Theme theme) { + mTheme = theme; switch (theme) { case WHITE: - sBackgroundColor = sResources.getColor(R.color.white_pure); + mBackgroundColor = mResources.getColor(R.color.white_pure); if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ? R.style.AppThemeWhite : R.style.AppThemeWhiteDialog); break; 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 ? R.style.AppThemeLight : R.style.AppThemeLightDialog); break; case GREY: - sBackgroundColor = sResources.getColor(R.color.grey_material); + mBackgroundColor = mResources.getColor(R.color.grey_material); if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ? R.style.AppThemeDark : R.style.AppThemeDarkDialog); break; case BLACK: - sBackgroundColor = sResources.getColor(R.color.black); + mBackgroundColor = mResources.getColor(R.color.black); if (mContext != null) mContext.setTheme(mContext instanceof MainActivity ? R.style.AppThemeDarkAmoled : R.style.AppThemeDarkAmoledDialog); break; } - switch (sTheme) { + switch (mTheme) { case WHITE: case OFFWHITE: - sTextOnBackgroundPrimary = sResources.getColor(R.color.theme_light_text_primary); - sTextOnBackgroundSecondary = sResources.getColor(R.color.theme_light_text_secondary); - sRippleBackground = sResources.getDrawable(R.drawable.button_background_transparent); + mTextOnBackgroundPrimary = mResources.getColor(R.color.theme_light_text_primary); + mtextOnBackgroundSecondary = mResources.getColor(R.color.theme_light_text_secondary); + mRippleBackground = mResources.getDrawable(R.drawable.button_background_transparent); if (mActivity != null) { mActivity.getToolbar().setPopupTheme(R.style.PopupThemeLight); } break; case GREY: case BLACK: - sTextOnBackgroundPrimary = sResources.getColor(R.color.theme_dark_text_primary); - sTextOnBackgroundSecondary = sResources.getColor(R.color.theme_dark_text_secondary); - sRippleBackground = sResources.getDrawable(R.drawable.button_background_transparent_light); + mTextOnBackgroundPrimary = mResources.getColor(R.color.theme_dark_text_primary); + mtextOnBackgroundSecondary = mResources.getColor(R.color.theme_dark_text_secondary); + mRippleBackground = mResources.getDrawable(R.drawable.button_background_transparent_light); if (mActivity != null) { mActivity.getToolbar().setPopupTheme(R.style.PopupTheme); } break; } - sTextOnColorPrimary = sResources.getColor(isColorDarkEnough(sColor) ? + mTextOnColorPrimary = mResources.getColor(isColorDarkEnough(mColor) ? 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); - setSentBubbleColored(sPrefs.getBoolean(SettingsFragment.COLOUR_SENT, true)); - setReceivedBubbleColored(sPrefs.getBoolean(SettingsFragment.COLOUR_RECEIVED, false)); - setBubbleStyleNew(sPrefs.getBoolean(SettingsFragment.BUBBLES_NEW, true)); + setSentBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOUR_SENT, true)); + setReceivedBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOUR_RECEIVED, false)); + setBubbleStyleNew(mPrefs.getBoolean(SettingsFragment.BUBBLES_NEW, true)); if (mActivity != null) { // We need to set this here because the title bar is initialized before the ThemeManager, // 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() .setContext(context) .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 // it's all done. - if (getSwatchColour(sColor) == PALETTE[i]) { + if (getSwatchColour(mColor) == PALETTE[i]) { enabledComponent = componentClassName; } else { @@ -447,106 +459,106 @@ public class ThemeManager { .show(); } - public static int getBackgroundColor() { - return sBackgroundColor; + public int getBackgroundColor() { + return mBackgroundColor; } - public static int getTextOnColorPrimary() { - return sTextOnColorPrimary; + public int getTextOnColorPrimary() { + return mTextOnColorPrimary; } - public static int getTextOnColorSecondary() { - return sTextOnColorSecondary; + public int getTextOnColorSecondary() { + return mTextOnColorSecondary; } - public static int getTextOnBackgroundPrimary() { - return sTextOnBackgroundPrimary; + public int getTextOnBackgroundPrimary() { + return mTextOnBackgroundPrimary; } - public static int getTextOnBackgroundSecondary() { - return sTextOnBackgroundSecondary; + public int getTextOnBackgroundSecondary() { + return mtextOnBackgroundSecondary; } - public static int getSentBubbleRes() { - return sSentBubbleRes; + public int getSentBubbleRes() { + return mSentBubbleRes; } - public static int getSentBubbleAltRes() { - return sSentBubbleAltRes; + public int getSentBubbleAltRes() { + return mSentBubbleAltRes; } - public static int getSentBubbleColor() { - return sSentBubbleColored ? sActiveColor : getNeutralBubbleColor(); + public int getSentBubbleColor() { + return mSentBubbleColored ? mActiveColor : getNeutralBubbleColor(); } - public static int getReceivedBubbleRes() { - return sReceivedBubbleRes; + public int getReceivedBubbleRes() { + return mReceivedBubbleRes; } - public static int getReceivedBubbleAltRes() { - return sReceivedBubbleAltRes; + public int getReceivedBubbleAltRes() { + return mReceivedBubbleAltRes; } - public static int getReceivedBubbleColor() { - return sReceivedBubbleColored ? sActiveColor : getNeutralBubbleColor(); + public int getReceivedBubbleColor() { + return mReceivedBubbleColored ? mActiveColor : getNeutralBubbleColor(); } - public static void setBubbleStyleNew(boolean styleNew) { - sSentBubbleRes = styleNew ? R.drawable.message_sent_2 : R.drawable.message_sent; - sSentBubbleAltRes = styleNew ? R.drawable.message_sent_alt_2 : R.drawable.message_sent_alt; - sReceivedBubbleRes = styleNew ? R.drawable.message_received_2 : R.drawable.message_received; - sReceivedBubbleAltRes = styleNew ? R.drawable.message_received_alt_2 : R.drawable.message_received_alt; + public void setBubbleStyleNew(boolean styleNew) { + mSentBubbleRes = styleNew ? R.drawable.message_sent_2 : R.drawable.message_sent; + mSentBubbleAltRes = styleNew ? R.drawable.message_sent_alt_2 : R.drawable.message_sent_alt; + mReceivedBubbleRes = styleNew ? R.drawable.message_received_2 : R.drawable.message_received; + mReceivedBubbleAltRes = styleNew ? R.drawable.message_received_alt_2 : R.drawable.message_received_alt; } - public static void setSentBubbleColored(boolean colored) { - sSentBubbleColored = colored; + public void setSentBubbleColored(boolean colored) { + mSentBubbleColored = colored; } - public static void setReceivedBubbleColored(boolean colored) { - sReceivedBubbleColored = colored; + public void setReceivedBubbleColored(boolean colored) { + mReceivedBubbleColored = colored; } - public static int getNeutralBubbleColor() { - if (sTheme == null) { + public int getNeutralBubbleColor() { + if (mTheme == null) { return 0xeeeeee; } - switch (sTheme) { + switch (mTheme) { case WHITE: - return sResources.getColor(R.color.grey_light_mega_ultra); + return mResources.getColor(R.color.grey_light_mega_ultra); case OFFWHITE: - return sResources.getColor(R.color.white_pure); + return mResources.getColor(R.color.white_pure); case GREY: - return sResources.getColor(R.color.grey_dark); + return mResources.getColor(R.color.grey_dark); default: - return sResources.getColor(R.color.grey_material); + return mResources.getColor(R.color.grey_material); } } - public static Drawable getRippleBackground() { - return sRippleBackground; + public Drawable getRippleBackground() { + return mRippleBackground; } - public static int getColor() { - return sActiveColor; + public int getColor() { + return mActiveColor; } - public static int getThemeColor() { - return sColor; + public int getThemeColor() { + return mColor; } - public static Theme getTheme() { - return sTheme; + public Theme getTheme() { + return mTheme; } - public static boolean isNightMode() { - return sTheme == Theme.GREY || sTheme == Theme.BLACK; + public boolean isNightMode() { + 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(); ColorPickerPalette palette = new ColorPickerPalette(context); @@ -556,7 +568,7 @@ public class ThemeManager { dialog.dismiss(); }); - palette.drawPalette(PALETTE, getSwatchColour(sColor)); + palette.drawPalette(PALETTE, getSwatchColour(mColor)); dialog.setContext(context) .setTitle(R.string.pref_theme) @@ -566,7 +578,7 @@ public class ThemeManager { dialog.show(); } - private static void showColourPickerDialog(final QKActivity context, int swatchColour) { + private void showColourPickerDialog(final QKActivity context, int swatchColour) { final QKDialog dialog = new QKDialog(); ColorPickerPalette palette = new ColorPickerPalette(context); @@ -576,7 +588,7 @@ public class ThemeManager { dialog.dismiss(); }); - palette.drawPalette(getSwatch(swatchColour), sColor); + palette.drawPalette(getSwatch(swatchColour), mColor); dialog.setContext(context) .setTitle(R.string.pref_theme) @@ -586,11 +598,11 @@ public class ThemeManager { } @TargetApi(Build.VERSION_CODES.LOLLIPOP) - public static void setStatusBarTintEnabled(boolean enabled) { - if (sStatusTintEnabled != enabled) { - sStatusTintEnabled = enabled; - int colorFrom = enabled ? sResources.getColor(R.color.black) : sColor; - int colorTo = enabled ? sColor : sResources.getColor(R.color.black); + public void setStatusBarTintEnabled(boolean enabled) { + if (mStatusTintEnabled != enabled) { + mStatusTintEnabled = enabled; + int colorFrom = enabled ? mResources.getColor(R.color.black) : mColor; + int colorTo = enabled ? mColor : mResources.getColor(R.color.black); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(TRANSITION_LENGTH); @@ -602,11 +614,11 @@ public class ThemeManager { } @TargetApi(Build.VERSION_CODES.LOLLIPOP) - public static void setNavigationBarTintEnabled(boolean enabled) { - if (sNavigationTintEnabled != enabled) { - sNavigationTintEnabled = enabled; - int colorFrom = enabled ? sResources.getColor(R.color.black) : sColor; - int colorTo = enabled ? sColor : sResources.getColor(R.color.black); + public void setNavigationBarTintEnabled(boolean enabled) { + if (mNavigationTintEnabled != enabled) { + mNavigationTintEnabled = enabled; + int colorFrom = enabled ? mResources.getColor(R.color.black) : mColor; + int colorTo = enabled ? mColor : mResources.getColor(R.color.black); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); 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(); } - public static void setColour(int color) { + public void setColour(int color) { AnalyticsManager.getInstance().sendEvent( AnalyticsManager.CATEGORY_PREFERENCE_CHANGE, @@ -629,17 +641,17 @@ public class ThemeManager { getColorString(color) ); - int colourFrom = sColor; - sColor = color; - sActiveColor = color; + int colourFrom = mColor; + mColor = color; + mActiveColor = color; - sPrefs.edit().putString(SettingsFragment.THEME, "" + color).apply(); + mPrefs.edit().putString(SettingsFragment.THEME, "" + color).apply(); - setSentBubbleColored(sPrefs.getBoolean(SettingsFragment.COLOUR_SENT, true)); - setReceivedBubbleColored(sPrefs.getBoolean(SettingsFragment.COLOUR_RECEIVED, false)); - sTextOnColorPrimary = sResources.getColor(isColorDarkEnough(sColor) ? + setSentBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOUR_SENT, true)); + setReceivedBubbleColored(mPrefs.getBoolean(SettingsFragment.COLOUR_RECEIVED, false)); + mTextOnColorPrimary = mResources.getColor(isColorDarkEnough(mColor) ? 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); // 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)); } - if (sNavigationTintEnabled) { + if (mNavigationTintEnabled) { mWindow.setNavigationBarColor(ColorUtils.darken(color1)); } }); @@ -684,8 +696,8 @@ public class ThemeManager { //final Toolbar toolbar = (Toolbar) mActivity.findViewById(R.id.title); final QKTextView title = (QKTextView) mActivity.findViewById(R.id.toolbar_title); - if (title.getCurrentTextColor() != ThemeManager.sTextOnColorPrimary) { - ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), title.getCurrentTextColor(), ThemeManager.sTextOnColorPrimary); + if (title.getCurrentTextColor() != mTextOnColorPrimary) { + ValueAnimator titleColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), title.getCurrentTextColor(), mTextOnColorPrimary); titleColorAnimation.setDuration(TRANSITION_LENGTH); titleColorAnimation.setInterpolator(new DecelerateInterpolator()); titleColorAnimation.addUpdateListener(animation -> { @@ -698,18 +710,18 @@ public class ThemeManager { } } - public static void setActiveColor(int color) { - sActiveColor = color; + public void setActiveColor(int color) { + mActiveColor = color; if (mActivity != null) { if (mActivity.getSupportActionBar() != null) { mActivity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color)); } } - if (sStatusTintEnabled) { + if (mStatusTintEnabled) { mWindow.setStatusBarColor(ColorUtils.darken(color)); } - if (sNavigationTintEnabled) { + if (mNavigationTintEnabled) { 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 j = 0; j < COLOURS[i].length; j++) { if (color == COLOURS[i][j]) { @@ -730,7 +742,7 @@ public class ThemeManager { return true; } - public static int getSwatchColour(int colour) { + public int getSwatchColour(int colour) { for (int i = 0; i < COLOURS.length; i++) { for (int j = 0; j < COLOURS[i].length; j++) { if (colour == COLOURS[i][j]) { @@ -742,7 +754,7 @@ public class ThemeManager { return colour; } - private static int[] getSwatch(int colour) { + private int[] getSwatch(int colour) { for (int[] swatch : COLOURS) { for (int swatchColor : swatch) { if (colour == swatchColor) { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKActivity.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKActivity.java index c85c31af..6e9d4d8d 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKActivity.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKActivity.java @@ -72,7 +72,7 @@ public abstract class QKActivity extends ActionBarActivity { setSupportActionBar(mToolbar); } - ThemeManager.loadThemeProperties(this); + ThemeManager.getInstance().loadThemeProperties(this); } protected void showBackButton(boolean show) { @@ -173,7 +173,7 @@ public abstract class QKActivity extends ActionBarActivity { public boolean onPrepareOptionsMenu(Menu menu) { // Save a reference to the menu so that we can quickly access menu icons later. mMenu = menu; - colorMenuIcons(mMenu, ThemeManager.getTextOnColorPrimary()); + colorMenuIcons(mMenu, ThemeManager.getInstance().getTextOnColorPrimary()); return true; } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKContentFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKContentFragment.java index 2e45c808..9391c990 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKContentFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKContentFragment.java @@ -102,7 +102,7 @@ public abstract class QKContentFragment extends QKFragment implements LiveView, public void refresh() { View view = getView(); if (view != null) { - view.setBackgroundColor(ThemeManager.getBackgroundColor()); + view.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); } } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKFragment.java index e071a742..17d5d6d7 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKFragment.java @@ -37,7 +37,7 @@ public class QKFragment extends Fragment implements LiveView { @Override public void refresh() { if (getView() != null) { - getView().setBackgroundColor(ThemeManager.getBackgroundColor()); + getView().setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); } } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKPopupActivity.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKPopupActivity.java index 68ba6544..cd92d99d 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKPopupActivity.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/base/QKPopupActivity.java @@ -29,9 +29,9 @@ public abstract class QKPopupActivity extends QKActivity { setFinishOnTouchOutside(mPrefs.getBoolean(SettingsFragment.QUICKREPLY_TAP_DISMISS, true)); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); 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); if (title != null && title instanceof AppCompatTextView) { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListAdapter.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListAdapter.java index a35bc960..1ba65cc9 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListAdapter.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListAdapter.java @@ -80,23 +80,23 @@ public class ConversationListAdapter extends RecyclerCursorAdapter { if (mAdapter.isInMultiSelectMode()) { mAdapter.disableMultiSelectMode(true); @@ -307,11 +307,11 @@ public class ConversationListFragment extends QKFragment implements LoaderManage return; } - mFab.setColorNormal(ThemeManager.getColor()); - mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getColor())); - mFab.getDrawable().setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); + mFab.setColorNormal(ThemeManager.getInstance().getColor()); + mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getInstance().getColor())); + mFab.getDrawable().setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); - mEmptyStateIcon.setColorFilter(ThemeManager.getTextOnBackgroundPrimary()); + mEmptyStateIcon.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundPrimary()); } @Override diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListViewHolder.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListViewHolder.java index ae2a9519..dbcd63d0 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListViewHolder.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/conversationlist/ConversationListViewHolder.java @@ -110,7 +110,7 @@ public class ConversationListViewHolder extends ClickyViewHolder i buf.append(mContext.getResources().getString(R.string.draft_separator)); int before = buf.length(); 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; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/BubblePreferenceDialog.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/BubblePreferenceDialog.java index eea27319..f60505cf 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/BubblePreferenceDialog.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/BubblePreferenceDialog.java @@ -27,24 +27,24 @@ public class BubblePreferenceDialog extends QKDialog { View view = mContext.getLayoutInflater().inflate(R.layout.dialog_bubbles, null); final QKTextView in1 = (QKTextView) view.findViewById(R.id.in_1); - in1.setBackgroundResource(ThemeManager.getReceivedBubbleRes()); - in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); - in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); + in1.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleRes()); + in1.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); + in1.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); final QKTextView in2 = (QKTextView) view.findViewById(R.id.in_2); - in2.setBackgroundResource(ThemeManager.getReceivedBubbleAltRes()); - in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); - in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); + in2.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleAltRes()); + in2.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); + in2.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); final QKTextView out1 = (QKTextView) view.findViewById(R.id.out_1); - out1.setBackgroundResource(ThemeManager.getSentBubbleRes()); - out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); - out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); + out1.setBackgroundResource(ThemeManager.getInstance().getSentBubbleRes()); + out1.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); + out1.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); final QKTextView out2 = (QKTextView) view.findViewById(R.id.out_2); - out2.setBackgroundResource(ThemeManager.getSentBubbleAltRes()); - out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); - out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); + out2.setBackgroundResource(ThemeManager.getInstance().getSentBubbleAltRes()); + out2.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); + out2.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); Preference.OnPreferenceClickListener onPreferenceClickListener = new Preference.OnPreferenceClickListener() { @Override @@ -52,38 +52,38 @@ public class BubblePreferenceDialog extends QKDialog { Log.d(TAG, preference.getKey()); switch (preference.getKey()) { case SettingsFragment.BUBBLES_NEW: - ThemeManager.setBubbleStyleNew(((QKSwitchPreference) preference).isChecked()); - in1.setBackgroundResource(ThemeManager.getReceivedBubbleRes()); - in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); - in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); + ThemeManager.getInstance().setBubbleStyleNew(((QKSwitchPreference) preference).isChecked()); + in1.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleRes()); + in1.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); + in1.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); - in2.setBackgroundResource(ThemeManager.getReceivedBubbleAltRes()); - in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); - in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); + in2.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleAltRes()); + in2.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); + in2.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); - out1.setBackgroundResource(ThemeManager.getSentBubbleRes()); - out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); - out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); + out1.setBackgroundResource(ThemeManager.getInstance().getSentBubbleRes()); + out1.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); + out1.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); - out2.setBackgroundResource(ThemeManager.getSentBubbleAltRes()); - out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); - out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); + out2.setBackgroundResource(ThemeManager.getInstance().getSentBubbleAltRes()); + out2.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); + out2.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); return true; case SettingsFragment.COLOUR_RECEIVED: - ThemeManager.setReceivedBubbleColored(((QKSwitchPreference) preference).isChecked()); - in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); - in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); - in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); - in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor()); + ThemeManager.getInstance().setReceivedBubbleColored(((QKSwitchPreference) preference).isChecked()); + in1.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); + in1.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); + in2.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); + in2.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); return true; case SettingsFragment.COLOUR_SENT: - ThemeManager.setSentBubbleColored(((QKSwitchPreference) preference).isChecked()); - out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); - out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); - out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); - out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor()); + ThemeManager.getInstance().setSentBubbleColored(((QKSwitchPreference) preference).isChecked()); + out1.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); + out1.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); + out2.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); + out2.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); return true; } return false; diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/DefaultSmsHelper.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/DefaultSmsHelper.java index 0f92a9f3..f6969807 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/DefaultSmsHelper.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/DefaultSmsHelper.java @@ -45,7 +45,7 @@ public class DefaultSmsHelper implements ActionClickListener { .type(getSnackBarType()) .text(mMessage) .duration(duration) - .actionColor(ThemeManager.getColor()) + .actionColor(ThemeManager.getInstance().getColor()) .actionLabel(R.string.upgrade_now) .actionListener(this); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/QKDialog.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/QKDialog.java index 69d85eed..c5fa15d7 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/QKDialog.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/QKDialog.java @@ -130,7 +130,7 @@ public class QKDialog extends DialogFragment { mPositiveButtonView = (QKTextView) view.findViewById(R.id.buttonPositive); mPositiveButtonView.setVisibility(View.VISIBLE); mPositiveButtonView.setText(mPositiveButtonText); - mPositiveButtonView.setTextColor(ThemeManager.getColor()); + mPositiveButtonView.setTextColor(ThemeManager.getInstance().getColor()); mPositiveButtonView.setOnClickListener(mPositiveButtonClickListener); } @@ -443,11 +443,11 @@ public class QKDialog extends DialogFragment { } QKTextView title = (QKTextView) convertView.findViewById(R.id.list_item_title); - title.setTextColor(ThemeManager.getColor()); + title.setTextColor(ThemeManager.getInstance().getColor()); title.setText(getItem(position).title); QKTextView subtitle = (QKTextView) convertView.findViewById(R.id.list_item_subtitle); - subtitle.setTextColor(ThemeManager.getTextOnBackgroundPrimary()); + subtitle.setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary()); subtitle.setText(getItem(position).subtitle); ((QKTextView) convertView.findViewById(R.id.list_item_body)) diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/mms/MMSDialogFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/mms/MMSDialogFragment.java index 97d28454..399ed361 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/mms/MMSDialogFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/dialog/mms/MMSDialogFragment.java @@ -190,7 +190,7 @@ public class MMSDialogFragment extends DialogFragment { mPositiveButtonView = (QKTextView) view.findViewById(R.id.buttonPositive); mPositiveButtonView.setVisibility(View.VISIBLE); mPositiveButtonView.setText(mPositiveButtonText); - mPositiveButtonView.setTextColor(ThemeManager.getColor()); + mPositiveButtonView.setTextColor(ThemeManager.getInstance().getColor()); mPositiveButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -465,11 +465,11 @@ public class MMSDialogFragment extends DialogFragment { } QKTextView title = (QKTextView) convertView.findViewById(R.id.list_item_title); - title.setTextColor(ThemeManager.getColor()); + title.setTextColor(ThemeManager.getInstance().getColor()); title.setText(getItem(position).title); QKTextView subtitle = (QKTextView) convertView.findViewById(R.id.list_item_subtitle); - subtitle.setTextColor(ThemeManager.getTextOnBackgroundPrimary()); + subtitle.setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary()); subtitle.setText(getItem(position).subtitle); ((QKTextView) convertView.findViewById(R.id.list_item_body)) diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java index 9820e8cd..76b8e428 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListAdapter.java @@ -130,10 +130,10 @@ public class MessageListAdapter extends RecyclerCursorAdapter { 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 { - holder.mBodyTextView.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); + holder.mBodyTextView.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); } }); holder.refresh(); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListFragment.java index 2bf8667a..02bf35bd 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/messagelist/MessageListFragment.java @@ -762,7 +762,7 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa mSensorManager.registerListener(this, mProxSensor, SensorManager.SENSOR_DELAY_NORMAL); } - ThemeManager.setActiveColor(mConversationPrefs.getColor()); + ThemeManager.getInstance().setActiveColor(mConversationPrefs.getColor()); } @Override @@ -787,14 +787,14 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa } } - ThemeManager.setActiveColor(ThemeManager.getThemeColor()); + ThemeManager.getInstance().setActiveColor(ThemeManager.getInstance().getThemeColor()); } @Override public void onMenuChanging(float percentOpen) { if (mConversationPrefs != null) { - ThemeManager.setActiveColor((int) mArgbEvaluator.evaluate( - percentOpen, 0xFF000000 | mConversationPrefs.getColor(), 0xFF000000 | ThemeManager.getThemeColor())); + ThemeManager.getInstance().setActiveColor((int) mArgbEvaluator.evaluate( + percentOpen, 0xFF000000 | mConversationPrefs.getColor(), 0xFF000000 | ThemeManager.getInstance().getThemeColor())); } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java index ea1fc0eb..40aefef0 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/settings/SettingsFragment.java @@ -381,7 +381,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O String valueString = newValue == null ? "null" : newValue.toString(); if (key.equals(NOTIFICATION_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); @@ -393,13 +393,13 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O switch (key) { case BACKGROUND: - ThemeManager.setTheme(ThemeManager.Theme.fromString((String) newValue)); + ThemeManager.getInstance().setTheme(ThemeManager.Theme.fromString((String) newValue)); break; case STATUS_TINT: - ThemeManager.setStatusBarTintEnabled((Boolean) newValue); + ThemeManager.getInstance().setStatusBarTintEnabled((Boolean) newValue); break; case NAVIGATION_TINT: - ThemeManager.setNavigationBarTintEnabled((Boolean) newValue); + ThemeManager.getInstance().setNavigationBarTintEnabled((Boolean) newValue); break; case FONT_FAMILY: 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]); break; case COLOUR_SENT: - ThemeManager.setSentBubbleColored((Boolean) newValue); + ThemeManager.getInstance().setSentBubbleColored((Boolean) newValue); break; case COLOUR_RECEIVED: - ThemeManager.setReceivedBubbleColored((Boolean) newValue); + ThemeManager.getInstance().setReceivedBubbleColored((Boolean) newValue); break; case NIGHT_AUTO: updateAlarmManager(mContext, (Boolean) newValue); @@ -519,13 +519,13 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O switch (key) { case THEME: - ThemeManager.showColourSwatchesDialog(mContext); + ThemeManager.getInstance().showColourSwatchesDialog(mContext); break; case BUBBLES: new BubblePreferenceDialog().setContext(mContext).show(); break; case ICON: - ThemeManager.setIcon(mContext); + ThemeManager.getInstance().setIcon(mContext); break; case BLOCKED_FUTURE: BlockedNumberDialog.showDialog(mContext); @@ -701,7 +701,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O View view = getView(); if (view != null) { - view.setBackgroundColor(ThemeManager.getBackgroundColor()); + view.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AutoCompleteContactView.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AutoCompleteContactView.java index 3ddb31a1..75f9e347 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AutoCompleteContactView.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AutoCompleteContactView.java @@ -61,8 +61,8 @@ public class AutoCompleteContactView extends RecipientEditTextView implements Li FontManager.getFontWeight(mContext, false))); setTextSize(TypedValue.COMPLEX_UNIT_SP, FontManager.getTextSize(mContext, FontManager.TEXT_TYPE_PRIMARY)); - setTextColor(ThemeManager.getTextOnBackgroundPrimary()); - setHintTextColor(ThemeManager.getTextOnBackgroundSecondary()); + setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary()); + setHintTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary()); if (mAdapter != null) { SharedPreferences prefs = mContext.getPrefs(); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AvatarView.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AvatarView.java index 7e5486bb..c3537b0e 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AvatarView.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/AvatarView.java @@ -261,7 +261,7 @@ public class AvatarView extends ImageView implements View.OnClickListener, LiveV getBackground().setColorFilter(0x00000000, PorterDuff.Mode.SRC_ATOP); } else { 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 public void refresh() { - mPaint.setColor(ThemeManager.getTextOnColorPrimary()); - mDefaultDrawable.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); + mPaint.setColor(ThemeManager.getInstance().getTextOnColorPrimary()); + mDefaultDrawable.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); if (getBackground() == null) { 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 { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/ComposeView.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/ComposeView.java index 2e1ee640..302800ed 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/ComposeView.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/ComposeView.java @@ -951,24 +951,24 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L @Override public void refresh() { - mButtonBackground.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP); - mButtonBar1.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); - mButtonBar2.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); - mAttachmentPanel.setBackgroundColor(ThemeManager.getColor()); - mAttach.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); - mCamera.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); + mButtonBackground.setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP); + mButtonBar1.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); + mButtonBar2.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); + mAttachmentPanel.setBackgroundColor(ThemeManager.getInstance().getColor()); + mAttach.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); + mCamera.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); updateDelayButton(); - mProgress.setUnfinishedStrokeColor(ThemeManager.getTextOnColorSecondary()); - mProgress.setFinishedStrokeColor(ThemeManager.getTextOnColorPrimary()); - if (ThemeManager.getSentBubbleRes() != 0) mReplyText.setBackgroundResource(ThemeManager.getSentBubbleRes()); - mReplyText.getBackground().setColorFilter(ThemeManager.getNeutralBubbleColor(), PorterDuff.Mode.SRC_ATOP); + mProgress.setUnfinishedStrokeColor(ThemeManager.getInstance().getTextOnColorSecondary()); + mProgress.setFinishedStrokeColor(ThemeManager.getInstance().getTextOnColorPrimary()); + if (ThemeManager.getInstance().getSentBubbleRes() != 0) mReplyText.setBackgroundResource(ThemeManager.getInstance().getSentBubbleRes()); + mReplyText.getBackground().setColorFilter(ThemeManager.getInstance().getNeutralBubbleColor(), PorterDuff.Mode.SRC_ATOP); mReplyText.refresh(); - getBackground().setColorFilter(ThemeManager.getBackgroundColor(), PorterDuff.Mode.SRC_ATOP); + getBackground().setColorFilter(ThemeManager.getInstance().getBackgroundColor(), PorterDuff.Mode.SRC_ATOP); } private void updateDelayButton() { mDelay.setColorFilter(mDelayedMessagingEnabled ? - ThemeManager.getTextOnColorPrimary() : ThemeManager.getTextOnColorSecondary(), + ThemeManager.getInstance().getTextOnColorPrimary() : ThemeManager.getInstance().getTextOnColorSecondary(), PorterDuff.Mode.SRC_ATOP); } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java index 5b2ff0cc..f5dfdb78 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKEditText.java @@ -99,8 +99,8 @@ public class QKEditText extends android.widget.EditText implements LiveView { int fontWeight = FontManager.getFontWeight(mContext, false); setTypeface(TypefaceManager.obtainTypeface(mContext, fontFamily, fontWeight )); - setTextColor(ThemeManager.getTextOnBackgroundPrimary()); - setHintTextColor(ThemeManager.getTextOnBackgroundSecondary()); + setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary()); + setHintTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary()); // Text size int sp = FontManager.getTextSize(mContext, FontManager.TEXT_TYPE_PRIMARY); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKImageView.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKImageView.java index 911b8d25..db4f0165 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKImageView.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKImageView.java @@ -44,7 +44,7 @@ public class QKImageView extends ImageView implements LiveView { mDrawable = drawable; if (mDrawable != null) { - mDrawable.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP); + mDrawable.setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP); super.setImageDrawable(drawable); } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKSwitch.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKSwitch.java index 134629b0..e6039ff8 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKSwitch.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKSwitch.java @@ -50,16 +50,16 @@ public class QKSwitch extends SwitchCompat implements LiveView { // Disabled state 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); // Checked state states[1] = new int[]{android.R.attr.state_checked}; - colors[1] = ThemeManager.getColor(); + colors[1] = ThemeManager.getInstance().getColor(); // Unchecked enabled state state 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); return new ColorStateList(states, colors); @@ -71,19 +71,19 @@ public class QKSwitch extends SwitchCompat implements LiveView { // Disabled state 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); // Checked state states[1] = new int[]{android.R.attr.state_checked}; colors[1] = Color.argb(0x4D, // 30% alpha - Color.red(ThemeManager.getColor()), - Color.green(ThemeManager.getColor()), - Color.blue(ThemeManager.getColor())); + Color.red(ThemeManager.getInstance().getColor()), + Color.green(ThemeManager.getInstance().getColor()), + Color.blue(ThemeManager.getInstance().getColor())); // Unchecked enabled state state 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); return new ColorStateList(states, colors); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKTextView.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKTextView.java index 43956443..1833f1ba 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKTextView.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/QKTextView.java @@ -106,19 +106,19 @@ public class QKTextView extends TextView implements LiveView { if (onColorBackground) { if (mType == FontManager.TEXT_TYPE_PRIMARY) { - setTextColor(ThemeManager.getTextOnColorPrimary()); - setLinkTextColor(ThemeManager.getTextOnColorPrimary()); + setTextColor(ThemeManager.getInstance().getTextOnColorPrimary()); + setLinkTextColor(ThemeManager.getInstance().getTextOnColorPrimary()); } else if (mType == FontManager.TEXT_TYPE_SECONDARY || mType == FontManager.TEXT_TYPE_TERTIARY) { - setTextColor(ThemeManager.getTextOnColorSecondary()); + setTextColor(ThemeManager.getInstance().getTextOnColorSecondary()); } } else { if (mType == FontManager.TEXT_TYPE_PRIMARY) { - setTextColor(ThemeManager.getTextOnBackgroundPrimary()); - setLinkTextColor(ThemeManager.getColor()); + setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary()); + setLinkTextColor(ThemeManager.getInstance().getColor()); } else if (mType == FontManager.TEXT_TYPE_SECONDARY || mType == FontManager.TEXT_TYPE_TERTIARY) { - setTextColor(ThemeManager.getTextOnBackgroundSecondary()); + setTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary()); } } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/StarredContactsView.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/StarredContactsView.java index 140653a9..a6883c95 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/view/StarredContactsView.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/view/StarredContactsView.java @@ -58,7 +58,7 @@ public class StarredContactsView extends LinearLayout implements LoaderManager.L super.onFinishInflate(); mFavoritesBackground = (LinearLayout) findViewById(R.id.starred_contacts); - mFavoritesBackground.setBackgroundColor(ThemeManager.getBackgroundColor()); + mFavoritesBackground.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); mTitle = (QKTextView) findViewById(R.id.title); @@ -154,13 +154,13 @@ public class StarredContactsView extends LinearLayout implements LoaderManager.L } public void expand() { - mTitle.setTextColor(ThemeManager.getTextOnBackgroundPrimary()); + mTitle.setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary()); mFavorites.setVisibility(View.VISIBLE); mIndicator.setRotation(0f); } public void collapse() { - mTitle.setTextColor(ThemeManager.getTextOnBackgroundSecondary()); + mTitle.setTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary()); mFavorites.setVisibility(View.GONE); mIndicator.setRotation(90f); } @@ -176,7 +176,7 @@ public class StarredContactsView extends LinearLayout implements LoaderManager.L @Override public void refresh() { - mIndicator.setColorFilter(ThemeManager.getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); - mFavoritesBackground.setBackgroundColor(ThemeManager.getBackgroundColor()); + mIndicator.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); + mFavoritesBackground.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); } } diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeActivity.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeActivity.java index e0291733..67ebc5de 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeActivity.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeActivity.java @@ -38,7 +38,7 @@ public class WelcomeActivity extends QKActivity implements ViewPager.OnPageChang getSupportActionBar().hide(); mBackground = findViewById(R.id.welcome); - mBackground.setBackgroundColor(ThemeManager.getColor()); + mBackground.setBackgroundColor(ThemeManager.getInstance().getColor()); mPrevious = (ImageView) findViewById(R.id.welcome_previous); mPrevious.setOnClickListener(this); @@ -63,8 +63,8 @@ public class WelcomeActivity extends QKActivity implements ViewPager.OnPageChang } public void setColor(int color) { - ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), ThemeManager.getColor(), color); - colorAnimation.setDuration(ThemeManager.TRANSITION_LENGTH); + ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), ThemeManager.getInstance().getColor(), color); + colorAnimation.setDuration(ThemeManager.getInstance().TRANSITION_LENGTH); colorAnimation.setInterpolator(new DecelerateInterpolator()); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override @@ -74,7 +74,7 @@ public class WelcomeActivity extends QKActivity implements ViewPager.OnPageChang }); colorAnimation.start(); - ThemeManager.setColour(color); + ThemeManager.getInstance().setColour(color); } public void setColorBackground(int color) { diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeNightFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeNightFragment.java index 870bf6cd..2ca8e214 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeNightFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeNightFragment.java @@ -43,8 +43,8 @@ public class WelcomeNightFragment extends BaseWelcomeFragment implements BaseWel @Override public void onScrollOffsetChanged(WelcomeActivity activity, float offset) { - int colorBackground = (Integer) mArgbEvaluator.evaluate(Math.abs(offset), ThemeManager.getBackgroundColor(), ThemeManager.getColor()); - int colorAccent = (Integer) mArgbEvaluator.evaluate(1 - Math.abs(offset), 0xFFFFFFFF, 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.getInstance().getColor()); activity.setColorBackground(colorBackground); activity.tintIndicators(colorAccent); @@ -66,14 +66,14 @@ public class WelcomeNightFragment extends BaseWelcomeFragment implements BaseWel @Override public void onClick(View v) { 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 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); - colorAnimation.setDuration(ThemeManager.TRANSITION_LENGTH); + colorAnimation.setDuration(ThemeManager.getInstance().TRANSITION_LENGTH); colorAnimation.setInterpolator(new DecelerateInterpolator()); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeThemeFragment.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeThemeFragment.java index 8001682d..2fed9738 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeThemeFragment.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/welcome/WelcomeThemeFragment.java @@ -21,7 +21,7 @@ public class WelcomeThemeFragment extends BaseWelcomeFragment implements ColorPi mPallette = (ColorPickerPalette) view.findViewById(R.id.welcome_themes); mPallette.init(19, 4, this); - mPallette.drawPalette(ThemeManager.PALETTE, ThemeManager.getColor()); + mPallette.drawPalette(ThemeManager.getInstance().PALETTE, ThemeManager.getInstance().getColor()); return view; } @@ -29,7 +29,7 @@ public class WelcomeThemeFragment extends BaseWelcomeFragment implements ColorPi @Override public void onColorSelected(int color) { ((WelcomeActivity) getActivity()).setColor(color); - mPallette.drawPalette(ThemeManager.PALETTE, color); + mPallette.drawPalette(ThemeManager.getInstance().PALETTE, color); } @Override diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/widget/WidgetProvider.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/widget/WidgetProvider.java index 85b96b18..28a7bda8 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/widget/WidgetProvider.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/widget/WidgetProvider.java @@ -45,7 +45,7 @@ public class WidgetProvider extends AppWidgetProvider { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { super.onUpdate(context, appWidgetManager, appWidgetIds); - ThemeManager.loadThemeProperties(context); + ThemeManager.getInstance().loadThemeProperties(context); for (int appWidgetId : appWidgetIds) { updateWidget(context, appWidgetId, isSmallWidget(appWidgetManager, appWidgetId)); @@ -118,10 +118,10 @@ public class WidgetProvider extends AppWidgetProvider { remoteViews.setRemoteAdapter(R.id.conversation_list, intent); 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.header_background, "setColorFilter", ThemeManager.getColor()); + remoteViews.setInt(R.id.conversation_list_background, "setColorFilter", ThemeManager.getInstance().getBackgroundColor()); + remoteViews.setInt(R.id.header_background, "setColorFilter", ThemeManager.getInstance().getColor()); // Open Mms's app conversation list when click on header final Intent convIntent = new Intent(context, MainActivity.class); diff --git a/QKSMS/src/main/java/com/moez/QKSMS/ui/widget/WidgetService.java b/QKSMS/src/main/java/com/moez/QKSMS/ui/widget/WidgetService.java index cbfdbe54..8baf62ff 100644 --- a/QKSMS/src/main/java/com/moez/QKSMS/ui/widget/WidgetService.java +++ b/QKSMS/src/main/java/com/moez/QKSMS/ui/widget/WidgetService.java @@ -224,9 +224,9 @@ public class WidgetService extends RemoteViewsService { } private void bindIndicators(RemoteViews remoteViews, Conversation conversation) { - remoteViews.setInt(R.id.muted, "setColorFilter", ThemeManager.getColor()); - remoteViews.setInt(R.id.error, "setColorFilter", ThemeManager.getColor()); - remoteViews.setInt(R.id.unread, "setColorFilter", ThemeManager.getColor()); + remoteViews.setInt(R.id.muted, "setColorFilter", ThemeManager.getInstance().getColor()); + remoteViews.setInt(R.id.error, "setColorFilter", ThemeManager.getInstance().getColor()); + remoteViews.setInt(R.id.unread, "setColorFilter", ThemeManager.getInstance().getColor()); remoteViews.setViewVisibility(R.id.muted, new ConversationPrefsHelper(mContext, conversation.getThreadId()) .getNotificationsEnabled() ? View.GONE : View.VISIBLE); 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) { - SpannableStringBuilder from = addColor(conversation.getRecipients().formatNames(", "), ThemeManager.getTextOnBackgroundPrimary()); + SpannableStringBuilder from = addColor(conversation.getRecipients().formatNames(", "), ThemeManager.getInstance().getTextOnBackgroundPrimary()); if (conversation.hasDraft()) { from.append(mContext.getResources().getString(R.string.draft_separator)); int before = from.length(); from.append(mContext.getResources().getString(R.string.has_draft)); from.setSpan(new TextAppearanceSpan(mContext, android.R.style.TextAppearance_Small, - ThemeManager.getTextOnBackgroundPrimary()), before, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); - from.setSpan(new ForegroundColorSpan(ThemeManager.getColor()), before, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + ThemeManager.getInstance().getTextOnBackgroundPrimary()), 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); @@ -250,12 +250,12 @@ public class WidgetService extends RemoteViewsService { private void bindDate(RemoteViews remoteViews, Conversation conversation) { 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) { remoteViews.setTextViewText(R.id.snippet, addColor(conversation.getSnippet(), conversation.hasUnreadMessages() ? - ThemeManager.getTextOnBackgroundPrimary() : ThemeManager.getTextOnBackgroundSecondary())); + ThemeManager.getInstance().getTextOnBackgroundPrimary() : ThemeManager.getInstance().getTextOnBackgroundSecondary())); } /**