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

Commit f1d3cf02 authored by Shan Huang's avatar Shan Huang Committed by Android (Google) Code Review
Browse files

Merge "Add a background scrim to launcher for text protection." into sc-dev

parents 8d8a655b 18caa92d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -58,5 +58,6 @@
    <color name="text_color_tertiary_dark">#CCFFFFFF</color>

    <color name="wallpaper_popup_scrim">?android:attr/colorAccent</color>
    <color name="wallpaper_scrim_color">#0D878787</color>

</resources>
+2 −2
Original line number Diff line number Diff line
@@ -4,6 +4,6 @@
    <entry id="@color/delete_target_hover_tint" />
    <entry id="@color/delete_target_hover_tint" />
    <entry id="@color/delete_target_hover_tint" />

    <entry id="@color/wallpaper_scrim_color" />

</DynamicResources>
+4 −0
Original line number Diff line number Diff line
@@ -240,6 +240,10 @@ public final class FeatureFlags {
    public static final BooleanFlag PROTOTYPE_APP_CLOSE = getDebugFlag(
            "PROTOTYPE_APP_CLOSE", false, "Enables new app close");

    public static final BooleanFlag ENABLE_WALLPAPER_SCRIM = getDebugFlag(
            "ENABLE_WALLPAPER_SCRIM", false,
            "Enables scrim over wallpaper for text protection.");

    public static void initialize(Context context) {
        synchronized (sDebugFlags) {
            for (DebugFlag flag : sDebugFlags) {
+20 −1
Original line number Diff line number Diff line
@@ -45,7 +45,10 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
import com.android.launcher3.ResourceUtils;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.DynamicResource;
import com.android.launcher3.util.Themes;
import com.android.systemui.plugins.ResourceProvider;

/**
 * View scrim which draws behind hotseat and workspace
@@ -101,8 +104,10 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {
    private static final int ALPHA_MASK_BITMAP_DP = 200;
    private static final int ALPHA_MASK_WIDTH_DP = 2;

    private boolean mDrawTopScrim, mDrawBottomScrim;
    private boolean mDrawTopScrim, mDrawBottomScrim, mDrawWallpaperScrim;

    private final RectF mWallpaperScrimRect = new RectF();
    private final Paint mWallpaperScrimPaint = new Paint();
    private final RectF mFinalMaskRect = new RectF();
    private final Paint mBottomMaskPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
    private final Bitmap mBottomMask;
@@ -117,6 +122,7 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {

    private boolean mAnimateScrimOnNextDraw = false;
    private float mSysUiAnimMultiplier = 1;
    private int mWallpaperScrimMaxAlpha;

    public SysUiScrim(View view) {
        mRoot = view;
@@ -127,6 +133,14 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {
        mBottomMask = mTopScrim == null ? null : createDitheredAlphaMask();
        mHideSysUiScrim = mTopScrim == null;

        mDrawWallpaperScrim = FeatureFlags.ENABLE_WALLPAPER_SCRIM.get()
                && !Themes.getAttrBoolean(view.getContext(), R.attr.isMainColorDark)
                && !Themes.getAttrBoolean(view.getContext(), R.attr.isWorkspaceDarkText);
        ResourceProvider rp = DynamicResource.provider(view.getContext());
        int wallpaperScrimColor = rp.getColor(R.color.wallpaper_scrim_color);
        mWallpaperScrimMaxAlpha = Color.alpha(wallpaperScrimColor);
        mWallpaperScrimPaint.setColor(wallpaperScrimColor);

        view.addOnAttachStateChangeListener(this);
    }

@@ -151,6 +165,9 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {
                mAnimateScrimOnNextDraw = false;
            }

            if (mDrawWallpaperScrim) {
                canvas.drawRect(mWallpaperScrimRect, mWallpaperScrimPaint);
            }
            if (mDrawTopScrim) {
                mTopScrim.draw(canvas);
            }
@@ -214,6 +231,7 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {
            mTopScrim.setBounds(0, 0, w, h);
            mFinalMaskRect.set(0, h - mMaskHeight, w, h);
        }
        mWallpaperScrimRect.set(0, 0, w, h);
    }

    private void setSysUiProgress(float progress) {
@@ -236,6 +254,7 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {
        if (mTopScrim != null) {
            mTopScrim.setAlpha(Math.round(255 * factor));
        }
        mWallpaperScrimPaint.setAlpha(Math.round(mWallpaperScrimMaxAlpha * factor));
    }

    private Bitmap createDitheredAlphaMask() {