diff options
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | api/system-current.txt | 1 | ||||
-rw-r--r-- | core/java/android/app/ActivityOptions.java | 31 | ||||
-rw-r--r-- | core/java/android/view/IWindowManager.aidl | 2 | ||||
-rw-r--r-- | core/java/android/view/animation/ClipRectAnimation.java | 13 | ||||
-rw-r--r-- | core/java/android/view/animation/ClipRectLRAnimation.java | 49 | ||||
-rw-r--r-- | core/java/android/view/animation/ClipRectTBAnimation.java | 49 | ||||
-rw-r--r-- | core/java/android/view/animation/Transformation.java | 16 | ||||
-rw-r--r-- | core/java/android/view/animation/TranslateAnimation.java | 34 | ||||
-rw-r--r-- | core/java/android/view/animation/TranslateXAnimation.java | 55 | ||||
-rw-r--r-- | core/java/android/view/animation/TranslateYAnimation.java | 55 | ||||
-rwxr-xr-x | services/core/java/com/android/server/am/ActivityRecord.java | 11 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/AppTransition.java | 129 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/WindowManagerService.java | 9 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java | 6 |
15 files changed, 435 insertions, 26 deletions
diff --git a/api/current.txt b/api/current.txt index aeb95ab..009fc51 100644 --- a/api/current.txt +++ b/api/current.txt @@ -3696,6 +3696,7 @@ package android.app { } public class ActivityOptions { + 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); method public static android.app.ActivityOptions makeScaleUpAnimation(android.view.View, int, int, int, int); method public static android.app.ActivityOptions makeSceneTransitionAnimation(android.app.Activity, android.view.View, java.lang.String); diff --git a/api/system-current.txt b/api/system-current.txt index a04fe33..2f43bdf 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3784,6 +3784,7 @@ package android.app { } public class ActivityOptions { + 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); method public static android.app.ActivityOptions makeScaleUpAnimation(android.view.View, int, int, int, int); method public static android.app.ActivityOptions makeSceneTransitionAnimation(android.app.Activity, android.view.View, java.lang.String); diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index 39ae65c..8909b28 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -140,6 +140,8 @@ public class ActivityOptions { public static final int ANIM_THUMBNAIL_ASPECT_SCALE_DOWN = 9; /** @hide */ public static final int ANIM_CUSTOM_IN_PLACE = 10; + /** @hide */ + public static final int ANIM_CLIP_REVEAL = 11; private String mPackageName; private int mAnimationType = ANIM_NONE; @@ -291,6 +293,33 @@ public class ActivityOptions { } /** + * Create an ActivityOptions specifying an animation where the new + * activity is revealed 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 width The initial width of the new activity. + * @param height 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 makeClipRevealAnimation(View source, + int startX, int startY, int width, int height) { + ActivityOptions opts = new ActivityOptions(); + opts.mAnimationType = ANIM_CLIP_REVEAL; + int[] pts = new int[2]; + source.getLocationOnScreen(pts); + opts.mStartX = pts[0] + startX; + opts.mStartY = pts[1] + startY; + opts.mWidth = width; + opts.mHeight = height; + 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. @@ -582,6 +611,7 @@ public class ActivityOptions { break; case ANIM_SCALE_UP: + case ANIM_CLIP_REVEAL: mStartX = opts.getInt(KEY_ANIM_START_X, 0); mStartY = opts.getInt(KEY_ANIM_START_Y, 0); mWidth = opts.getInt(KEY_ANIM_WIDTH, 0); @@ -809,6 +839,7 @@ public class ActivityOptions { b.putInt(KEY_ANIM_IN_PLACE_RES_ID, mCustomInPlaceResId); break; case ANIM_SCALE_UP: + case ANIM_CLIP_REVEAL: b.putInt(KEY_ANIM_START_X, mStartX); b.putInt(KEY_ANIM_START_Y, mStartY); b.putInt(KEY_ANIM_WIDTH, mWidth); diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 743f6b7..8ac8bc5 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -91,6 +91,8 @@ interface IWindowManager IRemoteCallback startedCallback); void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, int startHeight); + void overridePendingAppTransitionClipReveal(int startX, int startY, + int startWidth, int startHeight); void overridePendingAppTransitionThumb(in Bitmap srcThumb, int startX, int startY, IRemoteCallback startedCallback, boolean scaleUp); void overridePendingAppTransitionAspectScaledThumb(in Bitmap srcThumb, int startX, diff --git a/core/java/android/view/animation/ClipRectAnimation.java b/core/java/android/view/animation/ClipRectAnimation.java index 2361501..e194927 100644 --- a/core/java/android/view/animation/ClipRectAnimation.java +++ b/core/java/android/view/animation/ClipRectAnimation.java @@ -26,8 +26,8 @@ import android.graphics.Rect; * @hide */ public class ClipRectAnimation extends Animation { - private Rect mFromRect = new Rect(); - private Rect mToRect = new Rect(); + protected Rect mFromRect = new Rect(); + protected Rect mToRect = new Rect(); /** * Constructor to use when building a ClipRectAnimation from code @@ -43,6 +43,15 @@ public class ClipRectAnimation extends Animation { mToRect.set(toClip); } + /** + * Constructor to use when building a ClipRectAnimation from code + */ + public ClipRectAnimation(int fromL, int fromT, int fromR, int fromB, + int toL, int toT, int toR, int toB) { + mFromRect.set(fromL, fromT, fromR, fromB); + mToRect.set(toL, toT, toR, toB); + } + @Override protected void applyTransformation(float it, Transformation tr) { int l = mFromRect.left + (int) ((mToRect.left - mFromRect.left) * it); diff --git a/core/java/android/view/animation/ClipRectLRAnimation.java b/core/java/android/view/animation/ClipRectLRAnimation.java new file mode 100644 index 0000000..8993cd3 --- /dev/null +++ b/core/java/android/view/animation/ClipRectLRAnimation.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.animation; + +import android.graphics.Rect; + +/** + * Special case of ClipRectAnimation that animates only the left/right + * dimensions of the clip, picking up the other dimensions from whatever is + * set on the transform already. + * + * @hide + */ +public class ClipRectLRAnimation extends ClipRectAnimation { + + /** + * Constructor. Passes in 0 for Top/Bottom parameters of ClipRectAnimation + */ + public ClipRectLRAnimation(int fromL, int fromR, int toL, int toR) { + super(fromL, 0, fromR, 0, toL, 0, toR, 0); + } + + /** + * Calculates and sets clip rect on given transformation. It uses existing values + * on the Transformation for Top/Bottom clip parameters. + */ + @Override + protected void applyTransformation(float it, Transformation tr) { + Rect oldClipRect = tr.getClipRect(); + tr.setClipRect(mFromRect.left + (int) ((mToRect.left - mFromRect.left) * it), + oldClipRect.top, + mFromRect.right + (int) ((mToRect.right - mFromRect.right) * it), + oldClipRect.bottom); + } +} diff --git a/core/java/android/view/animation/ClipRectTBAnimation.java b/core/java/android/view/animation/ClipRectTBAnimation.java new file mode 100644 index 0000000..06f86ce --- /dev/null +++ b/core/java/android/view/animation/ClipRectTBAnimation.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.animation; + +import android.graphics.Rect; + +/** + * Special case of ClipRectAnimation that animates only the top/bottom + * dimensions of the clip, picking up the other dimensions from whatever is + * set on the transform already. + * + * @hide + */ +public class ClipRectTBAnimation extends ClipRectAnimation { + + /** + * Constructor. Passes in 0 for Left/Right parameters of ClipRectAnimation + */ + public ClipRectTBAnimation(int fromT, int fromB, int toT, int toB) { + super(0, fromT, 0, fromB, 0, toT, 0, toB); + } + + /** + * Calculates and sets clip rect on given transformation. It uses existing values + * on the Transformation for Left/Right clip parameters. + */ + @Override + protected void applyTransformation(float it, Transformation tr) { + Rect oldClipRect = tr.getClipRect(); + tr.setClipRect(oldClipRect.left, mFromRect.top + (int) ((mToRect.top - mFromRect.top) * it), + oldClipRect.right, + mFromRect.bottom + (int) ((mToRect.bottom - mFromRect.bottom) * it)); + } + +} diff --git a/core/java/android/view/animation/Transformation.java b/core/java/android/view/animation/Transformation.java index 2f4fe73..30c12ed 100644 --- a/core/java/android/view/animation/Transformation.java +++ b/core/java/android/view/animation/Transformation.java @@ -122,7 +122,13 @@ public class Transformation { mAlpha *= t.getAlpha(); mMatrix.preConcat(t.getMatrix()); if (t.mHasClipRect) { - setClipRect(t.getClipRect()); + Rect bounds = t.getClipRect(); + if (mHasClipRect) { + setClipRect(mClipRect.left + bounds.left, mClipRect.top + bounds.top, + mClipRect.right + bounds.right, mClipRect.bottom + bounds.bottom); + } else { + setClipRect(bounds); + } } } @@ -135,7 +141,13 @@ public class Transformation { mAlpha *= t.getAlpha(); mMatrix.postConcat(t.getMatrix()); if (t.mHasClipRect) { - setClipRect(t.getClipRect()); + Rect bounds = t.getClipRect(); + if (mHasClipRect) { + setClipRect(mClipRect.left + bounds.left, mClipRect.top + bounds.top, + mClipRect.right + bounds.right, mClipRect.bottom + bounds.bottom); + } else { + setClipRect(bounds); + } } } diff --git a/core/java/android/view/animation/TranslateAnimation.java b/core/java/android/view/animation/TranslateAnimation.java index d2ff754..216022b 100644 --- a/core/java/android/view/animation/TranslateAnimation.java +++ b/core/java/android/view/animation/TranslateAnimation.java @@ -24,7 +24,7 @@ import android.util.AttributeSet; * An animation that controls the position of an object. See the * {@link android.view.animation full package} description for details and * sample code. - * + * */ public class TranslateAnimation extends Animation { private int mFromXType = ABSOLUTE; @@ -33,20 +33,28 @@ public class TranslateAnimation extends Animation { private int mFromYType = ABSOLUTE; private int mToYType = ABSOLUTE; - private float mFromXValue = 0.0f; - private float mToXValue = 0.0f; - - private float mFromYValue = 0.0f; - private float mToYValue = 0.0f; - - private float mFromXDelta; - private float mToXDelta; - private float mFromYDelta; - private float mToYDelta; + /** @hide */ + protected float mFromXValue = 0.0f; + /** @hide */ + protected float mToXValue = 0.0f; + + /** @hide */ + protected float mFromYValue = 0.0f; + /** @hide */ + protected float mToYValue = 0.0f; + + /** @hide */ + protected float mFromXDelta; + /** @hide */ + protected float mToXDelta; + /** @hide */ + protected float mFromYDelta; + /** @hide */ + protected float mToYDelta; /** * Constructor used when a TranslateAnimation is loaded from a resource. - * + * * @param context Application context to use * @param attrs Attribute set from which to read values */ @@ -81,7 +89,7 @@ public class TranslateAnimation extends Animation { /** * Constructor to use when building a TranslateAnimation from code - * + * * @param fromXDelta Change in X coordinate to apply at the start of the * animation * @param toXDelta Change in X coordinate to apply at the end of the diff --git a/core/java/android/view/animation/TranslateXAnimation.java b/core/java/android/view/animation/TranslateXAnimation.java new file mode 100644 index 0000000..d75323f --- /dev/null +++ b/core/java/android/view/animation/TranslateXAnimation.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.animation; + +import android.graphics.Matrix; + +/** + * Special case of TranslateAnimation that translates only horizontally, picking up the + * vertical values from whatever is set on the Transformation already. When used in + * conjunction with a TranslateYAnimation, allows independent animation of x and y + * position. + * @hide + */ +public class TranslateXAnimation extends TranslateAnimation { + float[] mTmpValues = new float[9]; + + /** + * Constructor. Passes in 0 for the y parameters of TranslateAnimation + */ + public TranslateXAnimation(float fromXDelta, float toXDelta) { + super(fromXDelta, toXDelta, 0, 0); + } + + /** + * Constructor. Passes in 0 for the y parameters of TranslateAnimation + */ + public TranslateXAnimation(int fromXType, float fromXValue, int toXType, float toXValue) { + super(fromXType, fromXValue, toXType, toXValue, ABSOLUTE, 0, ABSOLUTE, 0); + } + + /** + * Calculates and sets x translation values on given transformation. + */ + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + Matrix m = t.getMatrix(); + m.getValues(mTmpValues); + float dx = mFromXDelta + ((mToXDelta - mFromXDelta) * interpolatedTime); + t.getMatrix().setTranslate(dx, mTmpValues[Matrix.MTRANS_Y]); + } +} diff --git a/core/java/android/view/animation/TranslateYAnimation.java b/core/java/android/view/animation/TranslateYAnimation.java new file mode 100644 index 0000000..714558d --- /dev/null +++ b/core/java/android/view/animation/TranslateYAnimation.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.animation; + +import android.graphics.Matrix; + +/** + * Special case of TranslateAnimation that translates only vertically, picking up the + * horizontal values from whatever is set on the Transformation already. When used in + * conjunction with a TranslateXAnimation, allows independent animation of x and y + * position. + * @hide + */ +public class TranslateYAnimation extends TranslateAnimation { + float[] mTmpValues = new float[9]; + + /** + * Constructor. Passes in 0 for the x parameters of TranslateAnimation + */ + public TranslateYAnimation(float fromYDelta, float toYDelta) { + super(0, 0, fromYDelta, toYDelta); + } + + /** + * Constructor. Passes in 0 for the x parameters of TranslateAnimation + */ + public TranslateYAnimation(int fromYType, float fromYValue, int toYType, float toYValue) { + super(ABSOLUTE, 0, ABSOLUTE, 0, fromYType, fromYValue, toYType, toYValue); + } + + /** + * Calculates and sets y translation values on given transformation. + */ + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + Matrix m = t.getMatrix(); + m.getValues(mTmpValues); + float dy = mFromYDelta + ((mToYDelta - mFromYDelta) * interpolatedTime); + t.getMatrix().setTranslate(mTmpValues[Matrix.MTRANS_X], dy); + } +} diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index b3f47e9..c0d2502 100755 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -712,6 +712,17 @@ final class ActivityRecord { pendingOptions.getCustomExitResId(), pendingOptions.getOnAnimationStartListener()); break; + case ActivityOptions.ANIM_CLIP_REVEAL: + service.mWindowManager.overridePendingAppTransitionClipReveal( + pendingOptions.getStartX(), pendingOptions.getStartY(), + pendingOptions.getWidth(), pendingOptions.getHeight()); + if (intent.getSourceBounds() == null) { + intent.setSourceBounds(new Rect(pendingOptions.getStartX(), + pendingOptions.getStartY(), + pendingOptions.getStartX()+pendingOptions.getWidth(), + pendingOptions.getStartY()+pendingOptions.getHeight())); + } + break; case ActivityOptions.ANIM_SCALE_UP: service.mWindowManager.overridePendingAppTransitionScaleUp( pendingOptions.getStartX(), pendingOptions.getStartY(), diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java index c0d54e1..a569322 100644 --- a/services/core/java/com/android/server/wm/AppTransition.java +++ b/services/core/java/com/android/server/wm/AppTransition.java @@ -17,12 +17,16 @@ package com.android.server.wm; import android.content.Context; +import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.Rect; +import android.graphics.drawable.Drawable; import android.os.Debug; import android.os.Handler; import android.os.IRemoteCallback; +import android.os.UserHandle; +import android.util.Log; import android.util.Slog; import android.view.WindowManager; import android.view.animation.AlphaAnimation; @@ -30,9 +34,14 @@ import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.AnimationUtils; import android.view.animation.ClipRectAnimation; +import android.view.animation.ClipRectLRAnimation; +import android.view.animation.ClipRectTBAnimation; import android.view.animation.Interpolator; +import android.view.animation.LinearInterpolator; import android.view.animation.ScaleAnimation; import android.view.animation.TranslateAnimation; +import android.view.animation.TranslateXAnimation; +import android.view.animation.TranslateYAnimation; import com.android.internal.util.DumpUtils.Dump; import com.android.server.AttributeCache; import com.android.server.wm.WindowManagerService.H; @@ -134,6 +143,7 @@ public class AppTransition implements Dump { private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP = 5; private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN = 6; private static final int NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE = 7; + private static final int NEXT_TRANSIT_TYPE_CLIP_REVEAL = 8; private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE; // These are the possible states for the enter/exit activities during a thumbnail transition @@ -169,19 +179,24 @@ public class AppTransition implements Dump { private final Interpolator mDecelerateInterpolator; private final Interpolator mThumbnailFadeInInterpolator; private final Interpolator mThumbnailFadeOutInterpolator; - private final Interpolator mThumbnailFastOutSlowInInterpolator; + private final Interpolator mLinearOutSlowInInterpolator; + private final Interpolator mFastOutSlowInInterpolator; + private final LinearInterpolator mLinearInterpolator; private int mCurrentUserId = 0; AppTransition(Context context, Handler h) { mContext = context; mH = h; + mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, + com.android.internal.R.interpolator.linear_out_slow_in); + mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, + com.android.internal.R.interpolator.fast_out_slow_in); + mLinearInterpolator = new LinearInterpolator(); mConfigShortAnimTime = context.getResources().getInteger( com.android.internal.R.integer.config_shortAnimTime); mDecelerateInterpolator = AnimationUtils.loadInterpolator(context, com.android.internal.R.interpolator.decelerate_cubic); - mThumbnailFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, - com.android.internal.R.interpolator.fast_out_slow_in); mThumbnailFadeInInterpolator = new Interpolator() { @Override public float getInterpolation(float input) { @@ -447,6 +462,83 @@ public class AppTransition implements Dump { return a; } + private Animation createClipRevealAnimationLocked(int transit, boolean enter, + int appWidth, int appHeight) { + final Animation anim; + if (enter) { + // Reveal will expand and move faster in horizontal direction + + // Start from size of launch icon, expand to full width/height + Animation clipAnimLR = new ClipRectLRAnimation( + (appWidth - mNextAppTransitionStartWidth) / 2, + (appWidth + mNextAppTransitionStartWidth) / 2, 0, appWidth); + clipAnimLR.setInterpolator(mLinearOutSlowInInterpolator); + clipAnimLR.setDuration(DEFAULT_APP_TRANSITION_DURATION); + Animation clipAnimTB = new ClipRectTBAnimation( + (appHeight - mNextAppTransitionStartHeight) / 2, + (appHeight + mNextAppTransitionStartHeight) / 2, 0, appHeight); + clipAnimTB.setInterpolator(mFastOutSlowInInterpolator); + clipAnimTB.setDuration(DEFAULT_APP_TRANSITION_DURATION); + + // Start from middle of launch icon area, move to 0, 0 + int startMiddleX = mNextAppTransitionStartX + + (mNextAppTransitionStartWidth - appWidth) / 2; + int startMiddleY = mNextAppTransitionStartY + + (mNextAppTransitionStartHeight - appHeight) / 2; + + TranslateXAnimation translateX = new TranslateXAnimation( + Animation.ABSOLUTE, startMiddleX, Animation.ABSOLUTE, 0); + translateX.setInterpolator(mLinearOutSlowInInterpolator); + translateX.setDuration(DEFAULT_APP_TRANSITION_DURATION); + TranslateYAnimation translateY = new TranslateYAnimation( + Animation.ABSOLUTE, startMiddleY, Animation.ABSOLUTE, 0); + translateY.setInterpolator(mFastOutSlowInInterpolator); + translateY.setDuration(DEFAULT_APP_TRANSITION_DURATION); + + // Quick fade-in from icon to app window + final int alphaDuration = 100; + AlphaAnimation alpha = new AlphaAnimation(0.1f, 1); + alpha.setDuration(alphaDuration); + alpha.setInterpolator(mLinearInterpolator); + + AnimationSet set = new AnimationSet(false); + set.addAnimation(clipAnimLR); + set.addAnimation(clipAnimTB); + set.addAnimation(translateX); + set.addAnimation(translateY); + set.addAnimation(alpha); + set.initialize(appWidth, appHeight, appWidth, appHeight); + anim = set; + } else { + final long duration; + switch (transit) { + case TRANSIT_ACTIVITY_OPEN: + case TRANSIT_ACTIVITY_CLOSE: + duration = mConfigShortAnimTime; + break; + default: + duration = DEFAULT_APP_TRANSITION_DURATION; + break; + } + if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || + transit == TRANSIT_WALLPAPER_INTRA_CLOSE) { + // If we are on top of the wallpaper, we need an animation that + // correctly handles the wallpaper staying static behind all of + // the animated elements. To do this, will just have the existing + // element fade out. + anim = new AlphaAnimation(1, 0); + anim.setDetachWallpaper(true); + } else { + // For normal animations, the exiting element just holds in place. + anim = new AlphaAnimation(1, 1); + } + anim.setInterpolator(mDecelerateInterpolator); + anim.setDuration(duration); + anim.setFillAfter(true); + } + return anim; + } + /** * Prepares the specified animation with a standard duration, interpolator, etc. */ @@ -522,14 +614,14 @@ public class AppTransition implements Dump { Animation scale = new ScaleAnimation(1f, scaleW, 1f, scaleW, mNextAppTransitionStartX + (thumbWidth / 2f), mNextAppTransitionStartY + (thumbHeight / 2f)); - scale.setInterpolator(mThumbnailFastOutSlowInInterpolator); + scale.setInterpolator(mFastOutSlowInInterpolator); scale.setDuration(THUMBNAIL_APP_TRANSITION_DURATION); Animation alpha = new AlphaAnimation(1, 0); alpha.setInterpolator(mThumbnailFadeOutInterpolator); alpha.setDuration(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION); Animation translate = new TranslateAnimation(0, 0, 0, -unscaledStartY + mNextAppTransitionInsets.top); - translate.setInterpolator(mThumbnailFastOutSlowInInterpolator); + translate.setInterpolator(mFastOutSlowInInterpolator); translate.setDuration(THUMBNAIL_APP_TRANSITION_DURATION); // This AnimationSet uses the Interpolators assigned above. @@ -543,14 +635,14 @@ public class AppTransition implements Dump { Animation scale = new ScaleAnimation(scaleW, 1f, scaleW, 1f, mNextAppTransitionStartX + (thumbWidth / 2f), mNextAppTransitionStartY + (thumbHeight / 2f)); - scale.setInterpolator(mThumbnailFastOutSlowInInterpolator); + scale.setInterpolator(mFastOutSlowInInterpolator); scale.setDuration(THUMBNAIL_APP_TRANSITION_DURATION); Animation alpha = new AlphaAnimation(0f, 1f); alpha.setInterpolator(mThumbnailFadeInInterpolator); alpha.setDuration(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION); Animation translate = new TranslateAnimation(0, 0, -unscaledStartY + mNextAppTransitionInsets.top, 0); - translate.setInterpolator(mThumbnailFastOutSlowInInterpolator); + translate.setInterpolator(mFastOutSlowInInterpolator); translate.setDuration(THUMBNAIL_APP_TRANSITION_DURATION); // This AnimationSet uses the Interpolators assigned above. @@ -562,7 +654,7 @@ public class AppTransition implements Dump { } return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, 0, - mThumbnailFastOutSlowInInterpolator); + mFastOutSlowInInterpolator); } /** @@ -698,7 +790,7 @@ public class AppTransition implements Dump { int duration = Math.max(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION, THUMBNAIL_APP_TRANSITION_DURATION); return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration, - mThumbnailFastOutSlowInInterpolator); + mFastOutSlowInInterpolator); } /** @@ -845,6 +937,12 @@ public class AppTransition implements Dump { "applyAnimation:" + " anim=" + a + " nextAppTransition=ANIM_CUSTOM_IN_PLACE" + " transit=" + transit + " Callers=" + Debug.getCallers(3)); + } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL) { + a = createClipRevealAnimationLocked(transit, enter, appWidth, appHeight); + if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, + "applyAnimation:" + + " anim=" + a + " nextAppTransition=ANIM_CLIP_REVEAL" + + " Callers=" + Debug.getCallers(3)); } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) { a = createScaleUpAnimationLocked(transit, enter, appWidth, appHeight); if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, @@ -987,6 +1085,19 @@ public class AppTransition implements Dump { } } + void overridePendingAppTransitionClipReveal(int startX, int startY, + int startWidth, int startHeight) { + if (isTransitionSet()) { + mNextAppTransitionType = NEXT_TRANSIT_TYPE_CLIP_REVEAL; + mNextAppTransitionStartX = startX; + mNextAppTransitionStartY = startY; + mNextAppTransitionStartWidth = startWidth; + mNextAppTransitionStartHeight = startHeight; + postAnimationCallback(); + mNextAppTransitionCallback = null; + } + } + void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY, IRemoteCallback startedCallback, boolean scaleUp) { if (isTransitionSet()) { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 02a4f4d..9461faa 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -4062,6 +4062,15 @@ public class WindowManagerService extends IWindowManager.Stub } @Override + public void overridePendingAppTransitionClipReveal(int startX, int startY, + int startWidth, int startHeight) { + synchronized(mWindowMap) { + mAppTransition.overridePendingAppTransitionClipReveal(startX, startY, startWidth, + startHeight); + } + } + + @Override public void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY, IRemoteCallback startedCallback, boolean scaleUp) { synchronized(mWindowMap) { diff --git a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java index d90271b..32305a0 100644 --- a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java +++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java @@ -215,6 +215,12 @@ public class IWindowManagerImpl implements IWindowManager { } @Override + public void overridePendingAppTransitionClipReveal(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, boolean scaleUp) throws RemoteException { // TODO Auto-generated method stub |