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

Commit f8d54bb7 authored by Joey's avatar Joey Committed by Michael W
Browse files

SystemUI: disable wallpaper-based tint for scrim



This is quite annoying especially when the lockscreen is displaying an album art.
You don't really want to see the green of your amazing wallpaper
picturing a gorgerous forest landscape when you're rocking Master of Puppets.

Also several users and contributors complained about this thing.
Also it was removed in P dp1 and it never came back in later P builds.

[BadDaemon]
For dark text, use a fully transparent scrim so there is no negative impact
for that usecase
GlobalActionsDialog: Adapted and refactored code for less code change

Change-Id: I5ce5d5ff002f3be9b13a4cbb8df2300d0d7dcb3b
Signed-off-by: default avatarJoey <joey@lineageos.org>
parent 2db48e30
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 * Copyright (C) 2010-2015 CyanogenMod Project
 * Copyright (C) 2017-2018 The LineageOS Project
 * Copyright (C) 2017-2019 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
@@ -42,6 +42,7 @@ import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
@@ -129,6 +130,9 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener,

    private static final boolean SHOW_SILENT_TOGGLE = false;

    // Default scrim color
    private static final int SCRIM_DEFAULT_COLOR = Color.BLACK;

    private final Context mContext;
    private final GlobalActionsManager mWindowManagerFuncs;
    private final AudioManager mAudioManager;
@@ -1709,7 +1713,7 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener,
         * @param animate Interpolates gradient if true, just sets otherwise.
         */
        private void updateColors(GradientColors colors, boolean animate) {
            mGradientDrawable.setColors(colors, animate);
            mGradientDrawable.setColors(getDarkGradientColor(colors), animate);
            View decorView = getWindow().getDecorView();
            if (colors.supportsDarkText()) {
                decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR |
@@ -1719,6 +1723,14 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener,
            }
        }

        private GradientColors getDarkGradientColor(GradientColors fromWallpaper) {
            GradientColors colors = new GradientColors();
            colors.setMainColor(SCRIM_DEFAULT_COLOR);
            colors.setSecondaryColor(SCRIM_DEFAULT_COLOR);
            colors.setSupportsDarkText(fromWallpaper.supportsDarkText());
            return colors;
        }

        @Override
        protected void onStop() {
            super.onStop();
+20 −8
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 * Copyright (C) 2019 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -105,6 +106,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
    private static final int TAG_END_ALPHA = R.id.scrim_alpha_end;
    private static final float NOT_INITIALIZED = -1;

    private static final int SCRIM_DEFAULT_COLOR = Color.BLACK;     // Default scrim color

    private ScrimState mState = ScrimState.UNINITIALIZED;
    private final Context mContext;
    protected final ScrimView mScrimBehind;
@@ -182,10 +185,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo

        mColorExtractor = Dependency.get(SysuiColorExtractor.class);
        mColorExtractor.addOnColorsChangedListener(this);
        mLockColors = mColorExtractor.getColors(WallpaperManager.FLAG_LOCK,
                ColorExtractor.TYPE_DARK, true /* ignoreVisibility */);
        mSystemColors = mColorExtractor.getColors(WallpaperManager.FLAG_SYSTEM,
                ColorExtractor.TYPE_DARK, true /* ignoreVisibility */);
        mLockColors = getDarkGradientColor(WallpaperManager.FLAG_LOCK,
                true /* ignoreVisibility */);
        mSystemColors = getDarkGradientColor(WallpaperManager.FLAG_SYSTEM,
                true /* ignoreVisibility */);
        mNeedsDrawableColorUpdate = true;

        final ScrimState[] states = ScrimState.values();
@@ -818,19 +821,28 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
    @Override
    public void onColorsChanged(ColorExtractor colorExtractor, int which) {
        if ((which & WallpaperManager.FLAG_LOCK) != 0) {
            mLockColors = mColorExtractor.getColors(WallpaperManager.FLAG_LOCK,
                    ColorExtractor.TYPE_DARK, true /* ignoreVisibility */);
            mLockColors = getDarkGradientColor(WallpaperManager.FLAG_LOCK,
                    true /* ignoreVisibility */);
            mNeedsDrawableColorUpdate = true;
            scheduleUpdate();
        }
        if ((which & WallpaperManager.FLAG_SYSTEM) != 0) {
            mSystemColors = mColorExtractor.getColors(WallpaperManager.FLAG_SYSTEM,
                    ColorExtractor.TYPE_DARK, mState != ScrimState.UNLOCKED);
            mSystemColors = getDarkGradientColor(WallpaperManager.FLAG_SYSTEM,
                    mState != ScrimState.UNLOCKED);
            mNeedsDrawableColorUpdate = true;
            scheduleUpdate();
        }
    }

    private GradientColors getDarkGradientColor(int flag, boolean ignoreVisibility) {
        GradientColors fromWallpaper = mColorExtractor.getColors(flag, ColorExtractor.TYPE_DARK,
                ignoreVisibility);
        int color = fromWallpaper.supportsDarkText() ? Color.TRANSPARENT : SCRIM_DEFAULT_COLOR;
        fromWallpaper.setMainColor(color);
        fromWallpaper.setSecondaryColor(color);
        return fromWallpaper;
    }

    @VisibleForTesting
    protected WakeLock createWakeLock() {
         return new DelayedWakeLock(getHandler(),