From ac01d3eacd3952716067f865a107282c03f0b422 Mon Sep 17 00:00:00 2001 From: ericek111 Date: Tue, 6 Oct 2026 21:19:06 +0000 Subject: [PATCH] Keep push-to-talk held when the finger slides off the button Co-Authored-By: Claude Opus 5.5 --- .../java/com/ts3client/android/ui/PushToTalk.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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,