From e03ad7ede2f8e65512c4f99677c1098a49b90076 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Wed, 27 May 2020 09:47:26 -0700 Subject: [PATCH] Set overview orientation for all nav modes 3 Button overview orientation wasn't getting set, but working because of the sensor. Now we set orientation when entering overview, and reset to rotation 0 when exiting overview. Also fix related bug in RecentsOriented state where we weren't updating the current sensor rotation with foreground app orientation. Fixes: 157069195 Change-Id: Ide1b7dbeb68aeaf6a3c45f7260595f69f4813d94 --- .../AppToOverviewAnimationProvider.java | 6 +++++- .../android/quickstep/BaseSwipeUpHandler.java | 3 --- .../android/quickstep/BaseSwipeUpHandlerV2.java | 2 +- .../quickstep/FallbackActivityInterface.java | 2 +- .../quickstep/LauncherActivityInterface.java | 6 +++++- .../android/quickstep/OverviewCommandHelper.java | 2 +- .../quickstep/views/LauncherRecentsView.java | 2 ++ .../android/quickstep/BaseActivityInterface.java | 2 +- .../quickstep/RecentsAnimationDeviceState.java | 16 +++++++++++----- .../quickstep/util/RecentsOrientedState.java | 1 + 10 files changed, 28 insertions(+), 14 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java index e5782e7a45..de83caf162 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java @@ -53,14 +53,17 @@ final class AppToOverviewAnimationProvider> extend private final BaseActivityInterface mActivityInterface; // The id of the currently running task that is transitioning to overview. private final int mTargetTaskId; + private final RecentsAnimationDeviceState mDeviceState; private T mActivity; private RecentsView mRecentsView; AppToOverviewAnimationProvider( - BaseActivityInterface activityInterface, int targetTaskId) { + BaseActivityInterface activityInterface, int targetTaskId, + RecentsAnimationDeviceState deviceState) { mActivityInterface = activityInterface; mTargetTaskId = targetTaskId; + mDeviceState = deviceState; } /** @@ -73,6 +76,7 @@ final class AppToOverviewAnimationProvider> extend activity.getOverviewPanel().showCurrentTask(mTargetTaskId); AbstractFloatingView.closeAllOpenViews(activity, wasVisible); BaseActivityInterface.AnimationFactory factory = mActivityInterface.prepareRecentsUI( + mDeviceState, wasVisible, (controller) -> { controller.dispatchOnStart(); controller.getAnimationPlayer().end(); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java index 6cbe794860..b5fb31a9de 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java @@ -300,9 +300,6 @@ public abstract class BaseSwipeUpHandler, Q extend if (TestProtocol.sDebugTracing) { Log.d(TestProtocol.PAUSE_NOT_DETECTED, "BaseSwipeUpHandler.2"); } - ((RecentsView) createdActivity.getOverviewPanel()) - .setLayoutRotation(mDeviceState.getCurrentActiveRotation(), - mDeviceState.getDisplayRotation()); initTransitionEndpoints(InvariantDeviceProfile.INSTANCE.get(mContext) .getDeviceProfile(mContext)); } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java index 92e10b14f9..f2438b62b2 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java @@ -331,7 +331,7 @@ public abstract class BaseSwipeUpHandlerV2, Q exte // as that will set the state as BACKGROUND_APP, overriding the animation to NORMAL. if (mGestureState.getEndTarget() != HOME) { Runnable initAnimFactory = () -> { - mAnimationFactory = mActivityInterface.prepareRecentsUI( + mAnimationFactory = mActivityInterface.prepareRecentsUI(mDeviceState, mWasLauncherAlreadyVisible, this::onAnimatorPlaybackControllerCreated); maybeUpdateRecentsAttachedState(false /* animate */); }; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java index 70be3ab8af..33b9cdee08 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java @@ -83,7 +83,7 @@ public final class FallbackActivityInterface extends /** 6 */ @Override - public AnimationFactory prepareRecentsUI( + public AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState, boolean activityVisible, Consumer callback) { DefaultAnimationFactory factory = new DefaultAnimationFactory(callback); factory.initUI(); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java index 62eb235251..6798cb0326 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java @@ -32,6 +32,7 @@ import android.view.animation.Interpolator; import androidx.annotation.Nullable; import androidx.annotation.UiThread; +import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; @@ -118,8 +119,11 @@ public final class LauncherActivityInterface extends } @Override - public AnimationFactory prepareRecentsUI( + public AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState, boolean activityVisible, Consumer callback) { + ((RecentsView) getCreatedActivity().getOverviewPanel()) + .setLayoutRotation(deviceState.getCurrentActiveRotation(), + deviceState.getDisplayRotation()); DefaultAnimationFactory factory = new DefaultAnimationFactory(callback) { @Override public void setShelfState(ShelfAnimState shelfState, Interpolator interpolator, diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java index 88467279d2..434a929b5c 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java @@ -165,7 +165,7 @@ public class OverviewCommandHelper { mActivityInterface = mOverviewComponentObserver.getActivityInterface(); mCreateTime = SystemClock.elapsedRealtime(); mAnimationProvider = new AppToOverviewAnimationProvider<>(mActivityInterface, - RecentsModel.getRunningTaskId()); + RecentsModel.getRunningTaskId(), mDeviceState); // Preload the plan mRecentsModel.getTasks(null); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java index 68cc481baa..a19026b275 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java @@ -33,6 +33,7 @@ import android.content.Context; import android.os.Build; import android.util.AttributeSet; import android.view.MotionEvent; +import android.view.Surface; import android.widget.FrameLayout; import com.android.launcher3.BaseQuickstepLauncher; @@ -225,6 +226,7 @@ public class LauncherRecentsView extends RecentsView public void reset() { super.reset(); + setLayoutRotation(Surface.ROTATION_0, Surface.ROTATION_0); // We are moving to home or some other UI with no recents. Switch back to the home client, // the home predictions should have been updated when the activity was resumed. PredictionUiStateManager.INSTANCE.get(getContext()).switchClient(Client.HOME); diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index 7122647e6f..2b698bdd5b 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -105,7 +105,7 @@ public abstract class BaseActivityInterface callback); public abstract ActivityInitListener createActivityInitListener( diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java index 161cc73571..adf2321d83 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java @@ -237,10 +237,8 @@ public class RecentsAnimationDeviceState implements @Override public void onNavigationModeChanged(SysUINavigationMode.Mode newMode) { mDefaultDisplay.removeChangeListener(this); - if (newMode.hasGestures) { - mDefaultDisplay.addChangeListener(this); - onDisplayInfoChanged(mDefaultDisplay.getInfo(), CHANGE_ALL); - } + mDefaultDisplay.addChangeListener(this); + onDisplayInfoChanged(mDefaultDisplay.getInfo(), CHANGE_ALL); if (newMode == NO_BUTTON) { mExclusionListener.register(); @@ -268,6 +266,10 @@ public class RecentsAnimationDeviceState implements } mDisplayRotation = info.rotation; + + if (!mMode.hasGestures) { + return; + } mNavBarPosition = new NavBarPosition(mMode, info); updateGestureTouchRegions(); mOrientationTouchTransformer.createOrAddTouchRegion(info); @@ -606,7 +608,11 @@ public class RecentsAnimationDeviceState implements } } - public int getCurrentActiveRotation() { + int getCurrentActiveRotation() { + if (!mMode.hasGestures) { + // touch rotation should always match that of display for 3 button + return mDisplayRotation; + } return mOrientationTouchTransformer.getCurrentActiveRotation(); } diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java index 498c232ec3..922f5ac79e 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java @@ -207,6 +207,7 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre mLauncherRotation = launcherRotation; mDisplayRotation = displayRotation; mTouchRotation = touchRotation; + mPreviousRotation = touchRotation; if (mLauncherRotation == mTouchRotation || canLauncherRotate()) { mOrientationHandler = PagedOrientationHandler.HOME_ROTATED;