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

Commit 23a02a9f authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

IME always provides bottom insets, if any

This fixes an issue where IME wasn't visible in landscape with a
cutout, because IME window didn't cover full edge.

Also fix an issue where floating IME didn't work because alpha
was calculated the wrong way.

Test: InsetsSourceTest
Bug: 111084606
Change-Id: I29b7a45cd590a52ecb03f2e539edde57aef4dba3
parent abaa9043
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -272,8 +272,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
            if (leash != null) {
                // TODO: use a better interpolation for fade.
                alpha = mFade ? ((float) maxInset / inset * 0.3f + 0.7f) : alpha;
                surfaceParams.add(new SurfaceParams(leash, alpha, mTmpMatrix,
                        null /* windowCrop */, 0 /* layer */, 0f /* cornerRadius*/,
                surfaceParams.add(new SurfaceParams(leash, side == ISIDE_FLOATING ? 1 : alpha,
                        mTmpMatrix, null /* windowCrop */, 0 /* layer */, 0f /* cornerRadius*/,
                        side == ISIDE_FLOATING ? state.getSource(source.getType()).isVisible()
                                : inset != 0 /* visible */));
            }
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.view;

import static android.view.InsetsState.ITYPE_IME;

import android.annotation.Nullable;
import android.graphics.Insets;
import android.graphics.Rect;
@@ -109,6 +111,12 @@ public class InsetsSource implements Parcelable {
            return Insets.NONE;
        }

        // TODO: Currently, non-floating IME always intersects at bottom due to issues with cutout.
        // However, we should let the policy decide from the server.
        if (getType() == ITYPE_IME) {
            return Insets.of(0, 0, 0, mTmpFrame.height());
        }

        // Intersecting at top/bottom
        if (mTmpFrame.width() == relativeFrame.width()) {
            if (mTmpFrame.top == relativeFrame.top) {
+11 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.view;

import static android.view.InsetsState.ITYPE_IME;
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;

import static org.junit.Assert.assertEquals;
@@ -44,10 +45,12 @@ import org.junit.runner.RunWith;
public class InsetsSourceTest {

    private InsetsSource mSource = new InsetsSource(ITYPE_NAVIGATION_BAR);
    private InsetsSource mImeSource = new InsetsSource(ITYPE_IME);

    @Before
    public void setUp() {
        mSource.setVisible(true);
        mImeSource.setVisible(true);
    }

    @Test
@@ -90,6 +93,14 @@ public class InsetsSourceTest {
        assertEquals(Insets.of(0, 100, 0, 0), insets);
    }

    @Test
    public void testCalculateInsets_ime_leftCutout() {
        mImeSource.setFrame(new Rect(100, 400, 500, 500));
        Insets insets = mImeSource.calculateInsets(new Rect(0, 0, 500, 500),
                false /* ignoreVisibility */);
        assertEquals(Insets.of(0, 0, 0, 100), insets);
    }

    @Test
    public void testCalculateInsets_invisible() {
        mSource.setFrame(new Rect(0, 0, 500, 100));