diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataView.kt index 8a905a6cf..24211ba36 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataView.kt @@ -61,7 +61,7 @@ fun NewUserMetadataView(onClose: () -> Unit, account: Account) { postViewModel.create() onClose() }, - postViewModel.userName.value.isNotBlank() + true ) } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt index 8e360481c..124959f60 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/navigation/DrawerContent.kt @@ -150,28 +150,33 @@ fun ProfileContent(baseAccountUser: User, modifier: Modifier = Modifier, scaffol } }) ) - Text( - accountUser.bestDisplayName() ?: "", - modifier = Modifier.padding(top = 7.dp).clickable(onClick = { - accountUser.let { - navController.navigate("User/${it.pubkeyHex}") - } - coroutineScope.launch { - scaffoldState.drawerState.close() - } - }), - fontWeight = FontWeight.Bold, - fontSize = 18.sp - ) - Text(" @${accountUser.bestUsername()}", color = Color.LightGray, - modifier = Modifier.padding(top = 15.dp).clickable(onClick = { - accountUser.let { - navController.navigate("User/${it.pubkeyHex}") - } - coroutineScope.launch { - scaffoldState.drawerState.close() - } - })) + if (accountUser.bestDisplayName() != null) { + Text( + accountUser.bestDisplayName() ?: "", + modifier = Modifier.padding(top = 7.dp).clickable(onClick = { + accountUser.let { + navController.navigate("User/${it.pubkeyHex}") + } + coroutineScope.launch { + scaffoldState.drawerState.close() + } + }), + fontWeight = FontWeight.Bold, + fontSize = 18.sp + ) + } + if (accountUser.bestUsername() != null) { + Text(" @${accountUser.bestUsername()}", color = Color.LightGray, + modifier = Modifier.padding(top = 15.dp).clickable(onClick = { + accountUser.let { + navController.navigate("User/${it.pubkeyHex}") + } + coroutineScope.launch { + scaffoldState.drawerState.close() + } + }) + ) + } Row(modifier = Modifier.padding(top = 15.dp).clickable(onClick = { accountUser.let { navController.navigate("User/${it.pubkeyHex}") diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PubKeyFormatter.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PubKeyFormatter.kt index e51f05f98..5196b42e9 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PubKeyFormatter.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/PubKeyFormatter.kt @@ -7,6 +7,6 @@ fun ByteArray.toShortenHex(): String { } fun String.toShortenHex(): String { - return replaceRange(6, length-6, ":") + return replaceRange(8, length-8, ":") } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt index 1f530b123..e981fb80f 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/UsernameDisplay.kt @@ -29,28 +29,34 @@ fun UsernameDisplay(baseUser: User, weight: Modifier = Modifier) { val userState by baseUser.live().metadata.observeAsState() val user = userState?.user ?: return - if (user.bestUsername() != null || user.bestDisplayName() != null) { - if (user.bestDisplayName().isNullOrBlank()) { - Text( - "@${(user.bestUsername() ?: "")}", - fontWeight = FontWeight.Bold, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - modifier = weight - ) - } else { - Text( - user.bestDisplayName() ?: "", - fontWeight = FontWeight.Bold, - ) - Text( - "@${(user.bestUsername() ?: "")}", - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f), - maxLines = 1, - overflow = TextOverflow.Ellipsis, - modifier = weight - ) - } + if (user.bestUsername() != null && user.bestDisplayName() != null) { + Text( + user.bestDisplayName() ?: "", + fontWeight = FontWeight.Bold, + ) + Text( + "@${(user.bestUsername() ?: "")}", + color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f), + maxLines = 1, + overflow = TextOverflow.Ellipsis, + modifier = weight + ) + } else if (user.bestDisplayName() != null) { + Text( + user.bestDisplayName() ?: "", + fontWeight = FontWeight.Bold, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + modifier = weight + ) + } else if (user.bestUsername() != null) { + Text( + "@${(user.bestUsername() ?: "")}", + fontWeight = FontWeight.Bold, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + modifier = weight + ) } else { Text( user.pubkeyDisplayHex(),