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

Commit 3c0c8f14 authored by Andy Mast's avatar Andy Mast
Browse files

Themes: PhoneWindowManager UI context on demand

Creating the UI context in init causes some elements
like the power menu to not theme correctly. This solution follows
the same pattern as VolumePanel.

Change-Id: I5c12f9a3bc8f5fe8d96ef2775b840926a6c35e28
parent c6cbfea8
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -1030,7 +1030,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            // Do the switch
            final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
            final int ringerMode = am.getRingerMode();
            final VolumePanel volumePanel = new VolumePanel(mUiContext,
            final VolumePanel volumePanel = new VolumePanel(getUiContext(),
                                                              (AudioService) getAudioService());
            if (ringerMode == AudioManager.RINGER_MODE_NORMAL) {
                boolean vibrateSetting = Settings.System.getIntForUser(mContext.getContentResolver(),
@@ -1045,6 +1045,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    };

    private Context getUiContext() {
        if (mUiContext == null) {
            mUiContext = ThemeUtils.createUiContext(mContext);
        }
        return mUiContext != null ? mUiContext : mContext;
    }

    Runnable mBackLongPress = new Runnable() {
        public void run() {
            if (DevUtils.killForegroundApplication(mContext)) {
@@ -1182,15 +1189,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    public void init(Context context, IWindowManager windowManager,
            WindowManagerFuncs windowManagerFuncs) {
        mContext = context;
        mUiContext = ThemeUtils.createUiContext(context);
        ThemeUtils.registerThemeChangeReceiver(context, new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                mUiContext = ThemeUtils.createUiContext(mContext);
            }
        });


        mWindowManager = windowManager;
        mWindowManagerFuncs = windowManagerFuncs;
        mHeadless = "1".equals(SystemProperties.get("ro.config.headless", "0"));
@@ -1375,6 +1373,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        + deviceKeyHandlerLib, e);
            }
        }

        ThemeUtils.registerThemeChangeReceiver(context, new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                mUiContext = null;
            }
        });
    }

    private void updateKeyAssignments() {