mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
allow to toggle direct mentions notifications in muted chats
This commit is contained in:
@@ -86,6 +86,7 @@ public class DcContext {
|
||||
public final static int DC_CONNECTIVITY_CONNECTED = 4000;
|
||||
|
||||
private static final String CONFIG_ACCOUNT_ENABLED = "ui.enabled";
|
||||
private static final String CONFIG_MENTION_NOTIF_ENABLED = "ui.notify_mentions";
|
||||
|
||||
// when using DcAccounts, use DcAccounts.addAccount() instead
|
||||
public DcContext(String osName, String dbfile) {
|
||||
@@ -226,6 +227,14 @@ public class DcContext {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMentionsEnabled() {
|
||||
return !"0".equals(getConfig(CONFIG_MENTION_NOTIF_ENABLED));
|
||||
}
|
||||
|
||||
public void setMentionsEnabled(boolean enabled) {
|
||||
setConfigInt(CONFIG_MENTION_NOTIF_ENABLED, enabled? 1 : 0);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
String displayname = getConfig("displayname");
|
||||
if (displayname.isEmpty()) {
|
||||
|
||||
@@ -416,6 +416,7 @@ public class NotificationCenter {
|
||||
DcContext dcContext = context.dcAccounts.getAccount(accountId);
|
||||
int chatId = dcChat.getId();
|
||||
ChatData chatData = new ChatData(accountId, chatId);
|
||||
isMention = isMention && dcContext.isMentionsEnabled();
|
||||
|
||||
if (dcContext.isMuted() || (!isMention && dcChat.isMuted())) {
|
||||
return;
|
||||
|
||||
+9
@@ -36,6 +36,7 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
|
||||
private CheckBoxPreference ignoreBattery;
|
||||
private CheckBoxPreference notificationsEnabled;
|
||||
private CheckBoxPreference mentionNotifEnabled;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle paramBundle) {
|
||||
@@ -99,6 +100,13 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
dcContext.setMuted(!enabled);
|
||||
return true;
|
||||
});
|
||||
|
||||
mentionNotifEnabled = this.findPreference("pref_enable_mention_notifications");
|
||||
mentionNotifEnabled.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
boolean enabled = (Boolean) newValue;
|
||||
dcContext.setMentionsEnabled(enabled);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,6 +122,7 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme
|
||||
// update ignoreBattery in onResume() to reflects changes done in the system settings
|
||||
ignoreBattery.setChecked(isIgnoringBatteryOptimizations());
|
||||
notificationsEnabled.setChecked(!dcContext.isMuted());
|
||||
mentionNotifEnabled.setChecked(dcContext.isMentionsEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user