From 67b883660ffb4957f871ed6fa395805d65d363ed Mon Sep 17 00:00:00 2001 From: Javi Rueda Date: Fri, 26 Feb 2021 19:31:11 +0100 Subject: [PATCH] Hide support button and comments consistently with claim tags (#1152) * Hide support button and comments consistently with claim tags * Set visibility to GONE instead of INVISIBLE for the tipping button --- .../ui/channel/ChannelCommentsFragment.java | 16 +++++++++++-- .../browser/ui/channel/ChannelFragment.java | 5 ++++ .../ui/findcontent/FileViewFragment.java | 24 +++++++++++++++++-- .../res/layout/fragment_channel_comments.xml | 17 ++++++++++++- .../main/res/layout/fragment_file_view.xml | 16 ++++++++++++- app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 74 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java b/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java index c32d0f05..3374e963 100644 --- a/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java @@ -187,9 +187,21 @@ public class ChannelCommentsFragment extends Fragment implements SdkStatusListen private void checkAndLoadComments() { View root = getView(); if (root != null) { + View commentsDisabledText = root.findViewById(R.id.channel_disabled_comments); + View commentForm = root.findViewById(R.id.container_comment_form); RecyclerView commentsList = root.findViewById(R.id.channel_comments_list); - if (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0) { - loadComments(); + + if (claim.getTags().contains("disable-comments")) { + Helper.setViewVisibility(commentsDisabledText, View.VISIBLE); + Helper.setViewVisibility(commentForm, View.GONE); + Helper.setViewVisibility(commentsList, View.GONE); + } else { + Helper.setViewVisibility(commentsDisabledText, View.GONE); + Helper.setViewVisibility(commentForm, View.VISIBLE); + Helper.setViewVisibility(commentsList, View.VISIBLE); + if (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0) { + loadComments(); + } } } } diff --git a/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java b/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java index f7bb34e3..d42d125e 100644 --- a/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/channel/ChannelFragment.java @@ -503,6 +503,11 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen layoutLoadingState.setVisibility(View.GONE); layoutDisplayArea.setVisibility(View.VISIBLE); + if (claim.getTags().contains("disable-support")) + buttonTip.setVisibility(View.GONE); + else + buttonTip.setVisibility(View.VISIBLE); + String thumbnailUrl = claim.getThumbnailUrl(); String coverUrl = claim.getCoverUrl(); textTitle.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle()); diff --git a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java index b2248c62..5db02284 100644 --- a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java @@ -210,6 +210,8 @@ public class FileViewFragment extends BaseFragment implements private View layoutResolving; private int lastPositionSaved; + private View tipButton; + private WebView webView; private boolean webViewAdded; @@ -255,6 +257,8 @@ public class FileViewFragment extends BaseFragment implements layoutDisplayArea = root.findViewById(R.id.file_view_claim_display_area); buttonPublishSomething = root.findViewById(R.id.nothing_at_location_publish_button); + tipButton = root.findViewById(R.id.file_view_action_tip); + containerReplyToComment = root.findViewById(R.id.comment_form_reply_to_container); textReplyingTo = root.findViewById(R.id.comment_form_replying_to_text); textReplyToBody = root.findViewById(R.id.comment_form_reply_to_body); @@ -1497,6 +1501,11 @@ public class FileViewFragment extends BaseFragment implements Helper.setViewVisibility(layoutLoadingState, View.GONE); Helper.setViewVisibility(layoutNothingAtLocation, View.GONE); + if (claim.getTags().contains("disable-support") || claim.getSigningChannel().getTags().contains("disable-support")) + Helper.setViewVisibility(tipButton, View.GONE); + else + Helper.setViewVisibility(tipButton, View.VISIBLE); + loadViewCount(); checkIsFollowing(); @@ -1679,9 +1688,20 @@ public class FileViewFragment extends BaseFragment implements private void checkAndLoadComments() { View root = getView(); if (root != null) { + View commentsDisabledText = root.findViewById(R.id.file_view_disabled_comments); + View commentForm = root.findViewById(R.id.container_comment_form); RecyclerView commentsList = root.findViewById(R.id.file_view_comments_list); - if (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0) { - loadComments(); + if (claim.getTags().contains("disable-comments") || claim.getSigningChannel().getTags().contains("disable-comments")) { + Helper.setViewVisibility(commentsDisabledText, View.VISIBLE); + Helper.setViewVisibility(commentForm, View.GONE); + Helper.setViewVisibility(commentsList, View.GONE); + } else { + Helper.setViewVisibility(commentsDisabledText, View.GONE); + Helper.setViewVisibility(commentForm, View.VISIBLE); + Helper.setViewVisibility(commentsList, View.VISIBLE); + if (commentsList == null || commentsList.getAdapter() == null || commentsList.getAdapter().getItemCount() == 0) { + loadComments(); + } } } } diff --git a/app/src/main/res/layout/fragment_channel_comments.xml b/app/src/main/res/layout/fragment_channel_comments.xml index d2c65ea2..75834a08 100644 --- a/app/src/main/res/layout/fragment_channel_comments.xml +++ b/app/src/main/res/layout/fragment_channel_comments.xml @@ -28,12 +28,27 @@ android:orientation="vertical"> + android:layout_marginBottom="16dp" + android:visibility="gone" /> + + - + + + No comments to display at this time. Comments will display after the background service is initialized. Your comment could not be posted at this time. Please try again later. + This channel has disabled comments on their page. + The creator of this content has disabled comments. Share LBRY content View Play