From ae1cfc1d56103336a46b0278013732321ad45ef6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 6 Feb 2020 23:19:52 +0300 Subject: [PATCH] emojireactions: add emoji reaction list to StatusViewData --- .../com/keylesspalace/tusky/entity/Status.kt | 4 ++++ .../tusky/util/ViewDataUtils.java | 1 + .../tusky/viewdata/StatusViewData.java | 23 ++++++++++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt index 7fc10a8f..5a91a117 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt @@ -142,6 +142,10 @@ data class Status( fun getConversationId(): Int { return pleroma?.conversationId ?: -1 } + + fun getEmojiReactions(): List? { + return pleroma?.emojiReactions; + } private fun getEditableText(): String { val builder = SpannableStringBuilder(content) diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.java b/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.java index ea0c5d5c..c435f426 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.java @@ -69,6 +69,7 @@ public final class ViewDataUtils { .setThreadMuted(visibleStatus.isThreadMuted()) .setThreadMutedOnBackend(visibleStatus.isThreadMuted()) .setConversationId(visibleStatus.getConversationId()) + .setEmojiReactions(visibleStatus.getEmojiReactions()) .createStatusViewData(); } diff --git a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java index c27305d0..d1c27727 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java @@ -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 emojiReactions; public Concrete(String id, Spanned content, boolean reblogged, boolean favourited, boolean bookmarked, @Nullable String spoilerText, Status.Visibility visibility, List attachments, @@ -104,7 +107,7 @@ public abstract class StatusViewData { @Nullable Status.Mention[] mentions, String senderId, boolean rebloggingEnabled, Status.Application application, List statusEmojis, List 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 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 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 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 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); } } }