mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Theme Toolbar from activity
This commit is contained in:
@@ -29,7 +29,7 @@ import java.util.WeakHashMap;
|
||||
public abstract class LiveViewManager {
|
||||
private static final String TAG = "ThemedViewManager";
|
||||
|
||||
private static HashMap<String, Set<LiveView>> sViews = new HashMap<>();
|
||||
private static final HashMap<String, Set<LiveView>> sViews = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Initialize preferences and register a listener for changes
|
||||
|
||||
@@ -11,7 +11,6 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
@@ -261,7 +260,6 @@ public class ThemeManager {
|
||||
*/
|
||||
public static void themeActivity(QKActivity activity) {
|
||||
|
||||
activity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(mColor));
|
||||
mWindow = activity.getWindow();
|
||||
|
||||
mStatusTintEnabled = mPrefs.getBoolean(SettingsFragment.STATUS_TINT, true) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||
@@ -644,16 +642,14 @@ public class ThemeManager {
|
||||
colorAnimation.addUpdateListener(animation -> {
|
||||
int color1 = (Integer) animation.getAnimatedValue();
|
||||
|
||||
if (activity.getSupportActionBar() != null) {
|
||||
activity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color1));
|
||||
}
|
||||
|
||||
if (mStatusTintEnabled) {
|
||||
mWindow.setStatusBarColor(ColorUtils.darken(color1));
|
||||
}
|
||||
if (mNavigationTintEnabled) {
|
||||
mWindow.setNavigationBarColor(ColorUtils.darken(color1));
|
||||
}
|
||||
|
||||
LiveViewManager.refreshViews(QKPreference.ACTIVE_THEME);
|
||||
});
|
||||
colorAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
@@ -686,10 +682,6 @@ public class ThemeManager {
|
||||
public static void setActiveColor(QKActivity activity, int color) {
|
||||
mActiveColor = color;
|
||||
|
||||
if (activity.getSupportActionBar() != null) {
|
||||
activity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
|
||||
}
|
||||
|
||||
if (mStatusTintEnabled) {
|
||||
mWindow.setStatusBarColor(ColorUtils.darken(color));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.widget.Toast;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.moez.QKSMS.QKSMSApp;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
import com.moez.QKSMS.common.preferences.QKPreference;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.moez.QKSMS.ui.view.QKTextView;
|
||||
@@ -72,6 +73,10 @@ public abstract class QKActivity extends ActionBarActivity {
|
||||
setSupportActionBar(mToolbar);
|
||||
}
|
||||
|
||||
LiveViewManager.registerView(QKPreference.ACTIVE_THEME, key -> {
|
||||
mToolbar.setBackgroundColor(ThemeManager.getColor());
|
||||
});
|
||||
|
||||
ThemeManager.themeActivity(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user