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

Commit e5b7dc70 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Reload theme when ui mode changes

ContextThemeWrappers must be reloaded because they have their
own internal themes and configurations.

Change-Id: Ib5ed9db4ca5b5c8af0c1dbdfc053f18836f40a59
Fixes: 117160883
Test: manually toggle dark mode multiple times
parent 2e189585
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ import com.android.systemui.Interpolators;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.GlobalActions.GlobalActionsManager;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.EmergencyDialerConstants;
import com.android.systemui.volume.SystemUIInterpolators.LogAccelerateInterpolator;

@@ -102,7 +103,8 @@ import java.util.List;
 * is provisioned.
 */
class GlobalActionsDialog implements DialogInterface.OnDismissListener,
        DialogInterface.OnClickListener, DialogInterface.OnShowListener {
        DialogInterface.OnClickListener, DialogInterface.OnShowListener,
        ConfigurationController.ConfigurationListener {

    static public final String SYSTEM_DIALOG_REASON_KEY = "reason";
    static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
@@ -197,6 +199,8 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener,

        mEmergencyAffordanceManager = new EmergencyAffordanceManager(context);
        mScreenshotHelper = new ScreenshotHelper(context);

        Dependency.get(ConfigurationController.class).addCallback(this);
    }

    /**
@@ -417,6 +421,15 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener,
                || state == SOME_AUTH_REQUIRED_AFTER_USER_REQUEST);
    }

    @Override
    public void onUiModeChanged() {
        mContext.getTheme().applyStyle(mContext.getThemeResId(), true);
    }

    public void destroy() {
        Dependency.get(ConfigurationController.class).removeCallback(this);
    }

    private final class PowerAction extends SinglePressAction implements LongPressAction {
        private PowerAction() {
            super(R.drawable.ic_lock_power_off,
+4 −0
Original line number Diff line number Diff line
@@ -61,6 +61,10 @@ public class GlobalActionsImpl implements GlobalActions, CommandQueue.Callbacks
    @Override
    public void destroy() {
        SysUiServiceProvider.getComponent(mContext, CommandQueue.class).removeCallbacks(this);
        if (mGlobalActions != null) {
            mGlobalActions.destroy();
            mGlobalActions = null;
        }
    }

    @Override