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

Commit 5d090b2c authored by Jeremy Sim's avatar Jeremy Sim
Browse files

Fix bug where IME caused an unnecessary divider reposition in flex split

In ag/30137792, we introduced a way for the divider bar to animate to a new position when insets are changed, so that flex split ratios could adjust when changing to Pinned Taskbar or 3-button-nav.

However, this new function (`calculatePinnedTaskbarInsets`) mistakenly reported insets as zero when IME was active. Actually, IME insets are independent of pinned taskbar insets, so there was no need to make a special case for IME.

This patch fixes that by removing the IME check, allowing divider position to remain stable when IME appears and disappears.

Bug: 396031160
Bug: 399304764
Flag: com.android.wm.shell.enable_flexible_two_app_split
Test: IME launches properly and does not cause a divider reposition anymore.
Change-Id: Id74a38d75971213c8c6ed2a629ff357ff6cc73ed
parent fc2d0835
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -662,14 +662,14 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
            return;
        }

        // Check to see if insets changed in such a way that the divider algorithm needs to be
        // recalculated.
        // Check to see if insets changed in such a way that the divider needs to be animated to
        // a new position. (We only do this when switching to pinned taskbar mode and back).
        Insets pinnedTaskbarInsets = calculatePinnedTaskbarInsets(insetsState);
        if (!mPinnedTaskbarInsets.equals(pinnedTaskbarInsets)) {
            mPinnedTaskbarInsets = pinnedTaskbarInsets;
            // Refresh the DividerSnapAlgorithm.
            updateLayouts();
            // If the divider is no longer placed on a snap point, animate it to the nearest one.
            // If the divider is no longer placed on a snap point, animate it to the nearest one
            DividerSnapAlgorithm.SnapTarget snapTarget =
                    findSnapTarget(mDividerPosition, 0, false /* hardDismiss */);
            if (snapTarget.position != mDividerPosition) {
@@ -683,18 +683,12 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
    }

    /**
     * Calculates the insets that might trigger a divider algorithm recalculation. Currently, only
     * pinned Taskbar does this, and only when the IME is not showing.
     * Calculates the insets that might trigger a divider algorithm recalculation.
     */
    private Insets calculatePinnedTaskbarInsets(InsetsState insetsState) {
        if (insetsState.isSourceOrDefaultVisible(InsetsSource.ID_IME, WindowInsets.Type.ime())) {
            return Insets.NONE;
        }

        // If IME is not showing...
        for (int i = insetsState.sourceSize() - 1; i >= 0; i--) {
            final InsetsSource source = insetsState.sourceAt(i);
            // and Taskbar is pinned...
            // If Taskbar is pinned...
            if (source.getType() == WindowInsets.Type.navigationBars()
                    && source.hasFlags(InsetsSource.FLAG_INSETS_ROUNDED_CORNER)) {
                // Return Insets representing the pinned taskbar state.