Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0682668 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Automerger Merge Worker
Browse files

Merge "Introduce setSplashscreenStyle to specify splash screen style." into sc-dev am: 6b0741b3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14609925

Change-Id: I87fd2e21067ba80b409c99875f219deb03267f33
parents 70543860 6b0741b3
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.window.IRemoteTransition;
import android.window.SplashScreen;
import android.window.WindowContainerToken;

import java.lang.annotation.Retention;
@@ -327,6 +328,10 @@ public class ActivityOptions {
    private static final String KEY_LAUNCHED_FROM_BUBBLE =
            "android.activity.launchTypeBubble";

    /** See {@link #setSplashscreenStyle(int)}. */
    private static final String KEY_SPLASH_SCREEN_STYLE =
            "android.activity.splashScreenStyle";

    /** See {@link #setTransientLaunch()}. */
    private static final String KEY_TRANSIENT_LAUNCH = "android.activity.transientLaunch";

@@ -415,6 +420,8 @@ public class ActivityOptions {
    private IRemoteTransition mRemoteTransition;
    private boolean mOverrideTaskTransition;
    private int mSplashScreenThemeResId;
    @SplashScreen.SplashScreenStyle
    private int mSplashScreenStyle;
    private boolean mRemoveWithTaskOrganizer;
    private boolean mLaunchedFromBubble;
    private boolean mTransientLaunch;
@@ -1171,6 +1178,7 @@ public class ActivityOptions {
        mRemoveWithTaskOrganizer = opts.getBoolean(KEY_REMOVE_WITH_TASK_ORGANIZER);
        mLaunchedFromBubble = opts.getBoolean(KEY_LAUNCHED_FROM_BUBBLE);
        mTransientLaunch = opts.getBoolean(KEY_TRANSIENT_LAUNCH);
        mSplashScreenStyle = opts.getInt(KEY_SPLASH_SCREEN_STYLE);
    }

    /**
@@ -1364,6 +1372,23 @@ public class ActivityOptions {
        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.
     *
@@ -1932,6 +1957,9 @@ public class ActivityOptions {
        if (mTransientLaunch) {
            b.putBoolean(KEY_TRANSIENT_LAUNCH, mTransientLaunch);
        }
        if (mSplashScreenStyle != 0) {
            b.putInt(KEY_SPLASH_SCREEN_STYLE, mSplashScreenStyle);
        }
        return b;
    }

+19 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.window;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.StyleRes;
import android.annotation.SuppressLint;
@@ -41,6 +42,24 @@ import java.util.ArrayList;
 * <code>Activity.getSplashScreen()</code> to get the SplashScreen.</p>
 */
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
     * own. Normally the splash screen will show on screen before the content of the activity has
+9 −0
Original line number Diff line number Diff line
@@ -308,6 +308,7 @@ import android.view.WindowManager.TransitionOldType;
import android.view.animation.Animation;
import android.window.IRemoteTransition;
import android.window.SizeConfigurationBuckets;
import android.window.SplashScreen;
import android.window.SplashScreenView.SplashScreenViewParcelable;
import android.window.TaskSnapshot;
import android.window.WindowContainerToken;
@@ -6182,6 +6183,14 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    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) {
            sourceRecord = searchCandidateLaunchingActivity();
        }