summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wei Sheng Shih <wilsonshih@google.com> 2022-01-06 05:25:33 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-01-06 05:25:33 +0000
commit82cf9d7a4af0c16d276b431b126ac8ff989ca8ef (patch)
treedbbf9c7c4cc5f4c3a2cf1a1c0d8c34ba28470805
parent2a18ba18045e00f4a77a83ee79d238601fb07f76 (diff)
parentbf666289d7f669d54ea617f9c74838b3ca7c18f2 (diff)
Merge "Public API set and get splashscreen style"
-rw-r--r--core/api/current.txt3
-rw-r--r--core/java/android/app/ActivityOptions.java25
-rw-r--r--core/java/android/window/SplashScreen.java9
3 files changed, 24 insertions, 13 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index c1e63a3e4d28..96795ea21bd9 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -4469,6 +4469,7 @@ package android.app {
method public android.app.ActivityOptions setLaunchDisplayId(int);
method public android.app.ActivityOptions setLockTaskEnabled(boolean);
method public void setPendingIntentBackgroundActivityLaunchAllowed(boolean);
+ method @NonNull public android.app.ActivityOptions setSplashScreenStyle(int);
method public android.os.Bundle toBundle();
method public void update(android.app.ActivityOptions);
field public static final String EXTRA_USAGE_TIME_REPORT = "android.activity.usage_time";
@@ -57677,6 +57678,8 @@ package android.window {
method public void clearOnExitAnimationListener();
method public void setOnExitAnimationListener(@NonNull android.window.SplashScreen.OnExitAnimationListener);
method public void setSplashScreenTheme(@StyleRes int);
+ field public static final int SPLASH_SCREEN_STYLE_EMPTY = 0; // 0x0
+ field public static final int SPLASH_SCREEN_STYLE_ICON = 1; // 0x1
}
public static interface SplashScreen.OnExitAnimationListener {
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index f7d5e52e3675..5e5649f4eadf 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -337,7 +337,7 @@ public class ActivityOptions extends ComponentOptions {
private static final String KEY_LAUNCHED_FROM_BUBBLE =
"android.activity.launchTypeBubble";
- /** See {@link #setSplashscreenStyle(int)}. */
+ /** See {@link #setSplashScreenStyle(int)}. */
private static final String KEY_SPLASH_SCREEN_STYLE =
"android.activity.splashScreenStyle";
@@ -1393,20 +1393,27 @@ public class ActivityOptions extends ComponentOptions {
}
/**
- * Sets the preferred splash screen style.
+ * Gets the style can be used for cold-launching an activity.
+ * @see #setSplashScreenStyle(int)
* @hide
*/
- public void setSplashscreenStyle(@SplashScreen.SplashScreenStyle int style) {
- mSplashScreenStyle = style;
+ public @SplashScreen.SplashScreenStyle int getSplashScreenStyle() {
+ return mSplashScreenStyle;
}
/**
- * Gets the preferred splash screen style from caller
- * @hide
+ * Sets the preferred splash screen style of the opening activities. This only applies if the
+ * Activity or Process is not yet created.
+ * @param style Can be either {@link SplashScreen#SPLASH_SCREEN_STYLE_ICON} or
+ * {@link SplashScreen#SPLASH_SCREEN_STYLE_EMPTY}
*/
- @SplashScreen.SplashScreenStyle
- public int getSplashScreenStyle() {
- return mSplashScreenStyle;
+ @NonNull
+ public ActivityOptions setSplashScreenStyle(@SplashScreen.SplashScreenStyle int style) {
+ if (style == SplashScreen.SPLASH_SCREEN_STYLE_ICON
+ || style == SplashScreen.SPLASH_SCREEN_STYLE_EMPTY) {
+ mSplashScreenStyle = style;
+ }
+ return this;
}
/**
diff --git a/core/java/android/window/SplashScreen.java b/core/java/android/window/SplashScreen.java
index 090dbff488e9..3f65f475fbd5 100644
--- a/core/java/android/window/SplashScreen.java
+++ b/core/java/android/window/SplashScreen.java
@@ -22,6 +22,7 @@ import android.annotation.StyleRes;
import android.annotation.SuppressLint;
import android.annotation.UiThread;
import android.app.Activity;
+import android.app.ActivityOptions;
import android.app.ActivityThread;
import android.app.AppGlobals;
import android.content.Context;
@@ -48,13 +49,13 @@ public interface SplashScreen {
*/
int SPLASH_SCREEN_STYLE_UNDEFINED = -1;
/**
- * Force splash screen to be empty.
- * @hide
+ * Flag to be used with {@link ActivityOptions#setSplashScreenStyle}, to avoid showing the
+ * splash screen icon of the launched activity
*/
int SPLASH_SCREEN_STYLE_EMPTY = 0;
/**
- * Force splash screen to show icon.
- * @hide
+ * Flag to be used with {@link ActivityOptions#setSplashScreenStyle}, to show the splash screen
+ * icon of the launched activity.
*/
int SPLASH_SCREEN_STYLE_ICON = 1;