Loading core/api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -1614,6 +1614,7 @@ package android { field public static final int windowAllowReturnTransitionOverlap = 16843835; // 0x101043b field public static final int windowAnimationStyle = 16842926; // 0x10100ae field public static final int windowBackground = 16842836; // 0x1010054 field public static final int windowBackgroundBlurRadius = 16844331; // 0x101062b field public static final int windowBackgroundFallback = 16844035; // 0x1010503 field public static final int windowBlurBehindEnabled = 16844316; // 0x101061c field public static final int windowBlurBehindRadius = 16844315; // 0x101061b Loading Loading @@ -49365,6 +49366,7 @@ package android.view { method public void setAllowEnterTransitionOverlap(boolean); method public void setAllowReturnTransitionOverlap(boolean); method public void setAttributes(android.view.WindowManager.LayoutParams); method public void setBackgroundBlurRadius(int); method public abstract void setBackgroundDrawable(android.graphics.drawable.Drawable); method public void setBackgroundDrawableResource(@DrawableRes int); method public void setCallback(android.view.Window.Callback); core/java/android/view/Window.java +24 −0 Original line number Diff line number Diff line Loading @@ -1702,6 +1702,30 @@ public abstract class Window { */ public abstract void setBackgroundDrawable(Drawable drawable); /** * Blurs the screen behind the window within the bounds of the window. * * The density of the blur is set by the blur radius. The radius defines the size * of the neighbouring area, from which pixels will be averaged to form the final * color for each pixel. The operation approximates a Gaussian blur. * A radius of 0 means no blur. The higher the radius, the denser the blur. * * The window background drawable is drawn on top of the blurred region. The blur * region bounds and rounded corners will mimic those of the background drawable. * * For the blur region to be visible, the window has to be translucent. See * {@link android.R.styleable#Window_windowIsTranslucent}. * * Note the difference with {@link android.view.WindowManager.LayoutParams#blurBehindRadius}, * which blurs the whole screen behind the window. Background blur blurs the screen behind * only within the bounds of the window. * * @param blurRadius The blur radius to use for window background blur in pixels * * @see android.R.styleable#Window_windowBackgroundBlurRadius */ public void setBackgroundBlurRadius(int blurRadius) {} /** * Set the value for a drawable feature of this window, from a resource * identifier. You must have called requestFeature(featureId) before Loading core/java/com/android/internal/policy/DecorView.java +48 −7 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ import android.widget.FrameLayout; import android.widget.PopupWindow; import com.android.internal.R; import com.android.internal.graphics.drawable.BackgroundBlurDrawable; import com.android.internal.policy.PhoneWindow.PanelFeatureState; import com.android.internal.policy.PhoneWindow.PhoneWindowMenuCallback; import com.android.internal.view.FloatingActionMode; Loading Loading @@ -255,6 +256,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind private Drawable mOriginalBackgroundDrawable; private Drawable mLastOriginalBackgroundDrawable; private Drawable mResizingBackgroundDrawable; private BackgroundBlurDrawable mBackgroundBlurDrawable; /** * Temporary holder for a window background when it is set before {@link #mWindow} is Loading @@ -280,9 +282,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind private final Paint mLegacyNavigationBarBackgroundPaint = new Paint(); private Insets mBackgroundInsets = Insets.NONE; private Insets mLastBackgroundInsets = Insets.NONE; private int mLastBackgroundBlurRadius = 0; private boolean mDrawLegacyNavigationBarBackground; private PendingInsetsController mPendingInsetsController = new PendingInsetsController(); private final ViewTreeObserver.OnPreDrawListener mBackgroundBlurOnPreDrawListener = () -> { updateBackgroundBlur(); return true; }; DecorView(Context context, int featureId, PhoneWindow window, WindowManager.LayoutParams params) { Loading Loading @@ -1263,18 +1270,27 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind if (mBackgroundInsets == null) { mBackgroundInsets = Insets.NONE; } if (mBackgroundInsets.equals(mLastBackgroundInsets) && mWindow.mBackgroundBlurRadius == mLastBackgroundBlurRadius && mLastOriginalBackgroundDrawable == mOriginalBackgroundDrawable) { return; } if (mOriginalBackgroundDrawable == null || mBackgroundInsets.equals(Insets.NONE)) { // Call super since we are intercepting setBackground on this class. super.setBackgroundDrawable(mOriginalBackgroundDrawable); } else { Drawable destDrawable = mOriginalBackgroundDrawable; if (mWindow.mBackgroundBlurRadius > 0 && getViewRootImpl() != null && mWindow.isTranslucent()) { if (mBackgroundBlurDrawable == null) { mBackgroundBlurDrawable = getViewRootImpl().createBackgroundBlurDrawable(); } destDrawable = new LayerDrawable(new Drawable[] {mBackgroundBlurDrawable, mOriginalBackgroundDrawable}); mLastBackgroundBlurRadius = mWindow.mBackgroundBlurRadius; } // Call super since we are intercepting setBackground on this class. super.setBackgroundDrawable(new InsetDrawable(mOriginalBackgroundDrawable, if (destDrawable != null && !mBackgroundInsets.equals(Insets.NONE)) { destDrawable = new InsetDrawable(destDrawable, mBackgroundInsets.left, mBackgroundInsets.top, mBackgroundInsets.right, mBackgroundInsets.bottom) { Loading @@ -1286,12 +1302,32 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind public boolean getPadding(Rect padding) { return getDrawable().getPadding(padding); } }); }; } // Call super since we are intercepting setBackground on this class. super.setBackgroundDrawable(destDrawable); mLastBackgroundInsets = mBackgroundInsets; mLastOriginalBackgroundDrawable = mOriginalBackgroundDrawable; } private void updateBackgroundBlur() { if (mBackgroundBlurDrawable == null) return; // If the blur radius is 0, the blur region won't be sent to surface flinger, so we don't // need to calculate the corner radius. if (mWindow.mBackgroundBlurRadius > 0) { if (mOriginalBackgroundDrawable != null) { final Outline outline = new Outline(); mOriginalBackgroundDrawable.getOutline(outline); mBackgroundBlurDrawable.setCornerRadius(outline.mMode == Outline.MODE_ROUND_RECT ? outline.getRadius() : 0); } } mBackgroundBlurDrawable.setBlurRadius(mWindow.mBackgroundBlurRadius); } @Override public Drawable getBackground() { return mOriginalBackgroundDrawable; Loading Loading @@ -1722,6 +1758,9 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind cb.onAttachedToWindow(); } getViewTreeObserver().addOnPreDrawListener(mBackgroundBlurOnPreDrawListener); updateBackgroundDrawable(); if (mFeatureId == -1) { /* * The main window has been attached, try to restore any panels Loading Loading @@ -1755,6 +1794,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind cb.onDetachedFromWindow(); } getViewTreeObserver().removeOnPreDrawListener(mBackgroundBlurOnPreDrawListener); if (mWindow.mDecorContentParent != null) { mWindow.mDecorContentParent.dismissPopups(); } Loading core/java/com/android/internal/policy/PhoneWindow.java +14 −0 Original line number Diff line number Diff line Loading @@ -258,6 +258,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { Drawable mBackgroundDrawable = null; Drawable mBackgroundFallbackDrawable = null; int mBackgroundBlurRadius = 0; private boolean mLoadElevation = true; private float mElevation; Loading Loading @@ -1522,6 +1524,15 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } } @Override public final void setBackgroundBlurRadius(int blurRadius) { super.setBackgroundBlurRadius(blurRadius); if (getContext().getPackageManager().hasSystemFeature( PackageManager.FEATURE_CROSS_LAYER_BLUR)) { mBackgroundBlurRadius = Math.max(blurRadius, 0); } } @Override public final void setFeatureDrawableResource(int featureId, int resId) { if (resId != 0) { Loading Loading @@ -2549,6 +2560,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { android.R.styleable.Window_windowBlurBehindRadius, 0); } setBackgroundBlurRadius(a.getDimensionPixelSize( R.styleable.Window_windowBackgroundBlurRadius, 0)); if (params.windowAnimations == 0) { params.windowAnimations = a.getResourceId( Loading core/res/res/values/attrs.xml +7 −0 Original line number Diff line number Diff line Loading @@ -362,6 +362,12 @@ surface when the app has not drawn any content into this area. One example is when the user is resizing a window of an activity in multi-window mode. --> <attr name="windowBackgroundFallback" format="reference|color" /> <!-- Blur the screen behind the window with the bounds of the window. The radius defines the size of the neighbouring area, from which pixels will be averaged to form the final color for each pixel in the region. A radius of 0 means no blur. The higher the radius, the denser the blur. Corresponds to {@link android.view.Window#setBackgroundBlurRadius}. --> <attr name="windowBackgroundBlurRadius" format="dimension" /> <!-- Drawable to use as a frame around the window. --> <attr name="windowFrame" format="reference" /> <!-- Flag indicating whether there should be no title on this window. --> Loading Loading @@ -1966,6 +1972,7 @@ <declare-styleable name="Window"> <attr name="windowBackground" /> <attr name="windowBackgroundFallback" /> <attr name="windowBackgroundBlurRadius" /> <attr name="windowContentOverlay" /> <attr name="windowFrame" /> <attr name="windowNoTitle" /> Loading Loading
core/api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -1614,6 +1614,7 @@ package android { field public static final int windowAllowReturnTransitionOverlap = 16843835; // 0x101043b field public static final int windowAnimationStyle = 16842926; // 0x10100ae field public static final int windowBackground = 16842836; // 0x1010054 field public static final int windowBackgroundBlurRadius = 16844331; // 0x101062b field public static final int windowBackgroundFallback = 16844035; // 0x1010503 field public static final int windowBlurBehindEnabled = 16844316; // 0x101061c field public static final int windowBlurBehindRadius = 16844315; // 0x101061b Loading Loading @@ -49365,6 +49366,7 @@ package android.view { method public void setAllowEnterTransitionOverlap(boolean); method public void setAllowReturnTransitionOverlap(boolean); method public void setAttributes(android.view.WindowManager.LayoutParams); method public void setBackgroundBlurRadius(int); method public abstract void setBackgroundDrawable(android.graphics.drawable.Drawable); method public void setBackgroundDrawableResource(@DrawableRes int); method public void setCallback(android.view.Window.Callback);
core/java/android/view/Window.java +24 −0 Original line number Diff line number Diff line Loading @@ -1702,6 +1702,30 @@ public abstract class Window { */ public abstract void setBackgroundDrawable(Drawable drawable); /** * Blurs the screen behind the window within the bounds of the window. * * The density of the blur is set by the blur radius. The radius defines the size * of the neighbouring area, from which pixels will be averaged to form the final * color for each pixel. The operation approximates a Gaussian blur. * A radius of 0 means no blur. The higher the radius, the denser the blur. * * The window background drawable is drawn on top of the blurred region. The blur * region bounds and rounded corners will mimic those of the background drawable. * * For the blur region to be visible, the window has to be translucent. See * {@link android.R.styleable#Window_windowIsTranslucent}. * * Note the difference with {@link android.view.WindowManager.LayoutParams#blurBehindRadius}, * which blurs the whole screen behind the window. Background blur blurs the screen behind * only within the bounds of the window. * * @param blurRadius The blur radius to use for window background blur in pixels * * @see android.R.styleable#Window_windowBackgroundBlurRadius */ public void setBackgroundBlurRadius(int blurRadius) {} /** * Set the value for a drawable feature of this window, from a resource * identifier. You must have called requestFeature(featureId) before Loading
core/java/com/android/internal/policy/DecorView.java +48 −7 Original line number Diff line number Diff line Loading @@ -110,6 +110,7 @@ import android.widget.FrameLayout; import android.widget.PopupWindow; import com.android.internal.R; import com.android.internal.graphics.drawable.BackgroundBlurDrawable; import com.android.internal.policy.PhoneWindow.PanelFeatureState; import com.android.internal.policy.PhoneWindow.PhoneWindowMenuCallback; import com.android.internal.view.FloatingActionMode; Loading Loading @@ -255,6 +256,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind private Drawable mOriginalBackgroundDrawable; private Drawable mLastOriginalBackgroundDrawable; private Drawable mResizingBackgroundDrawable; private BackgroundBlurDrawable mBackgroundBlurDrawable; /** * Temporary holder for a window background when it is set before {@link #mWindow} is Loading @@ -280,9 +282,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind private final Paint mLegacyNavigationBarBackgroundPaint = new Paint(); private Insets mBackgroundInsets = Insets.NONE; private Insets mLastBackgroundInsets = Insets.NONE; private int mLastBackgroundBlurRadius = 0; private boolean mDrawLegacyNavigationBarBackground; private PendingInsetsController mPendingInsetsController = new PendingInsetsController(); private final ViewTreeObserver.OnPreDrawListener mBackgroundBlurOnPreDrawListener = () -> { updateBackgroundBlur(); return true; }; DecorView(Context context, int featureId, PhoneWindow window, WindowManager.LayoutParams params) { Loading Loading @@ -1263,18 +1270,27 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind if (mBackgroundInsets == null) { mBackgroundInsets = Insets.NONE; } if (mBackgroundInsets.equals(mLastBackgroundInsets) && mWindow.mBackgroundBlurRadius == mLastBackgroundBlurRadius && mLastOriginalBackgroundDrawable == mOriginalBackgroundDrawable) { return; } if (mOriginalBackgroundDrawable == null || mBackgroundInsets.equals(Insets.NONE)) { // Call super since we are intercepting setBackground on this class. super.setBackgroundDrawable(mOriginalBackgroundDrawable); } else { Drawable destDrawable = mOriginalBackgroundDrawable; if (mWindow.mBackgroundBlurRadius > 0 && getViewRootImpl() != null && mWindow.isTranslucent()) { if (mBackgroundBlurDrawable == null) { mBackgroundBlurDrawable = getViewRootImpl().createBackgroundBlurDrawable(); } destDrawable = new LayerDrawable(new Drawable[] {mBackgroundBlurDrawable, mOriginalBackgroundDrawable}); mLastBackgroundBlurRadius = mWindow.mBackgroundBlurRadius; } // Call super since we are intercepting setBackground on this class. super.setBackgroundDrawable(new InsetDrawable(mOriginalBackgroundDrawable, if (destDrawable != null && !mBackgroundInsets.equals(Insets.NONE)) { destDrawable = new InsetDrawable(destDrawable, mBackgroundInsets.left, mBackgroundInsets.top, mBackgroundInsets.right, mBackgroundInsets.bottom) { Loading @@ -1286,12 +1302,32 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind public boolean getPadding(Rect padding) { return getDrawable().getPadding(padding); } }); }; } // Call super since we are intercepting setBackground on this class. super.setBackgroundDrawable(destDrawable); mLastBackgroundInsets = mBackgroundInsets; mLastOriginalBackgroundDrawable = mOriginalBackgroundDrawable; } private void updateBackgroundBlur() { if (mBackgroundBlurDrawable == null) return; // If the blur radius is 0, the blur region won't be sent to surface flinger, so we don't // need to calculate the corner radius. if (mWindow.mBackgroundBlurRadius > 0) { if (mOriginalBackgroundDrawable != null) { final Outline outline = new Outline(); mOriginalBackgroundDrawable.getOutline(outline); mBackgroundBlurDrawable.setCornerRadius(outline.mMode == Outline.MODE_ROUND_RECT ? outline.getRadius() : 0); } } mBackgroundBlurDrawable.setBlurRadius(mWindow.mBackgroundBlurRadius); } @Override public Drawable getBackground() { return mOriginalBackgroundDrawable; Loading Loading @@ -1722,6 +1758,9 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind cb.onAttachedToWindow(); } getViewTreeObserver().addOnPreDrawListener(mBackgroundBlurOnPreDrawListener); updateBackgroundDrawable(); if (mFeatureId == -1) { /* * The main window has been attached, try to restore any panels Loading Loading @@ -1755,6 +1794,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind cb.onDetachedFromWindow(); } getViewTreeObserver().removeOnPreDrawListener(mBackgroundBlurOnPreDrawListener); if (mWindow.mDecorContentParent != null) { mWindow.mDecorContentParent.dismissPopups(); } Loading
core/java/com/android/internal/policy/PhoneWindow.java +14 −0 Original line number Diff line number Diff line Loading @@ -258,6 +258,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { Drawable mBackgroundDrawable = null; Drawable mBackgroundFallbackDrawable = null; int mBackgroundBlurRadius = 0; private boolean mLoadElevation = true; private float mElevation; Loading Loading @@ -1522,6 +1524,15 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { } } @Override public final void setBackgroundBlurRadius(int blurRadius) { super.setBackgroundBlurRadius(blurRadius); if (getContext().getPackageManager().hasSystemFeature( PackageManager.FEATURE_CROSS_LAYER_BLUR)) { mBackgroundBlurRadius = Math.max(blurRadius, 0); } } @Override public final void setFeatureDrawableResource(int featureId, int resId) { if (resId != 0) { Loading Loading @@ -2549,6 +2560,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { android.R.styleable.Window_windowBlurBehindRadius, 0); } setBackgroundBlurRadius(a.getDimensionPixelSize( R.styleable.Window_windowBackgroundBlurRadius, 0)); if (params.windowAnimations == 0) { params.windowAnimations = a.getResourceId( Loading
core/res/res/values/attrs.xml +7 −0 Original line number Diff line number Diff line Loading @@ -362,6 +362,12 @@ surface when the app has not drawn any content into this area. One example is when the user is resizing a window of an activity in multi-window mode. --> <attr name="windowBackgroundFallback" format="reference|color" /> <!-- Blur the screen behind the window with the bounds of the window. The radius defines the size of the neighbouring area, from which pixels will be averaged to form the final color for each pixel in the region. A radius of 0 means no blur. The higher the radius, the denser the blur. Corresponds to {@link android.view.Window#setBackgroundBlurRadius}. --> <attr name="windowBackgroundBlurRadius" format="dimension" /> <!-- Drawable to use as a frame around the window. --> <attr name="windowFrame" format="reference" /> <!-- Flag indicating whether there should be no title on this window. --> Loading Loading @@ -1966,6 +1972,7 @@ <declare-styleable name="Window"> <attr name="windowBackground" /> <attr name="windowBackgroundFallback" /> <attr name="windowBackgroundBlurRadius" /> <attr name="windowContentOverlay" /> <attr name="windowFrame" /> <attr name="windowNoTitle" /> Loading