diff options
-rw-r--r-- | core/java/android/view/InsetsAnimationControlImpl.java | 4 | ||||
-rw-r--r-- | core/java/android/view/InsetsSource.java | 8 | ||||
-rw-r--r-- | core/tests/coretests/src/android/view/InsetsSourceTest.java | 11 |
3 files changed, 21 insertions, 2 deletions
diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java index e863aa06ed26..5c24047a2c19 100644 --- a/core/java/android/view/InsetsAnimationControlImpl.java +++ b/core/java/android/view/InsetsAnimationControlImpl.java @@ -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 */)); } diff --git a/core/java/android/view/InsetsSource.java b/core/java/android/view/InsetsSource.java index 67ccfd6707f4..37034ee065ee 100644 --- a/core/java/android/view/InsetsSource.java +++ b/core/java/android/view/InsetsSource.java @@ -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) { diff --git a/core/tests/coretests/src/android/view/InsetsSourceTest.java b/core/tests/coretests/src/android/view/InsetsSourceTest.java index e3b08bb14e46..756d63d2857d 100644 --- a/core/tests/coretests/src/android/view/InsetsSourceTest.java +++ b/core/tests/coretests/src/android/view/InsetsSourceTest.java @@ -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 @@ -91,6 +94,14 @@ public class InsetsSourceTest { } @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)); mSource.setVisible(false); |