Static usages of ThemeManager

This commit is contained in:
Moez Bhatti
2015-12-30 22:32:47 -05:00
parent 2ff75f347e
commit d1c623694e
36 changed files with 238 additions and 246 deletions
@@ -41,6 +41,7 @@ import com.moez.QKSMS.common.google.ThumbnailManager;
import com.moez.QKSMS.data.Contact; import com.moez.QKSMS.data.Contact;
import com.moez.QKSMS.data.Conversation; import com.moez.QKSMS.data.Conversation;
import com.moez.QKSMS.transaction.NotificationManager; import com.moez.QKSMS.transaction.NotificationManager;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.mms.layout.LayoutManager; import com.moez.QKSMS.ui.mms.layout.LayoutManager;
import com.squareup.leakcanary.LeakCanary; import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher; import com.squareup.leakcanary.RefWatcher;
@@ -88,6 +89,7 @@ public class QKSMSAppBase extends MultiDexApplication {
mPduLoaderManager = new PduLoaderManager(context); mPduLoaderManager = new PduLoaderManager(context);
mThumbnailManager = new ThumbnailManager(context); mThumbnailManager = new ThumbnailManager(context);
ThemeManager.init(this);
MmsConfig.init(this); MmsConfig.init(this);
Contact.init(this); Contact.init(this);
DraftCache.init(this); DraftCache.init(this);
@@ -97,7 +99,6 @@ public class QKSMSAppBase extends MultiDexApplication {
LayoutManager.init(this); LayoutManager.init(this);
NotificationManager.init(this); NotificationManager.init(this);
LiveViewManager.init(this); LiveViewManager.init(this);
//MessagingNotification.init(this);
activePendingMessages(); activePendingMessages();
} }
@@ -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.getInstance().getTheme() == ThemeManager.Theme.GREY || boolean isNight = ThemeManager.getTheme() == ThemeManager.Theme.GREY ||
ThemeManager.getInstance().getTheme() == ThemeManager.Theme.BLACK; ThemeManager.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.getInstance().getTextOnBackgroundSecondary()); return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary());
case FontManager.TEXT_TYPE_TERTIARY: case FontManager.TEXT_TYPE_TERTIARY:
return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundSecondary()); return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary());
case FontManager.TEXT_TYPE_CATEGORY: case FontManager.TEXT_TYPE_CATEGORY:
return ColorStateList.valueOf(ThemeManager.getInstance().getColor()); return ColorStateList.valueOf(ThemeManager.getColor());
case FontManager.TEXT_TYPE_DIALOG_TITLE: case FontManager.TEXT_TYPE_DIALOG_TITLE:
return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundPrimary()); return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary());
case FontManager.TEXT_TYPE_DIALOG_MESSAGE: case FontManager.TEXT_TYPE_DIALOG_MESSAGE:
return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundSecondary()); return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundSecondary());
case FontManager.TEXT_TYPE_DIALOG_BUTTON: case FontManager.TEXT_TYPE_DIALOG_BUTTON:
return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundPrimary()); return ColorStateList.valueOf(ThemeManager.getTextOnBackgroundPrimary());
case FontManager.TEXT_TYPE_TOOLBAR: case FontManager.TEXT_TYPE_TOOLBAR:
return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnColorPrimary()); return ColorStateList.valueOf(ThemeManager.getTextOnColorPrimary());
} }
return ColorStateList.valueOf(ThemeManager.getInstance().getTextOnBackgroundPrimary()); return ColorStateList.valueOf(ThemeManager.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.getInstance().getTextOnBackgroundSecondary()), Color.red(ThemeManager.getTextOnBackgroundSecondary()),
Color.green(ThemeManager.getInstance().getTextOnBackgroundSecondary()), Color.green(ThemeManager.getTextOnBackgroundSecondary()),
Color.blue(ThemeManager.getInstance().getTextOnBackgroundSecondary())), Color.blue(ThemeManager.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.getInstance().getColor()); bitmap.eraseColor(ThemeManager.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.getInstance().loadThemeProperties(context); ThemeManager.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.getInstance().setTheme(ThemeManager.Theme.GREY); ThemeManager.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.getInstance().setTheme(ThemeManager.Theme.OFFWHITE); ThemeManager.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.getInstance().DEFAULT_COLOR))); background.eraseColor(Integer.parseInt(prefs.getString(SettingsFragment.THEME, "" + ThemeManager.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.getInstance().getColor()); .setColor(ThemeManager.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.getInstance().getBackgroundColor()); findViewById(R.id.menu_frame).getRootView().setBackgroundColor(ThemeManager.getBackgroundColor());
findViewById(R.id.menu_frame).setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); findViewById(R.id.menu_frame).setBackgroundColor(ThemeManager.getBackgroundColor());
findViewById(R.id.content_frame).setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); findViewById(R.id.content_frame).setBackgroundColor(ThemeManager.getBackgroundColor());
} }
public static class DeleteThreadListener implements DialogInterface.OnClickListener { public static class DeleteThreadListener implements DialogInterface.OnClickListener {
@@ -220,58 +220,49 @@ 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 static int mColor;
private int mActiveColor; private static int mActiveColor;
private int mBackgroundColor; private static int mBackgroundColor;
private Theme mTheme; private static Theme mTheme;
private int mTextOnColorPrimary; private static int mTextOnColorPrimary;
private int mTextOnColorSecondary; private static int mTextOnColorSecondary;
private int mTextOnBackgroundPrimary; private static int mTextOnBackgroundPrimary;
private int mtextOnBackgroundSecondary; private static int mtextOnBackgroundSecondary;
private int mSentBubbleRes; private static int mSentBubbleRes;
private int mSentBubbleAltRes; private static int mSentBubbleAltRes;
private boolean mSentBubbleColored; private static boolean mSentBubbleColored;
private int mReceivedBubbleRes; private static int mReceivedBubbleRes;
private int mReceivedBubbleAltRes; private static int mReceivedBubbleAltRes;
private boolean mReceivedBubbleColored; private static boolean mReceivedBubbleColored;
private Drawable mRippleBackground; private static Drawable mRippleBackground;
private Resources mResources; private static Resources mResources;
private SharedPreferences mPrefs; private static SharedPreferences mPrefs;
private boolean mStatusTintEnabled = false; private static boolean mStatusTintEnabled = false;
private boolean mNavigationTintEnabled = false; private static boolean mNavigationTintEnabled = false;
private QKActivity mActivity; private static QKActivity mActivity;
private Context mContext; private static Context mContext;
private Window mWindow; private static Window mWindow;
private static ThemeManager sInstance; public static void init(Context context) {
mContext = context;
public static ThemeManager getInstance() {
if (sInstance == null) {
sInstance = new ThemeManager();
}
return sInstance;
}
private ThemeManager() {
mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
mResources = context.getResources();
} }
/** /**
* 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 void loadThemeProperties(Context context) { public static void loadThemeProperties(Context context) {
mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
mResources = context.getResources();
mContext = context; mContext = context;
mColor = Integer.parseInt(mPrefs.getString(SettingsFragment.THEME, "" + ThemeManager.getInstance().DEFAULT_COLOR)); mColor = Integer.parseInt(mPrefs.getString(SettingsFragment.THEME, "" + ThemeManager.DEFAULT_COLOR));
mActiveColor = mColor; mActiveColor = mColor;
if (context instanceof QKActivity) { if (context instanceof QKActivity) {
@@ -296,7 +287,7 @@ public class ThemeManager {
} }
public void setTheme(Theme theme) { public static void setTheme(Theme theme) {
int startColor = mBackgroundColor; int startColor = mBackgroundColor;
initializeTheme(theme); initializeTheme(theme);
int endColor = mBackgroundColor; int endColor = mBackgroundColor;
@@ -343,7 +334,7 @@ public class ThemeManager {
} }
} }
public void initializeTheme(Theme theme) { public static void initializeTheme(Theme theme) {
mTheme = theme; mTheme = theme;
switch (theme) { switch (theme) {
@@ -406,7 +397,7 @@ public class ThemeManager {
} }
} }
public void setIcon(final QKActivity context) { public static 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)
@@ -459,66 +450,66 @@ public class ThemeManager {
.show(); .show();
} }
public int getBackgroundColor() { public static int getBackgroundColor() {
return mBackgroundColor; return mBackgroundColor;
} }
public int getTextOnColorPrimary() { public static int getTextOnColorPrimary() {
return mTextOnColorPrimary; return mTextOnColorPrimary;
} }
public int getTextOnColorSecondary() { public static int getTextOnColorSecondary() {
return mTextOnColorSecondary; return mTextOnColorSecondary;
} }
public int getTextOnBackgroundPrimary() { public static int getTextOnBackgroundPrimary() {
return mTextOnBackgroundPrimary; return mTextOnBackgroundPrimary;
} }
public int getTextOnBackgroundSecondary() { public static int getTextOnBackgroundSecondary() {
return mtextOnBackgroundSecondary; return mtextOnBackgroundSecondary;
} }
public int getSentBubbleRes() { public static int getSentBubbleRes() {
return mSentBubbleRes; return mSentBubbleRes;
} }
public int getSentBubbleAltRes() { public static int getSentBubbleAltRes() {
return mSentBubbleAltRes; return mSentBubbleAltRes;
} }
public int getSentBubbleColor() { public static int getSentBubbleColor() {
return mSentBubbleColored ? mActiveColor : getNeutralBubbleColor(); return mSentBubbleColored ? mActiveColor : getNeutralBubbleColor();
} }
public int getReceivedBubbleRes() { public static int getReceivedBubbleRes() {
return mReceivedBubbleRes; return mReceivedBubbleRes;
} }
public int getReceivedBubbleAltRes() { public static int getReceivedBubbleAltRes() {
return mReceivedBubbleAltRes; return mReceivedBubbleAltRes;
} }
public int getReceivedBubbleColor() { public static int getReceivedBubbleColor() {
return mReceivedBubbleColored ? mActiveColor : getNeutralBubbleColor(); return mReceivedBubbleColored ? mActiveColor : getNeutralBubbleColor();
} }
public void setBubbleStyleNew(boolean styleNew) { public static void setBubbleStyleNew(boolean styleNew) {
mSentBubbleRes = styleNew ? R.drawable.message_sent_2 : R.drawable.message_sent; mSentBubbleRes = styleNew ? R.drawable.message_sent_2 : R.drawable.message_sent;
mSentBubbleAltRes = 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;
mReceivedBubbleRes = styleNew ? R.drawable.message_received_2 : R.drawable.message_received; mReceivedBubbleRes = styleNew ? R.drawable.message_received_2 : R.drawable.message_received;
mReceivedBubbleAltRes = 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 void setSentBubbleColored(boolean colored) { public static void setSentBubbleColored(boolean colored) {
mSentBubbleColored = colored; mSentBubbleColored = colored;
} }
public void setReceivedBubbleColored(boolean colored) { public static void setReceivedBubbleColored(boolean colored) {
mReceivedBubbleColored = colored; mReceivedBubbleColored = colored;
} }
public int getNeutralBubbleColor() { public static int getNeutralBubbleColor() {
if (mTheme == null) { if (mTheme == null) {
return 0xeeeeee; return 0xeeeeee;
} }
@@ -538,27 +529,27 @@ public class ThemeManager {
} }
} }
public Drawable getRippleBackground() { public static Drawable getRippleBackground() {
return mRippleBackground; return mRippleBackground;
} }
public int getColor() { public static int getColor() {
return mActiveColor; return mActiveColor;
} }
public int getThemeColor() { public static int getThemeColor() {
return mColor; return mColor;
} }
public Theme getTheme() { public static Theme getTheme() {
return mTheme; return mTheme;
} }
public boolean isNightMode() { public static boolean isNightMode() {
return mTheme == Theme.GREY || mTheme == Theme.BLACK; return mTheme == Theme.GREY || mTheme == Theme.BLACK;
} }
public void showColourSwatchesDialog(final QKActivity context) { public static 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);
@@ -578,7 +569,7 @@ public class ThemeManager {
dialog.show(); dialog.show();
} }
private void showColourPickerDialog(final QKActivity context, int swatchColour) { private static 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);
@@ -598,7 +589,7 @@ public class ThemeManager {
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setStatusBarTintEnabled(boolean enabled) { public static void setStatusBarTintEnabled(boolean enabled) {
if (mStatusTintEnabled != enabled) { if (mStatusTintEnabled != enabled) {
mStatusTintEnabled = enabled; mStatusTintEnabled = enabled;
int colorFrom = enabled ? mResources.getColor(R.color.black) : mColor; int colorFrom = enabled ? mResources.getColor(R.color.black) : mColor;
@@ -614,7 +605,7 @@ public class ThemeManager {
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setNavigationBarTintEnabled(boolean enabled) { public static void setNavigationBarTintEnabled(boolean enabled) {
if (mNavigationTintEnabled != enabled) { if (mNavigationTintEnabled != enabled) {
mNavigationTintEnabled = enabled; mNavigationTintEnabled = enabled;
int colorFrom = enabled ? mResources.getColor(R.color.black) : mColor; int colorFrom = enabled ? mResources.getColor(R.color.black) : mColor;
@@ -629,11 +620,11 @@ public class ThemeManager {
} }
} }
public String getColorString(int color) { public static String getColorString(int color) {
return String.format("#%08x", color).toUpperCase(); return String.format("#%08x", color).toUpperCase();
} }
public void setColour(int color) { public static void setColour(int color) {
AnalyticsManager.getInstance().sendEvent( AnalyticsManager.getInstance().sendEvent(
AnalyticsManager.CATEGORY_PREFERENCE_CHANGE, AnalyticsManager.CATEGORY_PREFERENCE_CHANGE,
@@ -710,7 +701,7 @@ public class ThemeManager {
} }
} }
public void setActiveColor(int color) { public static void setActiveColor(int color) {
mActiveColor = color; mActiveColor = color;
if (mActivity != null) { if (mActivity != null) {
@@ -730,7 +721,7 @@ public class ThemeManager {
} }
} }
private boolean isColorDarkEnough(int color) { private static 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]) {
@@ -742,7 +733,7 @@ public class ThemeManager {
return true; return true;
} }
public int getSwatchColour(int colour) { public static 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]) {
@@ -754,7 +745,7 @@ public class ThemeManager {
return colour; return colour;
} }
private int[] getSwatch(int colour) { private static 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.getInstance().loadThemeProperties(this); ThemeManager.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.getInstance().getTextOnColorPrimary()); colorMenuIcons(mMenu, ThemeManager.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.getInstance().getBackgroundColor()); view.setBackgroundColor(ThemeManager.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.getInstance().getBackgroundColor()); getView().setBackgroundColor(ThemeManager.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.getInstance().loadThemeProperties(this); ThemeManager.loadThemeProperties(this);
((QKLinearLayout) findViewById(R.id.popup)).setBackgroundTint(ThemeManager.getInstance().getBackgroundColor()); ((QKLinearLayout) findViewById(R.id.popup)).setBackgroundTint(ThemeManager.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.getInstance().getTextOnBackgroundPrimary()); holder.snippetView.setTextColor(ThemeManager.getTextOnBackgroundPrimary());
holder.dateView.setTextColor(ThemeManager.getInstance().getColor()); holder.dateView.setTextColor(ThemeManager.getColor());
} else { } else {
holder.unreadView.setVisibility(View.GONE); holder.unreadView.setVisibility(View.GONE);
holder.snippetView.setTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary()); holder.snippetView.setTextColor(ThemeManager.getTextOnBackgroundSecondary());
holder.dateView.setTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary()); holder.dateView.setTextColor(ThemeManager.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.getInstance().getColor()); holder.mSelected.setColorFilter(ThemeManager.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.getInstance().getTextOnBackgroundSecondary()); holder.mSelected.setColorFilter(ThemeManager.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.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP); mMuted.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP);
mUnread.setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP); mUnread.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP);
mError.setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP); mError.setColorFilter(ThemeManager.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.getInstance().getTextOnBackgroundPrimary()); mEmptyStateIcon.setColorFilter(ThemeManager.getTextOnBackgroundPrimary());
mRecyclerView.setHasFixedSize(true); mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mAdapter); mRecyclerView.setAdapter(mAdapter);
mFab.setColorNormal(ThemeManager.getInstance().getColor()); mFab.setColorNormal(ThemeManager.getColor());
mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getInstance().getColor())); mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getColor()));
mFab.attachToRecyclerView(mRecyclerView); mFab.attachToRecyclerView(mRecyclerView);
mFab.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary()); mFab.setColorFilter(ThemeManager.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.getInstance().getColor()); mFab.setColorNormal(ThemeManager.getColor());
mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getInstance().getColor())); mFab.setColorPressed(ColorUtils.lighten(ThemeManager.getColor()));
mFab.getDrawable().setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mFab.getDrawable().setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mEmptyStateIcon.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundPrimary()); mEmptyStateIcon.setColorFilter(ThemeManager.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.getInstance().getColor()), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); buf.setSpan(new ForegroundColorSpan(ThemeManager.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.getInstance().getReceivedBubbleRes()); in1.setBackgroundResource(ThemeManager.getReceivedBubbleRes());
in1.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in1.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
final QKTextView in2 = (QKTextView) view.findViewById(R.id.in_2); final QKTextView in2 = (QKTextView) view.findViewById(R.id.in_2);
in2.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleAltRes()); in2.setBackgroundResource(ThemeManager.getReceivedBubbleAltRes());
in2.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in2.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
final QKTextView out1 = (QKTextView) view.findViewById(R.id.out_1); final QKTextView out1 = (QKTextView) view.findViewById(R.id.out_1);
out1.setBackgroundResource(ThemeManager.getInstance().getSentBubbleRes()); out1.setBackgroundResource(ThemeManager.getSentBubbleRes());
out1.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out1.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor());
final QKTextView out2 = (QKTextView) view.findViewById(R.id.out_2); final QKTextView out2 = (QKTextView) view.findViewById(R.id.out_2);
out2.setBackgroundResource(ThemeManager.getInstance().getSentBubbleAltRes()); out2.setBackgroundResource(ThemeManager.getSentBubbleAltRes());
out2.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out2.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.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.getInstance().setBubbleStyleNew(((QKSwitchPreference) preference).isChecked()); ThemeManager.setBubbleStyleNew(((QKSwitchPreference) preference).isChecked());
in1.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleRes()); in1.setBackgroundResource(ThemeManager.getReceivedBubbleRes());
in1.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in1.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
in2.setBackgroundResource(ThemeManager.getInstance().getReceivedBubbleAltRes()); in2.setBackgroundResource(ThemeManager.getReceivedBubbleAltRes());
in2.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in2.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
out1.setBackgroundResource(ThemeManager.getInstance().getSentBubbleRes()); out1.setBackgroundResource(ThemeManager.getSentBubbleRes());
out1.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out1.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor());
out2.setBackgroundResource(ThemeManager.getInstance().getSentBubbleAltRes()); out2.setBackgroundResource(ThemeManager.getSentBubbleAltRes());
out2.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out2.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor());
return true; return true;
case SettingsFragment.COLOUR_RECEIVED: case SettingsFragment.COLOUR_RECEIVED:
ThemeManager.getInstance().setReceivedBubbleColored(((QKSwitchPreference) preference).isChecked()); ThemeManager.setReceivedBubbleColored(((QKSwitchPreference) preference).isChecked());
in1.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in1.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in1.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); in1.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
in2.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); in2.getBackground().setColorFilter(ThemeManager.getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP);
in2.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() == ThemeManager.getInstance().getColor()); in2.setOnColorBackground(ThemeManager.getReceivedBubbleColor() == ThemeManager.getColor());
return true; return true;
case SettingsFragment.COLOUR_SENT: case SettingsFragment.COLOUR_SENT:
ThemeManager.getInstance().setSentBubbleColored(((QKSwitchPreference) preference).isChecked()); ThemeManager.setSentBubbleColored(((QKSwitchPreference) preference).isChecked());
out1.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out1.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out1.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); out1.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.getColor());
out2.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); out2.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
out2.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() == ThemeManager.getInstance().getColor()); out2.setOnColorBackground(ThemeManager.getSentBubbleColor() == ThemeManager.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.getInstance().getColor()) .actionColor(ThemeManager.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.getInstance().getColor()); mPositiveButtonView.setTextColor(ThemeManager.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.getInstance().getColor()); title.setTextColor(ThemeManager.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.getInstance().getTextOnBackgroundPrimary()); subtitle.setTextColor(ThemeManager.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.getInstance().getColor()); mPositiveButtonView.setTextColor(ThemeManager.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.getInstance().getColor()); title.setTextColor(ThemeManager.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.getInstance().getTextOnBackgroundPrimary()); subtitle.setTextColor(ThemeManager.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))
@@ -136,10 +136,10 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
if (sent) { if (sent) {
// set up colors // set up colors
holder.mBodyTextView.setOnColorBackground(ThemeManager.getInstance().getSentBubbleColor() != ThemeManager.getInstance().getNeutralBubbleColor()); holder.mBodyTextView.setOnColorBackground(ThemeManager.getSentBubbleColor() != ThemeManager.getNeutralBubbleColor());
holder.mDateView.setOnColorBackground(false); holder.mDateView.setOnColorBackground(false);
holder.mDeliveredIndicator.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); holder.mDeliveredIndicator.setColorFilter(ThemeManager.getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP);
holder.mLockedIndicator.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); holder.mLockedIndicator.setColorFilter(ThemeManager.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));
@@ -151,10 +151,10 @@ public class MessageListAdapter extends RecyclerCursorAdapter<MessageListViewHol
} }
} else { } else {
// set up colors // set up colors
holder.mBodyTextView.setOnColorBackground(ThemeManager.getInstance().getReceivedBubbleColor() != ThemeManager.getInstance().getNeutralBubbleColor()); holder.mBodyTextView.setOnColorBackground(ThemeManager.getReceivedBubbleColor() != ThemeManager.getNeutralBubbleColor());
holder.mDateView.setOnColorBackground(false); holder.mDateView.setOnColorBackground(false);
holder.mDeliveredIndicator.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); holder.mDeliveredIndicator.setColorFilter(ThemeManager.getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP);
holder.mLockedIndicator.setColorFilter(ThemeManager.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); holder.mLockedIndicator.setColorFilter(ThemeManager.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)) {
@@ -308,15 +308,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.getInstance().getSentBubbleRes() : holder.mBodyTextView.setBackgroundResource(showAvatar ? (messageItem.isMe() ? ThemeManager.getSentBubbleRes() :
ThemeManager.getInstance().getReceivedBubbleRes()) : (messageItem.isMe() ? ThemeManager.getReceivedBubbleRes()) : (messageItem.isMe() ?
ThemeManager.getInstance().getSentBubbleAltRes() : ThemeManager.getInstance().getReceivedBubbleAltRes())); ThemeManager.getSentBubbleAltRes() : ThemeManager.getReceivedBubbleAltRes()));
holder.setLiveViewCallback(() -> { holder.setLiveViewCallback(() -> {
if (messageItem.isMe()) { if (messageItem.isMe()) {
holder.mBodyTextView.getBackground().setColorFilter(ThemeManager.getInstance().getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP); holder.mBodyTextView.getBackground().setColorFilter(ThemeManager.getSentBubbleColor(), PorterDuff.Mode.SRC_ATOP);
} else { } else {
holder.mBodyTextView.getBackground().setColorFilter(ThemeManager.getInstance().getReceivedBubbleColor(), PorterDuff.Mode.SRC_ATOP); holder.mBodyTextView.getBackground().setColorFilter(ThemeManager.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.getInstance().setActiveColor(mConversationPrefs.getColor()); ThemeManager.setActiveColor(mConversationPrefs.getColor());
} }
@Override @Override
@@ -787,14 +787,14 @@ public class MessageListFragment extends QKContentFragment implements ActivityLa
} }
} }
ThemeManager.getInstance().setActiveColor(ThemeManager.getInstance().getThemeColor()); ThemeManager.setActiveColor(ThemeManager.getThemeColor());
} }
@Override @Override
public void onMenuChanging(float percentOpen) { public void onMenuChanging(float percentOpen) {
if (mConversationPrefs != null) { if (mConversationPrefs != null) {
ThemeManager.getInstance().setActiveColor((int) mArgbEvaluator.evaluate( ThemeManager.setActiveColor((int) mArgbEvaluator.evaluate(
percentOpen, 0xFF000000 | mConversationPrefs.getColor(), 0xFF000000 | ThemeManager.getInstance().getThemeColor())); percentOpen, 0xFF000000 | mConversationPrefs.getColor(), 0xFF000000 | ThemeManager.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.getInstance().getColorString(Integer.parseInt(valueString)); valueString = ThemeManager.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.getInstance().setTheme(ThemeManager.Theme.fromString((String) newValue)); ThemeManager.setTheme(ThemeManager.Theme.fromString((String) newValue));
break; break;
case STATUS_TINT: case STATUS_TINT:
ThemeManager.getInstance().setStatusBarTintEnabled((Boolean) newValue); ThemeManager.setStatusBarTintEnabled((Boolean) newValue);
break; break;
case NAVIGATION_TINT: case NAVIGATION_TINT:
ThemeManager.getInstance().setNavigationBarTintEnabled((Boolean) newValue); ThemeManager.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.getInstance().setSentBubbleColored((Boolean) newValue); ThemeManager.setSentBubbleColored((Boolean) newValue);
break; break;
case COLOUR_RECEIVED: case COLOUR_RECEIVED:
ThemeManager.getInstance().setReceivedBubbleColored((Boolean) newValue); ThemeManager.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.getInstance().showColourSwatchesDialog(mContext); ThemeManager.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.getInstance().setIcon(mContext); ThemeManager.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.getInstance().getBackgroundColor()); view.setBackgroundColor(ThemeManager.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.getInstance().getTextOnBackgroundPrimary()); setTextColor(ThemeManager.getTextOnBackgroundPrimary());
setHintTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary()); setHintTextColor(ThemeManager.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.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP); getBackground().setColorFilter(ThemeManager.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.getInstance().getTextOnColorPrimary()); mPaint.setColor(ThemeManager.getTextOnColorPrimary());
mDefaultDrawable.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mDefaultDrawable.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
if (getBackground() == null) { if (getBackground() == null) {
setBackgroundResource(R.drawable.circle); setBackgroundResource(R.drawable.circle);
} }
getBackground().setColorFilter(ThemeManager.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP); getBackground().setColorFilter(ThemeManager.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.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP); mButtonBackground.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP);
mButtonBar1.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mButtonBar1.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mButtonBar2.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mButtonBar2.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mAttachmentPanel.setBackgroundColor(ThemeManager.getInstance().getColor()); mAttachmentPanel.setBackgroundColor(ThemeManager.getColor());
mAttach.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mAttach.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mCamera.setColorFilter(ThemeManager.getInstance().getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP); mCamera.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
updateDelayButton(); updateDelayButton();
mProgress.setUnfinishedStrokeColor(ThemeManager.getInstance().getTextOnColorSecondary()); mProgress.setUnfinishedStrokeColor(ThemeManager.getTextOnColorSecondary());
mProgress.setFinishedStrokeColor(ThemeManager.getInstance().getTextOnColorPrimary()); mProgress.setFinishedStrokeColor(ThemeManager.getTextOnColorPrimary());
if (ThemeManager.getInstance().getSentBubbleRes() != 0) mReplyText.setBackgroundResource(ThemeManager.getInstance().getSentBubbleRes()); if (ThemeManager.getSentBubbleRes() != 0) mReplyText.setBackgroundResource(ThemeManager.getSentBubbleRes());
mReplyText.getBackground().setColorFilter(ThemeManager.getInstance().getNeutralBubbleColor(), PorterDuff.Mode.SRC_ATOP); mReplyText.getBackground().setColorFilter(ThemeManager.getNeutralBubbleColor(), PorterDuff.Mode.SRC_ATOP);
mReplyText.refresh(); mReplyText.refresh();
getBackground().setColorFilter(ThemeManager.getInstance().getBackgroundColor(), PorterDuff.Mode.SRC_ATOP); getBackground().setColorFilter(ThemeManager.getBackgroundColor(), PorterDuff.Mode.SRC_ATOP);
} }
private void updateDelayButton() { private void updateDelayButton() {
mDelay.setColorFilter(mDelayedMessagingEnabled ? mDelay.setColorFilter(mDelayedMessagingEnabled ?
ThemeManager.getInstance().getTextOnColorPrimary() : ThemeManager.getInstance().getTextOnColorSecondary(), ThemeManager.getTextOnColorPrimary() : ThemeManager.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.getInstance().getTextOnBackgroundPrimary()); setTextColor(ThemeManager.getTextOnBackgroundPrimary());
setHintTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary()); setHintTextColor(ThemeManager.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.getInstance().getColor(), PorterDuff.Mode.SRC_ATOP); mDrawable.setColorFilter(ThemeManager.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.getInstance().isNightMode() ? colors[0] = mRes.getColor(ThemeManager.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.getInstance().getColor(); colors[1] = ThemeManager.getColor();
// Unchecked enabled state state // Unchecked enabled state state
states[2] = new int[0]; states[2] = new int[0];
colors[2] = mRes.getColor(ThemeManager.getInstance().isNightMode() ? colors[2] = mRes.getColor(ThemeManager.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.getInstance().isNightMode() ? colors[0] = mRes.getColor(ThemeManager.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.getInstance().getColor()), Color.red(ThemeManager.getColor()),
Color.green(ThemeManager.getInstance().getColor()), Color.green(ThemeManager.getColor()),
Color.blue(ThemeManager.getInstance().getColor())); Color.blue(ThemeManager.getColor()));
// Unchecked enabled state state // Unchecked enabled state state
states[2] = new int[0]; states[2] = new int[0];
colors[2] = mRes.getColor(ThemeManager.getInstance().isNightMode() ? colors[2] = mRes.getColor(ThemeManager.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.getInstance().getTextOnColorPrimary()); setTextColor(ThemeManager.getTextOnColorPrimary());
setLinkTextColor(ThemeManager.getInstance().getTextOnColorPrimary()); setLinkTextColor(ThemeManager.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.getInstance().getTextOnColorSecondary()); setTextColor(ThemeManager.getTextOnColorSecondary());
} }
} else { } else {
if (mType == FontManager.TEXT_TYPE_PRIMARY) { if (mType == FontManager.TEXT_TYPE_PRIMARY) {
setTextColor(ThemeManager.getInstance().getTextOnBackgroundPrimary()); setTextColor(ThemeManager.getTextOnBackgroundPrimary());
setLinkTextColor(ThemeManager.getInstance().getColor()); setLinkTextColor(ThemeManager.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.getInstance().getTextOnBackgroundSecondary()); setTextColor(ThemeManager.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.getInstance().getBackgroundColor()); mFavoritesBackground.setBackgroundColor(ThemeManager.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.getInstance().getTextOnBackgroundPrimary()); mTitle.setTextColor(ThemeManager.getTextOnBackgroundPrimary());
mFavorites.setVisibility(View.VISIBLE); mFavorites.setVisibility(View.VISIBLE);
mIndicator.setRotation(0f); mIndicator.setRotation(0f);
} }
public void collapse() { public void collapse() {
mTitle.setTextColor(ThemeManager.getInstance().getTextOnBackgroundSecondary()); mTitle.setTextColor(ThemeManager.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.getInstance().getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP); mIndicator.setColorFilter(ThemeManager.getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP);
mFavoritesBackground.setBackgroundColor(ThemeManager.getInstance().getBackgroundColor()); mFavoritesBackground.setBackgroundColor(ThemeManager.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.getInstance().getColor()); mBackground.setBackgroundColor(ThemeManager.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.getInstance().getColor(), color); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), ThemeManager.getColor(), color);
colorAnimation.setDuration(ThemeManager.getInstance().TRANSITION_LENGTH); colorAnimation.setDuration(ThemeManager.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.getInstance().setColour(color); ThemeManager.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.getInstance().getBackgroundColor(), ThemeManager.getInstance().getColor()); int colorBackground = (Integer) mArgbEvaluator.evaluate(Math.abs(offset), ThemeManager.getBackgroundColor(), ThemeManager.getColor());
int colorAccent = (Integer) mArgbEvaluator.evaluate(1 - Math.abs(offset), 0xFFFFFFFF, ThemeManager.getInstance().getColor()); int colorAccent = (Integer) mArgbEvaluator.evaluate(1 - Math.abs(offset), 0xFFFFFFFF, ThemeManager.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.getInstance().getTheme() == ThemeManager.Theme.OFFWHITE; boolean night = ThemeManager.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.getInstance().setTheme(night ? ThemeManager.Theme.GREY : ThemeManager.Theme.OFFWHITE); ThemeManager.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.getInstance().TRANSITION_LENGTH); colorAnimation.setDuration(ThemeManager.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.getInstance().PALETTE, ThemeManager.getInstance().getColor()); mPallette.drawPalette(ThemeManager.PALETTE, ThemeManager.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.getInstance().PALETTE, color); mPallette.drawPalette(ThemeManager.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.getInstance().loadThemeProperties(context); ThemeManager.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.getInstance().getTextOnColorPrimary()); remoteViews.setTextColor(R.id.widget_label, ThemeManager.getTextOnColorPrimary());
remoteViews.setInt(R.id.conversation_list_background, "setColorFilter", ThemeManager.getInstance().getBackgroundColor()); remoteViews.setInt(R.id.conversation_list_background, "setColorFilter", ThemeManager.getBackgroundColor());
remoteViews.setInt(R.id.header_background, "setColorFilter", ThemeManager.getInstance().getColor()); remoteViews.setInt(R.id.header_background, "setColorFilter", ThemeManager.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.getInstance().getColor()); remoteViews.setInt(R.id.muted, "setColorFilter", ThemeManager.getColor());
remoteViews.setInt(R.id.error, "setColorFilter", ThemeManager.getInstance().getColor()); remoteViews.setInt(R.id.error, "setColorFilter", ThemeManager.getColor());
remoteViews.setInt(R.id.unread, "setColorFilter", ThemeManager.getInstance().getColor()); remoteViews.setInt(R.id.unread, "setColorFilter", ThemeManager.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.getInstance().getTextOnBackgroundPrimary()); SpannableStringBuilder from = addColor(conversation.getRecipients().formatNames(", "), ThemeManager.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.getInstance().getTextOnBackgroundPrimary()), before, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); ThemeManager.getTextOnBackgroundPrimary()), before, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
from.setSpan(new ForegroundColorSpan(ThemeManager.getInstance().getColor()), before, from.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); from.setSpan(new ForegroundColorSpan(ThemeManager.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.getInstance().getColor() : ThemeManager.getInstance().getTextOnBackgroundSecondary())); conversation.hasUnreadMessages() ? ThemeManager.getColor() : ThemeManager.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.getInstance().getTextOnBackgroundPrimary() : ThemeManager.getInstance().getTextOnBackgroundSecondary())); ThemeManager.getTextOnBackgroundPrimary() : ThemeManager.getTextOnBackgroundSecondary()));
} }
/** /**