API council recommended changes to bounds APIs in ActivityOptions

Bug: 26509660
Change-Id: Id90fbda0e15e83145ecc85c214b0ae5763fcc902
This commit is contained in:
Wale Ogunwale
2016-01-29 22:33:38 -08:00
parent 33f266201c
commit 5122df094b
5 changed files with 20 additions and 22 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)