Skip to content

Commit d367ca8

Browse files
author
Dianne Hackborn
committed
Tweak anim API to automatically call Intent.setSourceBounds().
Also don't retain the source bounds in recent tasks, since it has no meaning there and it would be better when relaunching an activity to have a new bounds set based on wherever it is now being launched from. Change-Id: Ia90c04ee98a888a7f725b038abe23d71e2b12800
1 parent ff0e8cd commit d367ca8

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

core/java/android/app/ActivityOptions.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,17 @@ public interface OnAnimationStartedListener {
147147
* activity is scaled from a small originating area of the screen to
148148
* its final full representation.
149149
*
150+
* <p>If the Intent this is being used with has not set its
151+
* {@link android.content.Intent#setSourceBounds Intent.setSourceBounds},
152+
* those bounds will be filled in for you based on the initial
153+
* bounds passed in here.
154+
*
150155
* @param source The View that the new activity is animating from. This
151156
* defines the coordinate space for <var>startX</var> and <var>startY</var>.
152157
* @param startX The x starting location of the new activity, relative to <var>source</var>.
153158
* @param startY The y starting location of the activity, relative to <var>source</var>.
154159
* @param startWidth The initial width of the new activity.
155-
* @param startWidth The initial height of the new activity.
160+
* @param startHeight The initial height of the new activity.
156161
* @return Returns a new ActivityOptions object that you can use to
157162
* supply these options as the options Bundle when starting an activity.
158163
*/
@@ -175,6 +180,11 @@ public static ActivityOptions makeScaleUpAnimation(View source,
175180
* is scaled from a given position to the new activity window that is
176181
* being started.
177182
*
183+
* <p>If the Intent this is being used with has not set its
184+
* {@link android.content.Intent#setSourceBounds Intent.setSourceBounds},
185+
* those bounds will be filled in for you based on the initial
186+
* thumbnail location and size provided here.
187+
*
178188
* @param source The View that this thumbnail is animating from. This
179189
* defines the coordinate space for <var>startX</var> and <var>startY</var>.
180190
* @param thumbnail The bitmap that will be shown as the initial thumbnail

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import android.content.res.CompatibilityInfo;
3030
import android.content.res.Configuration;
3131
import android.graphics.Bitmap;
32+
import android.graphics.Rect;
3233
import android.os.Build;
3334
import android.os.Bundle;
3435
import android.os.IBinder;
@@ -562,12 +563,26 @@ void applyOptionsLocked() {
562563
service.mWindowManager.overridePendingAppTransitionScaleUp(
563564
pendingOptions.getStartX(), pendingOptions.getStartY(),
564565
pendingOptions.getStartWidth(), pendingOptions.getStartHeight());
566+
if (intent.getSourceBounds() == null) {
567+
intent.setSourceBounds(new Rect(pendingOptions.getStartX(),
568+
pendingOptions.getStartY(),
569+
pendingOptions.getStartX()+pendingOptions.getStartWidth(),
570+
pendingOptions.getStartY()+pendingOptions.getStartHeight()));
571+
}
565572
break;
566573
case ActivityOptions.ANIM_THUMBNAIL:
567574
service.mWindowManager.overridePendingAppTransitionThumb(
568575
pendingOptions.getThumbnail(),
569576
pendingOptions.getStartX(), pendingOptions.getStartY(),
570577
pendingOptions.getOnAnimationStartListener());
578+
if (intent.getSourceBounds() == null) {
579+
intent.setSourceBounds(new Rect(pendingOptions.getStartX(),
580+
pendingOptions.getStartY(),
581+
pendingOptions.getStartX()
582+
+ pendingOptions.getThumbnail().getWidth(),
583+
pendingOptions.getStartY()
584+
+ pendingOptions.getThumbnail().getHeight()));
585+
}
571586
break;
572587
}
573588
pendingOptions = null;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ void setIntent(Intent _intent, ActivityInfo info) {
6363
// If this Intent has a selector, we want to clear it for the
6464
// recent task since it is not relevant if the user later wants
6565
// to re-launch the app.
66-
if (_intent.getSelector() != null) {
66+
if (_intent.getSelector() != null || _intent.getSourceBounds() != null) {
6767
_intent = new Intent(_intent);
6868
_intent.setSelector(null);
69+
_intent.setSourceBounds(null);
6970
}
7071
}
7172
intent = _intent;
@@ -78,6 +79,7 @@ void setIntent(Intent _intent, ActivityInfo info) {
7879
Intent targetIntent = new Intent(_intent);
7980
targetIntent.setComponent(targetComponent);
8081
targetIntent.setSelector(null);
82+
targetIntent.setSourceBounds(null);
8183
intent = targetIntent;
8284
realActivity = targetComponent;
8385
origActivity = _intent.getComponent();

0 commit comments

Comments
 (0)