From 40db8951f98465a59dea6a3d59dc440d8796c819 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Tue, 22 Sep 2020 18:35:50 +0200 Subject: [PATCH] Strikethrough the reply info if parent post isn't visible --- .../tusky/adapter/StatusBaseViewHolder.java | 5 +++++ .../com/keylesspalace/tusky/entity/Status.kt | 7 ++++++- .../tusky/util/ViewDataUtils.java | 1 + .../tusky/viewdata/StatusViewData.java | 20 ++++++++++++++++--- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java index d49b189b..6d956860 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java @@ -17,6 +17,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import android.util.Log; +import android.graphics.Paint; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; @@ -386,6 +387,10 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { Context context = replyInfo.getContext(); String replyToAccount = status.getInReplyToAccountAcct(); replyInfo.setText(context.getString(R.string.status_replied_to_format, replyToAccount)); + if (status.getParentVisible() == false) + replyInfo.setPaintFlags(replyInfo.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); + else + replyInfo.setPaintFlags(replyInfo.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); replyInfo.setVisibility(View.VISIBLE); } else { replyInfo.setVisibility(View.GONE); 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 a6c42151..47dc44d1 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt @@ -155,6 +155,10 @@ data class Status( return pleroma?.inReplyToAccountAcct; } + fun getParentVisible(): Boolean { + return pleroma?.parentVisible ?: true; + } + private fun getEditableText(): String { val builder = SpannableStringBuilder(content) for (span in content.getSpans(0, content.length, URLSpan::class.java)) { @@ -187,7 +191,8 @@ data class Status( @SerializedName("thread_muted") var threadMuted: Boolean?, @SerializedName("conversation_id") val conversationId: Int?, @SerializedName("emoji_reactions") val emojiReactions: List?, - @SerializedName("in_reply_to_account_acct") val inReplyToAccountAcct: String? + @SerializedName("in_reply_to_account_acct") val inReplyToAccountAcct: String?, + @SerializedName("parent_visible") val parentVisible: Boolean? ) data class Mention ( 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 8c3b3c4e..c961d746 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.java @@ -76,6 +76,7 @@ public final class ViewDataUtils { .setThreadMuted(visibleStatus.isThreadMuted()) .setConversationId(visibleStatus.getConversationId()) .setEmojiReactions(visibleStatus.getEmojiReactions()) + .setParentVisible(visibleStatus.getParentVisible()) .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 289402c1..0f2f5c82 100644 --- a/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java +++ b/app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.java @@ -100,6 +100,7 @@ public abstract class StatusViewData { private final int conversationId; @Nullable private final List emojiReactions; + private final boolean parentVisible; public Concrete(String id, Spanned content, boolean reblogged, boolean favourited, boolean bookmarked, @Nullable String spoilerText, Status.Visibility visibility, List attachments, @@ -109,7 +110,7 @@ public abstract class StatusViewData { @Nullable String inReplyToAccountAcct, @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 isMuted, boolean isThreadMuted, - boolean isUserMuted, int conversationId, @Nullable List emojiReactions) { + boolean isUserMuted, int conversationId, @Nullable List emojiReactions, boolean parentVisible) { this.id = id; if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) { @@ -155,6 +156,7 @@ public abstract class StatusViewData { this.isUserMuted = isUserMuted; this.conversationId = conversationId; this.emojiReactions = emojiReactions; + this.parentVisible = parentVisible; } public String getId() { @@ -273,6 +275,10 @@ public abstract class StatusViewData { return accountEmojis; } + public boolean getParentVisible() { + return parentVisible; + } + @Nullable public Card getCard() { return card; @@ -364,7 +370,8 @@ public abstract class StatusViewData { isThreadMuted == concrete.isThreadMuted && isUserMuted == concrete.isUserMuted && conversationId == concrete.conversationId && - Objects.equals(emojiReactions, concrete.emojiReactions); + Objects.equals(emojiReactions, concrete.emojiReactions) && + parentVisible == concrete.parentVisible; } static Spanned replaceCrashingCharacters(Spanned content) { @@ -477,6 +484,7 @@ public abstract class StatusViewData { private boolean isUserMuted; private int conversationId; private List emojiReactions; + private boolean parentVisible; public Builder() { } @@ -518,6 +526,7 @@ public abstract class StatusViewData { isThreadMuted = viewData.isThreadMuted; isUserMuted = viewData.isUserMuted; emojiReactions = viewData.emojiReactions; + parentVisible = viewData.parentVisible; } public Builder setId(String id) { @@ -660,6 +669,11 @@ public abstract class StatusViewData { return this; } + public Builder setParentVisible(boolean parentVisible) { + this.parentVisible = parentVisible; + return this; + } + public Builder setCard(Card card) { this.card = card; return this; @@ -729,7 +743,7 @@ public abstract class StatusViewData { isShowingContent, userFullName, nickname, avatar, createdAt, reblogsCount, favouritesCount, inReplyToId, inReplyToAccountAcct, mentions, senderId, rebloggingEnabled, application, statusEmojis, accountEmojis, card, isCollapsible, isCollapsed, poll, isBot, isMuted, isThreadMuted, - isUserMuted, conversationId, emojiReactions); + isUserMuted, conversationId, emojiReactions, parentVisible); } } }