diff options
| author | 2021-06-22 13:36:35 +0200 | |
|---|---|---|
| committer | 2021-06-23 15:01:17 +0200 | |
| commit | b83f4423f8958264a6f9f07019ac0c83149c60fd (patch) | |
| tree | 587d9cb21a51c0a6d9463f0505f261ab3afbeefe | |
| parent | d6f7eb33e3ceade837d0cbc1a9415857d7723197 (diff) | |
Apply the mask to all splashscreen forground icons
- Ensure the all icons including AVD are masked using the system mask
- Scale up the AVD if no background is set in the splash screen API
Also:
- Use the iconview size to check whether the icon should be faded out
Bug: 182883560
Test: Manually with oversized AVD, and setting a background under the
AVD
Change-Id: I69e38b35f71d0bb21d3e591c3eb37a3088ad48db
3 files changed, 22 insertions, 6 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashScreenExitAnimation.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashScreenExitAnimation.java index 1a365fee3b13..eecaf153db44 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashScreenExitAnimation.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashScreenExitAnimation.java @@ -85,7 +85,10 @@ public class SplashScreenExitAnimation implements Animator.AnimatorListener { } View iconView = view.getIconView(); - if (iconView == null || iconView.getBackground() == null) { + + // If the icon and the background are invisible, don't animate it + if (iconView == null || iconView.getLayoutParams().width == 0 + || iconView.getLayoutParams().height == 0) { mIconFadeOutDuration = 0; mIconStartAlpha = 0; mAppRevealDelay = 0; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java index df3fee043419..b09d0d89a6b9 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java @@ -77,6 +77,13 @@ public class SplashscreenContentDrawer { // For example, an icon with the foreground 108*108 opaque pixels and it's background // also 108*108 pixels, then do not enlarge this icon if only need to show foreground icon. private static final float ENLARGE_FOREGROUND_ICON_THRESHOLD = (72f * 72f) / (108f * 108f); + + /** + * If the developer doesn't specify a background for the icon, we slightly scale it up. + * + * The background is either manually specified in the theme or the Adaptive Icon + * background is used if it's different from the window background. + */ private static final float NO_BACKGROUND_SCALE = 192f / 160; private final Context mContext; private final IconProvider mIconProvider; @@ -228,7 +235,7 @@ public class SplashscreenContentDrawer { attrs.mWindowBgColor = safeReturnAttrDefault((def) -> typedArray.getColor( R.styleable.Window_windowSplashScreenBackground, def), Color.TRANSPARENT); - attrs.mReplaceIcon = safeReturnAttrDefault((def) -> typedArray.getDrawable( + attrs.mSplashScreenIcon = safeReturnAttrDefault((def) -> typedArray.getDrawable( R.styleable.Window_windowSplashScreenAnimatedIcon), null); attrs.mAnimationDuration = safeReturnAttrDefault((def) -> typedArray.getInt( R.styleable.Window_windowSplashScreenAnimationDuration, def), 0); @@ -241,7 +248,7 @@ public class SplashscreenContentDrawer { if (DEBUG) { Slog.d(TAG, "window attributes color: " + Integer.toHexString(attrs.mWindowBgColor) - + " icon " + attrs.mReplaceIcon + " duration " + attrs.mAnimationDuration + + " icon " + attrs.mSplashScreenIcon + " duration " + attrs.mAnimationDuration + " brandImage " + attrs.mBrandingImage); } } @@ -250,7 +257,7 @@ public class SplashscreenContentDrawer { public static class SplashScreenWindowAttrs { private int mWindowBgResId = 0; private int mWindowBgColor = Color.TRANSPARENT; - private Drawable mReplaceIcon = null; + private Drawable mSplashScreenIcon = null; private Drawable mBrandingImage = null; private int mIconBgColor = Color.TRANSPARENT; private int mAnimationDuration = 0; @@ -287,10 +294,15 @@ public class SplashscreenContentDrawer { // empty splash screen case animationDuration = 0; mFinalIconSize = 0; - } else if (mTmpAttrs.mReplaceIcon != null) { + } else if (mTmpAttrs.mSplashScreenIcon != null) { // replaced icon, don't process - iconDrawable = mTmpAttrs.mReplaceIcon; + iconDrawable = mTmpAttrs.mSplashScreenIcon; animationDuration = mTmpAttrs.mAnimationDuration; + + // There is no background below the icon, so scale the icon up + if (mTmpAttrs.mIconBgColor == Color.TRANSPARENT) { + mFinalIconSize *= NO_BACKGROUND_SCALE; + } createIconDrawable(iconDrawable, false); } else { final float iconScale = (float) mIconSize / (float) mDefaultIconSize; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenIconDrawableFactory.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenIconDrawableFactory.java index dae7055ede53..211941f44c8e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenIconDrawableFactory.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenIconDrawableFactory.java @@ -162,6 +162,7 @@ public class SplashscreenIconDrawableFactory { @Override public void draw(Canvas canvas) { + canvas.clipPath(mMaskScaleOnly); if (mMaskScaleOnly != null) { canvas.drawPath(mMaskScaleOnly, mPaint); } |