From 23681083b2f0a145f3d03cabf194774a68f98e66 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Thu, 7 May 2020 15:23:13 -0700 Subject: [PATCH] Hide shelf in 2-Button Landscape Disable overview rotation in 2-Button. Fixes: 154181816 Test: Tested no button and 2 button, overview actions worked as before. Change-Id: Ic22c791c7a93460840d54aaf0bf32884cc110e19 --- .../uioverrides/QuickstepLauncher.java | 4 ++- .../uioverrides/states/OverviewState.java | 8 ++++- .../android/quickstep/BaseSwipeUpHandler.java | 12 +++++++ .../quickstep/LauncherActivityInterface.java | 4 ++- .../quickstep/LauncherSwipeHandler.java | 2 ++ .../quickstep/TouchInteractionService.java | 15 --------- .../quickstep/util/RecentsOrientedState.java | 33 ++++++++++++++----- .../launcher3/InsettableFrameLayout.java | 3 ++ .../launcher3/allapps/DiscoveryBounce.java | 13 +++++--- 9 files changed, 63 insertions(+), 31 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index ad6a10bba3..95087bafdd 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -217,7 +217,9 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { break; } case OVERVIEW_STATE_ORDINAL: { - DiscoveryBounce.showForOverviewIfNeeded(this); + RecentsView recentsView = getOverviewPanel(); + DiscoveryBounce.showForOverviewIfNeeded(this, + recentsView.getPagedOrientationHandler()); RecentsView rv = getOverviewPanel(); sendCustomAccessibilityEvent( rv.getPageAt(rv.getCurrentPage()), TYPE_VIEW_FOCUSED, null); diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java index 9f31608ad7..9b4e8906a1 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -19,6 +19,8 @@ import static com.android.launcher3.anim.Interpolators.DEACCEL_2; import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS; import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; +import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS; +import static com.android.quickstep.SysUINavigationMode.getMode; import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview; import android.content.Context; @@ -127,7 +129,11 @@ public class OverviewState extends LauncherState { @Override public int getVisibleElements(Launcher launcher) { - if (ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(launcher)) { + RecentsView recentsView = launcher.getOverviewPanel(); + boolean hideShelfTwoButtonLandscape = getMode(launcher) == TWO_BUTTONS && + !recentsView.getPagedOrientationHandler().isLayoutNaturalToLauncher(); + if (ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(launcher) || + hideShelfTwoButtonLandscape) { return OVERVIEW_BUTTONS; } else if (launcher.getDeviceProfile().isVerticalBarLayout()) { return VERTICAL_SWIPE_INDICATOR | OVERVIEW_BUTTONS; 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 bbee67ce94..b6ccdc55e1 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java @@ -36,6 +36,7 @@ import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; import android.os.Build; +import android.util.Log; import android.view.MotionEvent; import android.view.animation.Interpolator; @@ -50,12 +51,14 @@ import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.statemanager.StatefulActivity; +import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.util.VibratorWrapper; import com.android.launcher3.views.FloatingIconView; import com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener; import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.ActivityInitListener; +import com.android.quickstep.util.AppWindowAnimationHelper; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.TaskViewSimulator; import com.android.quickstep.util.TransformParams; @@ -398,7 +401,16 @@ public abstract class BaseSwipeUpHandler, Q extend protected boolean onActivityInit(Boolean alreadyOnHome) { T createdActivity = mActivityInterface.getCreatedActivity(); + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.PAUSE_NOT_DETECTED, "BaseSwipeUpHandler.1"); + } if (createdActivity != null) { + 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/LauncherActivityInterface.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java index 4ebfbd6a4c..5dbf199599 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java @@ -100,7 +100,9 @@ public final class LauncherActivityInterface extends super.onSwipeUpToRecentsComplete(); Launcher launcher = getCreatedActivity(); if (launcher != null) { - DiscoveryBounce.showForOverviewIfNeeded(launcher); + RecentsView recentsView = launcher.getOverviewPanel(); + DiscoveryBounce.showForOverviewIfNeeded(launcher, + recentsView.getPagedOrientationHandler()); } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java index 82a3e79372..a8fa630b7b 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java @@ -276,6 +276,8 @@ public class LauncherSwipeHandler extends BaseSwipeUpHandler setFlag(FLAG_ROTATION_WATCHER_SUPPORTED, newMode != TWO_BUTTONS); + private final Context mContext; private final ContentResolver mContentResolver; private final SharedPreferences mSharedPrefs; @@ -163,13 +168,7 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre if (isFixedRotationTransformEnabled(context)) { mFlags |= FLAG_MULTIPLE_ORIENTATION_SUPPORTED_BY_FLAG; } - if (mOrientationListener.canDetectOrientation()) { - mFlags |= FLAG_ROTATION_WATCHER_SUPPORTED; - } - - // initialize external flags - updateAutoRotateSetting(); - updateHomeRotationSetting(); + initFlags(); } /** @@ -273,6 +272,18 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre mSharedPrefs.getBoolean(ALLOW_ROTATION_PREFERENCE_KEY, false)); } + private void initFlags() { + SysUINavigationMode.Mode currentMode = SysUINavigationMode.getMode(mContext); + if (mOrientationListener.canDetectOrientation() && + currentMode != TWO_BUTTONS) { + mFlags |= FLAG_ROTATION_WATCHER_SUPPORTED; + } + + // initialize external flags + updateAutoRotateSetting(); + updateHomeRotationSetting(); + } + /** * Initializes any system values and registers corresponding change listeners. It must be * paired with {@link #destroyListeners()} call @@ -283,9 +294,11 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre mContentResolver.registerContentObserver( Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), false, mSystemAutoRotateObserver); + SysUINavigationMode.Mode currentMode = + SysUINavigationMode.INSTANCE.get(mContext) + .addModeChangeListener(mNavModeChangeListener); } - updateAutoRotateSetting(); - updateHomeRotationSetting(); + initFlags(); } /** @@ -295,6 +308,8 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre if (isMultipleOrientationSupportedByDevice()) { mSharedPrefs.unregisterOnSharedPreferenceChangeListener(this); mContentResolver.unregisterContentObserver(mSystemAutoRotateObserver); + SysUINavigationMode.INSTANCE.get(mContext) + .removeModeChangeListener(mNavModeChangeListener); } setRotationWatcherEnabled(false); } diff --git a/src/com/android/launcher3/InsettableFrameLayout.java b/src/com/android/launcher3/InsettableFrameLayout.java index faa18b8050..9a66d32524 100644 --- a/src/com/android/launcher3/InsettableFrameLayout.java +++ b/src/com/android/launcher3/InsettableFrameLayout.java @@ -91,6 +91,9 @@ public class InsettableFrameLayout extends FrameLayout implements Insettable { @Override public void onViewAdded(View child) { super.onViewAdded(child); + if (!isAttachedToWindow()) { + return; + } setFrameLayoutChildInsets(child, mInsets, new Rect()); } diff --git a/src/com/android/launcher3/allapps/DiscoveryBounce.java b/src/com/android/launcher3/allapps/DiscoveryBounce.java index 539794230a..b4ff5ea19a 100644 --- a/src/com/android/launcher3/allapps/DiscoveryBounce.java +++ b/src/com/android/launcher3/allapps/DiscoveryBounce.java @@ -34,6 +34,7 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.statemanager.StateManager.StateListener; +import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.util.OnboardingPrefs; /** @@ -153,16 +154,19 @@ public class DiscoveryBounce extends AbstractFloatingView { new DiscoveryBounce(launcher, 0).show(HOTSEAT); } - public static void showForOverviewIfNeeded(Launcher launcher) { - showForOverviewIfNeeded(launcher, true); + public static void showForOverviewIfNeeded(Launcher launcher, + PagedOrientationHandler orientationHandler) { + showForOverviewIfNeeded(launcher, true, orientationHandler); } - private static void showForOverviewIfNeeded(Launcher launcher, boolean withDelay) { + private static void showForOverviewIfNeeded(Launcher launcher, boolean withDelay, + PagedOrientationHandler orientationHandler) { OnboardingPrefs onboardingPrefs = launcher.getOnboardingPrefs(); if (!launcher.isInState(OVERVIEW) || !launcher.hasBeenResumed() || launcher.isForceInvisible() || launcher.getDeviceProfile().isVerticalBarLayout() + || !orientationHandler.isLayoutNaturalToLauncher() || onboardingPrefs.getBoolean(OnboardingPrefs.SHELF_BOUNCE_SEEN) || launcher.getSystemService(UserManager.class).isDemoUser() || Utilities.IS_RUNNING_IN_TEST_HARNESS) { @@ -170,7 +174,8 @@ public class DiscoveryBounce extends AbstractFloatingView { } if (withDelay) { - new Handler().postDelayed(() -> showForOverviewIfNeeded(launcher, false), DELAY_MS); + new Handler().postDelayed(() -> showForOverviewIfNeeded(launcher, false, + orientationHandler), DELAY_MS); return; } else if (AbstractFloatingView.getTopOpenView(launcher) != null) { // TODO: Move these checks to the top and call this method after invalidate handler.