From 3381108be2e5676fce016c4061155c47a82e5269 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Thu, 27 Feb 2020 19:03:39 +0100 Subject: [PATCH] Unhide WindowInsets#inset with insets argument Test: WindowInsetsAnimationTests Bug: 118118435 Change-Id: I359ac49403bfc63120d4e9565e4fa7801a840333 --- api/current.txt | 1 + core/java/android/view/WindowInsets.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/api/current.txt b/api/current.txt index 1227006dbe046..3462be934705f 100644 --- a/api/current.txt +++ b/api/current.txt @@ -55459,6 +55459,7 @@ package android.view { method public boolean hasInsets(); method @Deprecated public boolean hasStableInsets(); method @Deprecated public boolean hasSystemWindowInsets(); + method @NonNull public android.view.WindowInsets inset(@NonNull android.graphics.Insets); method @NonNull public android.view.WindowInsets inset(@IntRange(from=0) int, @IntRange(from=0) int, @IntRange(from=0) int, @IntRange(from=0) int); method public boolean isConsumed(); method public boolean isRound(); diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java index a6c311e1daa5a..75e26a33d9afe 100644 --- a/core/java/android/view/WindowInsets.java +++ b/core/java/android/view/WindowInsets.java @@ -857,11 +857,21 @@ public final class WindowInsets { /** * Returns a copy of this instance inset in the given directions. * + * This is intended for dispatching insets to areas of the window that are smaller than the + * current area. + * + *

Example: + *

+     * childView.dispatchApplyWindowInsets(insets.inset(childMargins));
+     * 
+ * + * @param insets the amount of insets to remove from all sides. + * * @see #inset(int, int, int, int) - * @hide */ @NonNull - public WindowInsets inset(Insets insets) { + public WindowInsets inset(@NonNull Insets insets) { + Objects.requireNonNull(insets); return inset(insets.left, insets.top, insets.right, insets.bottom); } @@ -883,6 +893,8 @@ public final class WindowInsets { * @param bottom the amount of insets to remove from the bottom. Must be non-negative. * * @return the inset insets + * + * @see #inset(Insets) */ @NonNull public WindowInsets inset(@IntRange(from = 0) int left, @IntRange(from = 0) int top,