Support getting push notifications on move

Based on 28a02cf72a by a1ba.
This commit is contained in:
fruye 2022-11-13 17:36:52 +01:00
parent 384503b96b
commit 1906507ff7
5 changed files with 24 additions and 0 deletions

View File

@ -129,6 +129,7 @@ public class NotificationHelper {
public static final String CHANNEL_REPORT = "CHANNEL_REPORT"; public static final String CHANNEL_REPORT = "CHANNEL_REPORT";
public static final String CHANNEL_BACKGROUND_TASKS = "CHANNEL_BACKGROUND_TASKS"; public static final String CHANNEL_BACKGROUND_TASKS = "CHANNEL_BACKGROUND_TASKS";
public static final String CHANNEL_EMOJI_REACTION = "CHANNEL_EMOJI_REACTION"; public static final String CHANNEL_EMOJI_REACTION = "CHANNEL_EMOJI_REACTION";
public static final String CHANNEL_MOVE = "CHANNEL_MOVE";
/** /**
* WorkManager Tag * WorkManager Tag
@ -540,6 +541,7 @@ public class NotificationHelper {
CHANNEL_UPDATES + account.getIdentifier(), CHANNEL_UPDATES + account.getIdentifier(),
CHANNEL_REPORT + account.getIdentifier(), CHANNEL_REPORT + account.getIdentifier(),
CHANNEL_EMOJI_REACTION + account.getIdentifier(), CHANNEL_EMOJI_REACTION + account.getIdentifier(),
CHANNEL_MOVE + account.getIdentifier(),
}; };
int[] channelNames = { int[] channelNames = {
R.string.notification_mention_name, R.string.notification_mention_name,
@ -553,6 +555,7 @@ public class NotificationHelper {
R.string.notification_update_name, R.string.notification_update_name,
R.string.notification_report_name, R.string.notification_report_name,
R.string.notification_emoji_name, R.string.notification_emoji_name,
R.string.notification_move_name,
}; };
int[] channelDescriptions = { int[] channelDescriptions = {
R.string.notification_mention_descriptions, R.string.notification_mention_descriptions,
@ -566,6 +569,7 @@ public class NotificationHelper {
R.string.notification_update_description, R.string.notification_update_description,
R.string.notification_report_description, R.string.notification_report_description,
R.string.notification_emoji_description, R.string.notification_emoji_description,
R.string.notification_move_description,
}; };
List<NotificationChannel> channels = new ArrayList<>(6); List<NotificationChannel> channels = new ArrayList<>(6);
@ -710,6 +714,8 @@ public class NotificationHelper {
return account.getNotificationsReports(); return account.getNotificationsReports();
case EMOJI_REACTION: case EMOJI_REACTION:
return account.getNotificationsEmojiReactions(); return account.getNotificationsEmojiReactions();
case MOVE:
return account.getNotificationsMoves();
default: default:
return false; return false;
} }
@ -841,6 +847,8 @@ public class NotificationHelper {
private static String bodyForType(Notification notification, Context context, Boolean alwaysOpenSpoiler) { private static String bodyForType(Notification notification, Context context, Boolean alwaysOpenSpoiler) {
switch (notification.getType()) { switch (notification.getType()) {
case MOVE:
return "@" + notification.getTarget().getUsername();
case FOLLOW: case FOLLOW:
case FOLLOW_REQUEST: case FOLLOW_REQUEST:
case SIGN_UP: case SIGN_UP:

View File

@ -166,6 +166,17 @@ class NotificationPreferencesFragment : PreferenceFragmentCompat(), Injectable {
true true
} }
} }
switchPreference {
setTitle(R.string.pref_title_notification_filter_move)
key = PrefKeys.NOTIFICATION_FILTER_MOVES
isIconSpaceReserved = false
isChecked = activeAccount.notificationsMoves
setOnPreferenceChangeListener { _, newValue ->
updateAccount { it.notificationsMoves = newValue as Boolean }
true
}
}
} }
preferenceCategory(R.string.pref_title_notification_alerts) { category -> preferenceCategory(R.string.pref_title_notification_alerts) { category ->

View File

@ -58,6 +58,8 @@ data class AccountEntity(
var notificationsReports: Boolean = true, var notificationsReports: Boolean = true,
@ColumnInfo(defaultValue = "1") @ColumnInfo(defaultValue = "1")
var notificationsEmojiReactions: Boolean = true, var notificationsEmojiReactions: Boolean = true,
@ColumnInfo(defaultValue = "1")
var notificationsMoves: Boolean = true,
var notificationSound: Boolean = true, var notificationSound: Boolean = true,
var notificationVibration: Boolean = true, var notificationVibration: Boolean = true,
var notificationLight: Boolean = true, var notificationLight: Boolean = true,

View File

@ -100,6 +100,7 @@ object PrefKeys {
const val NOTIFICATION_FILTER_UPDATES = "notificationFilterUpdates" const val NOTIFICATION_FILTER_UPDATES = "notificationFilterUpdates"
const val NOTIFICATION_FILTER_REPORTS = "notificationFilterReports" const val NOTIFICATION_FILTER_REPORTS = "notificationFilterReports"
const val NOTIFICATION_FILTER_EMOJI_REACTIONS = "notificationFilterEmojiReactions" const val NOTIFICATION_FILTER_EMOJI_REACTIONS = "notificationFilterEmojiReactions"
const val NOTIFICATION_FILTER_MOVES = "notificationFilterMoves"
const val TAB_FILTER_HOME_REPLIES = "tabFilterHomeReplies_v2" // This was changed once to reset an unintentionally set default. const val TAB_FILTER_HOME_REPLIES = "tabFilterHomeReplies_v2" // This was changed once to reset an unintentionally set default.
const val TAB_FILTER_HOME_BOOSTS = "tabFilterHomeBoosts" const val TAB_FILTER_HOME_BOOSTS = "tabFilterHomeBoosts"

View File

@ -16,5 +16,7 @@
<string name="pref_title_notification_filter_emoji">my posts are reacted with emojis</string> <string name="pref_title_notification_filter_emoji">my posts are reacted with emojis</string>
<string name="notification_move_format">%s migrated to</string> <string name="notification_move_format">%s migrated to</string>
<string name="notification_move_name">Move</string> <string name="notification_move_name">Move</string>
<string name="notification_move_description">Notifications when somebody you\'re following migrated to another profile</string>
<string name="pref_title_notification_filter_move">somebody I\'m following migrated to another profile</string>
</resources> </resources>