Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7af10ad0 authored by Jeremy Sim's avatar Jeremy Sim
Browse files

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
parent afff9362
Loading
Loading
Loading
Loading
+35 −5
Original line number Diff line number Diff line
@@ -53,7 +53,9 @@ public class OverviewActionsView<T extends OverlayUICallbacks> 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<T extends OverlayUICallbacks> 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<T extends OverlayUICallbacks> 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<T extends OverlayUICallbacks> extends FrameLayo
    @ActionsDisabledFlags
    protected int mDisabledFlags;

    @SplitButtonDisabledFlags
    private int mSplitButtonDisabledFlags;

    @Nullable
    protected T mCallbacks;

@@ -182,6 +193,20 @@ public class OverviewActionsView<T extends OverlayUICallbacks> 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<T extends OverlayUICallbacks> 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);
    }
}
+8 −5
Original line number Diff line number Diff line
@@ -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<ACTIVITY_TYPE extends StatefulActivity<STATE_T
    private void updateCurrentTaskActionsVisibility() {
        boolean isCurrentSplit = getCurrentPageTaskView() instanceof GroupedTaskView;
        mActionsView.updateHiddenFlags(HIDDEN_SPLIT_SCREEN, isCurrentSplit);
        if (isCurrentSplit) {
            return;
        }
        mActionsView.setSplitButtonVisible(
                mActivity.getDeviceProfile().isTablet && getTaskViewCount() > 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();
    }

    /**