RageshakeDetectionEvents -> RageshakeDetectionEvent

This commit is contained in:
Benoit Marty 2026-01-19 18:17:58 +01:00
parent f5dd10388e
commit 7a366a0c88
6 changed files with 33 additions and 33 deletions

View file

@ -10,10 +10,10 @@ package io.element.android.features.rageshake.api.detection
import io.element.android.features.rageshake.api.screenshot.ImageResult
sealed interface RageshakeDetectionEvents {
data object Dismiss : RageshakeDetectionEvents
data object Disable : RageshakeDetectionEvents
data object StartDetection : RageshakeDetectionEvents
data object StopDetection : RageshakeDetectionEvents
data class ProcessScreenshot(val imageResult: ImageResult) : RageshakeDetectionEvents
sealed interface RageshakeDetectionEvent {
data object Dismiss : RageshakeDetectionEvent
data object Disable : RageshakeDetectionEvent
data object StartDetection : RageshakeDetectionEvent
data object StopDetection : RageshakeDetectionEvent
data class ProcessScreenshot(val imageResult: ImageResult) : RageshakeDetectionEvent
}

View file

@ -15,5 +15,5 @@ data class RageshakeDetectionState(
val showDialog: Boolean,
val isStarted: Boolean,
val preferenceState: RageshakePreferencesState,
val eventSink: (RageshakeDetectionEvents) -> Unit
val eventSink: (RageshakeDetectionEvent) -> Unit
)

View file

@ -35,22 +35,22 @@ fun RageshakeDetectionView(
val context = LocalContext.current
OnLifecycleEvent { _, event ->
when (event) {
Lifecycle.Event.ON_RESUME -> eventSink(RageshakeDetectionEvents.StartDetection)
Lifecycle.Event.ON_PAUSE -> eventSink(RageshakeDetectionEvents.StopDetection)
Lifecycle.Event.ON_RESUME -> eventSink(RageshakeDetectionEvent.StartDetection)
Lifecycle.Event.ON_PAUSE -> eventSink(RageshakeDetectionEvent.StopDetection)
else -> Unit
}
}
when {
state.takeScreenshot -> TakeScreenshot(
onScreenshot = { eventSink(RageshakeDetectionEvents.ProcessScreenshot(it)) }
onScreenshot = { eventSink(RageshakeDetectionEvent.ProcessScreenshot(it)) }
)
state.showDialog -> {
LaunchedEffect(Unit) {
context.vibrate()
}
RageshakeDialogContent(
onNoClick = { eventSink(RageshakeDetectionEvents.Dismiss) },
onDisableClick = { eventSink(RageshakeDetectionEvents.Disable) },
onNoClick = { eventSink(RageshakeDetectionEvent.Dismiss) },
onDisableClick = { eventSink(RageshakeDetectionEvent.Disable) },
onYesClick = onOpenBugReport
)
}