Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5525f9b1 authored by d34d's avatar d34d Committed by Gerrit Code Review
Browse files

Themes: Call recreateTheme when theme changed

In order to pick up changes in styles and attributes it is necessary
to call recreateTheme() when a theme change occurs.

Change-Id: I7cd22ec09914c467710fbe76672e975b30c556b3
TICKET: CYNGNOS-1126
parent 131dc667
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.ThemeConfig;
import android.os.SystemProperties;
import android.util.Log;

@@ -56,6 +57,7 @@ public class SystemUIApplication extends Application {
    private boolean mServicesStarted;
    private boolean mBootCompleted;
    private final Map<Class<?>, Object> mComponents = new HashMap<Class<?>, Object>();
    private Configuration mConfig;

    @Override
    public void onCreate() {
@@ -83,6 +85,7 @@ public class SystemUIApplication extends Application {
                }
            }
        }, filter);
        mConfig = new Configuration(getResources().getConfiguration());
    }

    /**
@@ -132,6 +135,12 @@ public class SystemUIApplication extends Application {

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        if (isThemeChange(mConfig, newConfig)) {
            // theme resource changed so recreate styles and attributes
            recreateTheme();
        }

        mConfig.setTo(newConfig);
        if (mServicesStarted) {
            int len = mServices.length;
            for (int i = 0; i < len; i++) {
@@ -148,4 +157,11 @@ public class SystemUIApplication extends Application {
    public SystemUI[] getServices() {
        return mServices;
    }

    private static boolean isThemeChange(Configuration oldConfig, Configuration newConfig) {
        final ThemeConfig oldThemeConfig = oldConfig != null ? oldConfig.themeConfig : null;
        final ThemeConfig newThemeConfig = newConfig != null ? newConfig.themeConfig : null;

        return newThemeConfig != null && !newThemeConfig.equals(oldThemeConfig);
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -4102,7 +4102,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        final boolean updateStatusBar = shouldUpdateStatusbar(mCurrentTheme, newTheme);
        if (newTheme != null) mCurrentTheme = (ThemeConfig) newTheme.clone();
        if (updateStatusBar) {
            mContext.recreateTheme();
            recreateStatusBar();
        } else {
            loadDimens();
+0 −1
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ public class VolumeUI extends SystemUI {
        super.onConfigurationChanged(newConfig);

        if (isThemeChange(newConfig)) {
            mContext.recreateTheme();
            initPanel();
        }
        mConfiguration.setTo(newConfig);