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

Commit 24d0a54d authored by Ido Ben-Hur's avatar Ido Ben-Hur Committed by Bruno Martins
Browse files

ThemeOverlayController: Don't enable neutral overlay when we use dark bg



Slightly hacky, but this allows the dark background to be applied to more 3rd party apps

Conflicting values in neutral overlays are:
color/system_neutral1_900
color/system_neutral2_900

Will consider only removing these from the overlay instead of disabling the whole thing

Change-Id: Icca896c15d169fc6e87f89cef4b5677c23daf5fb
Signed-off-by: default avatarPranav Vashi <neobuddy89@gmail.com>
parent 302a9567
Loading
Loading
Loading
Loading
+33 −4
Original line number Diff line number Diff line
@@ -41,7 +41,9 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.om.FabricatedOverlay;
import android.content.om.IOverlayManager;
import android.content.om.OverlayIdentifier;
import android.content.om.OverlayInfo;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -49,6 +51,8 @@ import android.database.ContentObserver;
import android.graphics.Color;
import android.net.Uri;
import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -172,6 +176,8 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
    private ColorScheme mDarkColorScheme;
    private ColorScheme mLightColorScheme;

    private IOverlayManager mOverlayManager;

    // Defers changing themes until Setup Wizard is done.
    private boolean mDeferredThemeEvaluation;
    // Determines if we should ignore THEME_CUSTOMIZATION_OVERLAY_PACKAGES setting changes.
@@ -442,6 +448,9 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
        mUiModeManager = uiModeManager;
        mActivityManager = activityManager;
        dumpManager.registerDumpable(TAG, this);

        mOverlayManager = IOverlayManager.Stub.asInterface(
                ServiceManager.getService(Context.OVERLAY_SERVICE));
    }

    @Override
@@ -763,6 +772,9 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
    }

    private void updateThemeOverlays() {
        boolean skipNeutral;
        boolean enableNeutral;

        final int currentUser = mUserTracker.getUserId();
        final String overlayPackageJson = mSecureSettings.getStringForUser(
                Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
@@ -814,10 +826,23 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
            }
        }

        if (mOverlayManager != null) {
            OverlayInfo info = null;
            try {
                info = mOverlayManager.getOverlayInfo(OVERLAY_BERRY_BLACK_THEME,
                        mUserTracker.getUserId());
            } catch (RemoteException e) {
                Log.e(TAG, "Failed getting overlay " + OVERLAY_BERRY_BLACK_THEME + " info");
                e.printStackTrace();
            }
            skipNeutral = isNightMode() && info != null && info.isEnabled();
            enableNeutral = !isNightMode() && info != null && info.isEnabled();
        }

        // Compatibility with legacy themes, where full packages were defined, instead of just
        // colors.
        if (!categoryToPackage.containsKey(OVERLAY_CATEGORY_SYSTEM_PALETTE)
                && mNeutralOverlay != null) {
                && mNeutralOverlay != null && (!skipNeutral || enableNeutral)) {
            categoryToPackage.put(OVERLAY_CATEGORY_SYSTEM_PALETTE,
                    mNeutralOverlay.getIdentifier());
        }
@@ -861,9 +886,13 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {

        if (mNeedsOverlayCreation) {
            mNeedsOverlayCreation = false;
            fOverlays = new FabricatedOverlay[]{
                    mSecondaryOverlay, mNeutralOverlay, mDynamicOverlay
            };
            fOverlays = new FabricatedOverlay[skipNeutral ? 2 : 3];
            int c = 0;
            fOverlays[c++] = mSecondaryOverlay;
            if (!skipNeutral || enableNeutral) {
                fOverlays[c++] = mNeutralOverlay;
            }
            fOverlays[c++] = mDynamicOverlay;
        }

        mThemeManager.applyCurrentUserOverlays(categoryToPackage, fOverlays, currentUser,