From 7af10ad02cc3e04cfe7480f97cdcbbc5c409b8b9 Mon Sep 17 00:00:00 2001 From: Jeremy Sim Date: Fri, 2 Sep 2022 14:18:09 -0700 Subject: [PATCH] Prevent Overview Actions from appearing during split from home Overview Actions will no longer erroneously appear when initiating a split from home. The bug occurred because split from home causes an irregular state where the user is in split select, yet there is still a focused (main) task in Overview. Overview Actions did not anticipate this state and had no case to handle it. Fixed by adding a check to Overview Actions so that they will never show when split selection is active. Fixes: 244499708 Test: Manual Change-Id: Idf1762c306dceb5048cefec8fa68ac9ca5468379 --- .../quickstep/views/OverviewActionsView.java | 40 ++++++++++++++++--- .../android/quickstep/views/RecentsView.java | 13 +++--- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java index 62ec0ef1df..747ba2ce9f 100644 --- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java +++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java @@ -53,7 +53,9 @@ public class OverviewActionsView extends FrameLayo HIDDEN_NON_ZERO_ROTATION, HIDDEN_NO_TASKS, HIDDEN_NO_RECENTS, - HIDDEN_SPLIT_SCREEN}) + HIDDEN_SPLIT_SCREEN, + HIDDEN_SPLIT_SELECT_ACTIVE + }) @Retention(RetentionPolicy.SOURCE) public @interface ActionsHiddenFlags { } @@ -61,6 +63,7 @@ public class OverviewActionsView extends FrameLayo public static final int HIDDEN_NO_TASKS = 1 << 1; public static final int HIDDEN_NO_RECENTS = 1 << 2; public static final int HIDDEN_SPLIT_SCREEN = 1 << 3; + public static final int HIDDEN_SPLIT_SELECT_ACTIVE = 1 << 4; @IntDef(flag = true, value = { DISABLED_SCROLLING, @@ -79,6 +82,11 @@ public class OverviewActionsView extends FrameLayo private static final int INDEX_HIDDEN_FLAGS_ALPHA = 3; private static final int INDEX_SHARE_TARGET_ALPHA = 4; + public @interface SplitButtonDisabledFlags { } + + public static final int FLAG_IS_NOT_TABLET = 1 << 0; + public static final int FLAG_SINGLE_TASK = 1 << 1; + private MultiValueAlpha mMultiValueAlpha; private Button mSplitButton; @@ -88,6 +96,9 @@ public class OverviewActionsView extends FrameLayo @ActionsDisabledFlags protected int mDisabledFlags; + @SplitButtonDisabledFlags + private int mSplitButtonDisabledFlags; + @Nullable protected T mCallbacks; @@ -182,6 +193,20 @@ public class OverviewActionsView extends FrameLayo LayoutUtils.setViewEnabled(this, isEnabled); } + /** + * Updates the proper flags to indicate whether the "Split screen" button should be enabled. + * + * @param flag The flag to update. + * @param enable Whether to enable the disable flag: True will cause view to be disabled. + */ + public void updateSplitButtonFlags(@SplitButtonDisabledFlags int flag, boolean enable) { + if (enable) { + mSplitButtonDisabledFlags |= flag; + } else { + mSplitButtonDisabledFlags &= ~flag; + } + } + public AlphaProperty getContentAlpha() { return mMultiValueAlpha.getProperty(INDEX_CONTENT_ALPHA); } @@ -263,12 +288,17 @@ public class OverviewActionsView extends FrameLayo 0, 0, 0); } - public void setSplitButtonVisible(boolean visible) { + /** + * Shows/hides the "Split" button based on the status of mHiddenFlags. + */ + public void updateSplitButtonVisibility() { if (mSplitButton == null) { return; } - - mSplitButton.setVisibility(visible ? VISIBLE : GONE); - findViewById(R.id.action_split_space).setVisibility(visible ? VISIBLE : GONE); + boolean shouldBeVisible = mSplitButtonDisabledFlags == 0 + // and neither of these flags are active + && (mHiddenFlags & (HIDDEN_SPLIT_SCREEN | HIDDEN_SPLIT_SELECT_ACTIVE)) == 0; + mSplitButton.setVisibility(shouldBeVisible ? VISIBLE : GONE); + findViewById(R.id.action_split_space).setVisibility(shouldBeVisible ? VISIBLE : GONE); } } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index efaa644502..6938951589 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -52,10 +52,13 @@ import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITIO import static com.android.launcher3.util.SystemUiController.UI_STATE_FULLSCREEN_TASK; import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId; import static com.android.quickstep.views.ClearAllButton.DISMISS_ALPHA; +import static com.android.quickstep.views.OverviewActionsView.FLAG_IS_NOT_TABLET; +import static com.android.quickstep.views.OverviewActionsView.FLAG_SINGLE_TASK; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NON_ZERO_ROTATION; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_RECENTS; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_NO_TASKS; import static com.android.quickstep.views.OverviewActionsView.HIDDEN_SPLIT_SCREEN; +import static com.android.quickstep.views.OverviewActionsView.HIDDEN_SPLIT_SELECT_ACTIVE; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -3387,11 +3390,11 @@ public abstract class RecentsView 1); + mActionsView.updateHiddenFlags(HIDDEN_SPLIT_SELECT_ACTIVE, isSplitSelectionActive()); + mActionsView.updateSplitButtonFlags(FLAG_IS_NOT_TABLET, + !mActivity.getDeviceProfile().isTablet); + mActionsView.updateSplitButtonFlags(FLAG_SINGLE_TASK, getTaskViewCount() <= 1); + mActionsView.updateSplitButtonVisibility(); } /**