Strikethrough the reply info if parent post isn't visible

main
Karol Kosek 4 years ago
parent 72a6b41bf6
commit 40db8951f9
  1. 5
      app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java
  2. 7
      app/src/main/java/com/keylesspalace/tusky/entity/Status.kt
  3. 1
      app/src/main/java/com/keylesspalace/tusky/util/ViewDataUtils.java
  4. 20
      app/src/main/java/com/keylesspalace/tusky/viewdata/StatusViewData.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);

@ -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<EmojiReaction>?,
@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 (

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

@ -100,6 +100,7 @@ public abstract class StatusViewData {
private final int conversationId;
@Nullable
private final List<EmojiReaction> emojiReactions;
private final boolean parentVisible;
public Concrete(String id, Spanned content, boolean reblogged, boolean favourited, boolean bookmarked,
@Nullable String spoilerText, Status.Visibility visibility, List<Attachment> attachments,
@ -109,7 +110,7 @@ public abstract class StatusViewData {
@Nullable String inReplyToAccountAcct, @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 isMuted, boolean isThreadMuted,
boolean isUserMuted, int conversationId, @Nullable List<EmojiReaction> emojiReactions) {
boolean isUserMuted, int conversationId, @Nullable List<EmojiReaction> 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<EmojiReaction> 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);
}
}
}

Loading…
Cancel
Save