[go: nahoru, domu]

Make RotaryScrollEvent API Stable

Bug: 261561229
Test: ./gradlew compose:ui:ui:cC -P android.testInstrumentationRunnerArguments.package=androidx.compose.ui.input.rotary.RotaryScrollEventTest

Relnote: The Rotary Scroll Event API is now stable
Change-Id: I42ad3a466855a165c905dc9e965d140da7269636
diff --git a/compose/ui/ui/api/current.txt b/compose/ui/ui/api/current.txt
index aa8aa59..64f1e59 100644
--- a/compose/ui/ui/api/current.txt
+++ b/compose/ui/ui/api/current.txt
@@ -1775,6 +1775,17 @@
 package androidx.compose.ui.input.rotary {
 
   public final class RotaryInputModifierKt {
+    method public static androidx.compose.ui.Modifier onPreRotaryScrollEvent(androidx.compose.ui.Modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.input.rotary.RotaryScrollEvent,java.lang.Boolean> onPreRotaryScrollEvent);
+    method public static androidx.compose.ui.Modifier onRotaryScrollEvent(androidx.compose.ui.Modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.input.rotary.RotaryScrollEvent,java.lang.Boolean> onRotaryScrollEvent);
+  }
+
+  public final class RotaryScrollEvent {
+    method public float getHorizontalScrollPixels();
+    method public long getUptimeMillis();
+    method public float getVerticalScrollPixels();
+    property public final float horizontalScrollPixels;
+    property public final long uptimeMillis;
+    property public final float verticalScrollPixels;
   }
 
 }
diff --git a/compose/ui/ui/api/public_plus_experimental_current.txt b/compose/ui/ui/api/public_plus_experimental_current.txt
index 5199a29..311f6cb 100644
--- a/compose/ui/ui/api/public_plus_experimental_current.txt
+++ b/compose/ui/ui/api/public_plus_experimental_current.txt
@@ -1951,8 +1951,8 @@
 package androidx.compose.ui.input.rotary {
 
   public final class RotaryInputModifierKt {
-    method @androidx.compose.ui.ExperimentalComposeUiApi public static androidx.compose.ui.Modifier onPreRotaryScrollEvent(androidx.compose.ui.Modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.input.rotary.RotaryScrollEvent,java.lang.Boolean> onPreRotaryScrollEvent);
-    method @androidx.compose.ui.ExperimentalComposeUiApi public static androidx.compose.ui.Modifier onRotaryScrollEvent(androidx.compose.ui.Modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.input.rotary.RotaryScrollEvent,java.lang.Boolean> onRotaryScrollEvent);
+    method public static androidx.compose.ui.Modifier onPreRotaryScrollEvent(androidx.compose.ui.Modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.input.rotary.RotaryScrollEvent,java.lang.Boolean> onPreRotaryScrollEvent);
+    method public static androidx.compose.ui.Modifier onRotaryScrollEvent(androidx.compose.ui.Modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.input.rotary.RotaryScrollEvent,java.lang.Boolean> onRotaryScrollEvent);
   }
 
   @androidx.compose.ui.ExperimentalComposeUiApi public interface RotaryInputModifierNode extends androidx.compose.ui.node.DelegatableNode {
@@ -1960,7 +1960,7 @@
     method public boolean onRotaryScrollEvent(androidx.compose.ui.input.rotary.RotaryScrollEvent event);
   }
 
-  @androidx.compose.ui.ExperimentalComposeUiApi public final class RotaryScrollEvent {
+  public final class RotaryScrollEvent {
     method public float getHorizontalScrollPixels();
     method public long getUptimeMillis();
     method public float getVerticalScrollPixels();
diff --git a/compose/ui/ui/api/restricted_current.txt b/compose/ui/ui/api/restricted_current.txt
index 7d8ccd9..8e347f9 100644
--- a/compose/ui/ui/api/restricted_current.txt
+++ b/compose/ui/ui/api/restricted_current.txt
@@ -1775,6 +1775,17 @@
 package androidx.compose.ui.input.rotary {
 
   public final class RotaryInputModifierKt {
+    method public static androidx.compose.ui.Modifier onPreRotaryScrollEvent(androidx.compose.ui.Modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.input.rotary.RotaryScrollEvent,java.lang.Boolean> onPreRotaryScrollEvent);
+    method public static androidx.compose.ui.Modifier onRotaryScrollEvent(androidx.compose.ui.Modifier, kotlin.jvm.functions.Function1<? super androidx.compose.ui.input.rotary.RotaryScrollEvent,java.lang.Boolean> onRotaryScrollEvent);
+  }
+
+  public final class RotaryScrollEvent {
+    method public float getHorizontalScrollPixels();
+    method public long getUptimeMillis();
+    method public float getVerticalScrollPixels();
+    property public final float horizontalScrollPixels;
+    property public final long uptimeMillis;
+    property public final float verticalScrollPixels;
   }
 
 }
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/focus/FocusAwareEventPropagationTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/focus/FocusAwareEventPropagationTest.kt
index 3350d69..6845b6a 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/focus/FocusAwareEventPropagationTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/focus/FocusAwareEventPropagationTest.kt
@@ -54,14 +54,12 @@
  * [androidx.compose.ui.input.rotary.RotaryScrollEvent]s, but it is meant to test the generic
  * propagation logic for all focus-aware events.
  */
-@OptIn(ExperimentalComposeUiApi::class)
 @MediumTest
 @RunWith(Parameterized::class)
 class FocusAwareEventPropagationTest(private val nodeType: NodeType) {
     @get:Rule
     val rule = createComposeRule()
 
-    @OptIn(ExperimentalComposeUiApi::class)
     private val sentEvent: Any = when (nodeType) {
         KeyInput ->
             KeyEvent(AndroidKeyEvent(AndroidKeyEvent.ACTION_DOWN, AndroidKeyEvent.KEYCODE_A))
@@ -528,6 +526,7 @@
     }
 
     private fun Modifier.onFocusAwareEvent(onEvent: (Any) -> Boolean): Modifier = this.then(
+        @OptIn(ExperimentalComposeUiApi::class)
         when (nodeType) {
             KeyInput -> modifierElementOf(
                 key = onEvent,
@@ -552,6 +551,7 @@
     )
 
     private fun Modifier.onPreFocusAwareEvent(onEvent: (Any) -> Boolean): Modifier = this.then(
+        @OptIn(ExperimentalComposeUiApi::class)
         when (nodeType) {
             KeyInput -> modifierElementOf(
                 key = onEvent,
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEventTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEventTest.kt
index 00613cd..2b9168f 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEventTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEventTest.kt
@@ -25,7 +25,6 @@
 import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.setValue
-import androidx.compose.ui.ExperimentalComposeUiApi
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.focus.FocusRequester
 import androidx.compose.ui.focus.focusRequester
@@ -48,7 +47,6 @@
 import org.junit.Test
 import org.junit.runner.RunWith
 
-@OptIn(ExperimentalComposeUiApi::class)
 @MediumTest
 @RunWith(AndroidJUnit4::class)
 class RotaryScrollEventTest {
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusOwner.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusOwner.kt
index 7393f77..9566714 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusOwner.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/focus/FocusOwner.kt
@@ -82,7 +82,6 @@
     /**
      * Dispatches a rotary scroll event through the compose hierarchy.
      */
-    @OptIn(ExperimentalComposeUiApi::class)
     fun dispatchRotaryEvent(event: RotaryScrollEvent): Boolean
 
     /**
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/rotary/RotaryInputModifier.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/rotary/RotaryInputModifier.kt
index c1d6b0e..6b591e7 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/rotary/RotaryInputModifier.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/rotary/RotaryInputModifier.kt
@@ -48,7 +48,7 @@
     fun onPreRotaryScrollEvent(event: RotaryScrollEvent): Boolean
 }
 
-@ExperimentalComposeUiApi
+@OptIn(ExperimentalComposeUiApi::class)
 internal class RotaryInputModifierNodeImpl(
     var onEvent: ((RotaryScrollEvent) -> Boolean)?,
     var onPreEvent: ((RotaryScrollEvent) -> Boolean)?
@@ -81,10 +81,10 @@
  * @sample androidx.compose.ui.samples.PreRotaryEventSample
  */
 @Suppress("ModifierInspectorInfo") // b/251831790.
-@ExperimentalComposeUiApi
 fun Modifier.onRotaryScrollEvent(
     onRotaryScrollEvent: (RotaryScrollEvent) -> Boolean
 ): Modifier = this.then(
+    @OptIn(ExperimentalComposeUiApi::class)
     modifierElementOf(
         key = onRotaryScrollEvent,
         create = { RotaryInputModifierNodeImpl(  },
@@ -118,10 +118,10 @@
  * @sample androidx.compose.ui.samples.PreRotaryEventSample
  */
 @Suppress("ModifierInspectorInfo") // b/251831790.
-@ExperimentalComposeUiApi
 fun Modifier.onPreRotaryScrollEvent(
     onPreRotaryScrollEvent: (RotaryScrollEvent) -> Boolean
 ): Modifier = this.then(
+    @OptIn(ExperimentalComposeUiApi::class)
     modifierElementOf(
         key = onPreRotaryScrollEvent,
         create = {
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEvent.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEvent.kt
index 732b277..c79101e 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEvent.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEvent.kt
@@ -16,15 +16,12 @@
 
 package androidx.compose.ui.input.rotary
 
-import androidx.compose.ui.ExperimentalComposeUiApi
-
 /**
  * This event represents a rotary input event.
  *
  * Some Wear OS devices contain a physical rotating side button, or a rotating bezel. When the user
  * turns the button or rotates the bezel, a [RotaryScrollEvent] is sent to the item in focus.
  */
-@ExperimentalComposeUiApi
 class RotaryScrollEvent internal constructor(
     /**
      * The amount to scroll (in pixels) in response to a [RotaryScrollEvent] in a container that