From 0cab5d642bfb552f8f9e393604ae247df7fb922c Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Wed, 9 Apr 2025 14:03:15 +0300 Subject: [PATCH] Contact related UI improvements --- .../tutpro/baresip/BaresipContactActivity.kt | 19 +++++++++++++------ .../com/tutpro/baresip/ConfigActivity.kt | 1 - 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipContactActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipContactActivity.kt index a78c3418..243b0019 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipContactActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipContactActivity.kt @@ -52,6 +52,7 @@ import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf @@ -60,6 +61,8 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.layout.ContentScale @@ -168,7 +171,7 @@ class BaresipContactActivity : ComponentActivity() { title = { Text( text = title, - color = LocalCustomColors.current.grayLight, + color = LocalCustomColors.current.light, fontWeight = FontWeight.Bold ) }, @@ -244,7 +247,7 @@ class BaresipContactActivity : ComponentActivity() { Canvas(modifier = Modifier.fillMaxSize()) { drawCircle(SolidColor(Color(textAvatarColor))) } - textAvatarText = if (name == "") "" else name[0].toString() + textAvatarText = if (name == "") "?" else name[0].toString() Text(textAvatarText, fontSize = 72.sp, color = Color.White) } } @@ -266,10 +269,9 @@ class BaresipContactActivity : ComponentActivity() { verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Center ) { - if (new) { - textAvatarText = "?" + if (new) textAvatarColor = color - } else { + else { val avatarImage = avatarImage val avatarFile = File(BaresipService.filesPath, "${id}.png") if (avatarImage != null && (newAvatar == "" || newAvatar == "image")) { @@ -308,6 +310,7 @@ class BaresipContactActivity : ComponentActivity() { @Composable fun contactName() { + val focusRequester = FocusRequester() var contactName by remember { mutableStateOf(name) } newName = contactName OutlinedTextField( @@ -317,7 +320,7 @@ class BaresipContactActivity : ComponentActivity() { contactName = it newName = contactName }, - modifier = Modifier.fillMaxWidth(), + modifier = Modifier.fillMaxWidth().focusRequester(focusRequester), textStyle = androidx.compose.ui.text.TextStyle( fontSize = 18.sp, color = LocalCustomColors.current.itemText ), @@ -327,6 +330,10 @@ class BaresipContactActivity : ComponentActivity() { capitalization = KeyboardCapitalization.Sentences ) ) + LaunchedEffect(new) { + if (new) + focusRequester.requestFocus() + } } @Composable diff --git a/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt index 8bead64c..ef876210 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt @@ -18,7 +18,6 @@ import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatDelegate -import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box