diff --git a/android/app/src/main/java/com/ts3client/android/ui/PushToTalk.kt b/android/app/src/main/java/com/ts3client/android/ui/PushToTalk.kt index a44086b..7d98f45 100644 --- a/android/app/src/main/java/com/ts3client/android/ui/PushToTalk.kt +++ b/android/app/src/main/java/com/ts3client/android/ui/PushToTalk.kt @@ -1,6 +1,7 @@ package com.ts3client.android.ui -import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.gestures.awaitEachGesture +import androidx.compose.foundation.gestures.awaitFirstDown import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding @@ -51,14 +52,19 @@ internal fun PushToTalk( val colors = MaterialTheme.colorScheme Surface( modifier.pointerInput(Unit) { - detectTapGestures(onPress = { + // Held until the finger lifts, wherever it wanders; a tap gesture would end once it left the button. + awaitEachGesture { + awaitFirstDown() onPressed(true) try { - awaitRelease() + do { + val event = awaitPointerEvent() + event.changes.forEach { it.consume() } + } while (event.changes.any { it.pressed }) } finally { onPressed(false) } - }) + } }, shape = shape, color = if (talking) StatusColors.talking else colors.primaryContainer,