android: fix voice file creation (mkdir errno logging), PTT while(true)
- voice_recorder: proper mkdir with errno/EEXIST check, errno logged on fopen failure - MessageBubble: pointerInput wrapped in while(true) so PTT works after first gesture
This commit is contained in:
1 parent
1dac0b8c81
commit
9fca8d5e1f
2 files changed
+40
-29
No files matched your search
+28
-26
@@ -183,35 +183,37 @@ fun InputBar(
|
||||
.background(pttBg, RoundedCornerShape(4.dp))
|
||||
.pointerInput(hasMicPerm) {
|
||||
awaitPointerEventScope {
|
||||
val down = awaitPointerEvent()
|
||||
val ch = down.changes.firstOrNull() ?: return@awaitPointerEventScope
|
||||
if (!ch.pressed) return@awaitPointerEventScope
|
||||
ch.consume()
|
||||
|
||||
if (!hasMicPerm) {
|
||||
permLauncher.launch(Manifest.permission.RECORD_AUDIO)
|
||||
return@awaitPointerEventScope
|
||||
}
|
||||
|
||||
onPttPressed()
|
||||
var locked = false
|
||||
var totalDragY = 0f
|
||||
var lastY = ch.position.y
|
||||
|
||||
while (true) {
|
||||
val event = awaitPointerEvent()
|
||||
val change = event.changes.firstOrNull() ?: break
|
||||
if (change.pressed) {
|
||||
val dy = change.position.y - lastY
|
||||
lastY = change.position.y
|
||||
totalDragY += dy
|
||||
if (totalDragY < -lockThresholdPx && !locked) { locked = true; onPttLock() }
|
||||
change.consume()
|
||||
} else {
|
||||
change.consume(); break
|
||||
val down = awaitPointerEvent()
|
||||
val ch = down.changes.firstOrNull() ?: continue
|
||||
if (!ch.pressed) continue
|
||||
ch.consume()
|
||||
|
||||
if (!hasMicPerm) {
|
||||
permLauncher.launch(Manifest.permission.RECORD_AUDIO)
|
||||
continue
|
||||
}
|
||||
|
||||
onPttPressed()
|
||||
var locked = false
|
||||
var totalDragY = 0f
|
||||
var lastY = ch.position.y
|
||||
|
||||
while (true) {
|
||||
val event = awaitPointerEvent()
|
||||
val change = event.changes.firstOrNull() ?: break
|
||||
if (change.pressed) {
|
||||
val dy = change.position.y - lastY
|
||||
lastY = change.position.y
|
||||
totalDragY += dy
|
||||
if (totalDragY < -lockThresholdPx && !locked) { locked = true; onPttLock() }
|
||||
change.consume()
|
||||
} else {
|
||||
change.consume(); break
|
||||
}
|
||||
}
|
||||
onPttReleased()
|
||||
}
|
||||
onPttReleased()
|
||||
}
|
||||
},
|
||||
contentAlignment = Alignment.Center
|
||||
|
||||
Reference in new issue
Block a user