Merge "Re-deprecate animation backgroundColor API" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-04-01 11:48:52 +00:00
committed by Android (Google) Code Review
8 changed files with 87 additions and 43 deletions

View File

@@ -390,6 +390,7 @@ package android {
field public static final int autoVerify = 16844014; // 0x10104ee
field public static final int autofillHints = 16844118; // 0x1010556
field public static final int autofilledHighlight = 16844136; // 0x1010568
field public static final int backdropColor;
field public static final int background = 16842964; // 0x10100d4
field public static final int backgroundDimAmount = 16842802; // 0x1010032
field public static final int backgroundDimEnabled = 16843295; // 0x101021f
@@ -1345,7 +1346,7 @@ package android {
field public static final int shouldDisableView = 16843246; // 0x10101ee
field public static final int shouldUseDefaultUnfoldTransition = 16844364; // 0x101064c
field public static final int showAsAction = 16843481; // 0x10102d9
field public static final int showBackground;
field public static final int showBackdrop;
field public static final int showClockAndComplications;
field public static final int showDefault = 16843258; // 0x10101fa
field public static final int showDividers = 16843561; // 0x1010329
@@ -52277,7 +52278,8 @@ package android.view.animation {
method protected android.view.animation.Animation clone() throws java.lang.CloneNotSupportedException;
method public long computeDurationHint();
method protected void ensureInterpolator();
method @ColorInt public int getBackgroundColor();
method @ColorInt public int getBackdropColor();
method @Deprecated @ColorInt public int getBackgroundColor();
method @Deprecated public boolean getDetachWallpaper();
method public long getDuration();
method public boolean getFillAfter();
@@ -52286,7 +52288,7 @@ package android.view.animation {
method public int getRepeatCount();
method public int getRepeatMode();
method protected float getScaleFactor();
method public boolean getShowBackground();
method public boolean getShowBackdrop();
method public long getStartOffset();
method public long getStartTime();
method public boolean getTransformation(long, android.view.animation.Transformation);
@@ -52302,7 +52304,8 @@ package android.view.animation {
method public void restrictDuration(long);
method public void scaleCurrentDuration(float);
method public void setAnimationListener(android.view.animation.Animation.AnimationListener);
method public void setBackgroundColor(@ColorInt int);
method public void setBackdropColor(@ColorInt int);
method @Deprecated public void setBackgroundColor(@ColorInt int);
method @Deprecated public void setDetachWallpaper(boolean);
method public void setDuration(long);
method public void setFillAfter(boolean);
@@ -52312,7 +52315,7 @@ package android.view.animation {
method public void setInterpolator(android.view.animation.Interpolator);
method public void setRepeatCount(int);
method public void setRepeatMode(int);
method public void setShowBackground(boolean);
method public void setShowBackdrop(boolean);
method public void setStartOffset(long);
method public void setStartTime(long);
method public void setZAdjustment(int);

View File

@@ -196,9 +196,9 @@ public abstract class Animation implements Cloneable {
private int mZAdjustment;
/**
* Desired background color behind animation.
* The desired color of the backdrop to show behind the animation.
*/
private int mBackgroundColor;
private int mBackdropColor;
/**
* scalefactor to apply to pivot points, etc. during animation. Subclasses retrieve the
@@ -211,10 +211,10 @@ public abstract class Animation implements Cloneable {
/**
* Whether to show a background behind the windows during the animation.
* @see #getShowBackground()
* @see #setShowBackground(boolean)
* @see #getShowBackdrop()
* @see #setShowBackdrop(boolean)
*/
private boolean mShowBackground;
private boolean mShowBackdrop;
private boolean mMore = true;
private boolean mOneMoreTime = true;
@@ -265,7 +265,7 @@ public abstract class Animation implements Cloneable {
setZAdjustment(a.getInt(com.android.internal.R.styleable.Animation_zAdjustment, ZORDER_NORMAL));
setBackgroundColor(a.getInt(com.android.internal.R.styleable.Animation_background, 0));
setBackdropColor(a.getInt(com.android.internal.R.styleable.Animation_backdropColor, 0));
setDetachWallpaper(
a.getBoolean(com.android.internal.R.styleable.Animation_detachWallpaper, false));
@@ -273,8 +273,8 @@ public abstract class Animation implements Cloneable {
a.getBoolean(com.android.internal.R.styleable.Animation_showWallpaper, false));
setHasRoundedCorners(
a.getBoolean(com.android.internal.R.styleable.Animation_hasRoundedCorners, false));
setShowBackground(
a.getBoolean(com.android.internal.R.styleable.Animation_showBackground, false));
setShowBackdrop(
a.getBoolean(com.android.internal.R.styleable.Animation_showBackdrop, false));
final int resID = a.getResourceId(com.android.internal.R.styleable.Animation_interpolator, 0);
@@ -646,9 +646,12 @@ public abstract class Animation implements Cloneable {
* @param bg The background color. If 0, no background. Currently must
* be black, with any desired alpha level.
*
* @deprecated None of window animations are running with background color.
* @see #setBackdropColor(int) for an alternative.
*/
@Deprecated
public void setBackgroundColor(@ColorInt int bg) {
mBackgroundColor = bg;
// The background color is not needed any more, do nothing.
}
/**
@@ -705,21 +708,35 @@ public abstract class Animation implements Cloneable {
}
/**
* If showBackground is {@code true} and this animation is applied on a window, then the windows
* If showBackdrop is {@code true} and this animation is applied on a window, then the windows
* in the animation will animate with the background associated with this window behind them.
*
* The background comes from the {@link android.R.styleable#Theme_colorBackground} that is
* applied to this window through its theme.
* If no backdrop color is explicitly set, the backdrop's color comes from the
* {@link android.R.styleable#Theme_colorBackground} that is applied to this window through its
* theme.
*
* If multiple animating windows have showBackground set to {@code true} during an animation,
* the top most window with showBackground set to {@code true} and a valid background color
* If multiple animating windows have showBackdrop set to {@code true} during an animation,
* the top most window with showBackdrop set to {@code true} and a valid background color
* takes precedence.
*
* @param showBackground Whether to show a background behind the windows during the animation.
* @attr ref android.R.styleable#Animation_showBackground
* @param showBackdrop Whether to show a background behind the windows during the animation.
* @attr ref android.R.styleable#Animation_showBackdrop
*/
public void setShowBackground(boolean showBackground) {
mShowBackground = showBackground;
public void setShowBackdrop(boolean showBackdrop) {
mShowBackdrop = showBackdrop;
}
/**
* Set the color to use for the backdrop shown behind the animating windows.
*
* Will only show the backdrop if showBackdrop was set to true.
* See {@link #setShowBackdrop(boolean)}.
*
* @param backdropColor The backdrop color. If 0, the backdrop color will not apply.
* @attr ref android.R.styleable#Animation_backdropColor
*/
public void setBackdropColor(@ColorInt int backdropColor) {
mBackdropColor = backdropColor;
}
/**
@@ -822,10 +839,14 @@ public abstract class Animation implements Cloneable {
/**
* Returns the background color behind the animation.
*
* @deprecated None of window animations are running with background color.
* @see #getBackdropColor() for an alternative.
*/
@Deprecated
@ColorInt
public int getBackgroundColor() {
return mBackgroundColor;
return 0;
}
/**
@@ -869,21 +890,36 @@ public abstract class Animation implements Cloneable {
}
/**
* If showBackground is {@code true} and this animation is applied on a window, then the windows
* If showBackdrop is {@code true} and this animation is applied on a window, then the windows
* in the animation will animate with the background associated with this window behind them.
*
* The background comes from the {@link android.R.styleable#Theme_colorBackground} that is
* applied to this window through its theme.
* If no backdrop color is explicitly set, the backdrop's color comes from the
* {@link android.R.styleable#Theme_colorBackground} that is applied to this window
* through its theme.
*
* If multiple animating windows have showBackground set to {@code true} during an animation,
* the top most window with showBackground set to {@code true} and a valid background color
* If multiple animating windows have showBackdrop set to {@code true} during an animation,
* the top most window with showBackdrop set to {@code true} and a valid background color
* takes precedence.
*
* @return if the background of this window should be shown behind the animating windows.
* @attr ref android.R.styleable#Animation_showBackground
* @return if a backdrop should be shown behind the animating windows.
* @attr ref android.R.styleable#Animation_showBackdrop
*/
public boolean getShowBackground() {
return mShowBackground;
public boolean getShowBackdrop() {
return mShowBackdrop;
}
/**
* Returns the background color to show behind the animating windows.
*
* Will only show the background if showBackdrop was set to true.
* See {@link #setShowBackdrop(boolean)}.
*
* @return The backdrop color. If 0, the backdrop color will not apply.
* @attr ref android.R.styleable#Animation_backdropColor
*/
@ColorInt
public int getBackdropColor() {
return mBackdropColor;
}
/**

View File

@@ -6960,9 +6960,13 @@
<!-- Special option for window animations: whether window should have rounded corners.
@see ScreenDecorationsUtils#getWindowCornerRadius(Resources) -->
<attr name="hasRoundedCorners" format="boolean" />
<!-- Special option for window animations: whether to show a background behind the animating
windows. By default the window's background is used unless overridden by the
animation. -->
<attr name="showBackdrop" format="boolean" />
<!-- Special option for window animations: whether the window's background should be used as
a background to the animation. -->
<attr name="showBackground" format="boolean" />
<attr name="backdropColor" format="color" />
</declare-styleable>
<declare-styleable name="AnimationSet">

View File

@@ -126,7 +126,7 @@
<public name="allowGameDownscaling" />
<public name="allowGameFpsOverride" />
<public name="localeConfig" />
<public name="showBackground" />
<public name="showBackdrop" />
<public name="removed_useTargetActivityForQuickAccess"/>
<public name="removed_inheritKeyStoreKeys" />
<public name="preferKeepClear" />
@@ -152,6 +152,7 @@
<public name="maxDrawableWidth" />
<!-- @hide -->
<public name="maxDrawableHeight" />
<public name="backdropColor" />
</staging-public-group>
<staging-public-group type="id" first-id="0x01de0000">

View File

@@ -437,15 +437,15 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
cornerRadius = 0;
}
if (a.getShowBackground()) {
if (a.getShowBackdrop()) {
if (info.getAnimationOptions().getBackgroundColor() != 0) {
// If available use the background color provided through AnimationOptions
backgroundColorForTransition =
info.getAnimationOptions().getBackgroundColor();
} else if (a.getBackgroundColor() != 0) {
} else if (a.getBackdropColor() != 0) {
// Otherwise fallback on the background color provided through the animation
// definition.
backgroundColorForTransition = a.getBackgroundColor();
backgroundColorForTransition = a.getBackdropColor();
} else if (change.getBackgroundColor() != 0) {
// Otherwise default to the window's background color if provided through
// the theme as the background color for the animation - the top most window

View File

@@ -43,7 +43,7 @@ interface AnimationAdapter {
/**
* @return Whether we should show a background behind the animating windows.
* @see Animation#getShowBackground()
* @see Animation#getShowBackdrop()
*/
default boolean getShowBackground() {
return false;
@@ -51,7 +51,7 @@ interface AnimationAdapter {
/**
* @return The background color to use during an animation if getShowBackground returns true.
* @see Animation#getBackgroundColor()
* @see Animation#getBackdropColor()
*/
default int getBackgroundColor() {
return 0;

View File

@@ -843,7 +843,7 @@ public class AppTransition implements Dump {
setAppTransitionFinishedCallbackIfNeeded(a);
if (mNextAppTransitionBackgroundColor != 0) {
a.setBackgroundColor(mNextAppTransitionBackgroundColor);
a.setBackdropColor(mNextAppTransitionBackgroundColor);
}
return a;

View File

@@ -87,12 +87,12 @@ public class WindowAnimationSpec implements AnimationSpec {
@Override
public boolean getShowBackground() {
return mAnimation.getShowBackground();
return mAnimation.getShowBackdrop();
}
@Override
public int getBackgroundColor() {
return mAnimation.getBackgroundColor();
return mAnimation.getBackdropColor();
}
/**