Loading core/java/android/view/InsetsState.java +4 −5 Original line number Diff line number Diff line Loading @@ -17,18 +17,17 @@ package android.view; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.DISPLAY_CUTOUT; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.DISPLAY_FRAME; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.SOURCES; import static android.util.SequenceUtils.getInitSeq; import static android.view.InsetsSource.FLAG_FORCE_CONSUMING; import static android.view.InsetsSource.FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR; import static android.view.InsetsSource.FLAG_INSETS_ROUNDED_CORNER; import static android.view.InsetsSource.FLAG_INVALID; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.DISPLAY_CUTOUT; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.DISPLAY_FRAME; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.SOURCES; import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE; import static android.view.WindowInsets.Type.TYPES; import static android.view.WindowInsets.Type.captionBar; import static android.view.WindowInsets.Type.defaultCompatible; import static android.view.WindowInsets.Type.displayCutout; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.indexOf; Loading Loading @@ -194,7 +193,7 @@ public class InsetsState implements Parcelable { final int softInputAdjustMode = legacySoftInputMode & SOFT_INPUT_MASK_ADJUST; @InsetsType int compatInsetsTypes = defaultCompatible(); int compatInsetsTypes = systemBars() | displayCutout(); if (softInputAdjustMode == SOFT_INPUT_ADJUST_RESIZE) { compatInsetsTypes |= ime(); } Loading core/java/android/view/WindowInsets.java +23 −37 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT; import static android.view.WindowInsets.Type.TYPES; import static android.view.WindowInsets.Type.all; import static android.view.WindowInsets.Type.defaultCompatible; import static android.view.WindowInsets.Type.displayCutout; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.indexOf; Loading Loading @@ -138,7 +137,7 @@ public final class WindowInsets { static { CONSUMED = new WindowInsets(createCompatTypeMap(null), createCompatTypeMap(null), createCompatVisibilityMap(createCompatTypeMap(null)), false, 0, false, 0, null, null, null, null, defaultCompatible(), false, null, null, 0, 0); null, null, null, systemBars(), false, null, null, 0, 0); } /** Loading Loading @@ -280,7 +279,7 @@ public final class WindowInsets { @UnsupportedAppUsage public WindowInsets(@Nullable Rect systemWindowInsets) { this(createCompatTypeMap(systemWindowInsets), null, new boolean[TYPES.length], false, 0, false, 0, null, null, null, null, defaultCompatible(), false, 0, null, null, null, null, systemBars(), false /* compatIgnoreVisibility */, new Rect[TYPES.length][], null, 0, 0); } Loading Loading @@ -357,16 +356,20 @@ public final class WindowInsets { * </p> * * @return The system window insets * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} */ @Deprecated @NonNull public Insets getSystemWindowInsets() { final Insets result = getInsets(mCompatInsetsTypes); return mCompatIgnoreVisibility ? Insets.max(result, getInsetsIgnoringVisibility(mCompatInsetsTypes & ~ime())) : result; Insets result = mCompatIgnoreVisibility ? getInsetsIgnoringVisibility(mCompatInsetsTypes & ~ime()) : getInsets(mCompatInsetsTypes); // We can't query max insets for IME, so we need to add it manually after. if ((mCompatInsetsTypes & ime()) != 0 && mCompatIgnoreVisibility) { result = Insets.max(result, getInsets(ime())); } return result; } /** Loading Loading @@ -436,8 +439,8 @@ public final class WindowInsets { * </p> * * @return The left system window inset * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} * instead. */ @Deprecated public int getSystemWindowInsetLeft() { Loading @@ -452,8 +455,8 @@ public final class WindowInsets { * </p> * * @return The top system window inset * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} * instead. */ @Deprecated public int getSystemWindowInsetTop() { Loading @@ -468,8 +471,8 @@ public final class WindowInsets { * </p> * * @return The right system window inset * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} * instead. */ @Deprecated public int getSystemWindowInsetRight() { Loading @@ -484,8 +487,8 @@ public final class WindowInsets { * </p> * * @return The bottom system window inset * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} * instead. */ @Deprecated public int getSystemWindowInsetBottom() { Loading @@ -500,8 +503,8 @@ public final class WindowInsets { * </p> * * @return true if any of the system window inset values are nonzero * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} * instead. */ @Deprecated public boolean hasSystemWindowInsets() { Loading Loading @@ -1408,8 +1411,6 @@ public final class WindowInsets { private final Rect[][] mTypeBoundingRectsMap; @NonNull private final Rect[][] mTypeMaxBoundingRectsMap; private final @InsetsType int mCompatInsetTypes; private final boolean mCompatIgnoreVisibility; private boolean mSystemInsetsConsumed = true; private boolean mStableInsetsConsumed = true; Loading Loading @@ -1441,8 +1442,6 @@ public final class WindowInsets { mTypeVisibilityMap = new boolean[TYPES.length]; mTypeBoundingRectsMap = new Rect[TYPES.length][]; mTypeMaxBoundingRectsMap = new Rect[TYPES.length][]; mCompatInsetTypes = defaultCompatible(); mCompatIgnoreVisibility = false; } /** Loading @@ -1454,8 +1453,6 @@ public final class WindowInsets { mTypeInsetsMap = insets.mTypeInsetsMap.clone(); mTypeMaxInsetsMap = insets.mTypeMaxInsetsMap.clone(); mTypeVisibilityMap = insets.mTypeVisibilityMap.clone(); mCompatInsetTypes = insets.mCompatInsetsTypes; mCompatIgnoreVisibility = insets.mCompatIgnoreVisibility; mSystemInsetsConsumed = insets.mSystemWindowInsetsConsumed; mStableInsetsConsumed = insets.mStableInsetsConsumed; mDisplayCutout = displayCutoutCopyConstructorArgument(insets); Loading Loading @@ -1831,7 +1828,7 @@ public final class WindowInsets { mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mIsRound, mForceConsumingTypes, mForceConsumingOpaqueCaptionBar, mSuppressScrimTypes, mDisplayCutout, mRoundedCorners, mPrivacyIndicatorBounds, mDisplayShape, mCompatInsetTypes, mCompatIgnoreVisibility, mDisplayShape, systemBars(), false /* compatIgnoreVisibility */, mSystemInsetsConsumed ? null : mTypeBoundingRectsMap, mStableInsetsConsumed ? null : mTypeMaxBoundingRectsMap, mFrameWidth, mFrameHeight); Loading Loading @@ -2087,17 +2084,6 @@ public final class WindowInsets { return STATUS_BARS | NAVIGATION_BARS | CAPTION_BAR | SYSTEM_OVERLAYS; } /** * @return Default compatible types. * * @see #getSystemWindowInsets() * @hide */ @InsetsType public static int defaultCompatible() { return systemBars() | displayCutout(); } /** * @return Default visible types. * Loading core/tests/coretests/src/android/view/WindowInsetsTest.java +0 −73 Original line number Diff line number Diff line Loading @@ -145,36 +145,6 @@ public class WindowInsetsTest { .consumeSystemWindowInsets().isConsumed()); } /** * Verifies that {@link WindowInsets#getSystemWindowInsets} returns the maximum value at each * side between typeInsetsMap and typeMaxInsetsMap regarding compatInsetsTypes when * compatIgnoreVisibility is true. */ @Test public void systemWindowInsets_compatIgnoreVisibility() { Insets[] insets = new Insets[TYPES.length]; Insets[] maxInsets = new Insets[TYPES.length]; boolean[] visible = new boolean[TYPES.length]; // Creates Windowinsets with larger values in typeInsetsMap than ones in typeMaxInsetsMap. WindowInsets.assignCompatInsets(insets, new Rect(5, 6, 7, 8)); WindowInsets.assignCompatInsets(maxInsets, new Rect(1, 2, 3, 4)); WindowInsets windowInsets1 = new WindowInsets(insets, maxInsets, visible, false, 0, false, 0, null, null, null, DisplayShape.NONE, systemBars(), true /* compatIgnoreVisibility */, null, null, 0, 0); // If compatIgnoreVisibility is true, getSystemWindowInsets should return the larger values. assertEquals(Insets.of(5, 6, 7, 8), windowInsets1.getSystemWindowInsets()); // Creates Windowinsets with larger values in typeMaxInsetsMap than ones in typeInsetsMap WindowInsets.assignCompatInsets(insets, new Rect(1, 2, 3, 4)); WindowInsets.assignCompatInsets(maxInsets, new Rect(5, 6, 7, 8)); WindowInsets windowInsets2 = new WindowInsets(insets, maxInsets, visible, false, 0, false, 0, null, null, null, DisplayShape.NONE, systemBars(), true /* compatIgnoreVisibility */, null, null, 0, 0); // If compatIgnoreVisibility is true, getSystemWindowInsets should return the larger values. assertEquals(Insets.of(5, 6, 7, 8), windowInsets2.getSystemWindowInsets()); } @Test public void multiNullConstructor_isConsumed() { assertTrue(new WindowInsets(null, null, null, false, 0, false, 0, null, null, null, null, Loading @@ -199,49 +169,6 @@ public class WindowInsetsTest { assertEquals(Insets.of(0, 10, 0, 0), windowInsets.getSystemWindowInsets()); } @Test public void builder_copy_compatInsetTypes() { final Insets[] insets = new Insets[TYPES.length]; final Insets[] maxInsets = new Insets[TYPES.length]; final boolean[] visible = new boolean[TYPES.length]; final int compatInsetTypes = systemBars() | displayCutout() | ime(); final WindowInsets windowInsets = new WindowInsets(insets, maxInsets, visible, false, 0, false, 0, null, null, null, DisplayShape.NONE, compatInsetTypes, false /* compatIgnoreVisibility */, null, null, 0, 0); final WindowInsets modified = new WindowInsets.Builder(windowInsets) .setInsets(statusBars(), Insets.of(0, 10, 0, 0)) .setInsets(navigationBars(), Insets.of(0, 0, 20, 0)) .setInsets(displayCutout(), Insets.of(30, 0, 0, 0)) .setInsets(ime(), Insets.of(0, 0, 0, 40)) .build(); assertEquals(Insets.of(30, 10, 20, 40), modified.getSystemWindowInsets()); } @Test public void builder_copy_compatIgnoreVisibility() { final Insets[] insets = new Insets[TYPES.length]; final Insets[] maxInsets = new Insets[TYPES.length]; final boolean[] visible = new boolean[TYPES.length]; final int compatInsetTypes = systemBars() | displayCutout(); final WindowInsets windowInsets = new WindowInsets(insets, maxInsets, visible, false, 0, false, 0, null, null, null, DisplayShape.NONE, compatInsetTypes, true /* compatIgnoreVisibility */, null, null, 0, 0); final WindowInsets modified = new WindowInsets.Builder(windowInsets) .setInsetsIgnoringVisibility(statusBars(), Insets.of(0, 10, 0, 0)) .setInsetsIgnoringVisibility(navigationBars(), Insets.of(0, 0, 20, 0)) .setInsetsIgnoringVisibility(displayCutout(), Insets.of(30, 0, 0, 0)) .build(); assertEquals(Insets.of(30, 10, 20, 0), modified.getSystemWindowInsets()); } @Test public void builder_displayCutout_getSystemWindowInsets() { final WindowInsets windowInsets = new WindowInsets.Builder() .setInsets(displayCutout(), Insets.of(0, 10, 0, 0)) .build(); assertEquals(Insets.of(0, 10, 0, 0), windowInsets.getSystemWindowInsets()); } @Test public void testSetBoundingRectsInBuilder_noInsets_preservedInWindowInsets() { final List<Rect> rects = List.of(new Rect(0, 0, 50, 100)); Loading Loading
core/java/android/view/InsetsState.java +4 −5 Original line number Diff line number Diff line Loading @@ -17,18 +17,17 @@ package android.view; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.DISPLAY_CUTOUT; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.DISPLAY_FRAME; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.SOURCES; import static android.util.SequenceUtils.getInitSeq; import static android.view.InsetsSource.FLAG_FORCE_CONSUMING; import static android.view.InsetsSource.FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR; import static android.view.InsetsSource.FLAG_INSETS_ROUNDED_CORNER; import static android.view.InsetsSource.FLAG_INVALID; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.DISPLAY_CUTOUT; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.DISPLAY_FRAME; import static android.internal.perfetto.protos.Insetsstate.InsetsStateProto.SOURCES; import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE; import static android.view.WindowInsets.Type.TYPES; import static android.view.WindowInsets.Type.captionBar; import static android.view.WindowInsets.Type.defaultCompatible; import static android.view.WindowInsets.Type.displayCutout; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.indexOf; Loading Loading @@ -194,7 +193,7 @@ public class InsetsState implements Parcelable { final int softInputAdjustMode = legacySoftInputMode & SOFT_INPUT_MASK_ADJUST; @InsetsType int compatInsetsTypes = defaultCompatible(); int compatInsetsTypes = systemBars() | displayCutout(); if (softInputAdjustMode == SOFT_INPUT_ADJUST_RESIZE) { compatInsetsTypes |= ime(); } Loading
core/java/android/view/WindowInsets.java +23 −37 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import static android.view.WindowInsets.Type.SYSTEM_GESTURES; import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT; import static android.view.WindowInsets.Type.TYPES; import static android.view.WindowInsets.Type.all; import static android.view.WindowInsets.Type.defaultCompatible; import static android.view.WindowInsets.Type.displayCutout; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.indexOf; Loading Loading @@ -138,7 +137,7 @@ public final class WindowInsets { static { CONSUMED = new WindowInsets(createCompatTypeMap(null), createCompatTypeMap(null), createCompatVisibilityMap(createCompatTypeMap(null)), false, 0, false, 0, null, null, null, null, defaultCompatible(), false, null, null, 0, 0); null, null, null, systemBars(), false, null, null, 0, 0); } /** Loading Loading @@ -280,7 +279,7 @@ public final class WindowInsets { @UnsupportedAppUsage public WindowInsets(@Nullable Rect systemWindowInsets) { this(createCompatTypeMap(systemWindowInsets), null, new boolean[TYPES.length], false, 0, false, 0, null, null, null, null, defaultCompatible(), false, 0, null, null, null, null, systemBars(), false /* compatIgnoreVisibility */, new Rect[TYPES.length][], null, 0, 0); } Loading Loading @@ -357,16 +356,20 @@ public final class WindowInsets { * </p> * * @return The system window insets * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} */ @Deprecated @NonNull public Insets getSystemWindowInsets() { final Insets result = getInsets(mCompatInsetsTypes); return mCompatIgnoreVisibility ? Insets.max(result, getInsetsIgnoringVisibility(mCompatInsetsTypes & ~ime())) : result; Insets result = mCompatIgnoreVisibility ? getInsetsIgnoringVisibility(mCompatInsetsTypes & ~ime()) : getInsets(mCompatInsetsTypes); // We can't query max insets for IME, so we need to add it manually after. if ((mCompatInsetsTypes & ime()) != 0 && mCompatIgnoreVisibility) { result = Insets.max(result, getInsets(ime())); } return result; } /** Loading Loading @@ -436,8 +439,8 @@ public final class WindowInsets { * </p> * * @return The left system window inset * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} * instead. */ @Deprecated public int getSystemWindowInsetLeft() { Loading @@ -452,8 +455,8 @@ public final class WindowInsets { * </p> * * @return The top system window inset * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} * instead. */ @Deprecated public int getSystemWindowInsetTop() { Loading @@ -468,8 +471,8 @@ public final class WindowInsets { * </p> * * @return The right system window inset * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} * instead. */ @Deprecated public int getSystemWindowInsetRight() { Loading @@ -484,8 +487,8 @@ public final class WindowInsets { * </p> * * @return The bottom system window inset * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} * instead. */ @Deprecated public int getSystemWindowInsetBottom() { Loading @@ -500,8 +503,8 @@ public final class WindowInsets { * </p> * * @return true if any of the system window inset values are nonzero * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} OR * {@link Type#displayCutout()} instead. * @deprecated Use {@link #getInsets(int)} with {@link Type#systemBars()} * instead. */ @Deprecated public boolean hasSystemWindowInsets() { Loading Loading @@ -1408,8 +1411,6 @@ public final class WindowInsets { private final Rect[][] mTypeBoundingRectsMap; @NonNull private final Rect[][] mTypeMaxBoundingRectsMap; private final @InsetsType int mCompatInsetTypes; private final boolean mCompatIgnoreVisibility; private boolean mSystemInsetsConsumed = true; private boolean mStableInsetsConsumed = true; Loading Loading @@ -1441,8 +1442,6 @@ public final class WindowInsets { mTypeVisibilityMap = new boolean[TYPES.length]; mTypeBoundingRectsMap = new Rect[TYPES.length][]; mTypeMaxBoundingRectsMap = new Rect[TYPES.length][]; mCompatInsetTypes = defaultCompatible(); mCompatIgnoreVisibility = false; } /** Loading @@ -1454,8 +1453,6 @@ public final class WindowInsets { mTypeInsetsMap = insets.mTypeInsetsMap.clone(); mTypeMaxInsetsMap = insets.mTypeMaxInsetsMap.clone(); mTypeVisibilityMap = insets.mTypeVisibilityMap.clone(); mCompatInsetTypes = insets.mCompatInsetsTypes; mCompatIgnoreVisibility = insets.mCompatIgnoreVisibility; mSystemInsetsConsumed = insets.mSystemWindowInsetsConsumed; mStableInsetsConsumed = insets.mStableInsetsConsumed; mDisplayCutout = displayCutoutCopyConstructorArgument(insets); Loading Loading @@ -1831,7 +1828,7 @@ public final class WindowInsets { mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap, mIsRound, mForceConsumingTypes, mForceConsumingOpaqueCaptionBar, mSuppressScrimTypes, mDisplayCutout, mRoundedCorners, mPrivacyIndicatorBounds, mDisplayShape, mCompatInsetTypes, mCompatIgnoreVisibility, mDisplayShape, systemBars(), false /* compatIgnoreVisibility */, mSystemInsetsConsumed ? null : mTypeBoundingRectsMap, mStableInsetsConsumed ? null : mTypeMaxBoundingRectsMap, mFrameWidth, mFrameHeight); Loading Loading @@ -2087,17 +2084,6 @@ public final class WindowInsets { return STATUS_BARS | NAVIGATION_BARS | CAPTION_BAR | SYSTEM_OVERLAYS; } /** * @return Default compatible types. * * @see #getSystemWindowInsets() * @hide */ @InsetsType public static int defaultCompatible() { return systemBars() | displayCutout(); } /** * @return Default visible types. * Loading
core/tests/coretests/src/android/view/WindowInsetsTest.java +0 −73 Original line number Diff line number Diff line Loading @@ -145,36 +145,6 @@ public class WindowInsetsTest { .consumeSystemWindowInsets().isConsumed()); } /** * Verifies that {@link WindowInsets#getSystemWindowInsets} returns the maximum value at each * side between typeInsetsMap and typeMaxInsetsMap regarding compatInsetsTypes when * compatIgnoreVisibility is true. */ @Test public void systemWindowInsets_compatIgnoreVisibility() { Insets[] insets = new Insets[TYPES.length]; Insets[] maxInsets = new Insets[TYPES.length]; boolean[] visible = new boolean[TYPES.length]; // Creates Windowinsets with larger values in typeInsetsMap than ones in typeMaxInsetsMap. WindowInsets.assignCompatInsets(insets, new Rect(5, 6, 7, 8)); WindowInsets.assignCompatInsets(maxInsets, new Rect(1, 2, 3, 4)); WindowInsets windowInsets1 = new WindowInsets(insets, maxInsets, visible, false, 0, false, 0, null, null, null, DisplayShape.NONE, systemBars(), true /* compatIgnoreVisibility */, null, null, 0, 0); // If compatIgnoreVisibility is true, getSystemWindowInsets should return the larger values. assertEquals(Insets.of(5, 6, 7, 8), windowInsets1.getSystemWindowInsets()); // Creates Windowinsets with larger values in typeMaxInsetsMap than ones in typeInsetsMap WindowInsets.assignCompatInsets(insets, new Rect(1, 2, 3, 4)); WindowInsets.assignCompatInsets(maxInsets, new Rect(5, 6, 7, 8)); WindowInsets windowInsets2 = new WindowInsets(insets, maxInsets, visible, false, 0, false, 0, null, null, null, DisplayShape.NONE, systemBars(), true /* compatIgnoreVisibility */, null, null, 0, 0); // If compatIgnoreVisibility is true, getSystemWindowInsets should return the larger values. assertEquals(Insets.of(5, 6, 7, 8), windowInsets2.getSystemWindowInsets()); } @Test public void multiNullConstructor_isConsumed() { assertTrue(new WindowInsets(null, null, null, false, 0, false, 0, null, null, null, null, Loading @@ -199,49 +169,6 @@ public class WindowInsetsTest { assertEquals(Insets.of(0, 10, 0, 0), windowInsets.getSystemWindowInsets()); } @Test public void builder_copy_compatInsetTypes() { final Insets[] insets = new Insets[TYPES.length]; final Insets[] maxInsets = new Insets[TYPES.length]; final boolean[] visible = new boolean[TYPES.length]; final int compatInsetTypes = systemBars() | displayCutout() | ime(); final WindowInsets windowInsets = new WindowInsets(insets, maxInsets, visible, false, 0, false, 0, null, null, null, DisplayShape.NONE, compatInsetTypes, false /* compatIgnoreVisibility */, null, null, 0, 0); final WindowInsets modified = new WindowInsets.Builder(windowInsets) .setInsets(statusBars(), Insets.of(0, 10, 0, 0)) .setInsets(navigationBars(), Insets.of(0, 0, 20, 0)) .setInsets(displayCutout(), Insets.of(30, 0, 0, 0)) .setInsets(ime(), Insets.of(0, 0, 0, 40)) .build(); assertEquals(Insets.of(30, 10, 20, 40), modified.getSystemWindowInsets()); } @Test public void builder_copy_compatIgnoreVisibility() { final Insets[] insets = new Insets[TYPES.length]; final Insets[] maxInsets = new Insets[TYPES.length]; final boolean[] visible = new boolean[TYPES.length]; final int compatInsetTypes = systemBars() | displayCutout(); final WindowInsets windowInsets = new WindowInsets(insets, maxInsets, visible, false, 0, false, 0, null, null, null, DisplayShape.NONE, compatInsetTypes, true /* compatIgnoreVisibility */, null, null, 0, 0); final WindowInsets modified = new WindowInsets.Builder(windowInsets) .setInsetsIgnoringVisibility(statusBars(), Insets.of(0, 10, 0, 0)) .setInsetsIgnoringVisibility(navigationBars(), Insets.of(0, 0, 20, 0)) .setInsetsIgnoringVisibility(displayCutout(), Insets.of(30, 0, 0, 0)) .build(); assertEquals(Insets.of(30, 10, 20, 0), modified.getSystemWindowInsets()); } @Test public void builder_displayCutout_getSystemWindowInsets() { final WindowInsets windowInsets = new WindowInsets.Builder() .setInsets(displayCutout(), Insets.of(0, 10, 0, 0)) .build(); assertEquals(Insets.of(0, 10, 0, 0), windowInsets.getSystemWindowInsets()); } @Test public void testSetBoundingRectsInBuilder_noInsets_preservedInWindowInsets() { final List<Rect> rects = List.of(new Rect(0, 0, 50, 100)); Loading