From 7c00457b634f7b8b66ea871f6a57a55b2a09c3a6 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Fri, 17 Jul 2026 15:09:13 +0300 Subject: [PATCH] ContactScreen code styling --- .../com/tutpro/baresip/ContactScreen.kt | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/ContactScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/ContactScreen.kt index 0f8757d2..c2697c8b 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ContactScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ContactScreen.kt @@ -166,9 +166,7 @@ private fun ContactScreen( } } lifecycleOwner.lifecycle.addObserver(observer) - onDispose { - lifecycleOwner.lifecycle.removeObserver(observer) - } + onDispose { lifecycleOwner.lifecycle.removeObserver(observer) } } LaunchedEffect(uriOrNameArg, kindArg, BaresipService.androidContacts.value, BaresipService.baresipContacts.value) { @@ -495,7 +493,7 @@ private fun AvatarSection( ) { val avatarImagePicker = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? -> - if (uri != null) { + if (uri != null) try { val avatarBitmap = Utils.decodeSampledBitmapFromUri(ctx, uri, 192, 192) @@ -527,7 +525,6 @@ private fun AvatarSection( } catch (e: Exception) { Log.e(TAG, "Could not process avatar image: ${e.message}") } - } } Row( @@ -551,20 +548,19 @@ private fun AvatarSection( modifier } ) { - if (currentAvatarUri == null) { + if (currentAvatarUri == null) Box(modifier = Modifier.size(avatarSize.dp), contentAlignment = Alignment.Center) { Canvas(modifier = Modifier.fillMaxSize()) { drawCircle(SolidColor(Color(color))) } val text = if (name.isNotBlank()) name.take(1).uppercase() else "?" Text(text, fontSize = 72.sp, color = Color.White) } - } else { + else Image( painter = rememberAsyncImagePainter(model = currentAvatarUri), contentDescription = stringResource(R.string.avatar_image), contentScale = ContentScale.Crop, modifier = Modifier.size(avatarSize.dp).clip(CircleShape) ) - } } } } @@ -910,10 +906,8 @@ private fun checkOnClick( } var newName = currentState.name.trim() - if (newName == "") newName = if (newUris.isNotEmpty()) - newUris[0].uri.substringAfter(":") - else - currentState.email + if (newName == "") + newName = if (newUris.isNotEmpty()) newUris[0].uri.substringAfter(":") else currentState.email if (!Utils.checkName(newName)) { alertTitle.value = ctx.getString(R.string.notice) alertMessage.value = String.format(ctx.getString(R.string.invalid_contact), newName) @@ -999,15 +993,7 @@ private fun rotateBitmap(bitmap: Bitmap, orientation: Int): Bitmap { ExifInterface.ORIENTATION_ROTATE_270 -> matrix.setRotate(-90f) else -> return bitmap } - val rotatedBitmap = Bitmap.createBitmap( - bitmap, - 0, - 0, - bitmap.width, - bitmap.height, - matrix, - true - ) + val rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true) bitmap.recycle() return rotatedBitmap }