Skip to content

Commit d2ae85d

Browse files
mikejurkaAndroid (Google) Code Review
authored andcommitted
Merge "Adding a thumbnail scale down animation" into jb-mr1-dev
2 parents aeca689 + 832cb22 commit d2ae85d

File tree

6 files changed

+118
-81
lines changed

6 files changed

+118
-81
lines changed

core/java/android/app/ActivityOptions.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ public class ActivityOptions {
9797
/** @hide */
9898
public static final int ANIM_SCALE_UP = 2;
9999
/** @hide */
100-
public static final int ANIM_THUMBNAIL = 3;
100+
public static final int ANIM_THUMBNAIL_SCALE_UP = 3;
101101
/** @hide */
102-
public static final int ANIM_THUMBNAIL_DELAYED = 4;
102+
public static final int ANIM_THUMBNAIL_SCALE_DOWN = 4;
103103

104104
private String mPackageName;
105105
private int mAnimationType = ANIM_NONE;
@@ -262,38 +262,37 @@ public static ActivityOptions makeThumbnailScaleUpAnimation(View source,
262262
*/
263263
public static ActivityOptions makeThumbnailScaleUpAnimation(View source,
264264
Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) {
265-
return makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY, listener, false);
265+
return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, true);
266266
}
267267

268268
/**
269-
* Create an ActivityOptions specifying an animation where a thumbnail
270-
* is scaled from a given position to the new activity window that is
271-
* being started. Before the animation, there is a short delay.
269+
* Create an ActivityOptions specifying an animation where an activity window
270+
* is scaled from a given position to a thumbnail at a specified location.
272271
*
273-
* @param source The View that this thumbnail is animating from. This
272+
* @param source The View that this thumbnail is animating to. This
274273
* defines the coordinate space for <var>startX</var> and <var>startY</var>.
275-
* @param thumbnail The bitmap that will be shown as the initial thumbnail
274+
* @param thumbnail The bitmap that will be shown as the final thumbnail
276275
* of the animation.
277-
* @param startX The x starting location of the bitmap, relative to <var>source</var>.
278-
* @param startY The y starting location of the bitmap, relative to <var>source</var>.
276+
* @param startX The x end location of the bitmap, relative to <var>source</var>.
277+
* @param startY The y end location of the bitmap, relative to <var>source</var>.
279278
* @param listener Optional OnAnimationStartedListener to find out when the
280279
* requested animation has started running. If for some reason the animation
281280
* is not executed, the callback will happen immediately.
282281
* @return Returns a new ActivityOptions object that you can use to
283282
* supply these options as the options Bundle when starting an activity.
284283
* @hide
285284
*/
286-
public static ActivityOptions makeDelayedThumbnailScaleUpAnimation(View source,
285+
public static ActivityOptions makeThumbnailScaleDownAnimation(View source,
287286
Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) {
288-
return makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY, listener, true);
287+
return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, false);
289288
}
290289

291-
private static ActivityOptions makeThumbnailScaleUpAnimation(View source,
290+
private static ActivityOptions makeThumbnailAnimation(View source,
292291
Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener,
293-
boolean delayed) {
292+
boolean scaleUp) {
294293
ActivityOptions opts = new ActivityOptions();
295294
opts.mPackageName = source.getContext().getPackageName();
296-
opts.mAnimationType = delayed ? ANIM_THUMBNAIL_DELAYED : ANIM_THUMBNAIL;
295+
opts.mAnimationType = scaleUp ? ANIM_THUMBNAIL_SCALE_UP : ANIM_THUMBNAIL_SCALE_DOWN;
297296
opts.mThumbnail = thumbnail;
298297
int[] pts = new int[2];
299298
source.getLocationOnScreen(pts);
@@ -320,8 +319,8 @@ public ActivityOptions(Bundle opts) {
320319
mStartY = opts.getInt(KEY_ANIM_START_Y, 0);
321320
mStartWidth = opts.getInt(KEY_ANIM_START_WIDTH, 0);
322321
mStartHeight = opts.getInt(KEY_ANIM_START_HEIGHT, 0);
323-
} else if (mAnimationType == ANIM_THUMBNAIL ||
324-
mAnimationType == ANIM_THUMBNAIL_DELAYED) {
322+
} else if (mAnimationType == ANIM_THUMBNAIL_SCALE_UP ||
323+
mAnimationType == ANIM_THUMBNAIL_SCALE_DOWN) {
325324
mThumbnail = (Bitmap)opts.getParcelable(KEY_ANIM_THUMBNAIL);
326325
mStartX = opts.getInt(KEY_ANIM_START_X, 0);
327326
mStartY = opts.getInt(KEY_ANIM_START_Y, 0);
@@ -434,8 +433,8 @@ public void update(ActivityOptions otherOptions) {
434433
}
435434
mAnimationStartedListener = null;
436435
break;
437-
case ANIM_THUMBNAIL:
438-
case ANIM_THUMBNAIL_DELAYED:
436+
case ANIM_THUMBNAIL_SCALE_UP:
437+
case ANIM_THUMBNAIL_SCALE_DOWN:
439438
mAnimationType = otherOptions.mAnimationType;
440439
mThumbnail = otherOptions.mThumbnail;
441440
mStartX = otherOptions.mStartX;
@@ -479,8 +478,8 @@ public Bundle toBundle() {
479478
b.putInt(KEY_ANIM_START_WIDTH, mStartWidth);
480479
b.putInt(KEY_ANIM_START_HEIGHT, mStartHeight);
481480
break;
482-
case ANIM_THUMBNAIL:
483-
case ANIM_THUMBNAIL_DELAYED:
481+
case ANIM_THUMBNAIL_SCALE_UP:
482+
case ANIM_THUMBNAIL_SCALE_DOWN:
484483
b.putInt(KEY_ANIM_TYPE, mAnimationType);
485484
b.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail);
486485
b.putInt(KEY_ANIM_START_X, mStartX);

core/java/android/view/IWindowManager.aidl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ interface IWindowManager
8484
void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
8585
int startHeight);
8686
void overridePendingAppTransitionThumb(in Bitmap srcThumb, int startX, int startY,
87-
IRemoteCallback startedCallback, boolean delayed);
87+
IRemoteCallback startedCallback, boolean scaleUp);
8888
void executeAppTransition();
8989
void setAppStartingWindow(IBinder token, String pkg, int theme,
9090
in CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes,

packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ public void handleOnClick(View view) {
767767
show(false, true);
768768

769769
mThumbnailScaleUpStarted = false;
770-
ActivityOptions opts = ActivityOptions.makeDelayedThumbnailScaleUpAnimation(
770+
ActivityOptions opts = ActivityOptions.makeThumbnailScaleUpAnimation(
771771
holder.thumbnailViewImage, bm, 0, 0,
772772
new ActivityOptions.OnAnimationStartedListener() {
773773
@Override public void onAnimationStarted() {

services/java/com/android/server/am/ActivityRecord.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,14 @@ void applyOptionsLocked() {
614614
pendingOptions.getStartY()+pendingOptions.getStartHeight()));
615615
}
616616
break;
617-
case ActivityOptions.ANIM_THUMBNAIL:
618-
case ActivityOptions.ANIM_THUMBNAIL_DELAYED:
619-
boolean delayed = (animationType == ActivityOptions.ANIM_THUMBNAIL_DELAYED);
617+
case ActivityOptions.ANIM_THUMBNAIL_SCALE_UP:
618+
case ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN:
619+
boolean scaleUp = (animationType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP);
620620
service.mWindowManager.overridePendingAppTransitionThumb(
621621
pendingOptions.getThumbnail(),
622622
pendingOptions.getStartX(), pendingOptions.getStartY(),
623623
pendingOptions.getOnAnimationStartListener(),
624-
delayed);
624+
scaleUp);
625625
if (intent.getSourceBounds() == null) {
626626
intent.setSourceBounds(new Rect(pendingOptions.getStartX(),
627627
pendingOptions.getStartY(),

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 91 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ public void onReceive(Context context, Intent intent) {
512512
int mNextAppTransitionType = ActivityOptions.ANIM_NONE;
513513
String mNextAppTransitionPackage;
514514
Bitmap mNextAppTransitionThumbnail;
515-
boolean mNextAppTransitionDelayed;
515+
// Used for thumbnail transitions. True if we're scaling up, false if scaling down
516+
boolean mNextAppTransitionScaleUp;
516517
IRemoteCallback mNextAppTransitionCallback;
517518
int mNextAppTransitionEnter;
518519
int mNextAppTransitionExit;
@@ -3224,7 +3225,7 @@ private Animation createScaleUpAnimationLocked(int transit, boolean enter) {
32243225
}
32253226

32263227
private Animation createThumbnailAnimationLocked(int transit,
3227-
boolean enter, boolean thumb, boolean delayed) {
3228+
boolean enter, boolean thumb, boolean scaleUp) {
32283229
Animation a;
32293230
final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
32303231
final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1;
@@ -3234,64 +3235,101 @@ private Animation createThumbnailAnimationLocked(int transit,
32343235
// it is the standard duration for that. Otherwise we use the longer
32353236
// task transition duration.
32363237
int duration;
3237-
int delayDuration = delayed ? 270 : 0;
32383238
switch (transit) {
32393239
case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
32403240
case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
32413241
duration = mContext.getResources().getInteger(
32423242
com.android.internal.R.integer.config_shortAnimTime);
32433243
break;
32443244
default:
3245-
duration = delayed ? 250 : 300;
3245+
duration = 250;
32463246
break;
32473247
}
32483248
// TOOD(multidisplay): For now assume all app animation is on the main screen.
32493249
DisplayInfo displayInfo = getDefaultDisplayInfo();
32503250
if (thumb) {
32513251
// Animation for zooming thumbnail from its initial size to
32523252
// filling the screen.
3253-
float scaleW = displayInfo.appWidth/thumbWidth;
3254-
float scaleH = displayInfo.appHeight/thumbHeight;
3255-
3256-
Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
3257-
computePivot(mNextAppTransitionStartX, 1/scaleW),
3258-
computePivot(mNextAppTransitionStartY, 1/scaleH));
3259-
AnimationSet set = new AnimationSet(true);
3260-
Animation alpha = new AlphaAnimation(1, 0);
3261-
scale.setDuration(duration);
3262-
scale.setInterpolator(
3263-
new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
3264-
set.addAnimation(scale);
3265-
alpha.setDuration(duration);
3266-
set.addAnimation(alpha);
3267-
set.setFillBefore(true);
3268-
if (delayDuration > 0) {
3269-
set.setStartOffset(delayDuration);
3253+
if (scaleUp) {
3254+
float scaleW = displayInfo.appWidth / thumbWidth;
3255+
float scaleH = displayInfo.appHeight / thumbHeight;
3256+
3257+
Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
3258+
computePivot(mNextAppTransitionStartX, 1 / scaleW),
3259+
computePivot(mNextAppTransitionStartY, 1 / scaleH));
3260+
AnimationSet set = new AnimationSet(true);
3261+
Animation alpha = new AlphaAnimation(1, 0);
3262+
scale.setDuration(duration);
3263+
scale.setInterpolator(
3264+
new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
3265+
set.addAnimation(scale);
3266+
alpha.setDuration(duration);
3267+
set.addAnimation(alpha);
3268+
set.setFillBefore(true);
3269+
a = set;
3270+
} else {
3271+
float scaleW = displayInfo.appWidth / thumbWidth;
3272+
float scaleH = displayInfo.appHeight / thumbHeight;
3273+
3274+
Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1,
3275+
computePivot(mNextAppTransitionStartX, 1 / scaleW),
3276+
computePivot(mNextAppTransitionStartY, 1 / scaleH));
3277+
AnimationSet set = new AnimationSet(true);
3278+
Animation alpha = new AlphaAnimation(1, 1);
3279+
scale.setDuration(duration);
3280+
scale.setInterpolator(
3281+
new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
3282+
set.addAnimation(scale);
3283+
alpha.setDuration(duration);
3284+
set.addAnimation(alpha);
3285+
set.setFillBefore(true);
3286+
3287+
a = set;
32703288
}
3271-
a = set;
32723289
} else if (enter) {
32733290
// Entering app zooms out from the center of the thumbnail.
3274-
float scaleW = thumbWidth / displayInfo.appWidth;
3275-
float scaleH = thumbHeight / displayInfo.appHeight;
3276-
Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1,
3277-
computePivot(mNextAppTransitionStartX, scaleW),
3278-
computePivot(mNextAppTransitionStartY, scaleH));
3279-
scale.setDuration(duration);
3280-
scale.setInterpolator(
3281-
new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
3282-
scale.setFillBefore(true);
3283-
if (delayDuration > 0) {
3284-
scale.setStartOffset(delayDuration);
3291+
if (scaleUp) {
3292+
float scaleW = thumbWidth / displayInfo.appWidth;
3293+
float scaleH = thumbHeight / displayInfo.appHeight;
3294+
Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1,
3295+
computePivot(mNextAppTransitionStartX, scaleW),
3296+
computePivot(mNextAppTransitionStartY, scaleH));
3297+
scale.setDuration(duration);
3298+
scale.setInterpolator(
3299+
new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
3300+
scale.setFillBefore(true);
3301+
a = scale;
3302+
} else {
3303+
// noop animation
3304+
a = new AlphaAnimation(1, 1);
3305+
a.setDuration(duration);
32853306
}
3286-
a = scale;
32873307
} else {
3288-
if (delayed) {
3289-
a = new AlphaAnimation(1, 0);
3290-
a.setStartOffset(0);
3291-
a.setDuration(delayDuration - 120);
3292-
a.setBackgroundColor(0xFF000000);
3308+
// Exiting app
3309+
if (scaleUp) {
3310+
// noop animation
3311+
a = new AlphaAnimation(1, 1);
3312+
a.setDuration(duration);
32933313
} else {
3294-
a = createExitAnimationLocked(transit, duration);
3314+
float scaleW = thumbWidth / displayInfo.appWidth;
3315+
float scaleH = thumbHeight / displayInfo.appHeight;
3316+
Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH,
3317+
computePivot(mNextAppTransitionStartX, scaleW),
3318+
computePivot(mNextAppTransitionStartY, scaleH));
3319+
scale.setDuration(duration);
3320+
scale.setInterpolator(
3321+
new DecelerateInterpolator(THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
3322+
scale.setFillBefore(true);
3323+
AnimationSet set = new AnimationSet(true);
3324+
Animation alpha = new AlphaAnimation(1, 0);
3325+
set.addAnimation(scale);
3326+
alpha.setDuration(duration);
3327+
alpha.setInterpolator(new DecelerateInterpolator(
3328+
THUMBNAIL_ANIMATION_DECELERATE_FACTOR));
3329+
set.addAnimation(alpha);
3330+
set.setFillBefore(true);
3331+
set.setZAdjustment(Animation.ZORDER_TOP);
3332+
a = set;
32953333
}
32963334
}
32973335
a.setFillAfter(true);
@@ -3326,14 +3364,14 @@ private boolean applyAnimationLocked(AppWindowToken wtoken,
33263364
"applyAnimation: wtoken=" + wtoken
33273365
+ " anim=" + a + " nextAppTransition=ANIM_SCALE_UP"
33283366
+ " transit=" + transit + " Callers " + Debug.getCallers(3));
3329-
} else if (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL ||
3330-
mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_DELAYED) {
3331-
boolean delayed = (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_DELAYED);
3332-
a = createThumbnailAnimationLocked(transit, enter, false, delayed);
3367+
} else if (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP ||
3368+
mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN) {
3369+
boolean scaleUp = (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP);
3370+
a = createThumbnailAnimationLocked(transit, enter, false, scaleUp);
33333371
initialized = true;
33343372

33353373
if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
3336-
String animName = delayed ? "ANIM_THUMBNAIL_DELAYED" : "ANIM_THUMBNAIL";
3374+
String animName = scaleUp ? "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN";
33373375
Slog.v(TAG, "applyAnimation: wtoken=" + wtoken
33383376
+ " anim=" + a + " nextAppTransition=" + animName
33393377
+ " transit=" + transit + " Callers " + Debug.getCallers(3));
@@ -4008,14 +4046,14 @@ public void overridePendingAppTransitionScaleUp(int startX, int startY, int star
40084046
}
40094047

40104048
public void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX,
4011-
int startY, IRemoteCallback startedCallback, boolean delayed) {
4049+
int startY, IRemoteCallback startedCallback, boolean scaleUp) {
40124050
synchronized(mWindowMap) {
40134051
if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
4014-
mNextAppTransitionType = delayed
4015-
? ActivityOptions.ANIM_THUMBNAIL_DELAYED : ActivityOptions.ANIM_THUMBNAIL;
4052+
mNextAppTransitionType = scaleUp
4053+
? ActivityOptions.ANIM_THUMBNAIL_SCALE_UP : ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN;
40164054
mNextAppTransitionPackage = null;
40174055
mNextAppTransitionThumbnail = srcThumb;
4018-
mNextAppTransitionDelayed = delayed;
4056+
mNextAppTransitionScaleUp = scaleUp;
40194057
mNextAppTransitionStartX = startX;
40204058
mNextAppTransitionStartY = startY;
40214059
scheduleAnimationCallback(mNextAppTransitionCallback);
@@ -8392,7 +8430,7 @@ public int handleAppTransitionReadyLocked(WindowList windows) {
83928430
drawSurface.release();
83938431
topOpeningApp.mAppAnimator.thumbnailLayer = topOpeningLayer;
83948432
Animation anim = createThumbnailAnimationLocked(
8395-
transit, true, true, mNextAppTransitionDelayed);
8433+
transit, true, true, mNextAppTransitionScaleUp);
83968434
topOpeningApp.mAppAnimator.thumbnailAnimation = anim;
83978435
anim.restrictDuration(MAX_ANIMATION_DURATION);
83988436
anim.scaleCurrentDuration(mTransitionAnimationScale);
@@ -10163,15 +10201,15 @@ void dumpWindowsNoHeaderLocked(PrintWriter pw, boolean dumpAll,
1016310201
pw.print(" mNextAppTransitionStartHeight=");
1016410202
pw.println(mNextAppTransitionStartHeight);
1016510203
break;
10166-
case ActivityOptions.ANIM_THUMBNAIL:
10167-
case ActivityOptions.ANIM_THUMBNAIL_DELAYED:
10204+
case ActivityOptions.ANIM_THUMBNAIL_SCALE_UP:
10205+
case ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN:
1016810206
pw.print(" mNextAppTransitionThumbnail=");
1016910207
pw.print(mNextAppTransitionThumbnail);
1017010208
pw.print(" mNextAppTransitionStartX=");
1017110209
pw.print(mNextAppTransitionStartX);
1017210210
pw.print(" mNextAppTransitionStartY=");
1017310211
pw.println(mNextAppTransitionStartY);
10174-
pw.print(" mNextAppTransitionDelayed="); pw.println(mNextAppTransitionDelayed);
10212+
pw.print(" mNextAppTransitionScaleUp="); pw.println(mNextAppTransitionScaleUp);
1017510213
break;
1017610214
}
1017710215
if (mNextAppTransitionCallback != null) {

0 commit comments

Comments
 (0)