Loading core/java/android/view/InsetsState.java +12 −5 Original line number Original line Diff line number Diff line Loading @@ -19,10 +19,15 @@ package android.view; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME; import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME; import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE; import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE; import static android.view.WindowInsets.Type.IME; import static android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES; import static android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES; import static android.view.WindowInsets.Type.SIZE; import static android.view.WindowInsets.Type.SIZE; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.indexOf; import static android.view.WindowInsets.Type.indexOf; import static android.view.WindowInsets.Type.systemBars; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.Nullable; Loading Loading @@ -156,11 +161,10 @@ public class InsetsState implements Parcelable { && source.getType() != ITYPE_IME; && source.getType() != ITYPE_IME; boolean skipSystemBars = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL boolean skipSystemBars = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR); && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR); boolean skipIme = source.getType() == ITYPE_IME && (legacySoftInputMode & LayoutParams.SOFT_INPUT_ADJUST_RESIZE) == 0; boolean skipLegacyTypes = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_NONE boolean skipLegacyTypes = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_NONE && (toPublicType(type) & Type.compatSystemInsets()) != 0; && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR if (skipSystemBars || skipIme || skipLegacyTypes || skipNonImeInImeMode) { || type == ITYPE_IME); if (skipSystemBars || skipLegacyTypes || skipNonImeInImeMode) { typeVisibilityMap[indexOf(toPublicType(type))] = source.isVisible(); typeVisibilityMap[indexOf(toPublicType(type))] = source.isVisible(); continue; continue; } } Loading @@ -175,8 +179,11 @@ public class InsetsState implements Parcelable { typeMaxInsetsMap, null /* typeSideMap */, null /* typeVisibilityMap */); typeMaxInsetsMap, null /* typeSideMap */, null /* typeVisibilityMap */); } } } } final int softInputAdjustMode = legacySoftInputMode & SOFT_INPUT_MASK_ADJUST; return new WindowInsets(typeInsetsMap, typeMaxInsetsMap, typeVisibilityMap, isScreenRound, return new WindowInsets(typeInsetsMap, typeMaxInsetsMap, typeVisibilityMap, isScreenRound, alwaysConsumeSystemBars, cutout); alwaysConsumeSystemBars, cutout, softInputAdjustMode == SOFT_INPUT_ADJUST_RESIZE ? systemBars() | ime() : systemBars()); } } private void processSource(InsetsSource source, Rect relativeFrame, boolean ignoreVisibility, private void processSource(InsetsSource source, Rect relativeFrame, boolean ignoreVisibility, Loading core/java/android/view/WindowInsets.java +22 −21 Original line number Original line Diff line number Diff line Loading @@ -27,8 +27,8 @@ import static android.view.WindowInsets.Type.STATUS_BARS; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT; import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT; import static android.view.WindowInsets.Type.all; import static android.view.WindowInsets.Type.all; import static android.view.WindowInsets.Type.compatSystemInsets; import static android.view.WindowInsets.Type.indexOf; import static android.view.WindowInsets.Type.indexOf; import static android.view.WindowInsets.Type.systemBars; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.IntRange; Loading Loading @@ -87,6 +87,8 @@ public final class WindowInsets { private final boolean mStableInsetsConsumed; private final boolean mStableInsetsConsumed; private final boolean mDisplayCutoutConsumed; private final boolean mDisplayCutoutConsumed; private final int mCompatInsetTypes; /** /** * Since new insets may be added in the future that existing apps couldn't * Since new insets may be added in the future that existing apps couldn't * know about, this fully empty constant shouldn't be made available to apps * know about, this fully empty constant shouldn't be made available to apps Loading @@ -112,7 +114,7 @@ public final class WindowInsets { boolean isRound, boolean alwaysConsumeSystemBars, DisplayCutout displayCutout) { boolean isRound, boolean alwaysConsumeSystemBars, DisplayCutout displayCutout) { this(createCompatTypeMap(systemWindowInsetsRect), createCompatTypeMap(stableInsetsRect), this(createCompatTypeMap(systemWindowInsetsRect), createCompatTypeMap(stableInsetsRect), createCompatVisibilityMap(createCompatTypeMap(systemWindowInsetsRect)), createCompatVisibilityMap(createCompatTypeMap(systemWindowInsetsRect)), isRound, alwaysConsumeSystemBars, displayCutout); isRound, alwaysConsumeSystemBars, displayCutout, systemBars()); } } /** /** Loading @@ -131,7 +133,7 @@ public final class WindowInsets { @Nullable Insets[] typeMaxInsetsMap, @Nullable Insets[] typeMaxInsetsMap, boolean[] typeVisibilityMap, boolean[] typeVisibilityMap, boolean isRound, boolean isRound, boolean alwaysConsumeSystemBars, DisplayCutout displayCutout) { boolean alwaysConsumeSystemBars, DisplayCutout displayCutout, int compatInsetTypes) { mSystemWindowInsetsConsumed = typeInsetsMap == null; mSystemWindowInsetsConsumed = typeInsetsMap == null; mTypeInsetsMap = mSystemWindowInsetsConsumed mTypeInsetsMap = mSystemWindowInsetsConsumed ? new Insets[SIZE] ? new Insets[SIZE] Loading @@ -145,6 +147,7 @@ public final class WindowInsets { mTypeVisibilityMap = typeVisibilityMap; mTypeVisibilityMap = typeVisibilityMap; mIsRound = isRound; mIsRound = isRound; mAlwaysConsumeSystemBars = alwaysConsumeSystemBars; mAlwaysConsumeSystemBars = alwaysConsumeSystemBars; mCompatInsetTypes = compatInsetTypes; mDisplayCutoutConsumed = displayCutout == null; mDisplayCutoutConsumed = displayCutout == null; mDisplayCutout = (mDisplayCutoutConsumed || displayCutout.isEmpty()) mDisplayCutout = (mDisplayCutoutConsumed || displayCutout.isEmpty()) Loading @@ -160,7 +163,8 @@ public final class WindowInsets { this(src.mSystemWindowInsetsConsumed ? null : src.mTypeInsetsMap, this(src.mSystemWindowInsetsConsumed ? null : src.mTypeInsetsMap, src.mStableInsetsConsumed ? null : src.mTypeMaxInsetsMap, src.mStableInsetsConsumed ? null : src.mTypeMaxInsetsMap, src.mTypeVisibilityMap, src.mIsRound, src.mTypeVisibilityMap, src.mIsRound, src.mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(src)); src.mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(src), src.mCompatInsetTypes); } } private static DisplayCutout displayCutoutCopyConstructorArgument(WindowInsets w) { private static DisplayCutout displayCutoutCopyConstructorArgument(WindowInsets w) { Loading Loading @@ -211,7 +215,8 @@ public final class WindowInsets { /** @hide */ /** @hide */ @UnsupportedAppUsage @UnsupportedAppUsage public WindowInsets(Rect systemWindowInsets) { public WindowInsets(Rect systemWindowInsets) { this(createCompatTypeMap(systemWindowInsets), null, new boolean[SIZE], false, false, null); this(createCompatTypeMap(systemWindowInsets), null, new boolean[SIZE], false, false, null, systemBars()); } } /** /** Loading Loading @@ -280,7 +285,7 @@ public final class WindowInsets { */ */ @NonNull @NonNull public Insets getSystemWindowInsets() { public Insets getSystemWindowInsets() { return getInsets(mTypeInsetsMap, compatSystemInsets()); return getInsets(mTypeInsetsMap, mCompatInsetTypes); } } /** /** Loading Loading @@ -439,7 +444,8 @@ public final class WindowInsets { mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, mIsRound, mAlwaysConsumeSystemBars, null /* displayCutout */); null /* displayCutout */, mCompatInsetTypes); } } Loading Loading @@ -485,7 +491,8 @@ public final class WindowInsets { return new WindowInsets(null, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, return new WindowInsets(null, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, mIsRound, mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(this)); displayCutoutCopyConstructorArgument(this), mCompatInsetTypes); } } // TODO(b/119190588): replace @code with @link below // TODO(b/119190588): replace @code with @link below Loading Loading @@ -555,7 +562,7 @@ public final class WindowInsets { */ */ @NonNull @NonNull public Insets getStableInsets() { public Insets getStableInsets() { return getInsets(mTypeMaxInsetsMap, compatSystemInsets()); return getInsets(mTypeMaxInsetsMap, mCompatInsetTypes); } } /** /** Loading Loading @@ -733,7 +740,8 @@ public final class WindowInsets { public WindowInsets consumeStableInsets() { public WindowInsets consumeStableInsets() { return new WindowInsets(mSystemWindowInsetsConsumed ? null : mTypeInsetsMap, null, return new WindowInsets(mSystemWindowInsetsConsumed ? null : mTypeInsetsMap, null, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(this)); displayCutoutCopyConstructorArgument(this), mCompatInsetTypes); } } /** /** Loading Loading @@ -817,7 +825,8 @@ public final class WindowInsets { ? null ? null : mDisplayCutout == null : mDisplayCutout == null ? DisplayCutout.NO_CUTOUT ? DisplayCutout.NO_CUTOUT : mDisplayCutout.inset(left, top, right, bottom)); : mDisplayCutout.inset(left, top, right, bottom), mCompatInsetTypes); } } @Override @Override Loading Loading @@ -1134,7 +1143,8 @@ public final class WindowInsets { public WindowInsets build() { public WindowInsets build() { return new WindowInsets(mSystemInsetsConsumed ? null : mTypeInsetsMap, return new WindowInsets(mSystemInsetsConsumed ? null : mTypeInsetsMap, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, mDisplayCutout); mIsRound, mAlwaysConsumeSystemBars, mDisplayCutout, systemBars()); } } } } Loading Loading @@ -1270,15 +1280,6 @@ public final class WindowInsets { return STATUS_BARS | NAVIGATION_BARS; return STATUS_BARS | NAVIGATION_BARS; } } /** * @return Inset types representing the list of bars that traditionally were denoted as * system insets. * @hide */ static @InsetsType int compatSystemInsets() { return STATUS_BARS | NAVIGATION_BARS | IME; } /** /** * @return All inset types combined. * @return All inset types combined. * * Loading core/tests/coretests/src/android/view/InsetsStateTest.java +13 −8 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.view.InsetsState.ITYPE_IME; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.ime; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; Loading Loading @@ -116,15 +117,19 @@ public class InsetsStateTest { @Test @Test public void testCalculateInsets_imeIgnoredWithoutAdjustResize() { public void testCalculateInsets_imeIgnoredWithoutAdjustResize() { try (final InsetsModeSession session = new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) { mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100)); mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100)); mState.getSource(ITYPE_STATUS_BAR).setVisible(true); mState.getSource(ITYPE_STATUS_BAR).setVisible(true); mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300)); mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300)); mState.getSource(ITYPE_IME).setVisible(true); mState.getSource(ITYPE_IME).setVisible(true); WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false, WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false, DisplayCutout.NO_CUTOUT, null, null, 0, null); DisplayCutout.NO_CUTOUT, null, null, SOFT_INPUT_ADJUST_NOTHING, null); assertEquals(0, insets.getSystemWindowInsetBottom()); assertEquals(0, insets.getSystemWindowInsetBottom()); assertEquals(100, insets.getInsets(ime()).bottom); assertTrue(insets.isVisible(ime())); assertTrue(insets.isVisible(ime())); } } } @Test @Test public void testStripForDispatch() { public void testStripForDispatch() { Loading core/tests/coretests/src/android/view/WindowInsetsTest.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -63,7 +63,8 @@ public class WindowInsetsTest { b.setInsets(navigationBars(), Insets.of(0, 0, 0, 100)); b.setInsets(navigationBars(), Insets.of(0, 0, 0, 100)); b.setInsets(ime(), Insets.of(0, 0, 0, 300)); b.setInsets(ime(), Insets.of(0, 0, 0, 300)); WindowInsets insets = b.build(); WindowInsets insets = b.build(); assertEquals(300, insets.getSystemWindowInsets().bottom); assertEquals(100, insets.getSystemWindowInsets().bottom); assertEquals(300, insets.getInsets(ime()).bottom); } } // TODO: Move this to CTS once API made public // TODO: Move this to CTS once API made public Loading Loading
core/java/android/view/InsetsState.java +12 −5 Original line number Original line Diff line number Diff line Loading @@ -19,10 +19,15 @@ package android.view; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME; import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME; import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE; import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE; import static android.view.WindowInsets.Type.IME; import static android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES; import static android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES; import static android.view.WindowInsets.Type.SIZE; import static android.view.WindowInsets.Type.SIZE; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.indexOf; import static android.view.WindowInsets.Type.indexOf; import static android.view.WindowInsets.Type.systemBars; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.Nullable; Loading Loading @@ -156,11 +161,10 @@ public class InsetsState implements Parcelable { && source.getType() != ITYPE_IME; && source.getType() != ITYPE_IME; boolean skipSystemBars = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL boolean skipSystemBars = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR); && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR); boolean skipIme = source.getType() == ITYPE_IME && (legacySoftInputMode & LayoutParams.SOFT_INPUT_ADJUST_RESIZE) == 0; boolean skipLegacyTypes = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_NONE boolean skipLegacyTypes = ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_NONE && (toPublicType(type) & Type.compatSystemInsets()) != 0; && (type == ITYPE_STATUS_BAR || type == ITYPE_NAVIGATION_BAR if (skipSystemBars || skipIme || skipLegacyTypes || skipNonImeInImeMode) { || type == ITYPE_IME); if (skipSystemBars || skipLegacyTypes || skipNonImeInImeMode) { typeVisibilityMap[indexOf(toPublicType(type))] = source.isVisible(); typeVisibilityMap[indexOf(toPublicType(type))] = source.isVisible(); continue; continue; } } Loading @@ -175,8 +179,11 @@ public class InsetsState implements Parcelable { typeMaxInsetsMap, null /* typeSideMap */, null /* typeVisibilityMap */); typeMaxInsetsMap, null /* typeSideMap */, null /* typeVisibilityMap */); } } } } final int softInputAdjustMode = legacySoftInputMode & SOFT_INPUT_MASK_ADJUST; return new WindowInsets(typeInsetsMap, typeMaxInsetsMap, typeVisibilityMap, isScreenRound, return new WindowInsets(typeInsetsMap, typeMaxInsetsMap, typeVisibilityMap, isScreenRound, alwaysConsumeSystemBars, cutout); alwaysConsumeSystemBars, cutout, softInputAdjustMode == SOFT_INPUT_ADJUST_RESIZE ? systemBars() | ime() : systemBars()); } } private void processSource(InsetsSource source, Rect relativeFrame, boolean ignoreVisibility, private void processSource(InsetsSource source, Rect relativeFrame, boolean ignoreVisibility, Loading
core/java/android/view/WindowInsets.java +22 −21 Original line number Original line Diff line number Diff line Loading @@ -27,8 +27,8 @@ import static android.view.WindowInsets.Type.STATUS_BARS; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT; import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT; import static android.view.WindowInsets.Type.all; import static android.view.WindowInsets.Type.all; import static android.view.WindowInsets.Type.compatSystemInsets; import static android.view.WindowInsets.Type.indexOf; import static android.view.WindowInsets.Type.indexOf; import static android.view.WindowInsets.Type.systemBars; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.IntRange; Loading Loading @@ -87,6 +87,8 @@ public final class WindowInsets { private final boolean mStableInsetsConsumed; private final boolean mStableInsetsConsumed; private final boolean mDisplayCutoutConsumed; private final boolean mDisplayCutoutConsumed; private final int mCompatInsetTypes; /** /** * Since new insets may be added in the future that existing apps couldn't * Since new insets may be added in the future that existing apps couldn't * know about, this fully empty constant shouldn't be made available to apps * know about, this fully empty constant shouldn't be made available to apps Loading @@ -112,7 +114,7 @@ public final class WindowInsets { boolean isRound, boolean alwaysConsumeSystemBars, DisplayCutout displayCutout) { boolean isRound, boolean alwaysConsumeSystemBars, DisplayCutout displayCutout) { this(createCompatTypeMap(systemWindowInsetsRect), createCompatTypeMap(stableInsetsRect), this(createCompatTypeMap(systemWindowInsetsRect), createCompatTypeMap(stableInsetsRect), createCompatVisibilityMap(createCompatTypeMap(systemWindowInsetsRect)), createCompatVisibilityMap(createCompatTypeMap(systemWindowInsetsRect)), isRound, alwaysConsumeSystemBars, displayCutout); isRound, alwaysConsumeSystemBars, displayCutout, systemBars()); } } /** /** Loading @@ -131,7 +133,7 @@ public final class WindowInsets { @Nullable Insets[] typeMaxInsetsMap, @Nullable Insets[] typeMaxInsetsMap, boolean[] typeVisibilityMap, boolean[] typeVisibilityMap, boolean isRound, boolean isRound, boolean alwaysConsumeSystemBars, DisplayCutout displayCutout) { boolean alwaysConsumeSystemBars, DisplayCutout displayCutout, int compatInsetTypes) { mSystemWindowInsetsConsumed = typeInsetsMap == null; mSystemWindowInsetsConsumed = typeInsetsMap == null; mTypeInsetsMap = mSystemWindowInsetsConsumed mTypeInsetsMap = mSystemWindowInsetsConsumed ? new Insets[SIZE] ? new Insets[SIZE] Loading @@ -145,6 +147,7 @@ public final class WindowInsets { mTypeVisibilityMap = typeVisibilityMap; mTypeVisibilityMap = typeVisibilityMap; mIsRound = isRound; mIsRound = isRound; mAlwaysConsumeSystemBars = alwaysConsumeSystemBars; mAlwaysConsumeSystemBars = alwaysConsumeSystemBars; mCompatInsetTypes = compatInsetTypes; mDisplayCutoutConsumed = displayCutout == null; mDisplayCutoutConsumed = displayCutout == null; mDisplayCutout = (mDisplayCutoutConsumed || displayCutout.isEmpty()) mDisplayCutout = (mDisplayCutoutConsumed || displayCutout.isEmpty()) Loading @@ -160,7 +163,8 @@ public final class WindowInsets { this(src.mSystemWindowInsetsConsumed ? null : src.mTypeInsetsMap, this(src.mSystemWindowInsetsConsumed ? null : src.mTypeInsetsMap, src.mStableInsetsConsumed ? null : src.mTypeMaxInsetsMap, src.mStableInsetsConsumed ? null : src.mTypeMaxInsetsMap, src.mTypeVisibilityMap, src.mIsRound, src.mTypeVisibilityMap, src.mIsRound, src.mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(src)); src.mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(src), src.mCompatInsetTypes); } } private static DisplayCutout displayCutoutCopyConstructorArgument(WindowInsets w) { private static DisplayCutout displayCutoutCopyConstructorArgument(WindowInsets w) { Loading Loading @@ -211,7 +215,8 @@ public final class WindowInsets { /** @hide */ /** @hide */ @UnsupportedAppUsage @UnsupportedAppUsage public WindowInsets(Rect systemWindowInsets) { public WindowInsets(Rect systemWindowInsets) { this(createCompatTypeMap(systemWindowInsets), null, new boolean[SIZE], false, false, null); this(createCompatTypeMap(systemWindowInsets), null, new boolean[SIZE], false, false, null, systemBars()); } } /** /** Loading Loading @@ -280,7 +285,7 @@ public final class WindowInsets { */ */ @NonNull @NonNull public Insets getSystemWindowInsets() { public Insets getSystemWindowInsets() { return getInsets(mTypeInsetsMap, compatSystemInsets()); return getInsets(mTypeInsetsMap, mCompatInsetTypes); } } /** /** Loading Loading @@ -439,7 +444,8 @@ public final class WindowInsets { mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, mIsRound, mAlwaysConsumeSystemBars, null /* displayCutout */); null /* displayCutout */, mCompatInsetTypes); } } Loading Loading @@ -485,7 +491,8 @@ public final class WindowInsets { return new WindowInsets(null, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, return new WindowInsets(null, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, mIsRound, mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(this)); displayCutoutCopyConstructorArgument(this), mCompatInsetTypes); } } // TODO(b/119190588): replace @code with @link below // TODO(b/119190588): replace @code with @link below Loading Loading @@ -555,7 +562,7 @@ public final class WindowInsets { */ */ @NonNull @NonNull public Insets getStableInsets() { public Insets getStableInsets() { return getInsets(mTypeMaxInsetsMap, compatSystemInsets()); return getInsets(mTypeMaxInsetsMap, mCompatInsetTypes); } } /** /** Loading Loading @@ -733,7 +740,8 @@ public final class WindowInsets { public WindowInsets consumeStableInsets() { public WindowInsets consumeStableInsets() { return new WindowInsets(mSystemWindowInsetsConsumed ? null : mTypeInsetsMap, null, return new WindowInsets(mSystemWindowInsetsConsumed ? null : mTypeInsetsMap, null, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(this)); displayCutoutCopyConstructorArgument(this), mCompatInsetTypes); } } /** /** Loading Loading @@ -817,7 +825,8 @@ public final class WindowInsets { ? null ? null : mDisplayCutout == null : mDisplayCutout == null ? DisplayCutout.NO_CUTOUT ? DisplayCutout.NO_CUTOUT : mDisplayCutout.inset(left, top, right, bottom)); : mDisplayCutout.inset(left, top, right, bottom), mCompatInsetTypes); } } @Override @Override Loading Loading @@ -1134,7 +1143,8 @@ public final class WindowInsets { public WindowInsets build() { public WindowInsets build() { return new WindowInsets(mSystemInsetsConsumed ? null : mTypeInsetsMap, return new WindowInsets(mSystemInsetsConsumed ? null : mTypeInsetsMap, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars, mDisplayCutout); mIsRound, mAlwaysConsumeSystemBars, mDisplayCutout, systemBars()); } } } } Loading Loading @@ -1270,15 +1280,6 @@ public final class WindowInsets { return STATUS_BARS | NAVIGATION_BARS; return STATUS_BARS | NAVIGATION_BARS; } } /** * @return Inset types representing the list of bars that traditionally were denoted as * system insets. * @hide */ static @InsetsType int compatSystemInsets() { return STATUS_BARS | NAVIGATION_BARS | IME; } /** /** * @return All inset types combined. * @return All inset types combined. * * Loading
core/tests/coretests/src/android/view/InsetsStateTest.java +13 −8 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.view.InsetsState.ITYPE_IME; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.ime; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; Loading Loading @@ -116,15 +117,19 @@ public class InsetsStateTest { @Test @Test public void testCalculateInsets_imeIgnoredWithoutAdjustResize() { public void testCalculateInsets_imeIgnoredWithoutAdjustResize() { try (final InsetsModeSession session = new InsetsModeSession(ViewRootImpl.NEW_INSETS_MODE_FULL)) { mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100)); mState.getSource(ITYPE_STATUS_BAR).setFrame(new Rect(0, 0, 100, 100)); mState.getSource(ITYPE_STATUS_BAR).setVisible(true); mState.getSource(ITYPE_STATUS_BAR).setVisible(true); mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300)); mState.getSource(ITYPE_IME).setFrame(new Rect(0, 200, 100, 300)); mState.getSource(ITYPE_IME).setVisible(true); mState.getSource(ITYPE_IME).setVisible(true); WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false, WindowInsets insets = mState.calculateInsets(new Rect(0, 0, 100, 300), false, false, DisplayCutout.NO_CUTOUT, null, null, 0, null); DisplayCutout.NO_CUTOUT, null, null, SOFT_INPUT_ADJUST_NOTHING, null); assertEquals(0, insets.getSystemWindowInsetBottom()); assertEquals(0, insets.getSystemWindowInsetBottom()); assertEquals(100, insets.getInsets(ime()).bottom); assertTrue(insets.isVisible(ime())); assertTrue(insets.isVisible(ime())); } } } @Test @Test public void testStripForDispatch() { public void testStripForDispatch() { Loading
core/tests/coretests/src/android/view/WindowInsetsTest.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -63,7 +63,8 @@ public class WindowInsetsTest { b.setInsets(navigationBars(), Insets.of(0, 0, 0, 100)); b.setInsets(navigationBars(), Insets.of(0, 0, 0, 100)); b.setInsets(ime(), Insets.of(0, 0, 0, 300)); b.setInsets(ime(), Insets.of(0, 0, 0, 300)); WindowInsets insets = b.build(); WindowInsets insets = b.build(); assertEquals(300, insets.getSystemWindowInsets().bottom); assertEquals(100, insets.getSystemWindowInsets().bottom); assertEquals(300, insets.getInsets(ime()).bottom); } } // TODO: Move this to CTS once API made public // TODO: Move this to CTS once API made public Loading