Public API set and get splashscreen style
Allow developer to control the splash screen style when the option is used for cold or warm launch an activity. Bug: 203497083 Test: atest SplashscreenTests#testLaunchFromLauncherWithEmptyIconOptions Test: atest SplashscreenTests#testLaunchAppWithIconOptions Change-Id: I9c4ccca2470df5dbac96da2d4a96b616b6670688
This commit is contained in:
@@ -4464,6 +4464,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";
|
||||
@@ -57667,6 +57668,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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user