From 3477804c7297bbdc33943bbfa2be4712ec840a58 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 11 Apr 2018 16:31:31 -0700 Subject: [PATCH] Using correct window bounds in multi-window for fallback activity Also fixing a bug where insets were not updated when recreating deviceprofile Bug: 77875376 Change-Id: I7806cf949da415ef171ccf2f4ab3e8f2b7606220 --- .../quickstep/ActivityControlHelper.java | 27 +++++++++++++++++++ .../android/quickstep/RecentsActivity.java | 4 +-- .../WindowTransformSwipeHandler.java | 14 ++++++---- .../quickstep/fallback/RecentsRootView.java | 1 + .../android/launcher3/LauncherRootView.java | 1 + 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java index f44def2d25..0ea729f280 100644 --- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java +++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java @@ -46,6 +46,7 @@ import com.android.quickstep.util.RemoteAnimationProvider; import com.android.quickstep.views.LauncherLayoutListener; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; +import com.android.systemui.shared.system.RemoteAnimationTargetCompat; import java.util.function.BiPredicate; @@ -92,6 +93,10 @@ public interface ActivityControlHelper { @UiThread boolean switchToRecentsIfVisible(); + Rect getOverviewWindowBounds(Rect homeBounds, RemoteAnimationTargetCompat target); + + boolean shouldMinimizeSplitScreen(); + /** * @return {@code true} if recents activity should be started immediately on touchDown, * {@code false} if it should deferred until some threshold is crossed. @@ -260,6 +265,16 @@ public interface ActivityControlHelper { public boolean deferStartingActivity(int downHitTarget) { return downHitTarget == HIT_TARGET_BACK; } + + @Override + public Rect getOverviewWindowBounds(Rect homeBounds, RemoteAnimationTargetCompat target) { + return homeBounds; + } + + @Override + public boolean shouldMinimizeSplitScreen() { + return true; + } } class FallbackActivityControllerHelper implements ActivityControlHelper { @@ -377,6 +392,18 @@ public interface ActivityControlHelper { // Always defer starting the activity when using fallback return true; } + + @Override + public Rect getOverviewWindowBounds(Rect homeBounds, RemoteAnimationTargetCompat target) { + // TODO: Remove this once b/77875376 is fixed + return target.sourceContainerBounds; + } + + @Override + public boolean shouldMinimizeSplitScreen() { + // TODO: Remove this once b/77875376 is fixed + return false; + } } interface LayoutListener { diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index 0c49f16b66..820875cc87 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -98,7 +98,6 @@ public class RecentsActivity extends BaseDraggingActivity { @Override public void onMultiWindowModeChanged(boolean isInMultiWindowMode, Configuration newConfig) { - mOldConfig.setTo(newConfig); onHandleConfigChanged(); super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig); } @@ -129,7 +128,8 @@ public class RecentsActivity extends BaseDraggingActivity { InvariantDeviceProfile idp = appState == null ? new InvariantDeviceProfile(this) : appState.getInvariantDeviceProfile(); DeviceProfile dp = idp.getDeviceProfile(this); - mDeviceProfile = dp.getMultiWindowProfile(this, mRecentsRootView.getLastKnownSize()); + mDeviceProfile = mRecentsRootView == null ? dp.copy(this) + : dp.getMultiWindowProfile(this, mRecentsRootView.getLastKnownSize()); } else { // If we are reusing the Invariant device profile, make a copy. mDeviceProfile = appState == null diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index 06e6556b53..1255a02514 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -459,7 +459,10 @@ public class WindowTransformSwipeHandler { // TODO: This logic is spartanic! boolean passedThreshold = shift > 0.12f; mRecentsAnimationWrapper.setAnimationTargetsBehindSystemBars(!passedThreshold); - mRecentsAnimationWrapper.setSplitScreenMinimizedForTransaction(passedThreshold); + if (mActivityControlHelper.shouldMinimizeSplitScreen()) { + mRecentsAnimationWrapper + .setSplitScreenMinimizedForTransaction(passedThreshold); + } } }; if (Looper.getMainLooper() == Looper.myLooper()) { @@ -478,15 +481,16 @@ public class WindowTransformSwipeHandler { for (RemoteAnimationTargetCompat target : apps) { if (target.mode == MODE_CLOSING) { DeviceProfile dp = LauncherAppState.getIDP(mContext).getDeviceProfile(mContext); - final Rect homeStackBounds; + final Rect overviewStackBounds; if (minimizedHomeBounds != null) { - homeStackBounds = minimizedHomeBounds; + overviewStackBounds = mActivityControlHelper + .getOverviewWindowBounds(minimizedHomeBounds, target); dp = dp.getMultiWindowProfile(mContext, new Point(minimizedHomeBounds.width(), minimizedHomeBounds.height())); dp.updateInsets(homeContentInsets); } else { - homeStackBounds = new Rect(0, 0, dp.widthPx, dp.heightPx); + overviewStackBounds = new Rect(0, 0, dp.widthPx, dp.heightPx); // TODO: Workaround for an existing issue where the home content insets are // not valid immediately after rotation, just use the stable insets for now Rect insets = new Rect(); @@ -495,7 +499,7 @@ public class WindowTransformSwipeHandler { dp.updateInsets(insets); } - mClipAnimationHelper.updateSource(homeStackBounds, target); + mClipAnimationHelper.updateSource(overviewStackBounds, target); initTransitionEndpoints(dp); } } diff --git a/quickstep/src/com/android/quickstep/fallback/RecentsRootView.java b/quickstep/src/com/android/quickstep/fallback/RecentsRootView.java index ad7d19a5f9..878a593482 100644 --- a/quickstep/src/com/android/quickstep/fallback/RecentsRootView.java +++ b/quickstep/src/com/android/quickstep/fallback/RecentsRootView.java @@ -84,6 +84,7 @@ public class RecentsRootView extends BaseDragLayer { } public void dispatchInsets() { + mActivity.getDeviceProfile().updateInsets(mInsets); super.setInsets(mInsets); } } \ No newline at end of file diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java index b1273b64c3..f204c16e28 100644 --- a/src/com/android/launcher3/LauncherRootView.java +++ b/src/com/android/launcher3/LauncherRootView.java @@ -100,6 +100,7 @@ public class LauncherRootView extends InsettableFrameLayout { } public void dispatchInsets() { + mLauncher.getDeviceProfile().updateInsets(mInsets); super.setInsets(mInsets); }