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

Commit 710ae2ec authored by Joey's avatar Joey Committed by Rashed Abdel-Tawab
Browse files

SystemUI: sync dark mode with AOSP night mode too



LiveDisplay night mode may not be available on all devices

Change-Id: I6882bc871881e3a2385b698831aa80bd70b830fd
Signed-off-by: default avatarJoey <joey@lineageos.org>
parent 24ce6c3e
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ import android.widget.ImageView;
import android.widget.TextView;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ColorDisplayController;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -569,6 +570,8 @@ public class StatusBar extends SystemUI implements DemoMode, TunerService.Tunabl
    private boolean mKeyguardShowingMedia;
    private boolean mShowMediaMetadata;

    private ColorDisplayController mColorDisplayController;

    private BroadcastReceiver mWallpaperChangedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
@@ -1075,6 +1078,9 @@ public class StatusBar extends SystemUI implements DemoMode, TunerService.Tunabl

        mVisualizerView = (VisualizerView) mStatusBarWindow.findViewById(R.id.visualizerview);

        mColorDisplayController = new ColorDisplayController(mContext,
                ActivityManager.getCurrentUser());

        // Other icons
        mVolumeComponent = getComponent(VolumeComponent.class);

@@ -2225,6 +2231,21 @@ public class StatusBar extends SystemUI implements DemoMode, TunerService.Tunabl
        return false;
    }

    private boolean isAospNightModeOn() {
        // SystemUI is initialized before ColorDisplayService, so the service may not
        // be ready when this is called the first time
        if (!mColorDisplayController.isAvailable(mContext)) {
            return false;
        }
        try {
            return mColorDisplayController.isActivated();
        } catch (NullPointerException e) {
            Log.w(TAG, e.getMessage());
        }
        return false;
    }


    private String getDarkOverlay() {
        return LineageSettings.System.getString(mContext.getContentResolver(),
                LineageSettings.System.BERRY_DARK_OVERLAY,
@@ -4154,7 +4175,7 @@ public class StatusBar extends SystemUI implements DemoMode, TunerService.Tunabl

        switch (globalStyleSetting) {
            case 1:
                useDarkTheme = isLiveDisplayNightModeOn();
                useDarkTheme = isLiveDisplayNightModeOn() || isAospNightModeOn();
                break;
            case 2:
                useDarkTheme = false;