Support getting push notifications on emoji reaction

This commit is contained in:
fruye 2022-11-13 13:13:57 +01:00
parent f1b3df55fb
commit 1039c2d81e
5 changed files with 27 additions and 0 deletions

View File

@ -128,6 +128,7 @@ public class NotificationHelper {
public static final String CHANNEL_UPDATES = "CHANNEL_UPDATES";
public static final String CHANNEL_REPORT = "CHANNEL_REPORT";
public static final String CHANNEL_BACKGROUND_TASKS = "CHANNEL_BACKGROUND_TASKS";
public static final String CHANNEL_EMOJI_REACTION = "CHANNEL_EMOJI_REACTION";
/**
* WorkManager Tag
@ -538,6 +539,7 @@ public class NotificationHelper {
CHANNEL_SIGN_UP + account.getIdentifier(),
CHANNEL_UPDATES + account.getIdentifier(),
CHANNEL_REPORT + account.getIdentifier(),
CHANNEL_EMOJI_REACTION + account.getIdentifier(),
};
int[] channelNames = {
R.string.notification_mention_name,
@ -550,6 +552,7 @@ public class NotificationHelper {
R.string.notification_sign_up_name,
R.string.notification_update_name,
R.string.notification_report_name,
R.string.notification_emoji_name,
};
int[] channelDescriptions = {
R.string.notification_mention_descriptions,
@ -562,6 +565,7 @@ public class NotificationHelper {
R.string.notification_sign_up_description,
R.string.notification_update_description,
R.string.notification_report_description,
R.string.notification_emoji_description,
};
List<NotificationChannel> channels = new ArrayList<>(6);
@ -704,6 +708,8 @@ public class NotificationHelper {
return account.getNotificationsUpdates();
case REPORT:
return account.getNotificationsReports();
case EMOJI_REACTION:
return account.getNotificationsEmojiReactions();
default:
return false;
}
@ -737,6 +743,8 @@ public class NotificationHelper {
return CHANNEL_UPDATES + account.getIdentifier();
case REPORT:
return CHANNEL_REPORT + account.getIdentifier();
case EMOJI_REACTION:
return CHANNEL_REPORT + account.getAccountId();
default:
return null;
}
@ -823,6 +831,8 @@ public class NotificationHelper {
return String.format(context.getString(R.string.notification_update_format), accountName);
case REPORT:
return context.getString(R.string.notification_report_format, account.getDomain());
case EMOJI_REACTION:
return String.format(context.getString(R.string.notification_emoji_format), accountName, notification.getEmoji());
}
return null;
}
@ -837,6 +847,7 @@ public class NotificationHelper {
case FAVOURITE:
case REBLOG:
case STATUS:
case EMOJI_REACTION:
if (!TextUtils.isEmpty(notification.getStatus().getSpoilerText()) && !alwaysOpenSpoiler) {
return notification.getStatus().getSpoilerText();
} else {

View File

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

View File

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

View File

@ -99,6 +99,7 @@ object PrefKeys {
const val NOTIFICATION_FILTER_SIGN_UPS = "notificationFilterSignUps"
const val NOTIFICATION_FILTER_UPDATES = "notificationFilterUpdates"
const val NOTIFICATION_FILTER_REPORTS = "notificationFilterReports"
const val NOTIFICATION_FILTER_EMOJI_REACTIONS = "notificationFilterEmojiReactions"
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"

View File

@ -12,5 +12,7 @@
<string name="title_emoji_reacted_by">%s reacted by</string>
<string name="notification_emoji_format">%s reacted with %s to your post</string>
<string name="notification_emoji_name">Emoji Reactions</string>
<string name="notification_emoji_description">Notifications about new emoji reactions</string>
<string name="pref_title_notification_filter_emoji">my posts are reacted with emojis</string>
</resources>