Merge "Introduce setSplashscreenStyle to specify splash screen style." into sc-dev

This commit is contained in:
Wei Sheng Shih
2021-06-08 12:16:24 +00:00
committed by Android (Google) Code Review
3 changed files with 56 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.window.IRemoteTransition; import android.window.IRemoteTransition;
import android.window.SplashScreen;
import android.window.WindowContainerToken; import android.window.WindowContainerToken;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@@ -327,6 +328,10 @@ public class ActivityOptions {
private static final String KEY_LAUNCHED_FROM_BUBBLE = private static final String KEY_LAUNCHED_FROM_BUBBLE =
"android.activity.launchTypeBubble"; "android.activity.launchTypeBubble";
/** See {@link #setSplashscreenStyle(int)}. */
private static final String KEY_SPLASH_SCREEN_STYLE =
"android.activity.splashScreenStyle";
/** See {@link #setTransientLaunch()}. */ /** See {@link #setTransientLaunch()}. */
private static final String KEY_TRANSIENT_LAUNCH = "android.activity.transientLaunch"; private static final String KEY_TRANSIENT_LAUNCH = "android.activity.transientLaunch";
@@ -415,6 +420,8 @@ public class ActivityOptions {
private IRemoteTransition mRemoteTransition; private IRemoteTransition mRemoteTransition;
private boolean mOverrideTaskTransition; private boolean mOverrideTaskTransition;
private int mSplashScreenThemeResId; private int mSplashScreenThemeResId;
@SplashScreen.SplashScreenStyle
private int mSplashScreenStyle;
private boolean mRemoveWithTaskOrganizer; private boolean mRemoveWithTaskOrganizer;
private boolean mLaunchedFromBubble; private boolean mLaunchedFromBubble;
private boolean mTransientLaunch; private boolean mTransientLaunch;
@@ -1171,6 +1178,7 @@ public class ActivityOptions {
mRemoveWithTaskOrganizer = opts.getBoolean(KEY_REMOVE_WITH_TASK_ORGANIZER); mRemoveWithTaskOrganizer = opts.getBoolean(KEY_REMOVE_WITH_TASK_ORGANIZER);
mLaunchedFromBubble = opts.getBoolean(KEY_LAUNCHED_FROM_BUBBLE); mLaunchedFromBubble = opts.getBoolean(KEY_LAUNCHED_FROM_BUBBLE);
mTransientLaunch = opts.getBoolean(KEY_TRANSIENT_LAUNCH); mTransientLaunch = opts.getBoolean(KEY_TRANSIENT_LAUNCH);
mSplashScreenStyle = opts.getInt(KEY_SPLASH_SCREEN_STYLE);
} }
/** /**
@@ -1364,6 +1372,23 @@ public class ActivityOptions {
return mSplashScreenThemeResId; return mSplashScreenThemeResId;
} }
/**
* Sets the preferred splash screen style.
* @hide
*/
public void setSplashscreenStyle(@SplashScreen.SplashScreenStyle int style) {
mSplashScreenStyle = style;
}
/**
* Gets the preferred splash screen style from caller
* @hide
*/
@SplashScreen.SplashScreenStyle
public int getSplashScreenStyle() {
return mSplashScreenStyle;
}
/** /**
* Sets whether the activity is to be launched into LockTask mode. * Sets whether the activity is to be launched into LockTask mode.
* *
@@ -1932,6 +1957,9 @@ public class ActivityOptions {
if (mTransientLaunch) { if (mTransientLaunch) {
b.putBoolean(KEY_TRANSIENT_LAUNCH, mTransientLaunch); b.putBoolean(KEY_TRANSIENT_LAUNCH, mTransientLaunch);
} }
if (mSplashScreenStyle != 0) {
b.putInt(KEY_SPLASH_SCREEN_STYLE, mSplashScreenStyle);
}
return b; return b;
} }

View File

@@ -16,6 +16,7 @@
package android.window; package android.window;
import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.StyleRes; import android.annotation.StyleRes;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
@@ -41,6 +42,24 @@ import java.util.ArrayList;
* <code>Activity.getSplashScreen()</code> to get the SplashScreen.</p> * <code>Activity.getSplashScreen()</code> to get the SplashScreen.</p>
*/ */
public interface SplashScreen { public interface SplashScreen {
/**
* Force splash screen to be empty.
* @hide
*/
int SPLASH_SCREEN_STYLE_EMPTY = 0;
/**
* Force splash screen to show icon.
* @hide
*/
int SPLASH_SCREEN_STYLE_ICON = 1;
/** @hide */
@IntDef(prefix = { "SPLASH_SCREEN_STYLE_" }, value = {
SPLASH_SCREEN_STYLE_EMPTY,
SPLASH_SCREEN_STYLE_ICON
})
@interface SplashScreenStyle {}
/** /**
* <p>Specifies whether an {@link Activity} wants to handle the splash screen animation on its * <p>Specifies whether an {@link Activity} wants to handle the splash screen animation on its
* own. Normally the splash screen will show on screen before the content of the activity has * own. Normally the splash screen will show on screen before the content of the activity has

View File

@@ -308,6 +308,7 @@ import android.view.WindowManager.TransitionOldType;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.window.IRemoteTransition; import android.window.IRemoteTransition;
import android.window.SizeConfigurationBuckets; import android.window.SizeConfigurationBuckets;
import android.window.SplashScreen;
import android.window.SplashScreenView.SplashScreenViewParcelable; import android.window.SplashScreenView.SplashScreenViewParcelable;
import android.window.TaskSnapshot; import android.window.TaskSnapshot;
import android.window.WindowContainerToken; import android.window.WindowContainerToken;
@@ -6182,6 +6183,14 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
} }
private boolean shouldUseEmptySplashScreen(ActivityRecord sourceRecord) { private boolean shouldUseEmptySplashScreen(ActivityRecord sourceRecord) {
if (mPendingOptions != null) {
final int optionsStyle = mPendingOptions.getSplashScreenStyle();
if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_EMPTY) {
return true;
} else if (optionsStyle == SplashScreen.SPLASH_SCREEN_STYLE_ICON) {
return false;
}
}
if (sourceRecord == null) { if (sourceRecord == null) {
sourceRecord = searchCandidateLaunchingActivity(); sourceRecord = searchCandidateLaunchingActivity();
} }