Add "just posted" header for new status notifications

This commit is contained in:
Grishka 2024-09-21 07:41:45 +03:00
parent c6130e4d29
commit 18b5c8ed50
3 changed files with 24 additions and 8 deletions

View File

@ -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<StatusDisplayItem> 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<StatusDisplayItem> 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);

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M158,778L158,660L194,660L194,454Q194,354 253,275.5Q312,197 409,178L409,133Q409,103.42 429.71,82.71Q450.42,62 480,62Q509.58,62 530.29,82.71Q551,103.42 551,133L551,178Q649,197 707.5,275Q766,353 766,454L766,660L802,660L802,778L158,778ZM480.79,909Q446.05,909 421.52,884.62Q397,860.24 397,826L564,826Q564,861 539.56,885Q515.11,909 480.79,909Z"/>
</vector>

View File

@ -796,4 +796,5 @@
<item quantity="other">%1$s ran a poll that you and %2$,d others voted in</item>
</plurals>
<string name="own_poll_ended">Your poll has ended</string>
<string name="user_just_posted">%s just posted</string>
</resources>