feat(status/translation): support translating spoiler

This commit is contained in:
FineFindus 2023-11-01 20:44:24 +01:00
parent 77b9efa7d1
commit 47b13384a8
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
2 changed files with 10 additions and 1 deletions

View File

@ -10,6 +10,7 @@ public class Translation extends BaseModel{
public String detectedSourceLanguage;
@RequiredField
public String provider;
public String spoilerText;
public MediaAttachment[] mediaAttachments;
public PollTranslation poll;

View File

@ -26,6 +26,7 @@ public class SpoilerStatusDisplayItem extends StatusDisplayItem{
public final Status status;
public final ArrayList<StatusDisplayItem> contentItems=new ArrayList<>();
private final CharSequence parsedTitle;
private CharSequence translatedTitle;
private final CustomEmojiHelper emojiHelper;
private final Type type;
@ -85,7 +86,14 @@ public class SpoilerStatusDisplayItem extends StatusDisplayItem{
@Override
public void onBind(SpoilerStatusDisplayItem item){
title.setText(item.parsedTitle);
if(item.status.translationState==Status.TranslationState.SHOWN){
if(item.translatedTitle==null){
item.translatedTitle=item.status.translation.spoilerText;
}
title.setText(item.translatedTitle);
}else{
title.setText(item.parsedTitle);
}
action.setText(item.status.spoilerRevealed ? R.string.spoiler_hide : R.string.spoiler_show);
}