Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show the users' federated name in drawer. #937

Merged
merged 8 commits into from
Jul 3, 2023
7 changes: 7 additions & 0 deletions app/src/main/java/com/jerboa/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,13 @@ fun personNameShown(person: Person, federatedName: Boolean = false): String {
}
}

/**
* In cases where there should be no ambiguity as to the given Person's federated name.
*/
fun federatedNameShown(person: Person): String {
return "${person.name}@${hostName(person.actor_id)}"
}

fun communityNameShown(community: Community): String {
return if (community.local) {
community.title
Expand Down
32 changes: 26 additions & 6 deletions app/src/main/java/com/jerboa/ui/components/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
Expand All @@ -78,6 +79,7 @@ import com.jerboa.datatypes.types.SortType
import com.jerboa.datatypes.types.Tagline
import com.jerboa.db.Account
import com.jerboa.db.AccountViewModel
import com.jerboa.federatedNameShown
import com.jerboa.getLocalizedListingTypeName
import com.jerboa.getLocalizedSortingTypeShortName
import com.jerboa.ui.components.common.IconAndTextDrawerItem
Expand Down Expand Up @@ -355,7 +357,7 @@ fun DrawerAddAccountMode(
)
accountsWithoutCurrent?.forEach {
IconAndTextDrawerItem(
text = stringResource(R.string.home_switch_to, it.instance, it.name),
text = stringResource(R.string.home_switch_to, it.name, it.instance),
icon = Icons.Outlined.Login,
onClick = { onSwitchAccountClick(it) },
)
Expand Down Expand Up @@ -407,8 +409,11 @@ fun DrawerHeader(
modifier = sizeMod
.padding(XL_PADDING),
) {
AvatarAndAccountName(myPerson, showAvatar)
Box(modifier = Modifier.weight(0.9f)) {
AvatarAndAccountName(myPerson, showAvatar)
}
Icon(
modifier = Modifier.weight(0.1f),
imageVector = if (showAccountAddMode) {
Icons.Outlined.ExpandLess
} else {
Expand All @@ -435,13 +440,28 @@ fun AvatarAndAccountName(myPerson: Person?, showAvatar: Boolean) {
LargerCircularIcon(icon = it)
}
}
PersonName(
person = myPerson,
color = MaterialTheme.colorScheme.onSurface,
)
Column() {
PersonName(
person = myPerson,
color = MaterialTheme.colorScheme.onSurface,
)
Text(
text = myPerson?.let { federatedNameShown(it) } ?: "",
color = MaterialTheme.colorScheme.tertiary,
style = MaterialTheme.typography.labelSmall,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
)
}
}
}

@Preview
@Composable
fun AvatarAndAccountNamePreview() {
AvatarAndAccountName(myPerson = samplePerson, showAvatar = true)
}

@Preview
@Composable
fun DrawerHeaderPreview() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<string name="home_settings">Indstillinger</string>
<string name="home_subscriptions">Abonnementer</string>
<string name="home_add_account">Tilføj konto</string>
<string name="home_switch_to">Skift til %1$s/%2$s</string>
<string name="home_switch_to">Skift til %1$s@%2$s</string>
<string name="home_sign_out">Log ud</string>
<string name="home_menu">Menu</string>
<string name="home_refresh">Opdater</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<string name="home_settings">Einstellungen</string>
<string name="home_subscriptions">Abonnements</string>
<string name="home_add_account">Account hinzufügen</string>
<string name="home_switch_to">Wechsele zu %1$s/%2$s</string>
<string name="home_switch_to">Wechsele zu %1$s@%2$s</string>
<string name="home_sign_out">Ausloggen</string>
<string name="home_menu">Menü</string>
<string name="home_refresh">Aktualisieren</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<string name="home_settings">Ajustes</string>
<string name="home_subscriptions">Suscripciones</string>
<string name="home_add_account">Agregar cuenta</string>
<string name="home_switch_to">Cambiar a %1$s/%2$s</string>
<string name="home_switch_to">Cambiar a %1$s@%2$s</string>
<string name="home_sign_out">Salir de Sesión</string>
<string name="home_menu">Menú</string>
<string name="home_refresh">Refrescar</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<string name="home_settings">Paramètres</string>
<string name="home_subscriptions">Abonnements</string>
<string name="home_add_account">Ajouter un compte</string>
<string name="home_switch_to">Passer à %1$s/%2$s</string>
<string name="home_switch_to">Passer à %1$s@%2$s</string>
<string name="home_sign_out">Se déconnecter</string>
<string name="home_menu">Menu</string>
<string name="home_refresh">Rafraîchir</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<string name="home_site_info">Info istanza</string>
<string name="home_subscribed">Iscrizioni</string>
<string name="home_subscriptions">Iscrizioni</string>
<string name="home_switch_to">Usa %1$s/%2$s</string>
<string name="home_switch_to">Usa %1$s@%2$s</string>
<string name="inbox_filter">Seleziona filtro per la posta in arrivo</string>
<string name="inbox_inbox">Posta in arrivo</string>
<string name="inbox_markAllRead">Segna tutti come già letti</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<string name="home_settings">設定</string>
<string name="home_subscriptions">登録コミュニティ</string>
<string name="home_add_account">アカウントを連携</string>
<string name="home_switch_to">アカウントを%1$s/%2$sに変更</string>
<string name="home_switch_to">アカウントを%1$s@%2$sに変更</string>
<string name="home_sign_out">サインアウト</string>
<string name="home_menu">メニュー</string>
<string name="home_refresh">再読み込み</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<string name="home_site_info">사이트 정보</string>
<string name="home_subscribed">구독함</string>
<string name="home_subscriptions">구독</string>
<string name="home_switch_to">%1$s/%2$s로 전환</string>
<string name="home_switch_to">%1$s@%2$s로 전환</string>
<string name="inbox_filter">받은 편지함 필터 선택</string>
<string name="inbox_inbox">받은 편지함</string>
<string name="inbox_markAllRead">모두 읽음 처리</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<string name="form_submit">Verzend</string>
<string name="homeHeader_filter">Selecteer feed</string>
<string name="home_add_account">Account toevoegen</string>
<string name="home_switch_to">Overschakelen naar %1$s/%2$s</string>
<string name="home_switch_to">Overschakelen naar %1$s@%2$s</string>
<string name="home_sign_out">Afmelden</string>
<string name="home_menu">Menu</string>
<string name="home_refresh">Vernieuwen</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<string name="home_settings">Ustawienia</string>
<string name="home_subscriptions">Subskrypcje</string>
<string name="home_add_account">Dodaj Konto</string>
<string name="home_switch_to">Przełącz na %1$s/%2$s</string>
<string name="home_switch_to">Przełącz na %1$s@%2$s</string>
<string name="home_sign_out">Wyloguj</string>
<string name="home_menu">Menu</string>
<string name="home_refresh">Odśwież</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<string name="home_settings">Configurações</string>
<string name="home_subscriptions">Participa das Comunidades</string>
<string name="home_add_account">Adicionar Conta</string>
<string name="home_switch_to">Mudar para %1$s/%2$s</string>
<string name="home_switch_to">Mudar para %1$s@%2$s</string>
<string name="home_sign_out">Sair</string>
<string name="home_menu">Menu</string>
<string name="home_refresh">Recarregar</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<string name="home_site_info">Информация о сайте</string>
<string name="home_subscribed">Подписки</string>
<string name="home_subscriptions">Подписки</string>
<string name="home_switch_to">Переключиться на %1$s/%2$s</string>
<string name="home_switch_to">Переключиться на %1$s@%2$s</string>
<string name="inbox_filter">Фильтр</string>
<string name="inbox_inbox">Сообщения</string>
<string name="inbox_markAllRead">Пометить все как прочитанные</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-se/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<string name="home_settings">Inställningar</string>
<string name="home_subscriptions">Prenumerationer</string>
<string name="home_add_account">Lägg till konto</string>
<string name="home_switch_to">Byt till %1$s/%2$s</string>
<string name="home_switch_to">Byt till %1$s@%2$s</string>
<string name="home_sign_out">Logga ut</string>
<string name="home_menu">Meny</string>
<string name="home_refresh">Uppdatera</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
<string name="home_site_info">Site Info</string>
<string name="home_subscribed">Subscribed</string>
<string name="home_subscriptions">Subscriptions</string>
<string name="home_switch_to">Switch to %1$s/%2$s</string>
<string name="home_switch_to">Switch to %1$s@%2$s</string>
<string name="inbox_filter">Filter</string>
<string name="inbox_inbox">Inbox</string>
<string name="inbox_markAllRead">Mark all as read</string>
Expand Down