diff options
| author | 2016-01-31 19:51:37 +0000 | |
|---|---|---|
| committer | 2016-01-31 19:51:37 +0000 | |
| commit | 1902169600be8fe1cf3dfdb69e969a3105ca1f8a (patch) | |
| tree | e230403ca4cde41dcef8c0dcfba360a76ea7bc01 | |
| parent | a8b42780c24aa6938731aff186f152a7f8829528 (diff) | |
| parent | 5122df094bcb07cff81dac02c397fb6a7cb2e009 (diff) | |
Merge "API council recommended changes to bounds APIs in ActivityOptions"
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | api/system-current.txt | 1 | ||||
| -rw-r--r-- | api/test-current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/app/ActivityOptions.java | 37 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityStackSupervisor.java | 2 |
5 files changed, 20 insertions, 22 deletions
diff --git a/api/current.txt b/api/current.txt index 0f4d43c5e4f6..12efae5aed22 100644 --- a/api/current.txt +++ b/api/current.txt @@ -3834,7 +3834,6 @@ package android.app { public class ActivityOptions { method public android.graphics.Rect getLaunchBounds(); - method public boolean hasLaunchBounds(); method public static android.app.ActivityOptions makeBasic(); method public static android.app.ActivityOptions makeClipRevealAnimation(android.view.View, int, int, int, int); method public static android.app.ActivityOptions makeCustomAnimation(android.content.Context, int, int); diff --git a/api/system-current.txt b/api/system-current.txt index 11e311a31b25..ad251a1dbb47 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3957,7 +3957,6 @@ package android.app { public class ActivityOptions { method public android.graphics.Rect getLaunchBounds(); - method public boolean hasLaunchBounds(); method public static android.app.ActivityOptions makeBasic(); method public static android.app.ActivityOptions makeClipRevealAnimation(android.view.View, int, int, int, int); method public static android.app.ActivityOptions makeCustomAnimation(android.content.Context, int, int); diff --git a/api/test-current.txt b/api/test-current.txt index c37b2a9978e5..2181cec5fe02 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3834,7 +3834,6 @@ package android.app { public class ActivityOptions { method public android.graphics.Rect getLaunchBounds(); - method public boolean hasLaunchBounds(); method public static android.app.ActivityOptions makeBasic(); method public static android.app.ActivityOptions makeClipRevealAnimation(android.view.View, int, int, int, int); method public static android.app.ActivityOptions makeCustomAnimation(android.content.Context, int, int); diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index b42cf683100a..094950bfb3fd 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -19,6 +19,7 @@ package android.app; import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; +import android.annotation.Nullable; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; @@ -203,7 +204,6 @@ public class ActivityOptions { public static final int ANIM_CLIP_REVEAL = 11; private String mPackageName; - private boolean mHasLaunchBounds; private Rect mLaunchBounds; private int mAnimationType = ANIM_NONE; private int mCustomEnterResId; @@ -716,10 +716,7 @@ public class ActivityOptions { } catch (RuntimeException e) { Slog.w(TAG, e); } - mHasLaunchBounds = opts.containsKey(KEY_LAUNCH_BOUNDS); - if (mHasLaunchBounds) { - mLaunchBounds = opts.getParcelable(KEY_LAUNCH_BOUNDS); - } + mLaunchBounds = opts.getParcelable(KEY_LAUNCH_BOUNDS); mAnimationType = opts.getInt(KEY_ANIM_TYPE); switch (mAnimationType) { case ANIM_CUSTOM: @@ -779,14 +776,16 @@ public class ActivityOptions { } /** - * Sets the bounds (window size) that the activity should be launched in. Set to null explicitly - * for full screen. - * NOTE: This value is ignored on devices that don't have - * {@link android.content.pm.PackageManager#FEATURE_FREEFORM_WINDOW_MANAGEMENT} enabled. + * Sets the bounds (window size) that the activity should be launched in. + * Set to null explicitly for fullscreen. + * <p> + * <strong>NOTE:<strong/> This value is ignored on devices that don't have + * {@link android.content.pm.PackageManager#FEATURE_FREEFORM_WINDOW_MANAGEMENT} or + * {@link android.content.pm.PackageManager#FEATURE_PICTURE_IN_PICTURE} enabled. + * @param launchBounds Launch bounds to use for the activity or null for fullscreen. */ - public ActivityOptions setLaunchBounds(Rect launchBounds) { - mHasLaunchBounds = true; - mLaunchBounds = launchBounds; + public ActivityOptions setLaunchBounds(@Nullable Rect launchBounds) { + mLaunchBounds = launchBounds != null ? new Rect(launchBounds) : null; return this; } @@ -795,11 +794,13 @@ public class ActivityOptions { return mPackageName; } - public boolean hasLaunchBounds() { - return mHasLaunchBounds; - } - - public Rect getLaunchBounds(){ + /** + * Returns the bounds that should be used to launch the activity. + * @see #setLaunchBounds(Rect) + * @return Bounds used to launch the activity. + */ + @Nullable + public Rect getLaunchBounds() { return mLaunchBounds; } @@ -1024,7 +1025,7 @@ public class ActivityOptions { if (mPackageName != null) { b.putString(KEY_PACKAGE_NAME, mPackageName); } - if (mHasLaunchBounds) { + if (mLaunchBounds != null) { b.putParcelable(KEY_LAUNCH_BOUNDS, mLaunchBounds); } b.putInt(KEY_ANIM_TYPE, mAnimationType); diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 7359859604b9..31712d9233a0 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -1754,7 +1754,7 @@ public final class ActivityStackSupervisor implements DisplayListener { boolean canUseActivityOptionsLaunchBounds(ActivityOptions options, int launchStackId) { // We use the launch bounds in the activity options is the device supports freeform // window management or is launching into the pinned stack. - if (!options.hasLaunchBounds()) { + if (options.getLaunchBounds() == null) { return false; } return (mService.mSupportsPictureInPicture && launchStackId == PINNED_STACK_ID) |