diff --git a/core/api/current.txt b/core/api/current.txt index a00eae9422d01..481850e5c1384 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -330,7 +330,7 @@ package android { field public static final int apiKey = 16843281; // 0x1010211 field public static final int appCategory = 16844101; // 0x1010545 field public static final int appComponentFactory = 16844154; // 0x101057a - field public static final int attributionTags = 16844353; // 0x1010641 + field public static final int attributionTags = 16844354; // 0x1010642 field public static final int author = 16843444; // 0x10102b4 field public static final int authorities = 16842776; // 0x1010018 field public static final int autoAdvanceViewId = 16843535; // 0x101030f @@ -508,7 +508,7 @@ package android { field public static final int dashGap = 16843175; // 0x10101a7 field public static final int dashWidth = 16843174; // 0x10101a6 field public static final int data = 16842798; // 0x101002e - field public static final int dataExtractionRules = 16844349; // 0x101063d + field public static final int dataExtractionRules = 16844350; // 0x101063e field public static final int datePickerDialogTheme = 16843948; // 0x10104ac field public static final int datePickerMode = 16843955; // 0x10104b3 field public static final int datePickerStyle = 16843612; // 0x101035c @@ -530,8 +530,8 @@ package android { field public static final int detailSocialSummary = 16843428; // 0x10102a4 field public static final int detailsElementBackground = 16843598; // 0x101034e field public static final int dial = 16843010; // 0x1010102 - field public static final int dialTint = 16844341; // 0x1010635 - field public static final int dialTintMode = 16844342; // 0x1010636 + field public static final int dialTint = 16844342; // 0x1010636 + field public static final int dialTintMode = 16844343; // 0x1010637 field public static final int dialogCornerRadius = 16844145; // 0x1010571 field public static final int dialogIcon = 16843252; // 0x10101f4 field public static final int dialogLayout = 16843255; // 0x10101f7 @@ -729,14 +729,14 @@ package android { field public static final int groupIndicator = 16843019; // 0x101010b field public static final int gwpAsanMode = 16844310; // 0x1010616 field public static final int hand_hour = 16843011; // 0x1010103 - field public static final int hand_hourTint = 16844343; // 0x1010637 - field public static final int hand_hourTintMode = 16844344; // 0x1010638 + field public static final int hand_hourTint = 16844344; // 0x1010638 + field public static final int hand_hourTintMode = 16844345; // 0x1010639 field public static final int hand_minute = 16843012; // 0x1010104 - field public static final int hand_minuteTint = 16844345; // 0x1010639 - field public static final int hand_minuteTintMode = 16844346; // 0x101063a + field public static final int hand_minuteTint = 16844346; // 0x101063a + field public static final int hand_minuteTintMode = 16844347; // 0x101063b field public static final int hand_second = 16844323; // 0x1010623 - field public static final int hand_secondTint = 16844347; // 0x101063b - field public static final int hand_secondTintMode = 16844348; // 0x101063c + field public static final int hand_secondTint = 16844348; // 0x101063c + field public static final int hand_secondTintMode = 16844349; // 0x101063d field public static final int handle = 16843354; // 0x101025a field public static final int handleProfiling = 16842786; // 0x1010022 field public static final int hapticFeedbackEnabled = 16843358; // 0x101025e @@ -820,7 +820,7 @@ package android { field public static final int installLocation = 16843447; // 0x10102b7 field public static final int interactiveUiTimeout = 16844181; // 0x1010595 field public static final int interpolator = 16843073; // 0x1010141 - field public static final int isAccessibilityTool = 16844352; // 0x1010640 + field public static final int isAccessibilityTool = 16844353; // 0x1010641 field public static final int isAlwaysSyncable = 16843571; // 0x1010333 field public static final int isAsciiCapable = 16843753; // 0x10103e9 field public static final int isAuxiliary = 16843647; // 0x101037f @@ -972,8 +972,8 @@ package android { field public static final int maxLines = 16843091; // 0x1010153 field public static final int maxLongVersionCode = 16844163; // 0x1010583 field public static final int maxRecents = 16843846; // 0x1010446 - field public static final int maxResizeHeight = 16844338; // 0x1010632 - field public static final int maxResizeWidth = 16844337; // 0x1010631 + field public static final int maxResizeHeight = 16844339; // 0x1010633 + field public static final int maxResizeWidth = 16844338; // 0x1010632 field public static final int maxRows = 16843059; // 0x1010133 field public static final int maxSdkVersion = 16843377; // 0x1010271 field public static final int maxWidth = 16843039; // 0x101011f @@ -1076,7 +1076,7 @@ package android { field public static final int panelTextAppearance = 16842850; // 0x1010062 field public static final int parentActivityName = 16843687; // 0x10103a7 field @Deprecated public static final int password = 16843100; // 0x101015c - field public static final int passwordsActivity = 16844350; // 0x101063e + field public static final int passwordsActivity = 16844351; // 0x101063f field public static final int path = 16842794; // 0x101002a field public static final int pathAdvancedPattern = 16844320; // 0x1010620 field public static final int pathData = 16843781; // 0x1010405 @@ -1262,7 +1262,7 @@ package android { field public static final int segmentedButtonStyle = 16843568; // 0x1010330 field public static final int selectAllOnFocus = 16843102; // 0x101015e field public static final int selectable = 16843238; // 0x10101e6 - field public static final int selectableAsDefault = 16844351; // 0x101063f + field public static final int selectableAsDefault = 16844352; // 0x1010640 field public static final int selectableItemBackground = 16843534; // 0x101030e field public static final int selectableItemBackgroundBorderless = 16843868; // 0x101045c field @Deprecated public static final int selectedDateVerticalBar = 16843591; // 0x1010347 @@ -1312,7 +1312,7 @@ package android { field public static final int spinnerMode = 16843505; // 0x10102f1 field public static final int spinnerStyle = 16842881; // 0x1010081 field public static final int spinnersShown = 16843595; // 0x101034b - field public static final int splashScreenTheme = 16844336; // 0x1010630 + field public static final int splashScreenTheme = 16844337; // 0x1010631 field public static final int splitMotionEvents = 16843503; // 0x10102ef field public static final int splitName = 16844105; // 0x1010549 field public static final int splitTrack = 16843852; // 0x101044c @@ -1395,7 +1395,7 @@ package android { field public static final int supportsRtl = 16843695; // 0x10103af field public static final int supportsSwitchingToNextInputMethod = 16843755; // 0x10103eb field public static final int supportsUploading = 16843419; // 0x101029b - field public static final int suppressesSpellChecker = 16844354; // 0x1010642 + field public static final int suppressesSpellChecker = 16844355; // 0x1010643 field public static final int switchMinWidth = 16843632; // 0x1010370 field public static final int switchPadding = 16843633; // 0x1010371 field public static final int switchPreferenceStyle = 16843629; // 0x101036d @@ -1410,8 +1410,8 @@ package android { field public static final int tabWidgetStyle = 16842883; // 0x1010083 field public static final int tag = 16842961; // 0x10100d1 field public static final int targetActivity = 16843266; // 0x1010202 - field public static final int targetCellHeight = 16844340; // 0x1010634 - field public static final int targetCellWidth = 16844339; // 0x1010633 + field public static final int targetCellHeight = 16844341; // 0x1010635 + field public static final int targetCellWidth = 16844340; // 0x1010634 field public static final int targetClass = 16842799; // 0x101002f field @Deprecated public static final int targetDescriptions = 16843680; // 0x10103a0 field public static final int targetId = 16843740; // 0x10103dc @@ -1680,6 +1680,7 @@ package android { field public static final int windowSplashScreenAnimationDuration = 16844334; // 0x101062e field public static final int windowSplashScreenBackground = 16844332; // 0x101062c field public static final int windowSplashScreenBrandingImage = 16844335; // 0x101062f + field public static final int windowSplashScreenIconBackgroundColor = 16844336; // 0x1010630 field @Deprecated public static final int windowSplashscreenContent = 16844132; // 0x1010564 field @Deprecated public static final int windowSwipeToDismiss = 16843763; // 0x10103f3 field public static final int windowTitleBackgroundStyle = 16842844; // 0x101005c diff --git a/core/api/test-current.txt b/core/api/test-current.txt index a97c3ae7b08e9..92dada62b264d 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -2929,6 +2929,7 @@ package android.window { public final class SplashScreenView extends android.widget.FrameLayout { method @Nullable public android.view.View getBrandingView(); + method @ColorInt public int getIconBackgroundColor(); } public final class StartingWindowInfo implements android.os.Parcelable { diff --git a/core/java/android/window/SplashScreenView.java b/core/java/android/window/SplashScreenView.java index ddea64a77f4b9..3709aa1583ba8 100644 --- a/core/java/android/window/SplashScreenView.java +++ b/core/java/android/window/SplashScreenView.java @@ -17,8 +17,6 @@ package android.window; import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; -import android.animation.Animator; -import android.animation.ValueAnimator; import android.annotation.ColorInt; import android.annotation.NonNull; import android.annotation.Nullable; @@ -29,7 +27,6 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Rect; -import android.graphics.drawable.Animatable; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Parcel; @@ -47,6 +44,8 @@ import android.widget.FrameLayout; import com.android.internal.R; import com.android.internal.policy.DecorView; +import java.util.function.Consumer; + /** *
The view which allows an activity to customize its splash screen exit animation.
* @@ -69,6 +68,7 @@ public final class SplashScreenView extends FrameLayout { private boolean mNotCopyable; private int mInitBackgroundColor; + private int mInitIconBackgroundColor; private View mIconView; private Bitmap mParceledIconBitmap; private View mBrandingImageView; @@ -76,8 +76,6 @@ public final class SplashScreenView extends FrameLayout { private long mIconAnimationDuration; private long mIconAnimationStart; - private Animatable mAnimatableIcon; - private ValueAnimator mAnimator; // The host activity when transfer view to it. private Activity mHostActivity; // cache original window and status @@ -94,6 +92,7 @@ public final class SplashScreenView extends FrameLayout { private final Context mContext; private int mIconSize; private @ColorInt int mBackgroundColor; + private @ColorInt int mIconBackground; private Bitmap mParceledIconBitmap; private Drawable mIconDrawable; private int mBrandingImageWidth; @@ -114,6 +113,7 @@ public final class SplashScreenView extends FrameLayout { public Builder createFromParcel(SplashScreenViewParcelable parcelable) { mIconSize = parcelable.getIconSize(); mBackgroundColor = parcelable.getBackgroundColor(); + mIconBackground = parcelable.getIconBackground(); if (parcelable.mIconBitmap != null) { mIconDrawable = new BitmapDrawable(mContext.getResources(), parcelable.mIconBitmap); mParceledIconBitmap = parcelable.mIconBitmap; @@ -153,6 +153,14 @@ public final class SplashScreenView extends FrameLayout { return this; } + /** + * Set the background color for the icon. + */ + public Builder setIconBackground(int color) { + mIconBackground = color; + return this; + } + /** * Set the animation duration if icon is animatable. */ @@ -179,6 +187,7 @@ public final class SplashScreenView extends FrameLayout { final SplashScreenView view = (SplashScreenView) layoutInflater.inflate(R.layout.splash_screen_view, null, false); view.mInitBackgroundColor = mBackgroundColor; + view.mInitIconBackgroundColor = mIconBackground; view.setBackgroundColor(mBackgroundColor); view.mIconView = view.findViewById(R.id.splashscreen_icon_view); view.mBrandingImageView = view.findViewById(R.id.splashscreen_branding_view); @@ -266,43 +275,15 @@ public final class SplashScreenView extends FrameLayout { } void initIconAnimation(Drawable iconDrawable, long duration) { - if (iconDrawable instanceof Animatable) { - mAnimatableIcon = (Animatable) iconDrawable; - mAnimator = ValueAnimator.ofInt(0, 1); - mAnimator.setDuration(duration); - mAnimator.addListener(new Animator.AnimatorListener() { - @Override - public void onAnimationStart(Animator animation) { - mIconAnimationStart = SystemClock.uptimeMillis(); - mAnimatableIcon.start(); - } - - @Override - public void onAnimationEnd(Animator animation) { - mAnimatableIcon.stop(); - } - - @Override - public void onAnimationCancel(Animator animation) { - mAnimatableIcon.stop(); - } - - @Override - public void onAnimationRepeat(Animator animation) { - // do not repeat - mAnimatableIcon.stop(); - } - }); + if (!(iconDrawable instanceof SplashscreenIconDrawable)) { + return; } + SplashscreenIconDrawable aniDrawable = (SplashscreenIconDrawable) iconDrawable; + aniDrawable.prepareAnimate(duration, this::animationStartCallback); } - /** - * @hide - */ - public void startIntroAnimation() { - if (mAnimatableIcon != null) { - mAnimator.start(); - } + private void animationStartCallback(long startAt) { + mIconAnimationStart = startAt; } /** @@ -400,6 +381,15 @@ public final class SplashScreenView extends FrameLayout { return mBrandingImageView; } + /** + * Get the icon background color + * @hide + */ + @TestApi + public @ColorInt int getIconBackgroundColor() { + return mInitIconBackgroundColor; + } + /** * Get the initial background color of this view. * @hide @@ -408,6 +398,23 @@ public final class SplashScreenView extends FrameLayout { return mInitBackgroundColor; } + /** + * A lightweight Drawable object to make the view drawing faster and keep this + * drawable masked by config_icon_mask. + * @hide + */ + public abstract static class SplashscreenIconDrawable extends Drawable { + /** + * Prepare the animation if this drawable also be animatable. + * @param duration The animation duration. + * @param startListener The callback listener used to receive the start of the animation. + * @return true if this drawable object can also be animated and it can be played now. + */ + protected boolean prepareAnimate(long duration, Consumer