emojireactions: add emoji reaction list to StatusViewData

main
Alibek Omarov 5 years ago
parent 2f818a77f3
commit ae1cfc1d56
  1. 4
      app/src/main/java/com/keylesspalace/tusky/entity/Status.kt
  2. 1
      app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.java
  3. 23
      app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java

@ -142,6 +142,10 @@ data class Status(
fun getConversationId(): Int {
return pleroma?.conversationId ?: -1
}
fun getEmojiReactions(): List<EmojiReaction>? {
return pleroma?.emojiReactions;
}
private fun getEditableText(): String {
val builder = SpannableStringBuilder(content)

@ -69,6 +69,7 @@ public final class ViewDataUtils {
.setThreadMuted(visibleStatus.isThreadMuted())
.setThreadMutedOnBackend(visibleStatus.isThreadMuted())
.setConversationId(visibleStatus.getConversationId())
.setEmojiReactions(visibleStatus.getEmojiReactions())
.createStatusViewData();
}

@ -23,6 +23,7 @@ import android.text.Spanned;
import com.keylesspalace.tusky.entity.Attachment;
import com.keylesspalace.tusky.entity.Card;
import com.keylesspalace.tusky.entity.Emoji;
import com.keylesspalace.tusky.entity.EmojiReaction;
import com.keylesspalace.tusky.entity.Poll;
import com.keylesspalace.tusky.entity.Status;
@ -95,6 +96,8 @@ public abstract class StatusViewData {
private final boolean isUserMuted;
private final boolean isThreadMutedOnBackend; /* thread_muted state got from backend */
private final int conversationId;
@Nullable
private final List<EmojiReaction> emojiReactions;
public Concrete(String id, Spanned content, boolean reblogged, boolean favourited, boolean bookmarked,
@Nullable String spoilerText, Status.Visibility visibility, List<Attachment> attachments,
@ -104,7 +107,7 @@ public abstract class StatusViewData {
@Nullable Status.Mention[] mentions, String senderId, boolean rebloggingEnabled,
Status.Application application, List<Emoji> statusEmojis, List<Emoji> accountEmojis, @Nullable Card card,
boolean isCollapsible, boolean isCollapsed, @Nullable PollViewData poll, boolean isBot, boolean isThreadMuted,
boolean isUserMuted, boolean isThreadMutedOnBackend, int conversationId) {
boolean isUserMuted, boolean isThreadMutedOnBackend, int conversationId, @Nullable List<EmojiReaction> emojiReactions) {
this.id = id;
if (Build.VERSION.SDK_INT == 23) {
@ -148,6 +151,7 @@ public abstract class StatusViewData {
this.isThreadMutedOnBackend = isThreadMutedOnBackend;
this.isUserMuted = isUserMuted;
this.conversationId = conversationId;
this.emojiReactions = emojiReactions;
}
public String getId() {
@ -307,6 +311,11 @@ public abstract class StatusViewData {
public boolean isUserMuted() {
return isUserMuted;
}
@Nullable
public List<EmojiReaction> getEmojiReactions() {
return emojiReactions;
}
public boolean deepEquals(StatusViewData o) {
if (this == o) return true;
@ -345,7 +354,8 @@ public abstract class StatusViewData {
isThreadMuted == concrete.isThreadMuted &&
isUserMuted == concrete.isUserMuted &&
isThreadMutedOnBackend == concrete.isThreadMutedOnBackend &&
conversationId == concrete.conversationId;
conversationId == concrete.conversationId &&
Objects.equals(emojiReactions, concrete.emojiReactions);
}
static Spanned replaceCrashingCharacters(Spanned content) {
@ -456,6 +466,7 @@ public abstract class StatusViewData {
private boolean isThreadMutedOnBackend;
private boolean isUserMuted;
private int conversationId;
private List<EmojiReaction> emojiReactions;
public Builder() {
}
@ -495,6 +506,7 @@ public abstract class StatusViewData {
isThreadMuted = viewData.isThreadMuted;
isUserMuted = viewData.isUserMuted;
isThreadMutedOnBackend = viewData.isThreadMutedOnBackend;
emojiReactions = viewData.emojiReactions;
}
public Builder setId(String id) {
@ -685,6 +697,11 @@ public abstract class StatusViewData {
this.conversationId = conversationId;
return this;
}
public Builder setEmojiReactions(List<EmojiReaction> emojiReactions) {
this.emojiReactions = emojiReactions;
return this;
}
public StatusViewData.Concrete createStatusViewData() {
if (this.statusEmojis == null) statusEmojis = Collections.emptyList();
@ -696,7 +713,7 @@ public abstract class StatusViewData {
isShowingContent, userFullName, nickname, avatar, createdAt, reblogsCount,
favouritesCount, inReplyToId, mentions, senderId, rebloggingEnabled, application,
statusEmojis, accountEmojis, card, isCollapsible, isCollapsed, poll, isBot, isThreadMuted,
isUserMuted, isThreadMutedOnBackend, conversationId);
isUserMuted, isThreadMutedOnBackend, conversationId, emojiReactions);
}
}
}

Loading…
Cancel
Save