Make full action window clickable

This commit is contained in:
Aleksandras Kostarevas 2023-08-31 19:33:24 +03:00
parent 9f6941eff0
commit 8f53297eea
3 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,7 @@
package org.futo.inputmethod.latin.uix.actions
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
@ -7,6 +9,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import org.futo.inputmethod.latin.R
@ -71,7 +74,14 @@ val VoiceInputAction = Action(
@Composable
override fun WindowContents() {
Box(modifier = Modifier.fillMaxSize()) {
Box(modifier = Modifier.fillMaxSize().clickable(
enabled = true,
onClickLabel = null,
onClick = { recognizerView.finish() },
role = null,
indication = null,
interactionSource = remember { MutableInteractionSource() }
)) {
Box(modifier = Modifier.align(Alignment.Center)) {
recognizerView.Content()
}

View File

@ -102,6 +102,7 @@ class AudioRecognizer(
}
fun finish() {
if(!isRecording) return
onFinishRecording()
}

View File

@ -112,6 +112,10 @@ class RecognizerView(
}
}
fun finish() {
recognizer.finish()
}
fun cancel() {
recognizer.cancel()
}