From 18b5c8ed50cfa9e631295e6cebfc7685f049923a Mon Sep 17 00:00:00 2001 From: Grishka Date: Sat, 21 Sep 2024 07:41:45 +0300 Subject: [PATCH] Add "just posted" header for new status notifications --- .../BaseNotificationsListFragment.java | 22 ++++++++++++------- .../ic_notifications_wght700fill1_20px.xml | 9 ++++++++ mastodon/src/main/res/values/strings.xml | 1 + 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 mastodon/src/main/res/drawable/ic_notifications_wght700fill1_20px.xml diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseNotificationsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseNotificationsListFragment.java index 599d0468..f5400932 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseNotificationsListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseNotificationsListFragment.java @@ -11,9 +11,11 @@ import org.joinmastodon.android.model.Status; import org.joinmastodon.android.model.viewmodel.NotificationViewModel; import org.joinmastodon.android.ui.displayitems.InlineStatusStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.NotificationHeaderStatusDisplayItem; +import org.joinmastodon.android.ui.displayitems.ReblogOrReplyLineStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.StatusDisplayItem; import org.parceler.Parcels; +import java.util.ArrayList; import java.util.List; import me.grishka.appkit.Nav; @@ -24,21 +26,25 @@ public abstract class BaseNotificationsListFragment extends BaseStatusListFragme @Override protected List buildDisplayItems(NotificationViewModel n){ - NotificationHeaderStatusDisplayItem titleItem; - if(n.notification.type==NotificationType.MENTION || n.notification.type==NotificationType.STATUS){ + StatusDisplayItem titleItem; + if(n.notification.type==NotificationType.MENTION){ titleItem=null; + }else if(n.notification.type==NotificationType.STATUS){ + if(n.status!=null) + titleItem=new ReblogOrReplyLineStatusDisplayItem(n.getID(), this, getString(R.string.user_just_posted, n.status.account.displayName), n.status.account.emojis, R.drawable.ic_notifications_wght700fill1_20px); + else + titleItem=null; }else{ titleItem=new NotificationHeaderStatusDisplayItem(n.getID(), this, n, accountID); - if(n.status!=null){ - n.status.card=null; - n.status.spoilerText=null; - } } if(n.status!=null){ - if(titleItem!=null){ + if(titleItem!=null && n.notification.type!=NotificationType.STATUS){ return List.of(titleItem, new InlineStatusStatusDisplayItem(n.getID(), this, n.status)); }else{ - return StatusDisplayItem.buildItems(this, n.status, accountID, n, knownAccounts, 0); + ArrayList items=StatusDisplayItem.buildItems(this, n.status, accountID, n, knownAccounts, 0); + if(titleItem!=null) + items.add(0, titleItem); + return items; } }else if(titleItem!=null){ return List.of(titleItem); diff --git a/mastodon/src/main/res/drawable/ic_notifications_wght700fill1_20px.xml b/mastodon/src/main/res/drawable/ic_notifications_wght700fill1_20px.xml new file mode 100644 index 00000000..2c432aeb --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_notifications_wght700fill1_20px.xml @@ -0,0 +1,9 @@ + + + diff --git a/mastodon/src/main/res/values/strings.xml b/mastodon/src/main/res/values/strings.xml index bb5c308b..dbce0d92 100644 --- a/mastodon/src/main/res/values/strings.xml +++ b/mastodon/src/main/res/values/strings.xml @@ -796,4 +796,5 @@ %1$s ran a poll that you and %2$,d others voted in Your poll has ended + %s just posted \ No newline at end of file