display timestamp in notification header
closes sk22#668
This commit is contained in:
@@ -46,11 +46,13 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
private final String accountID;
|
private final String accountID;
|
||||||
private final CustomEmojiHelper emojiHelper=new CustomEmojiHelper();
|
private final CustomEmojiHelper emojiHelper=new CustomEmojiHelper();
|
||||||
private final CharSequence text;
|
private final CharSequence text;
|
||||||
|
private final CharSequence timestamp;
|
||||||
|
|
||||||
public NotificationHeaderStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, Notification notification, String accountID){
|
public NotificationHeaderStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, Notification notification, String accountID){
|
||||||
super(parentID, parentFragment);
|
super(parentID, parentFragment);
|
||||||
this.notification=notification;
|
this.notification=notification;
|
||||||
this.accountID=accountID;
|
this.accountID=accountID;
|
||||||
|
this.timestamp=notification.createdAt==null ? null : UiUtils.formatRelativeTimestamp(context, notification.createdAt);
|
||||||
|
|
||||||
if(notification.type==Notification.Type.POLL){
|
if(notification.type==Notification.Type.POLL){
|
||||||
text=parentFragment.getString(R.string.poll_ended);
|
text=parentFragment.getString(R.string.poll_ended);
|
||||||
@@ -112,7 +114,7 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
|
|
||||||
public static class Holder extends StatusDisplayItem.Holder<NotificationHeaderStatusDisplayItem> implements ImageLoaderViewHolder{
|
public static class Holder extends StatusDisplayItem.Holder<NotificationHeaderStatusDisplayItem> implements ImageLoaderViewHolder{
|
||||||
private final ImageView icon, avatar;
|
private final ImageView icon, avatar;
|
||||||
private final TextView text;
|
private final TextView text, timestamp;
|
||||||
private final int selectableItemBackground;
|
private final int selectableItemBackground;
|
||||||
|
|
||||||
public Holder(Activity activity, ViewGroup parent){
|
public Holder(Activity activity, ViewGroup parent){
|
||||||
@@ -120,6 +122,7 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
icon=findViewById(R.id.icon);
|
icon=findViewById(R.id.icon);
|
||||||
avatar=findViewById(R.id.avatar);
|
avatar=findViewById(R.id.avatar);
|
||||||
text=findViewById(R.id.text);
|
text=findViewById(R.id.text);
|
||||||
|
timestamp=findViewById(R.id.timestamp);
|
||||||
|
|
||||||
avatar.setOutlineProvider(OutlineProviders.roundedRect(8));
|
avatar.setOutlineProvider(OutlineProviders.roundedRect(8));
|
||||||
avatar.setClipToOutline(true);
|
avatar.setClipToOutline(true);
|
||||||
@@ -152,6 +155,7 @@ public class NotificationHeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
@Override
|
@Override
|
||||||
public void onBind(NotificationHeaderStatusDisplayItem item){
|
public void onBind(NotificationHeaderStatusDisplayItem item){
|
||||||
text.setText(item.text);
|
text.setText(item.text);
|
||||||
|
timestamp.setText(item.timestamp);
|
||||||
avatar.setVisibility(item.notification.type==Notification.Type.POLL ? View.GONE : View.VISIBLE);
|
avatar.setVisibility(item.notification.type==Notification.Type.POLL ? View.GONE : View.VISIBLE);
|
||||||
icon.setImageResource(switch(item.notification.type){
|
icon.setImageResource(switch(item.notification.type){
|
||||||
case FAVORITE -> R.drawable.ic_fluent_star_24_filled;
|
case FAVORITE -> R.drawable.ic_fluent_star_24_filled;
|
||||||
|
|||||||
@@ -22,14 +22,42 @@
|
|||||||
android:layout_height="32dp"
|
android:layout_height="32dp"
|
||||||
android:layout_marginStart="12dp"/>
|
android:layout_marginStart="12dp"/>
|
||||||
|
|
||||||
|
<org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text"
|
android:id="@+id/text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:textAppearance="@style/m3_body_large"
|
android:textAppearance="@style/m3_body_large"
|
||||||
android:textColor="?colorM3OnSurface"
|
android:textColor="?colorM3OnSurface"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
|
android:ellipsize="end"
|
||||||
tools:text="Notification text"/>
|
tools:text="Notification text"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/separator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="4sp"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="@style/m3_body_medium"
|
||||||
|
android:textColor="?colorM3OnSurfaceVariant"
|
||||||
|
android:text="@string/sk_separator"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/timestamp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minWidth="56sp"
|
||||||
|
android:textAppearance="@style/m3_body_medium"
|
||||||
|
android:textColor="?colorM3OnSurfaceVariant"
|
||||||
|
android:maxLines="1"
|
||||||
|
tools:text="42m ago"/>
|
||||||
|
|
||||||
|
</org.joinmastodon.android.ui.views.HeaderSubtitleLinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user