MoreDialogFragment: Better null-safety and localization for account header

In case AuthData has expired and user is inside Aurora Store, MoreDialogFragment
will keep crashing while trying to load account name and email.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-12-31 18:04:30 +07:00
parent e36e3341f7
commit 9693a597c8
2 changed files with 7 additions and 4 deletions

View File

@@ -261,9 +261,10 @@ class MoreDialogFragment : DialogFragment() {
) { ) {
Text( Text(
text = if (authProvider.isAnonymous) { text = if (authProvider.isAnonymous) {
"Anonymous" stringResource(R.string.account_anonymous)
} else { } else {
authProvider.authData!!.userProfile!!.name authProvider.authData?.userProfile?.name
?: stringResource(R.string.status_unavailable)
}, },
fontWeight = FontWeight.Normal, fontWeight = FontWeight.Normal,
color = onBackgroundColor, color = onBackgroundColor,
@@ -273,9 +274,10 @@ class MoreDialogFragment : DialogFragment() {
) )
Text( Text(
text = if (authProvider.isAnonymous) { text = if (authProvider.isAnonymous) {
"anonymous@gmail.com" stringResource(R.string.account_anonymous_email)
} else { } else {
authProvider.authData!!.userProfile!!.email authProvider.authData?.userProfile?.email
?: stringResource(R.string.status_unavailable)
}, },
fontWeight = FontWeight.Light, fontWeight = FontWeight.Light,
color = onBackgroundColor, color = onBackgroundColor,

View File

@@ -413,6 +413,7 @@
<!-- MoreDialogFragment --> <!-- MoreDialogFragment -->
<string name="title_more">More</string> <string name="title_more">More</string>
<string name="manage_account">Manage your account</string> <string name="manage_account">Manage your account</string>
<string name="account_anonymous_email" translatable="false">anonymous@gmail.com</string>
<!-- InstallationPreference --> <!-- InstallationPreference -->
<string name="pref_clear_device_owner_title">Clear device owner</string> <string name="pref_clear_device_owner_title">Clear device owner</string>