feat(notifications/action): only show actions if necessary

This commit is contained in:
FineFindus 2023-02-26 19:15:31 +01:00
parent 55d2ca4a93
commit 360cd7b5df
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
2 changed files with 13 additions and 5 deletions

View File

@ -199,14 +199,21 @@ public class PushNotificationReceiver extends BroadcastReceiver{
}
if (notification != null) {
switch (pn.notificationType) {
case MENTION -> {
builder.addAction(buildNotificationAction(context, accountID, notification, context.getString(R.string.sk_notification_action_favorite), NotificationAction.FAVORITE));
builder.addAction(buildNotificationAction(context, accountID, notification, context.getString(R.string.sk_notification_action_bookmark), NotificationAction.BOOKMARK));
if (notification != null && notification.status.visibility != StatusPrivacy.DIRECT)
builder.addAction(buildNotificationAction(context, accountID, notification, context.getString(R.string.sk_notification_action_boost), NotificationAction.REBLOG));
if(!notification.status.favourited)
builder.addAction(buildNotificationAction(context, accountID, notification, context.getString(R.string.sk_notification_action_favorite), NotificationAction.FAVORITE));
if(!notification.status.bookmarked)
builder.addAction(buildNotificationAction(context, accountID, notification, context.getString(R.string.sk_notification_action_bookmark), NotificationAction.BOOKMARK));
if(notification.status.visibility != StatusPrivacy.DIRECT)
builder.addAction(buildNotificationAction(context, accountID, notification, context.getString(R.string.sk_notification_action_boost), NotificationAction.REBLOG));
}
// case FOLLOW -> builder.addAction(buildNotificationAction(context, accountID, notification, null, "Refollow", NotificationAction.FAVORITE));
case FOLLOW -> {
// if ( notification != null && notification.status.account.)
builder.addAction(buildNotificationAction(context, accountID, notification, context.getString(R.string.sk_notification_action_follow), NotificationAction.FAVORITE));
}
}
}
nm.notify(accountID, GlobalUserPreferences.keepOnlyLatestNotification ? NOTIFICATION_ID : notificationId++, builder.build());

View File

@ -265,4 +265,5 @@
<string name="sk_notification_action_favorite">Favorite</string>
<string name="sk_notification_action_bookmark">Bookmark</string>
<string name="sk_notification_action_boost">Boost</string>
<string name="sk_notification_action_follow">Refollow</string>
</resources>