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

Commit d3df201b authored by Massimo Carli's avatar Massimo Carli Committed by Android (Google) Code Review
Browse files

Merge "Replace Suppliers for Boolean, Int and Float" into main

parents e2828b45 18d4bdf7
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -36,7 +36,10 @@ import android.view.WindowManager;

import com.android.server.UiThread;

import java.util.function.BooleanSupplier;
import java.util.function.DoubleSupplier;
import java.util.function.IntConsumer;
import java.util.function.IntSupplier;
import java.util.function.Supplier;

/**
@@ -50,12 +53,12 @@ public class Letterbox {

    private final Supplier<SurfaceControl.Builder> mSurfaceControlFactory;
    private final Supplier<SurfaceControl.Transaction> mTransactionFactory;
    private final Supplier<Boolean> mAreCornersRounded;
    private final BooleanSupplier mAreCornersRounded;
    private final Supplier<Color> mColorSupplier;
    // Parameters for "blurred wallpaper" letterbox background.
    private final Supplier<Boolean> mHasWallpaperBackgroundSupplier;
    private final Supplier<Integer> mBlurRadiusSupplier;
    private final Supplier<Float> mDarkScrimAlphaSupplier;
    private final BooleanSupplier mHasWallpaperBackgroundSupplier;
    private final IntSupplier mBlurRadiusSupplier;
    private final DoubleSupplier mDarkScrimAlphaSupplier;
    private final Supplier<SurfaceControl> mParentSurfaceSupplier;

    private final Rect mOuter = new Rect();
@@ -82,11 +85,11 @@ public class Letterbox {
     */
    public Letterbox(Supplier<SurfaceControl.Builder> surfaceControlFactory,
            Supplier<SurfaceControl.Transaction> transactionFactory,
            Supplier<Boolean> areCornersRounded,
            BooleanSupplier areCornersRounded,
            Supplier<Color> colorSupplier,
            Supplier<Boolean> hasWallpaperBackgroundSupplier,
            Supplier<Integer> blurRadiusSupplier,
            Supplier<Float> darkScrimAlphaSupplier,
            BooleanSupplier hasWallpaperBackgroundSupplier,
            IntSupplier blurRadiusSupplier,
            DoubleSupplier darkScrimAlphaSupplier,
            IntConsumer doubleTapCallbackX,
            IntConsumer doubleTapCallbackY,
            Supplier<SurfaceControl> parentSurface) {
@@ -247,7 +250,7 @@ public class Letterbox {
     * Returns {@code true} when using {@link #mFullWindowSurface} instead of {@link mSurfaces}.
     */
    private boolean useFullWindowSurface() {
        return mAreCornersRounded.get() || mHasWallpaperBackgroundSupplier.get();
        return mAreCornersRounded.getAsBoolean() || mHasWallpaperBackgroundSupplier.getAsBoolean();
    }

    private final class TapEventReceiver extends InputEventReceiver {
@@ -424,7 +427,7 @@ public class Letterbox {
                        mSurfaceFrameRelative.height());
                t.reparent(mSurface, mParentSurface);

                mHasWallpaperBackground = mHasWallpaperBackgroundSupplier.get();
                mHasWallpaperBackground = mHasWallpaperBackgroundSupplier.getAsBoolean();
                updateAlphaAndBlur(t);

                t.show(mSurface);
@@ -445,17 +448,17 @@ public class Letterbox {
                t.setBackgroundBlurRadius(mSurface, 0);
                return;
            }
            final float alpha = mDarkScrimAlphaSupplier.get();
            final float alpha = (float) mDarkScrimAlphaSupplier.getAsDouble();
            t.setAlpha(mSurface, alpha);

            // Translucent dark scrim can be shown without blur.
            if (mBlurRadiusSupplier.get() <= 0) {
            if (mBlurRadiusSupplier.getAsInt() <= 0) {
                // Removing pre-exesting blur
                t.setBackgroundBlurRadius(mSurface, 0);
                return;
            }

            t.setBackgroundBlurRadius(mSurface, mBlurRadiusSupplier.get());
            t.setBackgroundBlurRadius(mSurface, mBlurRadiusSupplier.getAsInt());
        }

        private float[] getRgbColorArray() {
@@ -472,7 +475,7 @@ public class Letterbox {
                    // and mParentSurface may never be updated in applySurfaceChanges but this
                    // doesn't mean that update is needed.
                    || !mSurfaceFrameRelative.isEmpty()
                    && (mHasWallpaperBackgroundSupplier.get() != mHasWallpaperBackground
                    && (mHasWallpaperBackgroundSupplier.getAsBoolean() != mHasWallpaperBackground
                    || !mColorSupplier.get().equals(mColor)
                    || mParentSurfaceSupplier.get() != mParentSurface);
        }