From 44912b7982d61bfe061abfc7f15c723781f2beb4 Mon Sep 17 00:00:00 2001 From: sk Date: Sat, 7 Oct 2023 19:17:45 +0200 Subject: [PATCH] display timestamp in notification header closes sk22#668 --- .../NotificationHeaderStatusDisplayItem.java | 6 ++- .../display_item_notification_header.xml | 46 +++++++++++++++---- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/NotificationHeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/NotificationHeaderStatusDisplayItem.java index 7e9fd8077..30b40043c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/NotificationHeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/NotificationHeaderStatusDisplayItem.java @@ -46,11 +46,13 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{ private final String accountID; private final CustomEmojiHelper emojiHelper=new CustomEmojiHelper(); private final CharSequence text; + private final CharSequence timestamp; public NotificationHeaderStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, Notification notification, String accountID){ super(parentID, parentFragment); this.notification=notification; this.accountID=accountID; + this.timestamp=notification.createdAt==null ? null : UiUtils.formatRelativeTimestamp(context, notification.createdAt); if(notification.type==Notification.Type.POLL){ text=parentFragment.getString(R.string.poll_ended); @@ -112,7 +114,7 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{ public static class Holder extends StatusDisplayItem.Holder implements ImageLoaderViewHolder{ private final ImageView icon, avatar; - private final TextView text; + private final TextView text, timestamp; private final int selectableItemBackground; public Holder(Activity activity, ViewGroup parent){ @@ -120,6 +122,7 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{ icon=findViewById(R.id.icon); avatar=findViewById(R.id.avatar); text=findViewById(R.id.text); + timestamp=findViewById(R.id.timestamp); avatar.setOutlineProvider(OutlineProviders.roundedRect(8)); avatar.setClipToOutline(true); @@ -152,6 +155,7 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{ @Override public void onBind(NotificationHeaderStatusDisplayItem item){ text.setText(item.text); + timestamp.setText(item.timestamp); avatar.setVisibility(item.notification.type==Notification.Type.POLL ? View.GONE : View.VISIBLE); icon.setImageResource(switch(item.notification.type){ case FAVORITE -> R.drawable.ic_fluent_star_24_filled; diff --git a/mastodon/src/main/res/layout/display_item_notification_header.xml b/mastodon/src/main/res/layout/display_item_notification_header.xml index d9f598b4a..a6bbfdcde 100644 --- a/mastodon/src/main/res/layout/display_item_notification_header.xml +++ b/mastodon/src/main/res/layout/display_item_notification_header.xml @@ -22,14 +22,42 @@ android:layout_height="32dp" android:layout_marginStart="12dp"/> - + + + + + + + + + \ No newline at end of file