diff options
| author | wilsonshih <wilsonshih@google.com> | 2020-12-25 17:50:09 +0800 |
|---|---|---|
| committer | Vadim Caen <caen@google.com> | 2021-02-15 15:27:03 +0100 |
| commit | cf05d9265081e2dfaa45230eaa3beb381da8577e (patch) | |
| tree | 200f58f819853e79f2db2a53d2fcdfd2f4019555 /core/java | |
| parent | 8ac1b58101556b4ae63172de96e480dad8123f38 (diff) | |
Allow ShortcutInfo to specify a theme for splash screen.(5/N)
Provides new APIs so that shortcuts can preset the theme of the splash
screen window.
- Static way: android:splashScreenTheme
Preset the splash screen theme from xml.
- Dynamic way: ShortcutInfo.Builder#setStartingTheme
Preset the splash screen theme when construct the ShortcutInfo
programmatically.
Bug: 73289295
Test: build/flash
Test: atest AppWindowTokenTests ActivityRecordTests
Change-Id: Ie5e73f9b22fea22659e496c12198c942f4bc93cd
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/ActivityOptions.java | 19 | ||||
| -rw-r--r-- | core/java/android/content/pm/AppSearchShortcutInfo.java | 2 | ||||
| -rw-r--r-- | core/java/android/content/pm/ShortcutInfo.java | 37 | ||||
| -rw-r--r-- | core/java/android/content/pm/ShortcutServiceInternal.java | 7 | ||||
| -rw-r--r-- | core/java/android/window/StartingWindowInfo.java | 11 |
5 files changed, 73 insertions, 3 deletions
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index 28da1c3a3eb7..73cc13c82bcb 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -160,6 +160,12 @@ public class ActivityOptions { public static final String KEY_ANIM_START_LISTENER = "android:activity.animStartListener"; /** + * Specific a theme for a splash screen window. + * @hide + */ + public static final String KEY_SPLASH_SCREEN_THEME = "android.activity.splashScreenTheme"; + + /** * Callback for when the last frame of the animation is played. * @hide */ @@ -398,6 +404,7 @@ public class ActivityOptions { private IBinder mLaunchCookie; private IRemoteTransition mRemoteTransition; private boolean mOverrideTaskTransition; + private int mSplashScreenThemeResId; /** * Create an ActivityOptions specifying a custom animation to run when @@ -1147,6 +1154,7 @@ public class ActivityOptions { mRemoteTransition = IRemoteTransition.Stub.asInterface(opts.getBinder( KEY_REMOTE_TRANSITION)); mOverrideTaskTransition = opts.getBoolean(KEY_OVERRIDE_TASK_TRANSITION); + mSplashScreenThemeResId = opts.getInt(KEY_SPLASH_SCREEN_THEME); } /** @@ -1333,6 +1341,14 @@ public class ActivityOptions { } /** + * Gets whether the activity want to be launched as other theme for the splash screen. + * @hide + */ + public int getSplashScreenThemeResId() { + return mSplashScreenThemeResId; + } + + /** * Sets whether the activity is to be launched into LockTask mode. * * Use this option to start an activity in LockTask mode. Note that only apps permitted by @@ -1838,6 +1854,9 @@ public class ActivityOptions { if (mOverrideTaskTransition) { b.putBoolean(KEY_OVERRIDE_TASK_TRANSITION, mOverrideTaskTransition); } + if (mSplashScreenThemeResId != 0) { + b.putInt(KEY_SPLASH_SCREEN_THEME, mSplashScreenThemeResId); + } return b; } diff --git a/core/java/android/content/pm/AppSearchShortcutInfo.java b/core/java/android/content/pm/AppSearchShortcutInfo.java index 85549d854c6d..ebe202b2a3fa 100644 --- a/core/java/android/content/pm/AppSearchShortcutInfo.java +++ b/core/java/android/content/pm/AppSearchShortcutInfo.java @@ -273,7 +273,7 @@ public class AppSearchShortcutInfo extends GenericDocument { text, 0, null, disabledMessage, 0, null, categoriesSet, intents, rank, extras, getCreationTimestampMillis(), flags, iconResId, iconResName, bitmapPath, iconUri, - disabledReason, persons, locusId); + disabledReason, persons, locusId, 0); } /** @hide */ diff --git a/core/java/android/content/pm/ShortcutInfo.java b/core/java/android/content/pm/ShortcutInfo.java index 522f4ca88519..ce0547f5d0f4 100644 --- a/core/java/android/content/pm/ShortcutInfo.java +++ b/core/java/android/content/pm/ShortcutInfo.java @@ -434,6 +434,8 @@ public final class ShortcutInfo implements Parcelable { private int mDisabledReason; + private int mStartingThemeResId; + private ShortcutInfo(Builder b) { mUserId = b.mContext.getUserId(); @@ -462,6 +464,7 @@ public final class ShortcutInfo implements Parcelable { mLocusId = b.mLocusId; updateTimestamp(); + mStartingThemeResId = b.mStartingThemeResId; } /** @@ -608,6 +611,7 @@ public final class ShortcutInfo implements Parcelable { // Set this bit. mFlags |= FLAG_KEY_FIELDS_ONLY; } + mStartingThemeResId = source.mStartingThemeResId; } /** @@ -931,6 +935,9 @@ public final class ShortcutInfo implements Parcelable { if (source.mLocusId != null) { mLocusId = source.mLocusId; } + if (source.mStartingThemeResId != 0) { + mStartingThemeResId = source.mStartingThemeResId; + } } /** @@ -1000,6 +1007,8 @@ public final class ShortcutInfo implements Parcelable { private LocusId mLocusId; + private int mStartingThemeResId; + /** * Old style constructor. * @hide @@ -1102,6 +1111,15 @@ public final class ShortcutInfo implements Parcelable { } /** + * Sets a theme resource id for the splash screen. + */ + @NonNull + public Builder setStartingTheme(int themeResId) { + mStartingThemeResId = themeResId; + return this; + } + + /** * @hide We don't support resource strings for dynamic shortcuts for now. (But unit tests * use it.) */ @@ -1420,6 +1438,14 @@ public final class ShortcutInfo implements Parcelable { return mIcon; } + /** + * Returns the theme resource id used for the splash screen. + * @hide + */ + public int getStartingThemeResId() { + return mStartingThemeResId; + } + /** @hide -- old signature, the internal code still uses it. */ @Nullable @Deprecated @@ -2138,6 +2164,7 @@ public final class ShortcutInfo implements Parcelable { mPersons = source.readParcelableArray(cl, Person.class); mLocusId = source.readParcelable(cl); mIconUri = source.readString8(); + mStartingThemeResId = source.readInt(); } @Override @@ -2189,6 +2216,7 @@ public final class ShortcutInfo implements Parcelable { dest.writeParcelableArray(mPersons, flags); dest.writeParcelable(mLocusId, flags); dest.writeString8(mIconUri); + dest.writeInt(mStartingThemeResId); } public static final @NonNull Creator<ShortcutInfo> CREATOR = @@ -2345,6 +2373,12 @@ public final class ShortcutInfo implements Parcelable { sb.append("disabledReason="); sb.append(getDisabledReasonDebugString(mDisabledReason)); + if (mStartingThemeResId != 0) { + addIndentOrComma(sb, indent); + sb.append("SplashScreenThemeResId="); + sb.append(Integer.toHexString(mStartingThemeResId)); + } + addIndentOrComma(sb, indent); sb.append("categories="); @@ -2430,7 +2464,7 @@ public final class ShortcutInfo implements Parcelable { Set<String> categories, Intent[] intentsWithExtras, int rank, PersistableBundle extras, long lastChangedTimestamp, int flags, int iconResId, String iconResName, String bitmapPath, String iconUri, - int disabledReason, Person[] persons, LocusId locusId) { + int disabledReason, Person[] persons, LocusId locusId, int startingThemeResId) { mUserId = userId; mId = id; mPackageName = packageName; @@ -2459,5 +2493,6 @@ public final class ShortcutInfo implements Parcelable { mDisabledReason = disabledReason; mPersons = persons; mLocusId = locusId; + mStartingThemeResId = startingThemeResId; } } diff --git a/core/java/android/content/pm/ShortcutServiceInternal.java b/core/java/android/content/pm/ShortcutServiceInternal.java index c62767ee031b..233abf36131b 100644 --- a/core/java/android/content/pm/ShortcutServiceInternal.java +++ b/core/java/android/content/pm/ShortcutServiceInternal.java @@ -71,6 +71,13 @@ public abstract class ShortcutServiceInternal { public abstract int getShortcutIconResId(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId); + /** + * Get the theme res ID of the starting window, it can be 0 if not specified. + */ + public abstract int getShortcutStartingThemeResId(int launcherUserId, + @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, + int userId); + public abstract ParcelFileDescriptor getShortcutIconFd(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId); diff --git a/core/java/android/window/StartingWindowInfo.java b/core/java/android/window/StartingWindowInfo.java index 2282cc567936..63b9e9befb77 100644 --- a/core/java/android/window/StartingWindowInfo.java +++ b/core/java/android/window/StartingWindowInfo.java @@ -95,6 +95,12 @@ public final class StartingWindowInfo implements Parcelable { */ public int startingWindowTypeParameter; + /** + * Specifies a theme for the splash screen. + * @hide + */ + public int splashScreenThemeResId; + public StartingWindowInfo() { } @@ -115,6 +121,7 @@ public final class StartingWindowInfo implements Parcelable { dest.writeTypedObject(topOpaqueWindowInsetsState, flags); dest.writeTypedObject(topOpaqueWindowLayoutParams, flags); dest.writeTypedObject(mainWindowLayoutParams, flags); + dest.writeInt(splashScreenThemeResId); } void readFromParcel(@NonNull Parcel source) { @@ -124,6 +131,7 @@ public final class StartingWindowInfo implements Parcelable { topOpaqueWindowLayoutParams = source.readTypedObject( WindowManager.LayoutParams.CREATOR); mainWindowLayoutParams = source.readTypedObject(WindowManager.LayoutParams.CREATOR); + splashScreenThemeResId = source.readInt(); } @Override @@ -135,7 +143,8 @@ public final class StartingWindowInfo implements Parcelable { + Integer.toHexString(startingWindowTypeParameter) + " insetsState=" + topOpaqueWindowInsetsState + " topWindowLayoutParams=" + topOpaqueWindowLayoutParams - + " mainWindowLayoutParams=" + mainWindowLayoutParams; + + " mainWindowLayoutParams=" + mainWindowLayoutParams + + " splashScreenThemeResId " + Integer.toHexString(splashScreenThemeResId); } public static final @android.annotation.NonNull Creator<StartingWindowInfo> CREATOR = |
