summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-04-16 17:34:25 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-04-16 17:34:25 -0700
commitac76e72272c957dc7609aa68224efa2d32c23cd0 (patch)
tree3fb89e515da0aabcfedddf871aa92ee0b1173c38
parent2c2ab0e07106942ee64dd66d6efa71e70b336b0d (diff)
parenteabfb3a36e9469c5e219f92b39b7200104319185 (diff)
downloadframeworks_base-ac76e72272c957dc7609aa68224efa2d32c23cd0.zip
frameworks_base-ac76e72272c957dc7609aa68224efa2d32c23cd0.tar.gz
frameworks_base-ac76e72272c957dc7609aa68224efa2d32c23cd0.tar.bz2
Merge "Add new scale-up window manager animation."
-rw-r--r--api/current.txt1
-rw-r--r--core/java/android/app/ActivityOptions.java84
-rw-r--r--core/java/android/view/IWindowManager.aidl2
-rw-r--r--services/java/com/android/server/am/ActivityRecord.java5
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java119
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java6
6 files changed, 193 insertions, 24 deletions
diff --git a/api/current.txt b/api/current.txt
index ae7152b..00cf365 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -2896,6 +2896,7 @@ package android.app {
public class ActivityOptions {
method public void join(android.app.ActivityOptions);
method public static android.app.ActivityOptions makeCustomAnimation(android.content.Context, int, int);
+ method public static android.app.ActivityOptions makeScaleUpAnimation(android.view.View, int, int, int, int);
method public static android.app.ActivityOptions makeThumbnailScaleUpAnimation(android.view.View, android.graphics.Bitmap, int, int);
method public android.os.Bundle toBundle();
}
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index c3cceaf..423b02a 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -73,6 +73,18 @@ public class ActivityOptions {
public static final String KEY_ANIM_START_Y = "android:animStartY";
/**
+ * Initial width of the animation.
+ * @hide
+ */
+ public static final String KEY_ANIM_START_WIDTH = "android:animStartWidth";
+
+ /**
+ * Initial height of the animation.
+ * @hide
+ */
+ public static final String KEY_ANIM_START_HEIGHT = "android:animStartHeight";
+
+ /**
* Callback for when animation is started.
* @hide
*/
@@ -83,7 +95,9 @@ public class ActivityOptions {
/** @hide */
public static final int ANIM_CUSTOM = 1;
/** @hide */
- public static final int ANIM_THUMBNAIL = 2;
+ public static final int ANIM_SCALE_UP = 2;
+ /** @hide */
+ public static final int ANIM_THUMBNAIL = 3;
private String mPackageName;
private int mAnimationType = ANIM_NONE;
@@ -92,6 +106,8 @@ public class ActivityOptions {
private Bitmap mThumbnail;
private int mStartX;
private int mStartY;
+ private int mStartWidth;
+ private int mStartHeight;
private IRemoteCallback mAnimationStartedListener;
/**
@@ -127,6 +143,34 @@ public class ActivityOptions {
}
/**
+ * Create an ActivityOptions specifying an animation where the new
+ * activity is scaled from a small originating area of the screen to
+ * its final full representation.
+ *
+ * @param source The View that the new activity is animating from. This
+ * defines the coordinate space for <var>startX</var> and <var>startY</var>.
+ * @param startX The x starting location of the new activity, relative to <var>source</var>.
+ * @param startY The y starting location of the activity, relative to <var>source</var>.
+ * @param startWidth The initial width of the new activity.
+ * @param startWidth The initial height of the new activity.
+ * @return Returns a new ActivityOptions object that you can use to
+ * supply these options as the options Bundle when starting an activity.
+ */
+ public static ActivityOptions makeScaleUpAnimation(View source,
+ int startX, int startY, int startWidth, int startHeight) {
+ ActivityOptions opts = new ActivityOptions();
+ opts.mPackageName = source.getContext().getPackageName();
+ opts.mAnimationType = ANIM_SCALE_UP;
+ int[] pts = new int[2];
+ source.getLocationOnScreen(pts);
+ opts.mStartX = pts[0] + startX;
+ opts.mStartY = pts[1] + startY;
+ opts.mStartWidth = startWidth;
+ opts.mStartHeight = startHeight;
+ return opts;
+ }
+
+ /**
* Create an ActivityOptions specifying an animation where a thumbnail
* is scaled from a given position to the new activity window that is
* being started.
@@ -135,8 +179,8 @@ public class ActivityOptions {
* defines the coordinate space for <var>startX</var> and <var>startY</var>.
* @param thumbnail The bitmap that will be shown as the initial thumbnail
* of the animation.
- * @param startX The x starting location of the bitmap, in screen coordiantes.
- * @param startY The y starting location of the bitmap, in screen coordinates.
+ * @param startX The x starting location of the bitmap, relative to <var>source</var>.
+ * @param startY The y starting location of the bitmap, relative to <var>source</var>.
* @return Returns a new ActivityOptions object that you can use to
* supply these options as the options Bundle when starting an activity.
*/
@@ -154,8 +198,8 @@ public class ActivityOptions {
* defines the coordinate space for <var>startX</var> and <var>startY</var>.
* @param thumbnail The bitmap that will be shown as the initial thumbnail
* of the animation.
- * @param startX The x starting location of the bitmap, in screen coordiantes.
- * @param startY The y starting location of the bitmap, in screen coordinates.
+ * @param startX The x starting location of the bitmap, relative to <var>source</var>.
+ * @param startY The y starting location of the bitmap, relative to <var>source</var>.
* @param listener Optional OnAnimationStartedListener to find out when the
* requested animation has started running. If for some reason the animation
* is not executed, the callback will happen immediately.
@@ -199,6 +243,11 @@ public class ActivityOptions {
if (mAnimationType == ANIM_CUSTOM) {
mCustomEnterResId = opts.getInt(KEY_ANIM_ENTER_RES_ID, 0);
mCustomExitResId = opts.getInt(KEY_ANIM_EXIT_RES_ID, 0);
+ } else if (mAnimationType == ANIM_SCALE_UP) {
+ mStartX = opts.getInt(KEY_ANIM_START_X, 0);
+ mStartY = opts.getInt(KEY_ANIM_START_Y, 0);
+ mStartWidth = opts.getInt(KEY_ANIM_START_WIDTH, 0);
+ mStartHeight = opts.getInt(KEY_ANIM_START_HEIGHT, 0);
} else if (mAnimationType == ANIM_THUMBNAIL) {
mThumbnail = (Bitmap)opts.getParcelable(KEY_ANIM_THUMBNAIL);
mStartX = opts.getInt(KEY_ANIM_START_X, 0);
@@ -244,6 +293,16 @@ public class ActivityOptions {
}
/** @hide */
+ public int getStartWidth() {
+ return mStartWidth;
+ }
+
+ /** @hide */
+ public int getStartHeight() {
+ return mStartHeight;
+ }
+
+ /** @hide */
public IRemoteCallback getOnAnimationStartListener() {
return mAnimationStartedListener;
}
@@ -281,6 +340,13 @@ public class ActivityOptions {
mThumbnail = null;
mAnimationStartedListener = null;
break;
+ case ANIM_SCALE_UP:
+ mAnimationType = otherOptions.mAnimationType;
+ mStartX = otherOptions.mStartX;
+ mStartY = otherOptions.mStartY;
+ mStartWidth = otherOptions.mStartWidth;
+ mStartHeight = otherOptions.mStartHeight;
+ break;
case ANIM_THUMBNAIL:
mAnimationType = otherOptions.mAnimationType;
mThumbnail = otherOptions.mThumbnail;
@@ -316,6 +382,13 @@ public class ActivityOptions {
b.putInt(KEY_ANIM_ENTER_RES_ID, mCustomEnterResId);
b.putInt(KEY_ANIM_EXIT_RES_ID, mCustomExitResId);
break;
+ case ANIM_SCALE_UP:
+ b.putInt(KEY_ANIM_TYPE, mAnimationType);
+ b.putInt(KEY_ANIM_START_X, mStartX);
+ b.putInt(KEY_ANIM_START_Y, mStartY);
+ b.putInt(KEY_ANIM_START_WIDTH, mStartWidth);
+ b.putInt(KEY_ANIM_START_HEIGHT, mStartHeight);
+ break;
case ANIM_THUMBNAIL:
b.putInt(KEY_ANIM_TYPE, mAnimationType);
b.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail);
@@ -323,6 +396,7 @@ public class ActivityOptions {
b.putInt(KEY_ANIM_START_Y, mStartY);
b.putIBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener
!= null ? mAnimationStartedListener.asBinder() : null);
+ break;
}
return b;
}
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 8fe8e40..b70d7b5 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -80,6 +80,8 @@ interface IWindowManager
void prepareAppTransition(int transit, boolean alwaysKeepCurrent);
int getPendingAppTransition();
void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim);
+ void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
+ int startHeight);
void overridePendingAppTransitionThumb(in Bitmap srcThumb, int startX, int startY,
IRemoteCallback startedCallback);
void executeAppTransition();
diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java
index a098f18..cce8e7a 100644
--- a/services/java/com/android/server/am/ActivityRecord.java
+++ b/services/java/com/android/server/am/ActivityRecord.java
@@ -558,6 +558,11 @@ final class ActivityRecord {
pendingOptions.getCustomEnterResId(),
pendingOptions.getCustomExitResId());
break;
+ case ActivityOptions.ANIM_SCALE_UP:
+ service.mWindowManager.overridePendingAppTransitionScaleUp(
+ pendingOptions.getStartX(), pendingOptions.getStartY(),
+ pendingOptions.getStartWidth(), pendingOptions.getStartHeight());
+ break;
case ActivityOptions.ANIM_THUMBNAIL:
service.mWindowManager.overridePendingAppTransitionThumb(
pendingOptions.getThumbnail(),
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 0fe6921..0458a67 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -50,6 +50,7 @@ import com.android.server.input.InputManagerService;
import android.Manifest;
import android.app.ActivityManagerNative;
+import android.app.ActivityOptions;
import android.app.IActivityManager;
import android.app.StatusBarManager;
import android.app.admin.DevicePolicyManager;
@@ -497,6 +498,7 @@ public class WindowManagerService extends IWindowManager.Stub
// mOpeningApps and mClosingApps are the lists of tokens that will be
// made visible or hidden at the next transition.
int mNextAppTransition = WindowManagerPolicy.TRANSIT_UNSET;
+ int mNextAppTransitionType = ActivityOptions.ANIM_NONE;
String mNextAppTransitionPackage;
Bitmap mNextAppTransitionThumbnail;
IRemoteCallback mNextAppTransitionCallback;
@@ -504,6 +506,8 @@ public class WindowManagerService extends IWindowManager.Stub
int mNextAppTransitionExit;
int mNextAppTransitionStartX;
int mNextAppTransitionStartY;
+ int mNextAppTransitionStartWidth;
+ int mNextAppTransitionStartHeight;
boolean mAppTransitionReady = false;
boolean mAppTransitionRunning = false;
boolean mAppTransitionTimeout = false;
@@ -3072,6 +3076,50 @@ public class WindowManagerService extends IWindowManager.Stub
return null;
}
+ private Animation createScaleUpAnimationLocked(int transit, boolean enter) {
+ Animation a;
+ // Pick the desired duration. If this is an inter-activity transition,
+ // it is the standard duration for that. Otherwise we use the longer
+ // task transition duration.
+ int duration;
+ switch (transit) {
+ case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
+ case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
+ duration = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_shortAnimTime);
+ break;
+ default:
+ duration = 500;
+ break;
+ }
+ if (enter) {
+ // Entering app zooms out from the center of the initial rect.
+ Animation scale = new ScaleAnimation(
+ mNextAppTransitionStartWidth/mAppDisplayWidth, 1,
+ mNextAppTransitionStartHeight/mAppDisplayHeight, 1,
+ mNextAppTransitionStartX + mNextAppTransitionStartWidth/2,
+ mNextAppTransitionStartY + mNextAppTransitionStartHeight/2);
+ AnimationSet set = new AnimationSet(true);
+ Animation alpha = new AlphaAnimation(0, 1);
+ scale.setDuration(duration);
+ set.addAnimation(scale);
+ alpha.setDuration(duration);
+ set.addAnimation(alpha);
+ a = set;
+ } else {
+ // Exiting app just holds in place.
+ a = new AlphaAnimation(1, 1);
+ a.setDuration(duration);
+ }
+ a.setFillAfter(true);
+ final Interpolator interpolator = AnimationUtils.loadInterpolator(mContext,
+ com.android.internal.R.interpolator.decelerate_quint);
+ a.setInterpolator(interpolator);
+ a.initialize(mAppDisplayWidth, mAppDisplayHeight,
+ mAppDisplayWidth, mAppDisplayHeight);
+ return a;
+ }
+
private Animation createThumbnailAnimationLocked(int transit,
boolean enter, boolean thumb) {
Animation a;
@@ -3090,7 +3138,6 @@ public class WindowManagerService extends IWindowManager.Stub
default:
duration = 500;
break;
-
}
if (thumb) {
// Animation for zooming thumbnail from its initial size to
@@ -3138,12 +3185,15 @@ public class WindowManagerService extends IWindowManager.Stub
if (okToDisplay()) {
Animation a;
boolean initialized = false;
- if (mNextAppTransitionThumbnail != null) {
- a = createThumbnailAnimationLocked(transit, enter, false);
- initialized = true;
- } else if (mNextAppTransitionPackage != null) {
+ if (mNextAppTransitionType == ActivityOptions.ANIM_CUSTOM) {
a = loadAnimation(mNextAppTransitionPackage, enter ?
mNextAppTransitionEnter : mNextAppTransitionExit);
+ } else if (mNextAppTransitionType == ActivityOptions.ANIM_SCALE_UP) {
+ a = createScaleUpAnimationLocked(transit, enter);
+ initialized = true;
+ } else if (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL) {
+ a = createThumbnailAnimationLocked(transit, enter, false);
+ initialized = true;
} else {
int animAttr = 0;
switch (transit) {
@@ -3738,6 +3788,7 @@ public class WindowManagerService extends IWindowManager.Stub
public void overridePendingAppTransition(String packageName,
int enterAnim, int exitAnim) {
if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
+ mNextAppTransitionType = ActivityOptions.ANIM_CUSTOM;
mNextAppTransitionPackage = packageName;
mNextAppTransitionThumbnail = null;
mNextAppTransitionEnter = enterAnim;
@@ -3745,9 +3796,23 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
+ public void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
+ int startHeight) {
+ if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
+ mNextAppTransitionType = ActivityOptions.ANIM_SCALE_UP;
+ mNextAppTransitionPackage = null;
+ mNextAppTransitionThumbnail = null;
+ mNextAppTransitionStartX = startX;
+ mNextAppTransitionStartY = startY;
+ mNextAppTransitionStartWidth = startWidth;
+ mNextAppTransitionStartHeight = startHeight;
+ }
+ }
+
public void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX,
int startY, IRemoteCallback startedCallback) {
if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
+ mNextAppTransitionType = ActivityOptions.ANIM_THUMBNAIL;
mNextAppTransitionPackage = null;
mNextAppTransitionThumbnail = srcThumb;
mNextAppTransitionStartX = startX;
@@ -7845,6 +7910,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
+ mNextAppTransitionType = ActivityOptions.ANIM_NONE;
mNextAppTransitionPackage = null;
mNextAppTransitionThumbnail = null;
if (mNextAppTransitionCallback != null) {
@@ -8810,6 +8876,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
mNextAppTransition = WindowManagerPolicy.TRANSIT_UNSET;
+ mNextAppTransitionType = ActivityOptions.ANIM_NONE;
mNextAppTransitionPackage = null;
mNextAppTransitionThumbnail = null;
mAppTransitionReady = true;
@@ -9350,20 +9417,34 @@ public class WindowManagerService extends IWindowManager.Stub
pw.print(Integer.toHexString(mNextAppTransition));
pw.print(" mAppTransitionReady="); pw.println(mAppTransitionReady);
pw.print(" mAppTransitionRunning="); pw.print(mAppTransitionRunning);
- pw.print(" mAppTransitionTimeout="); pw.println( mAppTransitionTimeout);
- if (mNextAppTransitionPackage != null) {
- pw.print(" mNextAppTransitionPackage=");
- pw.print(mNextAppTransitionPackage);
- pw.print(" mNextAppTransitionEnter=0x");
- pw.print(Integer.toHexString(mNextAppTransitionEnter));
- pw.print(" mNextAppTransitionExit=0x");
- pw.print(Integer.toHexString(mNextAppTransitionExit));
- }
- if (mNextAppTransitionThumbnail != null) {
- pw.print(" mNextAppTransitionThumbnail=");
- pw.print(mNextAppTransitionThumbnail);
- pw.print(" mNextAppTransitionStartX="); pw.print(mNextAppTransitionStartX);
- pw.print(" mNextAppTransitionStartY="); pw.println(mNextAppTransitionStartY);
+ pw.print(" mAppTransitionTimeout="); pw.println(mAppTransitionTimeout);
+ if (mNextAppTransitionType != ActivityOptions.ANIM_NONE) {
+ pw.print(" mNextAppTransitionType="); pw.println(mNextAppTransitionType);
+ }
+ switch (mNextAppTransitionType) {
+ case ActivityOptions.ANIM_CUSTOM:
+ pw.print(" mNextAppTransitionPackage=");
+ pw.print(mNextAppTransitionPackage);
+ pw.print(" mNextAppTransitionEnter=0x");
+ pw.print(Integer.toHexString(mNextAppTransitionEnter));
+ pw.print(" mNextAppTransitionExit=0x");
+ pw.print(Integer.toHexString(mNextAppTransitionExit));
+ break;
+ case ActivityOptions.ANIM_SCALE_UP:
+ pw.print(" mNextAppTransitionStartX="); pw.print(mNextAppTransitionStartX);
+ pw.print(" mNextAppTransitionStartY=");
+ pw.println(mNextAppTransitionStartY);
+ pw.print(" mNextAppTransitionStartWidth=");
+ pw.print(mNextAppTransitionStartWidth);
+ pw.print(" mNextAppTransitionStartHeight=");
+ pw.println(mNextAppTransitionStartHeight);
+ break;
+ case ActivityOptions.ANIM_THUMBNAIL:
+ pw.print(" mNextAppTransitionThumbnail=");
+ pw.print(mNextAppTransitionThumbnail);
+ pw.print(" mNextAppTransitionStartX="); pw.print(mNextAppTransitionStartX);
+ pw.print(" mNextAppTransitionStartY="); pw.println(mNextAppTransitionStartY);
+ break;
}
pw.print(" mStartingIconInTransition="); pw.print(mStartingIconInTransition);
pw.print(", mSkipAppTransitionAnimation="); pw.println(mSkipAppTransitionAnimation);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
index e6c9351..44d28fa 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
@@ -229,6 +229,12 @@ public class BridgeWindowManager implements IWindowManager {
}
@Override
+ public void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
+ int startHeight) throws RemoteException {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
public void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY,
IRemoteCallback startedCallback) throws RemoteException {
// TODO Auto-generated method stub