From 0a12020fd809a66766462ae3e37ebabfafdd19d5 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 6 Dec 2020 11:24:36 +0100 Subject: [PATCH] Fix issue #129 --- .../fedilab/fedilabtube/PeertubeActivity.java | 4 +-- .../drawer/CommentListAdapter.java | 26 ++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 6ffb008..722efa5 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -403,7 +403,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd binding.closeReply.setOnClickListener(v -> closeCommentThread()); binding.closePost.setOnClickListener(v -> closePostComment()); - commentListAdapter = new CommentListAdapter(comments, isMyVideo || Helper.isVideoOwner(PeertubeActivity.this, peertube), false, peertubeInstance); + commentListAdapter = new CommentListAdapter(comments, isMyVideo || Helper.isVideoOwner(PeertubeActivity.this, peertube), false, peertubeInstance, sepiaSearch); commentListAdapter.allCommentRemoved = PeertubeActivity.this; LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this); binding.peertubeComments.setLayoutManager(mLayoutManager); @@ -532,7 +532,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd comment.setInReplyToCommentId(null); comment.setTotalReplies(0); commentsThread.add(0, comment); - commentReplyListAdapter = new CommentListAdapter(commentsThread, Helper.isVideoOwner(PeertubeActivity.this, peertube), true, peertubeInstance); + commentReplyListAdapter = new CommentListAdapter(commentsThread, Helper.isVideoOwner(PeertubeActivity.this, peertube), true, peertubeInstance, sepiaSearch); LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this); binding.peertubeReply.setLayoutManager(mLayoutManager); binding.peertubeReply.setNestedScrollingEnabled(false); diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java index 98ebd83..b5202b2 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java @@ -66,6 +66,7 @@ import es.dmoral.toasty.Toasty; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY; +import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn; public class CommentListAdapter extends RecyclerView.Adapter { @@ -78,13 +79,15 @@ public class CommentListAdapter extends RecyclerView.Adapter comments, boolean isVideoOwner, boolean isThread, String instance) { + public CommentListAdapter(List comments, boolean isVideoOwner, boolean isThread, String instance, boolean sepiaSearch) { this.comments = comments; commentListAdapter = this; this.isVideoOwner = isVideoOwner; this.isThread = isThread; this.instance = instance; + this.sepiaSearch = sepiaSearch; } @Override @@ -296,8 +299,25 @@ public class CommentListAdapter extends RecyclerView.Adapter ((PeertubeActivity) context).openPostComment(comment, i)); - holder.binding.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i)); + holder.binding.postReplyButton.setOnClickListener(v -> { + if (isLoggedIn(context) && !sepiaSearch) { + ((PeertubeActivity) context).openPostComment(comment, i); + } else { + if (sepiaSearch) { + Toasty.info(context, context.getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show(); + } else { + Toasty.error(context, context.getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show(); + } + } + + }); + if (isLoggedIn(context) && !sepiaSearch) { + holder.binding.replyButton.setVisibility(View.VISIBLE); + holder.binding.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i)); + } else { + holder.binding.replyButton.setVisibility(View.GONE); + } + } public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int i, APIResponse apiResponse) {