From 95a5940f04452842481e974a11e9fe893fd22cd8 Mon Sep 17 00:00:00 2001 From: qwerty287 Date: Wed, 15 Dec 2021 23:53:10 +0100 Subject: [PATCH] Improve notifications list (#1009) * show icons for repos and commit * hide repo if type is repo * improve some designs * allow click on repo notifications Co-authored-by: qwerty287 Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1009 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 Co-committed-by: qwerty287 --- .../gitnex/adapters/NotificationsAdapter.java | 41 +++++++++++- .../fragments/NotificationsFragment.java | 6 ++ .../main/res/layout/list_notifications.xml | 67 ++++++++++++++----- 3 files changed, 95 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/adapters/NotificationsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/NotificationsAdapter.java index c7dca257..3ab321d7 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/NotificationsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/NotificationsAdapter.java @@ -12,6 +12,7 @@ import androidx.annotation.NonNull; import androidx.core.content.res.ResourcesCompat; import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; +import org.apache.commons.lang3.StringUtils; import org.gitnex.tea4j.models.NotificationThread; import org.mian.gitnex.R; import org.mian.gitnex.database.api.BaseApi; @@ -90,8 +91,10 @@ public class NotificationsAdapter extends RecyclerView.Adapter" + context.getResources().getString(R.string.hash) + url.substring(url.lastIndexOf("/") + 1) + ""; + String subjectId = ""; + + if(StringUtils.containsAny(notificationThread.getSubject().getType().toLowerCase(), "pull", "issue")) { + subjectId = "" + context.getResources().getString(R.string.hash) + url.substring(url.lastIndexOf("/") + 1) + ""; + } subject.setText(HtmlCompat.fromHtml(subjectId + " " + notificationThread.getSubject().getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY)); - repository.setText(notificationThread.getRepository().getFullName()); + if(!notificationThread.getSubject().getType().equalsIgnoreCase("repository")) { + repository.setText(notificationThread.getRepository().getFullName()); + } else { + repository.setVisibility(View.GONE); + pinned.setVisibility(View.GONE); + pinned = itemView.findViewById(R.id.pinnedVertical); + } if(notificationThread.isPinned()) { pinned.setVisibility(View.VISIBLE); @@ -127,15 +142,35 @@ public class NotificationsAdapter extends RecyclerView.Adapter + + + + - - - - + app:srcCompat="@drawable/ic_pin" /> + + + + + + + + +