Merge "Fixing the alternate recents transition on landscape views."
diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java
index 7d8b5af..f17b2f4 100644
--- a/services/core/java/com/android/server/wm/AppTransition.java
+++ b/services/core/java/com/android/server/wm/AppTransition.java
@@ -17,6 +17,7 @@
package com.android.server.wm;
import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
@@ -147,6 +148,9 @@
private int mNextAppTransitionStartWidth;
private int mNextAppTransitionStartHeight;
+ private Rect mTmpFromClipRect = new Rect();
+ private Rect mTmpToClipRect = new Rect();
+
private final static int APP_STATE_IDLE = 0;
private final static int APP_STATE_READY = 1;
private final static int APP_STATE_RUNNING = 2;
@@ -485,7 +489,7 @@
* activity that is leaving, and the activity that is entering.
*/
Animation createAlternateThumbnailEnterExitAnimationLocked(int thumbTransitState, int appWidth,
- int appHeight, int transit,
+ int appHeight, int orientation, int transit,
Rect containingFrame, Rect contentInsets) {
Animation a;
final int thumbWidthI = mNextAppTransitionThumbnail.getWidth();
@@ -493,21 +497,36 @@
final int thumbHeightI = mNextAppTransitionThumbnail.getHeight();
final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1;
+ // Used for the ENTER_SCALE_UP and EXIT_SCALE_DOWN transitions
+ float scale = 1f;
+ int scaledTopDecor = 0;
+
switch (thumbTransitState) {
case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: {
// Entering app scales up with the thumbnail
- float scale = thumbWidth / appWidth;
- int unscaledThumbHeight = (int) (thumbHeight / scale);
- int scaledTopDecor = (int) (scale * contentInsets.top);
- Rect fromClipRect = new Rect(containingFrame);
- fromClipRect.bottom = (fromClipRect.top + unscaledThumbHeight);
- Rect toClipRect = new Rect(containingFrame);
+ if (orientation == Configuration.ORIENTATION_PORTRAIT) {
+ // In portrait, we scale the width and clip to the top/left square
+ scale = thumbWidth / appWidth;
+ scaledTopDecor = (int) (scale * contentInsets.top);
+ int unscaledThumbHeight = (int) (thumbHeight / scale);
+ mTmpFromClipRect.set(containingFrame);
+ mTmpFromClipRect.bottom = (mTmpFromClipRect.top + unscaledThumbHeight);
+ mTmpToClipRect.set(containingFrame);
+ } else {
+ // In landscape, we scale the height and clip to the top/left square
+ scale = thumbHeight / (appHeight - contentInsets.top);
+ scaledTopDecor = (int) (scale * contentInsets.top);
+ int unscaledThumbWidth = (int) (thumbWidth / scale);
+ mTmpFromClipRect.set(containingFrame);
+ mTmpFromClipRect.right = (mTmpFromClipRect.left + unscaledThumbWidth);
+ mTmpToClipRect.set(containingFrame);
+ }
Animation scaleAnim = new ScaleAnimation(scale, 1, scale, 1,
computePivot(mNextAppTransitionStartX, scale),
computePivot(mNextAppTransitionStartY, scale));
Animation alphaAnim = new AlphaAnimation(1, 1);
- Animation clipAnim = new ClipRectAnimation(fromClipRect, toClipRect);
+ Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
Animation translateAnim = new TranslateAnimation(0, 0, -scaledTopDecor, 0);
AnimationSet set = new AnimationSet(true);
@@ -539,18 +558,29 @@
}
case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: {
// Exiting the current app, the app should scale down with the thumbnail
- float scale = thumbWidth / appWidth;
- int unscaledThumbHeight = (int) (thumbHeight / scale);
- int scaledTopDecor = (int) (scale * contentInsets.top);
- Rect fromClipRect = new Rect(containingFrame);
- Rect toClipRect = new Rect(containingFrame);
- toClipRect.bottom = (toClipRect.top + unscaledThumbHeight);
+ if (orientation == Configuration.ORIENTATION_PORTRAIT) {
+ // In portrait, we scale the width and clip to the top/left square
+ scale = thumbWidth / appWidth;
+ scaledTopDecor = (int) (scale * contentInsets.top);
+ int unscaledThumbHeight = (int) (thumbHeight / scale);
+ mTmpFromClipRect.set(containingFrame);
+ mTmpToClipRect.set(containingFrame);
+ mTmpToClipRect.bottom = (mTmpToClipRect.top + unscaledThumbHeight);
+ } else {
+ // In landscape, we scale the height and clip to the top/left square
+ scale = thumbHeight / (appHeight - contentInsets.top);
+ scaledTopDecor = (int) (scale * contentInsets.top);
+ int unscaledThumbWidth = (int) (thumbWidth / scale);
+ mTmpFromClipRect.set(containingFrame);
+ mTmpToClipRect.set(containingFrame);
+ mTmpToClipRect.right = (mTmpToClipRect.left + unscaledThumbWidth);
+ }
Animation scaleAnim = new ScaleAnimation(1, scale, 1, scale,
computePivot(mNextAppTransitionStartX, scale),
computePivot(mNextAppTransitionStartY, scale));
Animation alphaAnim = new AlphaAnimation(1, 1);
- Animation clipAnim = new ClipRectAnimation(fromClipRect, toClipRect);
+ Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect);
Animation translateAnim = new TranslateAnimation(0, 0, 0, -scaledTopDecor);
AnimationSet set = new AnimationSet(true);
@@ -637,7 +667,8 @@
Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter,
- int appWidth, int appHeight, Rect containingFrame, Rect contentInsets) {
+ int appWidth, int appHeight, int orientation,
+ Rect containingFrame, Rect contentInsets) {
Animation a;
if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) {
a = loadAnimation(mNextAppTransitionPackage, enter ?
@@ -660,8 +691,8 @@
(mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP);
if (mUseAlternateThumbnailAnimation) {
a = createAlternateThumbnailEnterExitAnimationLocked(
- getThumbnailTransitionState(enter), appWidth, appHeight, transit,
- containingFrame, contentInsets);
+ getThumbnailTransitionState(enter), appWidth, appHeight, orientation,
+ transit, containingFrame, contentInsets);
} else {
a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter),
appWidth, appHeight, transit);
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index ad256c8..524d78b 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -3192,7 +3192,7 @@
}
Animation a = mAppTransition.loadAnimation(lp, transit, enter, width, height,
- containingFrame, contentInsets);
+ mCurConfiguration.orientation, containingFrame, contentInsets);
if (a != null) {
if (DEBUG_ANIM) {
RuntimeException e = null;