Show display names for reposts (#2041)
* WIP: Show display names for reposts * Display emojis on reposts * Move unicode wrapping Co-authored-by: Garrit Franke <garrit@slashdev.space>
This commit is contained in:
parent
be60155de5
commit
4c7d09b1e3
3 changed files with 27 additions and 8 deletions
|
@ -27,8 +27,10 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.keylesspalace.tusky.R;
|
import com.keylesspalace.tusky.R;
|
||||||
import com.keylesspalace.tusky.interfaces.StatusActionListener;
|
import com.keylesspalace.tusky.interfaces.StatusActionListener;
|
||||||
|
import com.keylesspalace.tusky.util.CustomEmojiHelper;
|
||||||
import com.keylesspalace.tusky.util.SmartLengthInputFilter;
|
import com.keylesspalace.tusky.util.SmartLengthInputFilter;
|
||||||
import com.keylesspalace.tusky.util.StatusDisplayOptions;
|
import com.keylesspalace.tusky.util.StatusDisplayOptions;
|
||||||
|
import com.keylesspalace.tusky.util.StringUtils;
|
||||||
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
||||||
|
|
||||||
import at.connyduck.sparkbutton.helpers.Utils;
|
import at.connyduck.sparkbutton.helpers.Utils;
|
||||||
|
@ -64,7 +66,7 @@ public class StatusViewHolder extends StatusBaseViewHolder {
|
||||||
if (rebloggedByDisplayName == null) {
|
if (rebloggedByDisplayName == null) {
|
||||||
hideStatusInfo();
|
hideStatusInfo();
|
||||||
} else {
|
} else {
|
||||||
setRebloggedByDisplayName(rebloggedByDisplayName);
|
setRebloggedByDisplayName(rebloggedByDisplayName, status);
|
||||||
statusInfo.setOnClickListener(v -> listener.onOpenReblog(getAdapterPosition()));
|
statusInfo.setOnClickListener(v -> listener.onOpenReblog(getAdapterPosition()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,10 +75,12 @@ public class StatusViewHolder extends StatusBaseViewHolder {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRebloggedByDisplayName(final String name) {
|
private void setRebloggedByDisplayName(final CharSequence name, final StatusViewData.Concrete status) {
|
||||||
Context context = statusInfo.getContext();
|
Context context = statusInfo.getContext();
|
||||||
String boostedText = context.getString(R.string.status_boosted_format, name);
|
CharSequence wrappedName = StringUtils.unicodeWrap(name);
|
||||||
statusInfo.setText(boostedText);
|
CharSequence boostedText = context.getString(R.string.status_boosted_format, wrappedName);
|
||||||
|
CharSequence emojifiedText = CustomEmojiHelper.emojify(boostedText, status.getRebloggedByAccountEmojis(), statusInfo);
|
||||||
|
statusInfo.setText(emojifiedText);
|
||||||
statusInfo.setVisibility(View.VISIBLE);
|
statusInfo.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public final class ViewDataUtils {
|
||||||
.setSensitive(visibleStatus.getSensitive())
|
.setSensitive(visibleStatus.getSensitive())
|
||||||
.setIsShowingSensitiveContent(alwaysShowSensitiveMedia || !visibleStatus.getSensitive())
|
.setIsShowingSensitiveContent(alwaysShowSensitiveMedia || !visibleStatus.getSensitive())
|
||||||
.setSpoilerText(visibleStatus.getSpoilerText())
|
.setSpoilerText(visibleStatus.getSpoilerText())
|
||||||
.setRebloggedByUsername(status.getReblog() == null ? null : status.getAccount().getUsername())
|
.setRebloggedByUsername(status.getReblog() == null ? null : status.getAccount().getDisplayName())
|
||||||
.setUserFullName(visibleStatus.getAccount().getName())
|
.setUserFullName(visibleStatus.getAccount().getName())
|
||||||
.setVisibility(visibleStatus.getVisibility())
|
.setVisibility(visibleStatus.getVisibility())
|
||||||
.setSenderId(visibleStatus.getAccount().getId())
|
.setSenderId(visibleStatus.getAccount().getId())
|
||||||
|
@ -60,6 +60,7 @@ public final class ViewDataUtils {
|
||||||
.setApplication(visibleStatus.getApplication())
|
.setApplication(visibleStatus.getApplication())
|
||||||
.setStatusEmojis(visibleStatus.getEmojis())
|
.setStatusEmojis(visibleStatus.getEmojis())
|
||||||
.setAccountEmojis(visibleStatus.getAccount().getEmojis())
|
.setAccountEmojis(visibleStatus.getAccount().getEmojis())
|
||||||
|
.setRebloggedByEmojis(status.getReblog() == null ? null : status.getAccount().getEmojis())
|
||||||
.setCollapsible(SmartLengthInputFilterKt.shouldTrimStatus(visibleStatus.getContent()))
|
.setCollapsible(SmartLengthInputFilterKt.shouldTrimStatus(visibleStatus.getContent()))
|
||||||
.setCollapsed(true)
|
.setCollapsed(true)
|
||||||
.setPoll(visibleStatus.getPoll())
|
.setPoll(visibleStatus.getPoll())
|
||||||
|
|
|
@ -16,10 +16,11 @@
|
||||||
package com.keylesspalace.tusky.viewdata;
|
package com.keylesspalace.tusky.viewdata;
|
||||||
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.keylesspalace.tusky.entity.Attachment;
|
import com.keylesspalace.tusky.entity.Attachment;
|
||||||
import com.keylesspalace.tusky.entity.Card;
|
import com.keylesspalace.tusky.entity.Card;
|
||||||
import com.keylesspalace.tusky.entity.Emoji;
|
import com.keylesspalace.tusky.entity.Emoji;
|
||||||
|
@ -85,6 +86,7 @@ public abstract class StatusViewData {
|
||||||
private final Status.Application application;
|
private final Status.Application application;
|
||||||
private final List<Emoji> statusEmojis;
|
private final List<Emoji> statusEmojis;
|
||||||
private final List<Emoji> accountEmojis;
|
private final List<Emoji> accountEmojis;
|
||||||
|
private final List<Emoji> rebloggedByAccountEmojis;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Card card;
|
private final Card card;
|
||||||
private final boolean isCollapsible; /** Whether the status meets the requirement to be collapse */
|
private final boolean isCollapsible; /** Whether the status meets the requirement to be collapse */
|
||||||
|
@ -99,7 +101,7 @@ public abstract class StatusViewData {
|
||||||
boolean isShowingContent, String userFullName, String nickname, String avatar,
|
boolean isShowingContent, String userFullName, String nickname, String avatar,
|
||||||
Date createdAt, int reblogsCount, int favouritesCount, @Nullable String inReplyToId,
|
Date createdAt, int reblogsCount, int favouritesCount, @Nullable String inReplyToId,
|
||||||
@Nullable Status.Mention[] mentions, String senderId, boolean rebloggingEnabled,
|
@Nullable Status.Mention[] mentions, String senderId, boolean rebloggingEnabled,
|
||||||
Status.Application application, List<Emoji> statusEmojis, List<Emoji> accountEmojis, @Nullable Card card,
|
Status.Application application, List<Emoji> statusEmojis, List<Emoji> accountEmojis, List<Emoji> rebloggedByAccountEmojis, @Nullable Card card,
|
||||||
boolean isCollapsible, boolean isCollapsed, @Nullable PollViewData poll, boolean isBot) {
|
boolean isCollapsible, boolean isCollapsed, @Nullable PollViewData poll, boolean isBot) {
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -136,6 +138,7 @@ public abstract class StatusViewData {
|
||||||
this.application = application;
|
this.application = application;
|
||||||
this.statusEmojis = statusEmojis;
|
this.statusEmojis = statusEmojis;
|
||||||
this.accountEmojis = accountEmojis;
|
this.accountEmojis = accountEmojis;
|
||||||
|
this.rebloggedByAccountEmojis = rebloggedByAccountEmojis;
|
||||||
this.card = card;
|
this.card = card;
|
||||||
this.isCollapsible = isCollapsible;
|
this.isCollapsible = isCollapsible;
|
||||||
this.isCollapsed = isCollapsed;
|
this.isCollapsed = isCollapsed;
|
||||||
|
@ -258,6 +261,10 @@ public abstract class StatusViewData {
|
||||||
return accountEmojis;
|
return accountEmojis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Emoji> getRebloggedByAccountEmojis() {
|
||||||
|
return rebloggedByAccountEmojis;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Card getCard() {
|
public Card getCard() {
|
||||||
return card;
|
return card;
|
||||||
|
@ -324,6 +331,7 @@ public abstract class StatusViewData {
|
||||||
Objects.equals(application, concrete.application) &&
|
Objects.equals(application, concrete.application) &&
|
||||||
Objects.equals(statusEmojis, concrete.statusEmojis) &&
|
Objects.equals(statusEmojis, concrete.statusEmojis) &&
|
||||||
Objects.equals(accountEmojis, concrete.accountEmojis) &&
|
Objects.equals(accountEmojis, concrete.accountEmojis) &&
|
||||||
|
Objects.equals(rebloggedByAccountEmojis, concrete.rebloggedByAccountEmojis) &&
|
||||||
Objects.equals(card, concrete.card) &&
|
Objects.equals(card, concrete.card) &&
|
||||||
Objects.equals(poll, concrete.poll)
|
Objects.equals(poll, concrete.poll)
|
||||||
&& isCollapsed == concrete.isCollapsed;
|
&& isCollapsed == concrete.isCollapsed;
|
||||||
|
@ -429,6 +437,7 @@ public abstract class StatusViewData {
|
||||||
private Status.Application application;
|
private Status.Application application;
|
||||||
private List<Emoji> statusEmojis;
|
private List<Emoji> statusEmojis;
|
||||||
private List<Emoji> accountEmojis;
|
private List<Emoji> accountEmojis;
|
||||||
|
private List<Emoji> rebloggedByAccountEmojis;
|
||||||
private Card card;
|
private Card card;
|
||||||
private boolean isCollapsible; /** Whether the status meets the requirement to be collapsed */
|
private boolean isCollapsible; /** Whether the status meets the requirement to be collapsed */
|
||||||
private boolean isCollapsed; /** Whether the status is shown partially or fully */
|
private boolean isCollapsed; /** Whether the status is shown partially or fully */
|
||||||
|
@ -613,6 +622,11 @@ public abstract class StatusViewData {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setRebloggedByEmojis(List<Emoji> emojis) {
|
||||||
|
this.rebloggedByAccountEmojis = emojis;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder setCard(Card card) {
|
public Builder setCard(Card card) {
|
||||||
this.card = card;
|
this.card = card;
|
||||||
return this;
|
return this;
|
||||||
|
@ -656,7 +670,7 @@ public abstract class StatusViewData {
|
||||||
visibility, attachments, rebloggedByUsername, rebloggedAvatar, isSensitive, isExpanded,
|
visibility, attachments, rebloggedByUsername, rebloggedAvatar, isSensitive, isExpanded,
|
||||||
isShowingContent, userFullName, nickname, avatar, createdAt, reblogsCount,
|
isShowingContent, userFullName, nickname, avatar, createdAt, reblogsCount,
|
||||||
favouritesCount, inReplyToId, mentions, senderId, rebloggingEnabled, application,
|
favouritesCount, inReplyToId, mentions, senderId, rebloggingEnabled, application,
|
||||||
statusEmojis, accountEmojis, card, isCollapsible, isCollapsed, poll, isBot);
|
statusEmojis, accountEmojis, rebloggedByAccountEmojis, card, isCollapsible, isCollapsed, poll, isBot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue