Contact related UI improvements

This commit is contained in:
Juha Heinanen
2025-04-09 14:03:15 +03:00
parent f715b24ca1
commit 0cab5d642b
2 changed files with 13 additions and 7 deletions
@@ -52,6 +52,7 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
@@ -60,6 +61,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip 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.Color
import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
@@ -168,7 +171,7 @@ class BaresipContactActivity : ComponentActivity() {
title = { title = {
Text( Text(
text = title, text = title,
color = LocalCustomColors.current.grayLight, color = LocalCustomColors.current.light,
fontWeight = FontWeight.Bold fontWeight = FontWeight.Bold
) )
}, },
@@ -244,7 +247,7 @@ class BaresipContactActivity : ComponentActivity() {
Canvas(modifier = Modifier.fillMaxSize()) { Canvas(modifier = Modifier.fillMaxSize()) {
drawCircle(SolidColor(Color(textAvatarColor))) 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) Text(textAvatarText, fontSize = 72.sp, color = Color.White)
} }
} }
@@ -266,10 +269,9 @@ class BaresipContactActivity : ComponentActivity() {
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center horizontalArrangement = Arrangement.Center
) { ) {
if (new) { if (new)
textAvatarText = "?"
textAvatarColor = color textAvatarColor = color
} else { else {
val avatarImage = avatarImage val avatarImage = avatarImage
val avatarFile = File(BaresipService.filesPath, "${id}.png") val avatarFile = File(BaresipService.filesPath, "${id}.png")
if (avatarImage != null && (newAvatar == "" || newAvatar == "image")) { if (avatarImage != null && (newAvatar == "" || newAvatar == "image")) {
@@ -308,6 +310,7 @@ class BaresipContactActivity : ComponentActivity() {
@Composable @Composable
fun contactName() { fun contactName() {
val focusRequester = FocusRequester()
var contactName by remember { mutableStateOf(name) } var contactName by remember { mutableStateOf(name) }
newName = contactName newName = contactName
OutlinedTextField( OutlinedTextField(
@@ -317,7 +320,7 @@ class BaresipContactActivity : ComponentActivity() {
contactName = it contactName = it
newName = contactName newName = contactName
}, },
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth().focusRequester(focusRequester),
textStyle = androidx.compose.ui.text.TextStyle( textStyle = androidx.compose.ui.text.TextStyle(
fontSize = 18.sp, color = LocalCustomColors.current.itemText fontSize = 18.sp, color = LocalCustomColors.current.itemText
), ),
@@ -327,6 +330,10 @@ class BaresipContactActivity : ComponentActivity() {
capitalization = KeyboardCapitalization.Sentences capitalization = KeyboardCapitalization.Sentences
) )
) )
LaunchedEffect(new) {
if (new)
focusRequester.requestFocus()
}
} }
@Composable @Composable
@@ -18,7 +18,6 @@ import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box