Skip to content

Commit

Permalink
Fix issue when rotary modifiers were stopping receiving new rotary ev…
Browse files Browse the repository at this point in the history
…ents (#1751)

* Fix issue when Picker was stopping receiving new rotary events when state was changed.

That was causing an issue with AlarmPicker b/301894733

Was fixed by updating Rotary modifier to the latest version from GOB.

* API update

* Fix issue with

* remove unnecessary annotation

* Remove annotations
  • Loading branch information
Kpeved authored Oct 12, 2023
1 parent 9400000 commit d7942d5
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.google.android.horologist.composables.picker

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import com.google.android.horologist.annotations.ExperimentalHorologistApi
import com.google.android.horologist.compose.rotaryinput.RotaryScrollAdapter

Expand All @@ -24,8 +26,9 @@ import com.google.android.horologist.compose.rotaryinput.RotaryScrollAdapter
/**
* An extension function for creating [RotaryScrollAdapter] from [Picker]
*/
@Composable
internal fun PickerState.toRotaryScrollAdapter(): PickerRotaryScrollAdapter =
PickerRotaryScrollAdapter(this)
remember(this) { PickerRotaryScrollAdapter(this) }

/**
* An implementation of rotary scroll adapter for [Picker]
Expand Down
63 changes: 3 additions & 60 deletions compose-layout/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,6 @@ package com.google.android.horologist.compose.rotaryinput {
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public static androidx.compose.ui.Modifier onRotaryInputAccumulatedWithFocus(androidx.compose.ui.Modifier, optional androidx.compose.ui.focus.FocusRequester? focusRequester, optional boolean isLowRes, kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit> onValueChange);
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public final class AnimationScrollBehavior implements com.google.android.horologist.compose.rotaryinput.RotaryScrollBehavior {
ctor public AnimationScrollBehavior(androidx.compose.foundation.gestures.ScrollableState scrollableState);
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public suspend Object? handleEvent(float targetValue, kotlin.coroutines.Continuation<? super kotlin.Unit>);
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public final class DefaultRotaryFlingBehavior implements com.google.android.horologist.compose.rotaryinput.RotaryFlingBehavior {
ctor public DefaultRotaryFlingBehavior(androidx.compose.foundation.gestures.ScrollableState scrollableState, androidx.compose.foundation.gestures.FlingBehavior flingBehavior, android.view.ViewConfiguration viewConfiguration, long flingTimeframe);
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public void observeEvent(long timestamp, float delta);
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public void startFlingTracking(long timestamp);
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public suspend Object? trackFling(kotlin.jvm.functions.Function0<kotlin.Unit> beforeFling, kotlin.coroutines.Continuation<? super kotlin.Unit>);
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public final class DefaultRotaryHapticFeedback implements com.google.android.horologist.compose.rotaryinput.RotaryHapticFeedback {
ctor public DefaultRotaryHapticFeedback(android.view.View view);
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public void performHapticFeedback(int type);
Expand All @@ -344,15 +332,6 @@ package com.google.android.horologist.compose.rotaryinput {
method public void handleSnapHaptic(float scrollDelta);
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public final class DefaultSnapBehavior implements com.google.android.horologist.compose.rotaryinput.RotarySnapBehavior {
ctor public DefaultSnapBehavior(com.google.android.horologist.compose.rotaryinput.RotaryScrollAdapter rotaryScrollAdapter, com.google.android.horologist.compose.rotaryinput.SnapParameters snapParameters);
method public boolean bottomEdgeReached();
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public void prepareSnapForItems(int moveForElements, boolean sequentialSnap);
method public suspend Object? snapToClosestItem(kotlin.coroutines.Continuation<? super kotlin.Unit>);
method public suspend Object? snapToTargetItem(kotlin.coroutines.Continuation<? super kotlin.Unit>);
method public boolean topEdgeReached();
}

public final class GenericMotionRotaryInputAccumulator {
ctor public GenericMotionRotaryInputAccumulator(android.content.Context context, kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit> onValueChange, optional long eventAccumulationThresholdMs, optional float minValueChangeDistancePx, optional long rateLimitCoolDownMs);
method public boolean onGenericMotionEvent(android.view.MotionEvent event);
Expand All @@ -365,19 +344,12 @@ package com.google.android.horologist.compose.rotaryinput {
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public final class RotaryDefaults {
method public com.google.android.horologist.compose.rotaryinput.SnapParameters getSnapParametersDefault();
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public boolean isLowResInput();
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public com.google.android.horologist.compose.rotaryinput.RotaryScrollHandler rememberFlingHandler(androidx.compose.foundation.gestures.ScrollableState scrollableState, optional androidx.compose.foundation.gestures.FlingBehavior? flingBehavior, optional boolean isLowRes);
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public com.google.android.horologist.compose.rotaryinput.RotaryScrollHandler rememberSnapHandler(com.google.android.horologist.compose.rotaryinput.RotaryScrollAdapter rotaryScrollAdapter, optional com.google.android.horologist.compose.rotaryinput.SnapParameters snapParameters, optional boolean isLowRes);
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public com.google.android.horologist.compose.rotaryinput.SnapParameters snapParametersDefault();
property public final com.google.android.horologist.compose.rotaryinput.SnapParameters snapParametersDefault;
field public static final com.google.android.horologist.compose.rotaryinput.RotaryDefaults INSTANCE;
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public interface RotaryFlingBehavior {
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public void observeEvent(long timestamp, float delta);
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public void startFlingTracking(long timestamp);
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public suspend Object? trackFling(kotlin.jvm.functions.Function0<kotlin.Unit> beforeFling, kotlin.coroutines.Continuation<? super kotlin.Unit>);
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public interface RotaryHapticFeedback {
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public void performHapticFeedback(int type);
}
Expand Down Expand Up @@ -410,12 +382,10 @@ package com.google.android.horologist.compose.rotaryinput {
}

public final class RotaryKt {
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public static kotlinx.coroutines.flow.Flow<com.google.android.horologist.compose.rotaryinput.TimestampedDelta> batchRequestsWithinTimeframe(kotlinx.coroutines.flow.Flow<com.google.android.horologist.compose.rotaryinput.TimestampedDelta>, long timeframe);
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public static androidx.compose.ui.Modifier rotaryHandler(androidx.compose.ui.Modifier, com.google.android.horologist.compose.rotaryinput.RotaryScrollHandler rotaryScrollHandler, boolean reverseDirection, com.google.android.horologist.compose.rotaryinput.RotaryHapticHandler rotaryHaptics);
method @Deprecated @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static androidx.compose.ui.Modifier rotaryWithFling(androidx.compose.ui.Modifier, androidx.compose.ui.focus.FocusRequester focusRequester, androidx.compose.foundation.gestures.ScrollableState scrollableState, optional androidx.compose.foundation.gestures.FlingBehavior flingBehavior, optional com.google.android.horologist.compose.rotaryinput.RotaryHapticHandler rotaryHaptics, optional boolean reverseDirection);
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static androidx.compose.ui.Modifier rotaryWithScroll(androidx.compose.ui.Modifier, androidx.compose.foundation.gestures.ScrollableState scrollableState, optional androidx.compose.ui.focus.FocusRequester focusRequester, optional androidx.compose.foundation.gestures.FlingBehavior? flingBehavior, optional com.google.android.horologist.compose.rotaryinput.RotaryHapticHandler rotaryHaptics, optional boolean reverseDirection);
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static androidx.compose.ui.Modifier rotaryWithSnap(androidx.compose.ui.Modifier, com.google.android.horologist.compose.rotaryinput.RotaryScrollAdapter rotaryScrollAdapter, optional androidx.compose.ui.focus.FocusRequester focusRequester, optional com.google.android.horologist.compose.rotaryinput.SnapParameters snapParameters, optional com.google.android.horologist.compose.rotaryinput.RotaryHapticHandler rotaryHaptics, optional boolean reverseDirection);
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public static com.google.android.horologist.compose.rotaryinput.RotaryScrollAdapter toRotaryScrollAdapter(androidx.wear.compose.foundation.lazy.ScalingLazyListState);
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static com.google.android.horologist.compose.rotaryinput.RotaryScrollAdapter toRotaryScrollAdapter(androidx.wear.compose.foundation.lazy.ScalingLazyListState);
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public interface RotaryScrollAdapter {
Expand All @@ -427,22 +397,6 @@ package com.google.android.horologist.compose.rotaryinput {
property public abstract androidx.compose.foundation.gestures.ScrollableState scrollableState;
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public interface RotaryScrollBehavior {
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public suspend Object? handleEvent(float targetValue, kotlin.coroutines.Continuation<? super kotlin.Unit>);
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public interface RotaryScrollHandler {
method @com.google.android.horologist.annotations.ExperimentalHorologistApi public suspend Object? handleScrollEvent(kotlinx.coroutines.CoroutineScope coroutineScope, com.google.android.horologist.compose.rotaryinput.TimestampedDelta event, com.google.android.horologist.compose.rotaryinput.RotaryHapticHandler rotaryHaptics, kotlin.coroutines.Continuation<? super kotlin.Unit>);
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public interface RotarySnapBehavior {
method public boolean bottomEdgeReached();
method public void prepareSnapForItems(int moveForElements, boolean sequentialSnap);
method public suspend Object? snapToClosestItem(kotlin.coroutines.Continuation<? super kotlin.Unit>);
method public suspend Object? snapToTargetItem(kotlin.coroutines.Continuation<? super kotlin.Unit>);
method public boolean topEdgeReached();
}

public final class RotaryVelocityTracker {
ctor public RotaryVelocityTracker();
method public void end();
Expand Down Expand Up @@ -473,17 +427,6 @@ package com.google.android.horologist.compose.rotaryinput {
property public final float thresholdDivider;
}

@com.google.android.horologist.annotations.ExperimentalHorologistApi public final class TimestampedDelta {
ctor public TimestampedDelta(long timestamp, float delta);
method public long component1();
method public float component2();
method public com.google.android.horologist.compose.rotaryinput.TimestampedDelta copy(long timestamp, float delta);
method public float getDelta();
method public long getTimestamp();
property public final float delta;
property public final long timestamp;
}

}

package com.google.android.horologist.compose.snackbar {
Expand Down
Loading

0 comments on commit d7942d5

Please sign in to comment.