Code cleanup, put everything into one method in StatusViewData
This commit is contained in:
parent
79246ba461
commit
ad42cab00a
|
@ -71,8 +71,8 @@
|
||||||
<string name="attachment_type_audio">Audio</string>
|
<string name="attachment_type_audio">Audio</string>
|
||||||
<string name="attachment_type_unknown">Załącznik</string>
|
<string name="attachment_type_unknown">Załącznik</string>
|
||||||
<string name="link">Odnośnik</string>
|
<string name="link">Odnośnik</string>
|
||||||
<string name="status_replied_to_format">Odpowiedź dla %s</string>
|
<string name="status_replied_to_format">Odpowiedź dla @%s</string>
|
||||||
<string name="chat_our_last_message"><b>Ty</b></string>
|
<string name="chat_our_last_message"><b>Ty</b></string>
|
||||||
<string name="pref_title_other">Inne</string>
|
<string name="pref_title_other">Inne</string>
|
||||||
<string name="status_replied_to_and_more_format">i %d więcej.</string>
|
<string name="status_replied_to_and_more_format">" i %d więcej."</string>
|
||||||
</resources>
|
</resources>
|
|
@ -119,8 +119,8 @@
|
||||||
<string name="status_share_content">Share content of post</string>
|
<string name="status_share_content">Share content of post</string>
|
||||||
<string name="status_share_link">Share link to post</string>
|
<string name="status_share_link">Share link to post</string>
|
||||||
<string name="status_boosted_format">%s repeated</string>
|
<string name="status_boosted_format">%s repeated</string>
|
||||||
<string name="status_replied_to_format">Reply to %s</string>
|
<string name="status_replied_to_format">Reply to @%s</string>
|
||||||
<string name="status_replied_to_and_more_format">and %d more.</string>
|
<string name="status_replied_to_and_more_format">" and %d more."</string>
|
||||||
|
|
||||||
<string name="title_scheduled_toot">Scheduled posts</string>
|
<string name="title_scheduled_toot">Scheduled posts</string>
|
||||||
<string name="title_reblogged_by">Repeated by</string>
|
<string name="title_reblogged_by">Repeated by</string>
|
||||||
|
|
|
@ -714,26 +714,11 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
contentWarningDescriptionTextView.setText(emojifiedContentWarning);
|
contentWarningDescriptionTextView.setText(emojifiedContentWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getReplyToAccountString(Context context, Status.Mention[] mentions){
|
|
||||||
String replyToAccountString = "";
|
|
||||||
String format = context.getString(R.string.status_replied_to_and_more_format);
|
|
||||||
if(mentions != null) {
|
|
||||||
if (mentions.length > 1) {
|
|
||||||
replyToAccountString = String.format(Locale.getDefault(),"@%s "+format, mentions[0].getLocalUsername(), mentions.length - 1);
|
|
||||||
} else if (mentions.length == 1) {
|
|
||||||
replyToAccountString = String.format("@%s", mentions[0].getLocalUsername());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return replyToAccountString;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupReplyInfo() {
|
private void setupReplyInfo() {
|
||||||
if (statusViewData.getInReplyToId() != null) {
|
if (statusViewData.getInReplyToId() != null) {
|
||||||
Context context = replyInfo.getContext();
|
Context context = replyInfo.getContext();
|
||||||
String replyToAccount = statusViewData.getInReplyToAccountAcct();
|
String replyToAccount = statusViewData.getReplyToAccountString(context);
|
||||||
Status.Mention[] mentions = statusViewData.getMentions();
|
replyInfo.setText(replyToAccount);
|
||||||
String replyToString = getReplyToAccountString(context, mentions);
|
|
||||||
replyInfo.setText(context.getString(R.string.status_replied_to_format, replyToAccount+replyToString));
|
|
||||||
if (!statusViewData.getParentVisible()) {
|
if (!statusViewData.getParentVisible()) {
|
||||||
replyInfo.setPaintFlags(replyInfo.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
replyInfo.setPaintFlags(replyInfo.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||||
replyInfo.setOnClickListener(null);
|
replyInfo.setOnClickListener(null);
|
||||||
|
|
|
@ -383,26 +383,11 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getReplyToAccountString(Context context, Status.Mention[] mentions){
|
|
||||||
String replyToAccountString = "";
|
|
||||||
String format = context.getString(R.string.status_replied_to_and_more_format);
|
|
||||||
if(mentions != null) {
|
|
||||||
if (mentions.length > 1) {
|
|
||||||
replyToAccountString = String.format(Locale.getDefault(),"@%s "+format, mentions[0].getLocalUsername(), mentions.length - 1);
|
|
||||||
} else if (mentions.length == 1) {
|
|
||||||
replyToAccountString = String.format("@%s", mentions[0].getLocalUsername());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return replyToAccountString;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setReplyInfo(StatusViewData.Concrete status, StatusActionListener listener) {
|
protected void setReplyInfo(StatusViewData.Concrete status, StatusActionListener listener) {
|
||||||
if (status.getInReplyToId() != null) {
|
if (status.getInReplyToId() != null) {
|
||||||
Context context = replyInfo.getContext();
|
Context context = replyInfo.getContext();
|
||||||
String replyToAccount = status.getInReplyToAccountAcct();
|
String replyToAccount = status.getReplyToAccountString(context);
|
||||||
Status.Mention[] mentions = status.getMentions();
|
replyInfo.setText(replyToAccount);
|
||||||
String replyToString = getReplyToAccountString(context, mentions);
|
|
||||||
replyInfo.setText(context.getString(R.string.status_replied_to_format, replyToAccount+replyToString));
|
|
||||||
if (!status.getParentVisible()) {
|
if (!status.getParentVisible()) {
|
||||||
replyInfo.setPaintFlags(replyInfo.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
replyInfo.setPaintFlags(replyInfo.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||||
replyInfo.setOnClickListener(null);
|
replyInfo.setOnClickListener(null);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
package com.keylesspalace.tusky.viewdata;
|
package com.keylesspalace.tusky.viewdata;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
|
@ -108,6 +109,20 @@ public abstract class StatusViewData {
|
||||||
private final List<EmojiReaction> emojiReactions;
|
private final List<EmojiReaction> emojiReactions;
|
||||||
private final boolean parentVisible;
|
private final boolean parentVisible;
|
||||||
|
|
||||||
|
public String getReplyToAccountString(Context context){
|
||||||
|
String replyToAccountString = "";
|
||||||
|
String replyTo = context.getString(R.string.status_replied_to_format);
|
||||||
|
String format = context.getString(R.string.status_replied_to_and_more_format);
|
||||||
|
if(this.mentions != null) {
|
||||||
|
if (this.mentions.length > 1) {
|
||||||
|
replyToAccountString = String.format(Locale.getDefault(),replyTo+format, this.mentions[0].getLocalUsername(), this.mentions.length - 1);
|
||||||
|
} else if (this.mentions.length == 1) {
|
||||||
|
replyToAccountString = String.format(replyTo, this.mentions[0].getLocalUsername());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return replyToAccountString;
|
||||||
|
}
|
||||||
|
|
||||||
public Concrete(String id, Spanned content, boolean reblogged, boolean favourited, boolean bookmarked,
|
public Concrete(String id, Spanned content, boolean reblogged, boolean favourited, boolean bookmarked,
|
||||||
@Nullable String spoilerText, Status.Visibility visibility, List<Attachment> attachments,
|
@Nullable String spoilerText, Status.Visibility visibility, List<Attachment> attachments,
|
||||||
@Nullable String rebloggedByUsername, @Nullable String rebloggedAvatar, boolean sensitive, boolean isExpanded,
|
@Nullable String rebloggedByUsername, @Nullable String rebloggedAvatar, boolean sensitive, boolean isExpanded,
|
||||||
|
|
Loading…
Reference in New Issue