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

Commit 8243b90d authored by Jeremy Sim's avatar Jeremy Sim Committed by Android (Google) Code Review
Browse files

Merge "Fix bug where IME caused an unnecessary divider reposition in flex split" into main

parents b5aa634a 5d090b2c
Loading
Loading
Loading
Loading
+5 −11
Original line number Original line Diff line number Diff line
@@ -662,14 +662,14 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
            return;
            return;
        }
        }


        // Check to see if insets changed in such a way that the divider algorithm needs to be
        // Check to see if insets changed in such a way that the divider needs to be animated to
        // recalculated.
        // a new position. (We only do this when switching to pinned taskbar mode and back).
        Insets pinnedTaskbarInsets = calculatePinnedTaskbarInsets(insetsState);
        Insets pinnedTaskbarInsets = calculatePinnedTaskbarInsets(insetsState);
        if (!mPinnedTaskbarInsets.equals(pinnedTaskbarInsets)) {
        if (!mPinnedTaskbarInsets.equals(pinnedTaskbarInsets)) {
            mPinnedTaskbarInsets = pinnedTaskbarInsets;
            mPinnedTaskbarInsets = pinnedTaskbarInsets;
            // Refresh the DividerSnapAlgorithm.
            // Refresh the DividerSnapAlgorithm.
            updateLayouts();
            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 =
            DividerSnapAlgorithm.SnapTarget snapTarget =
                    findSnapTarget(mDividerPosition, 0, false /* hardDismiss */);
                    findSnapTarget(mDividerPosition, 0, false /* hardDismiss */);
            if (snapTarget.position != mDividerPosition) {
            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
     * Calculates the insets that might trigger a divider algorithm recalculation.
     * pinned Taskbar does this, and only when the IME is not showing.
     */
     */
    private Insets calculatePinnedTaskbarInsets(InsetsState insetsState) {
    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--) {
        for (int i = insetsState.sourceSize() - 1; i >= 0; i--) {
            final InsetsSource source = insetsState.sourceAt(i);
            final InsetsSource source = insetsState.sourceAt(i);
            // and Taskbar is pinned...
            // If Taskbar is pinned...
            if (source.getType() == WindowInsets.Type.navigationBars()
            if (source.getType() == WindowInsets.Type.navigationBars()
                    && source.hasFlags(InsetsSource.FLAG_INSETS_ROUNDED_CORNER)) {
                    && source.hasFlags(InsetsSource.FLAG_INSETS_ROUNDED_CORNER)) {
                // Return Insets representing the pinned taskbar state.
                // Return Insets representing the pinned taskbar state.