From e68160800d86022149896a297d5285b9733952f0 Mon Sep 17 00:00:00 2001 From: FineFindus <63370021+FineFindus@users.noreply.github.com> Date: Sun, 26 Feb 2023 15:21:52 +0100 Subject: [PATCH] feat(notifications/action): add boost action --- .../android/PushNotificationReceiver.java | 11 +++++++++-- mastodon/src/main/res/values/strings_sk.xml | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index 3b665e118..5963aff85 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java +++ b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java @@ -24,8 +24,10 @@ import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.model.Account; import org.joinmastodon.android.model.NotificationAction; +import org.joinmastodon.android.model.Preferences; import org.joinmastodon.android.model.PushNotification; import org.joinmastodon.android.model.Status; +import org.joinmastodon.android.model.StatusPrivacy; import org.joinmastodon.android.ui.utils.UiUtils; import org.parceler.Parcels; @@ -109,7 +111,11 @@ public class PushNotificationReceiver extends BroadcastReceiver{ switch (NotificationAction.values()[intent.getIntExtra("notificationAction", 0)]) { case FAVORITE -> new SetStatusFavorited(statusID, true).exec(accountID); case BOOKMARK -> new SetStatusBookmarked(statusID, true).exec(accountID); -// case REBLOG -> new SetStatusReblogged(notification.status.id, true, GlobalUserPreferences.); + case REBLOG -> { + AccountSessionManager accountSessionManager = AccountSessionManager.getInstance(); + Preferences preferences = accountSessionManager.getAccount(accountID).preferences; + new SetStatusReblogged(notification.status.id, true, preferences.postingDefaultVisibility).exec(accountID); + } default -> Log.w(TAG, "onReceive: Failed to get NotificationAction"); } } @@ -196,7 +202,8 @@ public class PushNotificationReceiver extends BroadcastReceiver{ case MENTION -> { builder.addAction(buildNotificationAction(context, accountID, notification, "Favourite", NotificationAction.FAVORITE)); builder.addAction(buildNotificationAction(context, accountID, notification, "Bookmark", NotificationAction.BOOKMARK)); -// builder.addAction(buildNotificationAction(context, accountID, notification, "Reblog", NotificationAction.REBLOG)); + if (notification != null && 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)); } diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index a94de6489..28857dd63 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -262,4 +262,5 @@ Follow from other account Followed from %s Auto-hide Compose button + Boost \ No newline at end of file