mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Migrate more Activity theming ThemeManager
This commit is contained in:
@@ -90,7 +90,7 @@ public enum QKPreference {
|
||||
QK_COMPOSE("pref_key_quickcompose", false),
|
||||
|
||||
// LiveViews
|
||||
ACTIVE_THEME("pref_key_active_theme");
|
||||
ACTIVE_COLOR("pref_key_active_theme");
|
||||
|
||||
private String mKey;
|
||||
private Object mDefaultValue;
|
||||
|
||||
@@ -353,18 +353,12 @@ public class ThemeManager {
|
||||
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:
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -377,11 +371,7 @@ public class ThemeManager {
|
||||
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(mTextOnColorPrimary);
|
||||
}*/
|
||||
LiveViewManager.refreshViews(QKPreference.THEME);
|
||||
}
|
||||
|
||||
public static void setIcon(final QKActivity context) {
|
||||
@@ -649,7 +639,7 @@ public class ThemeManager {
|
||||
mWindow.setNavigationBarColor(ColorUtils.darken(color1));
|
||||
}
|
||||
|
||||
LiveViewManager.refreshViews(QKPreference.ACTIVE_THEME);
|
||||
LiveViewManager.refreshViews(QKPreference.ACTIVE_COLOR);
|
||||
});
|
||||
colorAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
@@ -689,7 +679,7 @@ public class ThemeManager {
|
||||
mWindow.setNavigationBarColor(ColorUtils.darken(color));
|
||||
}
|
||||
|
||||
LiveViewManager.refreshViews(QKPreference.ACTIVE_THEME);
|
||||
LiveViewManager.refreshViews(QKPreference.ACTIVE_COLOR);
|
||||
}
|
||||
|
||||
private static boolean isColorDarkEnough(int color) {
|
||||
|
||||
@@ -73,10 +73,25 @@ public abstract class QKActivity extends AppCompatActivity {
|
||||
setSupportActionBar(mToolbar);
|
||||
}
|
||||
|
||||
LiveViewManager.registerView(QKPreference.ACTIVE_THEME, this, key -> {
|
||||
LiveViewManager.registerView(QKPreference.ACTIVE_COLOR, this, key -> {
|
||||
mToolbar.setBackgroundColor(ThemeManager.getColor());
|
||||
});
|
||||
|
||||
LiveViewManager.registerView(QKPreference.THEME, this, key -> {
|
||||
switch (ThemeManager.getTheme()) {
|
||||
case WHITE:
|
||||
case OFFWHITE:
|
||||
mToolbar.setPopupTheme(R.style.PopupThemeLight);
|
||||
break;
|
||||
|
||||
case GREY:
|
||||
case BLACK:
|
||||
mToolbar.setPopupTheme(R.style.PopupTheme);
|
||||
break;
|
||||
}
|
||||
((QKTextView) findViewById(R.id.toolbar_title)).setTextColor(ThemeManager.getTextOnColorPrimary());
|
||||
});
|
||||
|
||||
ThemeManager.themeActivity(this);
|
||||
}
|
||||
|
||||
@@ -102,10 +117,10 @@ public abstract class QKActivity extends AppCompatActivity {
|
||||
public void colorMenuIcons(Menu menu, int color) {
|
||||
|
||||
// Toolbar navigation icon
|
||||
Drawable navigationIcon = getToolbar().getNavigationIcon();
|
||||
Drawable navigationIcon = mToolbar.getNavigationIcon();
|
||||
if (navigationIcon != null) {
|
||||
navigationIcon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||
getToolbar().setNavigationIcon(navigationIcon);
|
||||
mToolbar.setNavigationIcon(navigationIcon);
|
||||
}
|
||||
|
||||
// Overflow icon
|
||||
@@ -217,15 +232,6 @@ public abstract class QKActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Toolbar for this activity.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Toolbar getToolbar() {
|
||||
return mToolbar;
|
||||
}
|
||||
|
||||
public boolean isScreenOn() {
|
||||
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
||||
|
||||
@@ -94,7 +94,7 @@ public class MessageListViewHolder extends ClickyViewHolder<MessageItem> impleme
|
||||
}
|
||||
|
||||
protected void setLiveViewCallback(LiveView liveViewCallback) {
|
||||
LiveViewManager.registerView(QKPreference.ACTIVE_THEME, this, liveViewCallback);
|
||||
LiveViewManager.registerView(QKPreference.ACTIVE_COLOR, this, liveViewCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -91,7 +91,7 @@ public class AvatarView extends ImageView implements View.OnClickListener {
|
||||
|
||||
setOnClickListener(this);
|
||||
|
||||
LiveViewManager.registerView(QKPreference.ACTIVE_THEME, this, key -> {
|
||||
LiveViewManager.registerView(QKPreference.ACTIVE_COLOR, this, key -> {
|
||||
mPaint.setColor(ThemeManager.getTextOnColorPrimary());
|
||||
mDefaultDrawable.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ public class ComposeView extends LinearLayout implements View.OnClickListener {
|
||||
mCancel.setOnClickListener(this);
|
||||
mDelay.setOnClickListener(this);
|
||||
|
||||
LiveViewManager.registerView(QKPreference.ACTIVE_THEME, this, key -> {
|
||||
LiveViewManager.registerView(QKPreference.ACTIVE_COLOR, this, key -> {
|
||||
mButtonBackground.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP);
|
||||
mButtonBar1.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
|
||||
mButtonBar2.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
Reference in New Issue
Block a user