Remove suggestions when call button is pressed

This commit is contained in:
Juha Heinanen
2025-04-08 12:18:15 +03:00
parent b72851bded
commit f3da8288b9
@@ -194,6 +194,7 @@ class MainActivity : ComponentActivity() {
private var securityIcon = mutableIntStateOf(-1) private var securityIcon = mutableIntStateOf(-1)
private var callTimer: Chronometer? = null private var callTimer: Chronometer? = null
private var showCallTimer = mutableStateOf(false) private var showCallTimer = mutableStateOf(false)
private var showSuggestions = mutableStateOf(false)
private var showCallButton = mutableStateOf(true) private var showCallButton = mutableStateOf(true)
private var showAnswerRejectButtons = mutableStateOf(false) private var showAnswerRejectButtons = mutableStateOf(false)
private var showHangupButton = mutableStateOf(false) private var showHangupButton = mutableStateOf(false)
@@ -887,7 +888,6 @@ class MainActivity : ComponentActivity() {
fun CallUriRow(ctx: Context) { fun CallUriRow(ctx: Context) {
val suggestions by remember { contactNames } val suggestions by remember { contactNames }
var filteredSuggestions by remember { mutableStateOf(suggestions) } var filteredSuggestions by remember { mutableStateOf(suggestions) }
var showSuggestions by remember { mutableStateOf(false) }
val focusRequester = remember { FocusRequester() } val focusRequester = remember { FocusRequester() }
val lazyListState = rememberLazyListState() val lazyListState = rememberLazyListState()
@@ -907,7 +907,7 @@ class MainActivity : ComponentActivity() {
val newValue = it val newValue = it
if (it != callUri.value) { if (it != callUri.value) {
callUri.value = newValue callUri.value = newValue
showSuggestions = newValue.length > 2 showSuggestions.value = newValue.length > 2
filteredSuggestions = suggestions.filter { suggestion -> filteredSuggestions = suggestions.filter { suggestion ->
newValue.length > 2 && suggestion.startsWith(newValue, ignoreCase = true) newValue.length > 2 && suggestion.startsWith(newValue, ignoreCase = true)
} }
@@ -920,7 +920,7 @@ class MainActivity : ComponentActivity() {
modifier = Modifier modifier = Modifier
.clickable { .clickable {
callUri.value = "" callUri.value = ""
showSuggestions = false showSuggestions.value = false
} }
) )
}, },
@@ -954,7 +954,7 @@ class MainActivity : ComponentActivity() {
) )
.animateContentSize() .animateContentSize()
) { ) {
if (showSuggestions && filteredSuggestions.isNotEmpty()) { if (showSuggestions.value && filteredSuggestions.isNotEmpty()) {
Box(modifier = Modifier Box(modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.heightIn(max = 150.dp)) { .heightIn(max = 150.dp)) {
@@ -977,7 +977,7 @@ class MainActivity : ComponentActivity() {
.fillMaxWidth() .fillMaxWidth()
.clickable { .clickable {
callUri.value = suggestion callUri.value = suggestion
showSuggestions = false showSuggestions.value = false
} }
.padding(12.dp) .padding(12.dp)
) { ) {
@@ -1081,6 +1081,7 @@ class MainActivity : ComponentActivity() {
IconButton( IconButton(
modifier = Modifier.size(48.dp), modifier = Modifier.size(48.dp),
onClick = { onClick = {
showSuggestions.value = false
callClick(ctx) callClick(ctx)
}, },
) { ) {