ContactScreen code styling
This commit is contained in:
@@ -166,9 +166,7 @@ private fun ContactScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
lifecycleOwner.lifecycle.addObserver(observer)
|
lifecycleOwner.lifecycle.addObserver(observer)
|
||||||
onDispose {
|
onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
|
||||||
lifecycleOwner.lifecycle.removeObserver(observer)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(uriOrNameArg, kindArg, BaresipService.androidContacts.value, BaresipService.baresipContacts.value) {
|
LaunchedEffect(uriOrNameArg, kindArg, BaresipService.androidContacts.value, BaresipService.baresipContacts.value) {
|
||||||
@@ -495,7 +493,7 @@ private fun AvatarSection(
|
|||||||
) {
|
) {
|
||||||
val avatarImagePicker =
|
val avatarImagePicker =
|
||||||
rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? ->
|
rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? ->
|
||||||
if (uri != null) {
|
if (uri != null)
|
||||||
try {
|
try {
|
||||||
val avatarBitmap = Utils.decodeSampledBitmapFromUri(ctx, uri, 192, 192)
|
val avatarBitmap = Utils.decodeSampledBitmapFromUri(ctx, uri, 192, 192)
|
||||||
|
|
||||||
@@ -528,7 +526,6 @@ private fun AvatarSection(
|
|||||||
Log.e(TAG, "Could not process avatar image: ${e.message}")
|
Log.e(TAG, "Could not process avatar image: ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
Modifier.fillMaxWidth(),
|
Modifier.fillMaxWidth(),
|
||||||
@@ -551,13 +548,13 @@ private fun AvatarSection(
|
|||||||
modifier
|
modifier
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
if (currentAvatarUri == null) {
|
if (currentAvatarUri == null)
|
||||||
Box(modifier = Modifier.size(avatarSize.dp), contentAlignment = Alignment.Center) {
|
Box(modifier = Modifier.size(avatarSize.dp), contentAlignment = Alignment.Center) {
|
||||||
Canvas(modifier = Modifier.fillMaxSize()) { drawCircle(SolidColor(Color(color))) }
|
Canvas(modifier = Modifier.fillMaxSize()) { drawCircle(SolidColor(Color(color))) }
|
||||||
val text = if (name.isNotBlank()) name.take(1).uppercase() else "?"
|
val text = if (name.isNotBlank()) name.take(1).uppercase() else "?"
|
||||||
Text(text, fontSize = 72.sp, color = Color.White)
|
Text(text, fontSize = 72.sp, color = Color.White)
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
Image(
|
Image(
|
||||||
painter = rememberAsyncImagePainter(model = currentAvatarUri),
|
painter = rememberAsyncImagePainter(model = currentAvatarUri),
|
||||||
contentDescription = stringResource(R.string.avatar_image),
|
contentDescription = stringResource(R.string.avatar_image),
|
||||||
@@ -566,7 +563,6 @@ private fun AvatarSection(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -910,10 +906,8 @@ private fun checkOnClick(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var newName = currentState.name.trim()
|
var newName = currentState.name.trim()
|
||||||
if (newName == "") newName = if (newUris.isNotEmpty())
|
if (newName == "")
|
||||||
newUris[0].uri.substringAfter(":")
|
newName = if (newUris.isNotEmpty()) newUris[0].uri.substringAfter(":") else currentState.email
|
||||||
else
|
|
||||||
currentState.email
|
|
||||||
if (!Utils.checkName(newName)) {
|
if (!Utils.checkName(newName)) {
|
||||||
alertTitle.value = ctx.getString(R.string.notice)
|
alertTitle.value = ctx.getString(R.string.notice)
|
||||||
alertMessage.value = String.format(ctx.getString(R.string.invalid_contact), newName)
|
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)
|
ExifInterface.ORIENTATION_ROTATE_270 -> matrix.setRotate(-90f)
|
||||||
else -> return bitmap
|
else -> return bitmap
|
||||||
}
|
}
|
||||||
val rotatedBitmap = Bitmap.createBitmap(
|
val rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
|
||||||
bitmap,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
bitmap.width,
|
|
||||||
bitmap.height,
|
|
||||||
matrix,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
bitmap.recycle()
|
bitmap.recycle()
|
||||||
return rotatedBitmap
|
return rotatedBitmap
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user