diff --git a/play-services-core/src/main/java/org/microg/gms/ui/AccountsFragment.kt b/play-services-core/src/main/java/org/microg/gms/ui/AccountsFragment.kt index 9031feacb8..d7a8078f43 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/AccountsFragment.kt +++ b/play-services-core/src/main/java/org/microg/gms/ui/AccountsFragment.kt @@ -124,30 +124,36 @@ class AccountsFragment : PreferenceFragmentCompat() { clearAccountPreferences() val preferenceCategory = findPreference("prefcat_current_accounts") - - lifecycleScope.launch(Dispatchers.Main) { - accounts.forEach { account -> - val photo = PeopleManager.getOwnerAvatarBitmap(context, account.name, false) - val newPreference = Preference(requireContext()).apply { - title = getDisplayName(account) - summary = account.name - icon = getCircleBitmapDrawable(photo) - key = "account:${account.name}" - order = 0 - - setOnPreferenceClickListener { - showConfirmationDialog(account.name) - true - } - } - - if (preferenceCategory?.findPreference(newPreference.key) == null) { - if (photo == null) { - withContext(Dispatchers.IO) { - PeopleManager.getOwnerAvatarBitmap(context, account.name, true) - }?.let { newPreference.icon = getCircleBitmapDrawable(it) } + val accountsCategoryVisible = accounts.isNotEmpty() + + preferenceCategory?.let { + it.isVisible = accountsCategoryVisible + if (accountsCategoryVisible) { + lifecycleScope.launch(Dispatchers.Main) { + accounts.forEach { account -> + val photo = PeopleManager.getOwnerAvatarBitmap(context, account.name, false) + val newPreference = Preference(requireContext()).apply { + title = getDisplayName(account) + summary = account.name + icon = getCircleBitmapDrawable(photo) + key = "account:${account.name}" + order = 0 + + setOnPreferenceClickListener { + showConfirmationDialog(account.name) + true + } + } + + if (preferenceCategory.findPreference(newPreference.key) == null) { + if (photo == null) { + withContext(Dispatchers.IO) { + PeopleManager.getOwnerAvatarBitmap(context, account.name, true) + }?.let { newPreference.icon = getCircleBitmapDrawable(it) } + } + preferenceCategory.addPreference(newPreference) + } } - preferenceCategory?.addPreference(newPreference) } } } diff --git a/play-services-core/src/main/res/values-pt-rBR/strings.xml b/play-services-core/src/main/res/values-pt-rBR/strings.xml index 0aec7dbf36..09282c1bdf 100644 --- a/play-services-core/src/main/res/values-pt-rBR/strings.xml +++ b/play-services-core/src/main/res/values-pt-rBR/strings.xml @@ -181,7 +181,7 @@ Isso pode levar alguns minutos." Tem certeza de que deseja remover esta conta?\n\nAlguns serviços e funções não estarão disponíveis\n\nSeus dados não serão perdidos Remover Cancelar - %s removida + Conta %s removida diff --git a/play-services-core/src/main/res/values/strings.xml b/play-services-core/src/main/res/values/strings.xml index e81936ec69..7b474a7408 100644 --- a/play-services-core/src/main/res/values/strings.xml +++ b/play-services-core/src/main/res/values/strings.xml @@ -192,7 +192,7 @@ This can take a couple of minutes" Are you sure you want to remove this account?\n\nSome services and functions will be unavailable\n\nYour data will not be lost Remove Cancel - %s removed + Account %s removed diff --git a/play-services-core/src/main/res/xml/preferences_accounts.xml b/play-services-core/src/main/res/xml/preferences_accounts.xml index 23c600c377..baec84c8c4 100644 --- a/play-services-core/src/main/res/xml/preferences_accounts.xml +++ b/play-services-core/src/main/res/xml/preferences_accounts.xml @@ -1,6 +1,5 @@ - + \ No newline at end of file