From 422c3c38090cd14a6461775947154d0456956525 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Mon, 2 Oct 2023 16:42:04 -0300 Subject: [PATCH] fix(translations): fix crash when status language is null --- .../android/ui/displayitems/TextStatusDisplayItem.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java index b47ea7e93..53fbe8e90 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java @@ -16,6 +16,7 @@ import android.widget.TextView; import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.R; +import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.fragments.BaseStatusListFragment; import org.joinmastodon.android.model.Status; import org.joinmastodon.android.model.Translation; @@ -207,7 +208,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ translationProgress.setVisibility(View.GONE); Translation existingTrans=item.status.getContentStatus().translation; String lang=existingTrans!=null ? existingTrans.detectedSourceLanguage : null; - String displayLang=Locale.forLanguageTag(lang!=null ? lang : item.status.getContentStatus().language).getDisplayLanguage(); + String displayLang=Locale.forLanguageTag(lang!=null ? lang : (item.status.getContentStatus().language != null ? item.status.getContentStatus().language : AccountSessionManager.get(item.parentFragment.getAccountID()).preferences.postingDefaultLanguage)).getDisplayLanguage(); translationButton.setText(item.parentFragment.getString(R.string.translate_post, !displayLang.isBlank() ? displayLang : lang)); translationButton.setEnabled(true); translationButton.setAlpha(1);