From 976fa284a7d3a354810181f9f19f21380690e705 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Wed, 19 Jun 2024 16:51:22 +0200 Subject: [PATCH] hide content warning button when there is no content (#4518) I encountered [this weird post](https://akko.wtf/notice/Aiz78vrg9jBNHJrvIO) today that had a content warning button but no content. This change will match Mastodon behavior and hide the button when there is no content to reveal. We probably did not encounter this bug earlier because Mastodon moves the CW to the content when the content is empty, but apparently not for federated posts. --- .../tusky/adapter/StatusBaseViewHolder.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 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 89a7d7eb7..0cf9cb150 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java @@ -235,9 +235,14 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { ); contentWarningDescription.setText(emojiSpoiler); contentWarningDescription.setVisibility(View.VISIBLE); - contentWarningButton.setVisibility(View.VISIBLE); - setContentWarningButtonText(expanded); - contentWarningButton.setOnClickListener(view -> toggleExpandedState(true, !expanded, status, statusDisplayOptions, listener)); + boolean hasContent = !TextUtils.isEmpty(status.getContent()); + if (hasContent) { + contentWarningButton.setVisibility(View.VISIBLE); + setContentWarningButtonText(expanded); + contentWarningButton.setOnClickListener(view -> toggleExpandedState(true, !expanded, status, statusDisplayOptions, listener)); + } else { + contentWarningButton.setVisibility(View.GONE); + } this.setTextVisible(true, expanded, status, statusDisplayOptions, listener); } else { contentWarningDescription.setVisibility(View.GONE);