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

Commit d79a87bf authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Disable split button instead of hiding it

The split button remains visible when there is only a single task present, but in a disabled state.

Test: Manual
Bug: 227600027
Change-Id: I36e8904bf342021db210cea7355a3806c783f235
parent a7be3549
Loading
Loading
Loading
Loading
+38 −14
Original line number Original line Diff line number Diff line
@@ -82,10 +82,11 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
    private static final int INDEX_HIDDEN_FLAGS_ALPHA = 3;
    private static final int INDEX_HIDDEN_FLAGS_ALPHA = 3;
    private static final int INDEX_SHARE_TARGET_ALPHA = 4;
    private static final int INDEX_SHARE_TARGET_ALPHA = 4;


    public @interface SplitButtonDisabledFlags { }
    public @interface SplitButtonHiddenFlags { }

    public static final int FLAG_IS_NOT_TABLET = 1 << 0;
    public static final int FLAG_IS_NOT_TABLET = 1 << 0;
    public static final int FLAG_SINGLE_TASK = 1 << 1;

    public @interface SplitButtonDisabledFlags { }
    public static final int FLAG_SINGLE_TASK = 1 << 0;


    private MultiValueAlpha mMultiValueAlpha;
    private MultiValueAlpha mMultiValueAlpha;
    private Button mSplitButton;
    private Button mSplitButton;
@@ -96,6 +97,9 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
    @ActionsDisabledFlags
    @ActionsDisabledFlags
    protected int mDisabledFlags;
    protected int mDisabledFlags;


    @SplitButtonHiddenFlags
    private int mSplitButtonHiddenFlags;

    @SplitButtonDisabledFlags
    @SplitButtonDisabledFlags
    private int mSplitButtonDisabledFlags;
    private int mSplitButtonDisabledFlags;


@@ -191,20 +195,40 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
        }
        }
        boolean isEnabled = (mDisabledFlags & ~DISABLED_ROTATED) == 0;
        boolean isEnabled = (mDisabledFlags & ~DISABLED_ROTATED) == 0;
        LayoutUtils.setViewEnabled(this, isEnabled);
        LayoutUtils.setViewEnabled(this, isEnabled);
        updateSplitButtonEnabledState();
    }
    }


    /**
    /**
     * Updates the proper flags to indicate whether the "Split screen" button should be enabled.
     * Updates the proper flags to indicate whether the "Split screen" button should be hidden.
     *
     * @param flag   The flag to update.
     * @param enable Whether to enable the hidden flag: True will cause view to be hidden.
     */
    public void updateSplitButtonHiddenFlags(@SplitButtonHiddenFlags int flag, boolean enable) {
        if (enable) {
            mSplitButtonHiddenFlags |= flag;
        } else {
            mSplitButtonHiddenFlags &= ~flag;
        }
        if (mSplitButton == null) return;
        boolean shouldBeVisible = mSplitButtonHiddenFlags == 0;
        mSplitButton.setVisibility(shouldBeVisible ? VISIBLE : GONE);
        findViewById(R.id.action_split_space).setVisibility(shouldBeVisible ? VISIBLE : GONE);
    }

    /**
     * Updates the proper flags to indicate whether the "Split screen" button should be disabled.
     *
     *
     * @param flag   The flag to update.
     * @param flag   The flag to update.
     * @param enable Whether to enable the disable flag: True will cause view to be disabled.
     * @param enable Whether to enable the disable flag: True will cause view to be disabled.
     */
     */
    public void updateSplitButtonFlags(@SplitButtonDisabledFlags int flag, boolean enable) {
    public void updateSplitButtonDisabledFlags(@SplitButtonDisabledFlags int flag, boolean enable) {
        if (enable) {
        if (enable) {
            mSplitButtonDisabledFlags |= flag;
            mSplitButtonDisabledFlags |= flag;
        } else {
        } else {
            mSplitButtonDisabledFlags &= ~flag;
            mSplitButtonDisabledFlags &= ~flag;
        }
        }
        updateSplitButtonEnabledState();
    }
    }


    public AlphaProperty getContentAlpha() {
    public AlphaProperty getContentAlpha() {
@@ -289,16 +313,16 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
    }
    }


    /**
    /**
     * Shows/hides the "Split" button based on the status of mHiddenFlags.
     * Enables/disables the "Split" button based on the status of mSplitButtonDisabledFlags and
     * mDisabledFlags.
     */
     */
    public void updateSplitButtonVisibility() {
    private void updateSplitButtonEnabledState() {
        if (mSplitButton == null) {
        if (mSplitButton == null) {
            return;
            return;
        }
        }
        boolean shouldBeVisible = mSplitButtonDisabledFlags == 0
        boolean isParentEnabled = (mDisabledFlags & ~DISABLED_ROTATED) == 0;
                // and neither of these flags are active
        boolean shouldBeEnabled = mSplitButtonDisabledFlags == 0 && isParentEnabled;
                && (mHiddenFlags & (HIDDEN_SPLIT_SCREEN | HIDDEN_SPLIT_SELECT_ACTIVE)) == 0;
        mSplitButton.setEnabled(shouldBeEnabled);
        mSplitButton.setVisibility(shouldBeVisible ? VISIBLE : GONE);
        findViewById(R.id.action_split_space).setVisibility(shouldBeVisible ? VISIBLE : GONE);
    }
    }

}
}
+2 −3
Original line number Original line Diff line number Diff line
@@ -3391,10 +3391,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        boolean isCurrentSplit = getCurrentPageTaskView() instanceof GroupedTaskView;
        boolean isCurrentSplit = getCurrentPageTaskView() instanceof GroupedTaskView;
        mActionsView.updateHiddenFlags(HIDDEN_SPLIT_SCREEN, isCurrentSplit);
        mActionsView.updateHiddenFlags(HIDDEN_SPLIT_SCREEN, isCurrentSplit);
        mActionsView.updateHiddenFlags(HIDDEN_SPLIT_SELECT_ACTIVE, isSplitSelectionActive());
        mActionsView.updateHiddenFlags(HIDDEN_SPLIT_SELECT_ACTIVE, isSplitSelectionActive());
        mActionsView.updateSplitButtonFlags(FLAG_IS_NOT_TABLET,
        mActionsView.updateSplitButtonHiddenFlags(FLAG_IS_NOT_TABLET,
                !mActivity.getDeviceProfile().isTablet);
                !mActivity.getDeviceProfile().isTablet);
        mActionsView.updateSplitButtonFlags(FLAG_SINGLE_TASK, getTaskViewCount() <= 1);
        mActionsView.updateSplitButtonDisabledFlags(FLAG_SINGLE_TASK, getTaskViewCount() <= 1);
        mActionsView.updateSplitButtonVisibility();
    }
    }


    /**
    /**