Unhide APIs in WindowInsetsCompat and ViewDragHelper
The APIs were added in I3f2694decc56bd1416cffe4fd6e3057037d57c28
but we were in API freeze.
BUG: 134704438
Test: ./gradlew checkApi
Change-Id: Ia334575e10003d7f9c5ca8533a9e3e7d8c14e5cd
diff --git a/core/core/api/1.2.0-alpha02.txt b/core/core/api/1.2.0-alpha02.txt
index db34b49..09d5cc1 100644
--- a/core/core/api/1.2.0-alpha02.txt
+++ b/core/core/api/1.2.0-alpha02.txt
@@ -2313,6 +2313,8 @@
method public boolean isRound();
method public androidx.core.view.WindowInsetsCompat! replaceSystemWindowInsets(int, int, int, int);
method public androidx.core.view.WindowInsetsCompat! replaceSystemWindowInsets(android.graphics.Rect!);
+ method @RequiresApi(20) public android.view.WindowInsets? toWindowInsets();
+ method @RequiresApi(20) public static androidx.core.view.WindowInsetsCompat toWindowInsetsCompat(android.view.WindowInsets);
}
}
diff --git a/core/core/api/current.txt b/core/core/api/current.txt
index db34b49..09d5cc1 100644
--- a/core/core/api/current.txt
+++ b/core/core/api/current.txt
@@ -2313,6 +2313,8 @@
method public boolean isRound();
method public androidx.core.view.WindowInsetsCompat! replaceSystemWindowInsets(int, int, int, int);
method public androidx.core.view.WindowInsetsCompat! replaceSystemWindowInsets(android.graphics.Rect!);
+ method @RequiresApi(20) public android.view.WindowInsets? toWindowInsets();
+ method @RequiresApi(20) public static androidx.core.view.WindowInsetsCompat toWindowInsetsCompat(android.view.WindowInsets);
}
}
diff --git a/core/core/api/restricted_1.2.0-alpha02.txt b/core/core/api/restricted_1.2.0-alpha02.txt
index de17564..b3e6ec9 100644
--- a/core/core/api/restricted_1.2.0-alpha02.txt
+++ b/core/core/api/restricted_1.2.0-alpha02.txt
@@ -521,11 +521,6 @@
@IntDef(flag=true, value={androidx.core.view.ViewCompat.SCROLL_INDICATOR_TOP, androidx.core.view.ViewCompat.SCROLL_INDICATOR_BOTTOM, androidx.core.view.ViewCompat.SCROLL_INDICATOR_LEFT, androidx.core.view.ViewCompat.SCROLL_INDICATOR_RIGHT, androidx.core.view.ViewCompat.SCROLL_INDICATOR_START, androidx.core.view.ViewCompat.SCROLL_INDICATOR_END}) @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) public static @interface ViewCompat.ScrollIndicators {
}
- public class WindowInsetsCompat {
- method @RequiresApi(20) @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public static android.view.WindowInsets? unwrap(androidx.core.view.WindowInsetsCompat);
- method @RequiresApi(20) @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public static androidx.core.view.WindowInsetsCompat wrap(android.view.WindowInsets);
- }
-
}
package androidx.core.view.accessibility {
diff --git a/core/core/api/restricted_current.txt b/core/core/api/restricted_current.txt
index de17564..b3e6ec9 100644
--- a/core/core/api/restricted_current.txt
+++ b/core/core/api/restricted_current.txt
@@ -521,11 +521,6 @@
@IntDef(flag=true, value={androidx.core.view.ViewCompat.SCROLL_INDICATOR_TOP, androidx.core.view.ViewCompat.SCROLL_INDICATOR_BOTTOM, androidx.core.view.ViewCompat.SCROLL_INDICATOR_LEFT, androidx.core.view.ViewCompat.SCROLL_INDICATOR_RIGHT, androidx.core.view.ViewCompat.SCROLL_INDICATOR_START, androidx.core.view.ViewCompat.SCROLL_INDICATOR_END}) @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) public static @interface ViewCompat.ScrollIndicators {
}
- public class WindowInsetsCompat {
- method @RequiresApi(20) @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public static android.view.WindowInsets? unwrap(androidx.core.view.WindowInsetsCompat);
- method @RequiresApi(20) @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public static androidx.core.view.WindowInsetsCompat wrap(android.view.WindowInsets);
- }
-
}
package androidx.core.view.accessibility {
diff --git a/core/core/src/main/java/androidx/core/view/ViewCompat.java b/core/core/src/main/java/androidx/core/view/ViewCompat.java
index e04f5c6..526fd12 100644
--- a/core/core/src/main/java/androidx/core/view/ViewCompat.java
+++ b/core/core/src/main/java/androidx/core/view/ViewCompat.java
@@ -2434,13 +2434,11 @@
return;
}
- v.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
- @Override
- public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
- WindowInsetsCompat compatInsets = WindowInsetsCompat.wrap(insets);
- compatInsets = listener.onApplyWindowInsets(view, compatInsets);
- return WindowInsetsCompat.unwrap(compatInsets);
- }
+ v.setOnApplyWindowInsetsListener((view, insets) -> {
+ WindowInsetsCompat compatInsets = WindowInsetsCompat
+ .toWindowInsetsCompat(insets);
+ compatInsets = listener.onApplyWindowInsets(view, compatInsets);
+ return compatInsets.toWindowInsets();
});
}
}
@@ -2460,12 +2458,12 @@
public static WindowInsetsCompat onApplyWindowInsets(@NonNull View view,
WindowInsetsCompat insets) {
if (Build.VERSION.SDK_INT >= 21) {
- WindowInsets unwrapped = WindowInsetsCompat.unwrap(insets);
+ WindowInsets unwrapped = insets.toWindowInsets();
WindowInsets result = view.onApplyWindowInsets(unwrapped);
if (!result.equals(unwrapped)) {
unwrapped = new WindowInsets(result);
}
- return WindowInsetsCompat.wrap(unwrapped);
+ return WindowInsetsCompat.toWindowInsetsCompat(unwrapped);
}
return insets;
}
@@ -2485,12 +2483,12 @@
public static WindowInsetsCompat dispatchApplyWindowInsets(@NonNull View view,
WindowInsetsCompat insets) {
if (Build.VERSION.SDK_INT >= 21) {
- WindowInsets unwrapped = WindowInsetsCompat.unwrap(insets);
+ WindowInsets unwrapped = insets.toWindowInsets();
WindowInsets result = view.dispatchApplyWindowInsets(unwrapped);
if (!result.equals(unwrapped)) {
unwrapped = new WindowInsets(result);
}
- return WindowInsetsCompat.wrap(unwrapped);
+ return WindowInsetsCompat.toWindowInsetsCompat(unwrapped);
}
return insets;
}
diff --git a/core/core/src/main/java/androidx/core/view/WindowInsetsCompat.java b/core/core/src/main/java/androidx/core/view/WindowInsetsCompat.java
index f97e989..85f0ff0 100644
--- a/core/core/src/main/java/androidx/core/view/WindowInsetsCompat.java
+++ b/core/core/src/main/java/androidx/core/view/WindowInsetsCompat.java
@@ -520,29 +520,25 @@
}
/**
+ * Return the source {@link WindowInsets} instance used in this {@link WindowInsetsCompat}.
+ *
+ * @return the wrapped WindowInsets instance
+ */
+ @Nullable
+ @RequiresApi(20)
+ public WindowInsets toWindowInsets() {
+ return (WindowInsets) mInsets;
+ }
+
+ /**
* Wrap an instance of {@link WindowInsets} into a {@link WindowInsetsCompat}.
*
* @param insets source insets to wrap
* @return the wrapped instance
- *
- * @hide
*/
@NonNull
@RequiresApi(20)
- @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
- public static WindowInsetsCompat wrap(@NonNull WindowInsets insets) {
+ public static WindowInsetsCompat toWindowInsetsCompat(@NonNull WindowInsets insets) {
return new WindowInsetsCompat(Objects.requireNonNull(insets));
}
-
- /**
- * Unwrap the given WindowInsetsCompat and return the source {@link WindowInsets} instance.
- *
- * @hide
- */
- @Nullable
- @RequiresApi(20)
- @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
- public static WindowInsets unwrap(@NonNull WindowInsetsCompat insets) {
- return (WindowInsets) insets.mInsets;
- }
}
diff --git a/customview/api/1.1.0-alpha01.txt b/customview/api/1.1.0-alpha01.txt
index c9a1369..34ea985 100644
--- a/customview/api/1.1.0-alpha01.txt
+++ b/customview/api/1.1.0-alpha01.txt
@@ -56,6 +56,7 @@
method public void flingCapturedView(int, int, int, int);
method public int getActivePointerId();
method public android.view.View? getCapturedView();
+ method @Px public int getDefaultEdgeSize();
method @Px public int getEdgeSize();
method public float getMinVelocity();
method @Px public int getTouchSlop();
@@ -66,6 +67,7 @@
method public boolean isPointerDown(int);
method public boolean isViewUnder(android.view.View?, int, int);
method public void processTouchEvent(android.view.MotionEvent);
+ method public void setEdgeSize(@Px @IntRange(from=0) int);
method public void setEdgeTrackingEnabled(int);
method public void setMinVelocity(float);
method public boolean settleCapturedViewAt(int, int);
diff --git a/customview/api/current.txt b/customview/api/current.txt
index c9a1369..34ea985 100644
--- a/customview/api/current.txt
+++ b/customview/api/current.txt
@@ -56,6 +56,7 @@
method public void flingCapturedView(int, int, int, int);
method public int getActivePointerId();
method public android.view.View? getCapturedView();
+ method @Px public int getDefaultEdgeSize();
method @Px public int getEdgeSize();
method public float getMinVelocity();
method @Px public int getTouchSlop();
@@ -66,6 +67,7 @@
method public boolean isPointerDown(int);
method public boolean isViewUnder(android.view.View?, int, int);
method public void processTouchEvent(android.view.MotionEvent);
+ method public void setEdgeSize(@Px @IntRange(from=0) int);
method public void setEdgeTrackingEnabled(int);
method public void setMinVelocity(float);
method public boolean settleCapturedViewAt(int, int);
diff --git a/customview/api/restricted_1.1.0-alpha01.txt b/customview/api/restricted_1.1.0-alpha01.txt
index ae89e29..da4f6cc 100644
--- a/customview/api/restricted_1.1.0-alpha01.txt
+++ b/customview/api/restricted_1.1.0-alpha01.txt
@@ -1,10 +1 @@
// Signature format: 3.0
-package androidx.customview.widget {
-
- public class ViewDragHelper {
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) @Px public int getDefaultEdgeSize();
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setEdgeSize(@Px @IntRange(from=0) int);
- }
-
-}
-
diff --git a/customview/api/restricted_current.txt b/customview/api/restricted_current.txt
index ae89e29..da4f6cc 100644
--- a/customview/api/restricted_current.txt
+++ b/customview/api/restricted_current.txt
@@ -1,10 +1 @@
// Signature format: 3.0
-package androidx.customview.widget {
-
- public class ViewDragHelper {
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) @Px public int getDefaultEdgeSize();
- method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public void setEdgeSize(@Px @IntRange(from=0) int);
- }
-
-}
-
diff --git a/customview/src/main/java/androidx/customview/widget/ViewDragHelper.java b/customview/src/main/java/androidx/customview/widget/ViewDragHelper.java
index f799354..e6a32cc 100644
--- a/customview/src/main/java/androidx/customview/widget/ViewDragHelper.java
+++ b/customview/src/main/java/androidx/customview/widget/ViewDragHelper.java
@@ -31,7 +31,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
-import androidx.annotation.RestrictTo;
import androidx.core.view.ViewCompat;
import java.util.Arrays;
@@ -471,10 +470,7 @@
*
* @see #setEdgeTrackingEnabled(int)
* @see #getEdgeSize()
- *
- * @hide
*/
- @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
public void setEdgeSize(@Px @IntRange(from = 0) int size) {
mEdgeSize = size;
}
@@ -486,10 +482,7 @@
*
* @see #setEdgeTrackingEnabled(int)
* @see #getEdgeSize()
- *
- * @hide
*/
- @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
@Px
public int getDefaultEdgeSize() {
return mDefaultEdgeSize;
diff --git a/drawerlayout/src/main/java/androidx/drawerlayout/widget/DrawerLayout.java b/drawerlayout/src/main/java/androidx/drawerlayout/widget/DrawerLayout.java
index 6fdf811..6954d5c 100644
--- a/drawerlayout/src/main/java/androidx/drawerlayout/widget/DrawerLayout.java
+++ b/drawerlayout/src/main/java/androidx/drawerlayout/widget/DrawerLayout.java
@@ -1307,7 +1307,8 @@
// Update the ViewDragHelper edge sizes to match the gesture insets
WindowInsets rootInsets = getRootWindowInsets();
if (rootInsets != null) {
- WindowInsetsCompat rootInsetsCompat = WindowInsetsCompat.wrap(rootInsets);
+ WindowInsetsCompat rootInsetsCompat = WindowInsetsCompat
+ .toWindowInsetsCompat(rootInsets);
Insets gestureInsets = rootInsetsCompat.getSystemGestureInsets();
// We use Math.max() here since the gesture insets will be 0 if the device