Fangjun Kuang
Committed by GitHub

Fix UI for Android TTS Engine. (#1735)

Set max number of lines of the input text field so that
the buttons are still visible when the input text is long.
@@ -22,7 +22,9 @@ import androidx.compose.foundation.layout.fillMaxSize @@ -22,7 +22,9 @@ import androidx.compose.foundation.layout.fillMaxSize
22 import androidx.compose.foundation.layout.fillMaxWidth 22 import androidx.compose.foundation.layout.fillMaxWidth
23 import androidx.compose.foundation.layout.padding 23 import androidx.compose.foundation.layout.padding
24 import androidx.compose.foundation.layout.wrapContentHeight 24 import androidx.compose.foundation.layout.wrapContentHeight
  25 +import androidx.compose.foundation.rememberScrollState
25 import androidx.compose.foundation.text.KeyboardOptions 26 import androidx.compose.foundation.text.KeyboardOptions
  27 +import androidx.compose.foundation.verticalScroll
26 import androidx.compose.material3.Button 28 import androidx.compose.material3.Button
27 import androidx.compose.material3.ExperimentalMaterial3Api 29 import androidx.compose.material3.ExperimentalMaterial3Api
28 import androidx.compose.material3.MaterialTheme 30 import androidx.compose.material3.MaterialTheme
@@ -109,6 +111,7 @@ class MainActivity : ComponentActivity() { @@ -109,6 +111,7 @@ class MainActivity : ComponentActivity() {
109 var rtfText by remember { 111 var rtfText by remember {
110 mutableStateOf("") 112 mutableStateOf("")
111 } 113 }
  114 + val scrollState = rememberScrollState(0)
112 115
113 val numSpeakers = TtsEngine.tts!!.numSpeakers() 116 val numSpeakers = TtsEngine.tts!!.numSpeakers()
114 if (numSpeakers > 1) { 117 if (numSpeakers > 1) {
@@ -142,9 +145,11 @@ class MainActivity : ComponentActivity() { @@ -142,9 +145,11 @@ class MainActivity : ComponentActivity() {
142 value = testText, 145 value = testText,
143 onValueChange = { testText = it }, 146 onValueChange = { testText = it },
144 label = { Text("Please input your text here") }, 147 label = { Text("Please input your text here") },
  148 + maxLines = 10,
145 modifier = Modifier 149 modifier = Modifier
146 .fillMaxWidth() 150 .fillMaxWidth()
147 .padding(bottom = 16.dp) 151 .padding(bottom = 16.dp)
  152 + .verticalScroll(scrollState)
148 .wrapContentHeight(), 153 .wrapContentHeight(),
149 singleLine = false, 154 singleLine = false,
150 ) 155 )