From 250aa03e9a2d066595b3fb947e7f327b5a1b8b8a Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 25 Nov 2020 15:08:38 +0100 Subject: [PATCH 1/3] some tries --- .../drawer/CommentListAdapter.java | 103 +++++++----------- .../main/res/drawable/rounded_decoration.xml | 63 +++++++++++ .../res/drawable/rounded_decoration_2.xml | 24 ++++ app/src/main/res/layout/drawer_comment.xml | 39 ++++++- 4 files changed, 163 insertions(+), 66 deletions(-) create mode 100644 app/src/main/res/drawable/rounded_decoration.xml create mode 100644 app/src/main/res/drawable/rounded_decoration_2.xml 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 419486d..3c2db29 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java @@ -33,15 +33,14 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.widget.Button; import android.widget.EditText; -import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.widget.PopupMenu; +import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.ContextCompat; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ViewModelProvider; @@ -59,6 +58,7 @@ import app.fedilab.fedilabtube.client.APIResponse; import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI; import app.fedilab.fedilabtube.client.data.CommentData.Comment; import app.fedilab.fedilabtube.client.entities.Report; +import app.fedilab.fedilabtube.databinding.DrawerCommentBinding; import app.fedilab.fedilabtube.helper.CommentDecorationHelper; import app.fedilab.fedilabtube.helper.EmojiHelper; import app.fedilab.fedilabtube.helper.Helper; @@ -104,8 +104,8 @@ public class CommentListAdapter extends RecyclerView.Adapter { - PopupMenu popup = new PopupMenu(context, holder.more_actions); + holder.binding.commentAccountProfile.setLayoutParams(params); + holder.binding.moreActions.setOnClickListener(view -> { + PopupMenu popup = new PopupMenu(context, holder.binding.moreActions); popup.getMenuInflater() .inflate(R.menu.comment_menu, popup.getMenu()); if (!Helper.isOwner(context, comment.getAccount())) { @@ -219,7 +221,7 @@ public class CommentListAdapter extends RecyclerView.Adapter { + holder.binding.commentContent.setOnTouchListener((view, motionEvent) -> { if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) { try { view.requestFocus(); @@ -234,22 +236,22 @@ public class CommentListAdapter extends RecyclerView.Adapter ((PeertubeActivity) context).openCommentThread(comment)); - holder.comment_content.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment)); + holder.binding.mainContainer.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment)); + holder.binding.commentContent.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment)); } if (comment.getTotalReplies() > 0) { - holder.number_of_replies.setVisibility(View.VISIBLE); - holder.number_of_replies.setText(context.getResources().getQuantityString(R.plurals.number_of_replies, comment.getTotalReplies(), comment.getTotalReplies())); + holder.binding.numberOfReplies.setVisibility(View.VISIBLE); + holder.binding.numberOfReplies.setText(context.getResources().getQuantityString(R.plurals.number_of_replies, comment.getTotalReplies(), comment.getTotalReplies())); } else { - holder.number_of_replies.setVisibility(View.GONE); + holder.binding.numberOfReplies.setVisibility(View.GONE); } if (comment.getAccount() != null) { @@ -265,10 +267,10 @@ public class CommentListAdapter extends RecyclerView.Adapter { + holder.binding.commentAccountProfile.setOnClickListener(v -> { Bundle b = new Bundle(); Intent intent = new Intent(context, ShowAccountActivity.class); b.putParcelable("account", comment.getAccount()); @@ -287,17 +289,17 @@ public class CommentListAdapter extends RecyclerView.Adapter ((PeertubeActivity) context).openPostComment(comment, i)); - holder.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i)); + holder.binding.postReplyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i)); + holder.binding.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i)); } public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int i, APIResponse apiResponse) { @@ -358,40 +360,15 @@ public class CommentListAdapter extends RecyclerView.Adapter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_decoration_2.xml b/app/src/main/res/drawable/rounded_decoration_2.xml new file mode 100644 index 0000000..504273d --- /dev/null +++ b/app/src/main/res/drawable/rounded_decoration_2.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_comment.xml b/app/src/main/res/layout/drawer_comment.xml index d6dfc9e..7cd2958 100644 --- a/app/src/main/res/layout/drawer_comment.xml +++ b/app/src/main/res/layout/drawer_comment.xml @@ -28,11 +28,43 @@ + + + + + + + @@ -42,9 +74,10 @@ android:layout_width="40dp" android:layout_height="40dp" android:layout_marginTop="5dp" + android:src="@drawable/missing_peertube" android:layout_marginStart="10dp" android:contentDescription="@string/profile_picture" - app:layout_constraintStart_toStartOf="@id/decoration" + app:layout_constraintStart_toStartOf="@id/decoration_long" app:layout_constraintTop_toTopOf="parent" /> From a02b8b79c1cb220d9fd9771f6b17647ce6dd1949 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 26 Nov 2020 14:16:44 +0100 Subject: [PATCH 2/3] some tests --- .../drawer/CommentListAdapter.java | 24 +- .../helper/CommentDecorationHelper.java | 36 ++ .../main/res/drawable/rounded_decoration.xml | 63 ---- .../drawable/rounded_decoration_bottom.xml | 38 ++ ...ation_2.xml => rounded_decoration_top.xml} | 4 +- app/src/main/res/layout/activity_peertube.xml | 335 +++++++++--------- app/src/main/res/layout/drawer_comment.xml | 80 +++-- app/src/main/res/values-night/styles.xml | 4 + 8 files changed, 322 insertions(+), 262 deletions(-) delete mode 100644 app/src/main/res/drawable/rounded_decoration.xml create mode 100644 app/src/main/res/drawable/rounded_decoration_bottom.xml rename app/src/main/res/drawable/{rounded_decoration_2.xml => rounded_decoration_top.xml} (90%) 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 3c2db29..9fa3fa1 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java @@ -67,6 +67,9 @@ 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.CommentDecorationHelper.allDecoration; +import static app.fedilab.fedilabtube.helper.CommentDecorationHelper.hideDecoration; +import static app.fedilab.fedilabtube.helper.CommentDecorationHelper.topDecorationOnly; public class CommentListAdapter extends RecyclerView.Adapter { @@ -108,6 +111,7 @@ public class CommentListAdapter extends RecyclerView.Adapter { PopupMenu popup = new PopupMenu(context, holder.binding.moreActions); popup.getMenuInflater() diff --git a/app/src/main/java/app/fedilab/fedilabtube/helper/CommentDecorationHelper.java b/app/src/main/java/app/fedilab/fedilabtube/helper/CommentDecorationHelper.java index f308f7c..264506d 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/helper/CommentDecorationHelper.java +++ b/app/src/main/java/app/fedilab/fedilabtube/helper/CommentDecorationHelper.java @@ -14,9 +14,12 @@ package app.fedilab.fedilabtube.helper; * You should have received a copy of the GNU General Public License along with TubeLab; if not, * see . */ +import android.view.View; + import java.util.List; import app.fedilab.fedilabtube.client.data.CommentData; +import app.fedilab.fedilabtube.databinding.DrawerCommentBinding; public class CommentDecorationHelper { @@ -40,4 +43,37 @@ public class CommentDecorationHelper { return Math.min(currentIdentation, 5); } } + + public static void topDecorationOnly(DrawerCommentBinding binding) { + binding.decorationTop.setVisibility(View.VISIBLE); + binding.decorationCurvedTop.setVisibility(View.VISIBLE); + binding.decorationCurvedBottom.setVisibility(View.GONE); + binding.decorationCurvedLine.setVisibility(View.VISIBLE); + binding.decorationBottom.setVisibility(View.GONE); + } + + public static void allDecoration(DrawerCommentBinding binding) { + binding.decorationTop.setVisibility(View.VISIBLE); + binding.decorationCurvedTop.setVisibility(View.VISIBLE); + binding.decorationCurvedBottom.setVisibility(View.VISIBLE); + binding.decorationCurvedLine.setVisibility(View.VISIBLE); + binding.decorationBottom.setVisibility(View.VISIBLE); + } + + public static void hideDecoration(DrawerCommentBinding binding) { + binding.decorationTop.setVisibility(View.GONE); + binding.decorationCurvedTop.setVisibility(View.GONE); + binding.decorationCurvedBottom.setVisibility(View.GONE); + binding.decorationCurvedLine.setVisibility(View.GONE); + binding.decorationBottom.setVisibility(View.GONE); + } + + public static boolean hasReplies(String commentId, List comments) { + for (CommentData.Comment comment : comments) { + if (comment.getInReplyToCommentId() != null && commentId.compareTo(comment.getInReplyToCommentId()) == 0) { + return true; + } + } + return false; + } } diff --git a/app/src/main/res/drawable/rounded_decoration.xml b/app/src/main/res/drawable/rounded_decoration.xml deleted file mode 100644 index 26dbb27..0000000 --- a/app/src/main/res/drawable/rounded_decoration.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_decoration_bottom.xml b/app/src/main/res/drawable/rounded_decoration_bottom.xml new file mode 100644 index 0000000..2113fe3 --- /dev/null +++ b/app/src/main/res/drawable/rounded_decoration_bottom.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/rounded_decoration_2.xml b/app/src/main/res/drawable/rounded_decoration_top.xml similarity index 90% rename from app/src/main/res/drawable/rounded_decoration_2.xml rename to app/src/main/res/drawable/rounded_decoration_top.xml index 504273d..582675b 100644 --- a/app/src/main/res/drawable/rounded_decoration_2.xml +++ b/app/src/main/res/drawable/rounded_decoration_top.xml @@ -11,8 +11,8 @@ + android:bottom="1.5dp" + android:left="1.5dp"> + android:orientation="horizontal" + tools:ignore="UseCompoundDrawables"> - - - - - - - - - - - - - - - - - - - - - -