notifications throttling setting for all conversations

This commit is contained in:
kosyak 2024-06-16 23:52:38 +02:00
parent 9f0b59af9f
commit ece06b9651
7 changed files with 48 additions and 4 deletions

View file

@ -1111,7 +1111,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
} }
public long getNotificationThrottlingPeriod() { public long getNotificationThrottlingPeriod() {
return this.getLongAttribute(ATTRIBUTE_NOTIFICATIONS_THROTTLING_PERIOD, -1); return this.getLongAttribute(ATTRIBUTE_NOTIFICATIONS_THROTTLING_PERIOD, -2);
} }
public boolean alwaysNotify() { public boolean alwaysNotify() {

View file

@ -969,6 +969,10 @@ public class NotificationService {
long throttlingPeriod = c.getNotificationThrottlingPeriod(); long throttlingPeriod = c.getNotificationThrottlingPeriod();
if (throttlingPeriod < -1) {
throttlingPeriod = mXmppConnectionService.getLongPreference("notification_throttling_period", R.integer.default_notification_throttling_period);
}
if (throttlingPeriod <= 0) { if (throttlingPeriod <= 0) {
return false; return false;
} }

View file

@ -2517,7 +2517,8 @@ public class ConversationFragment extends XmppFragment
protected void throttleNoisyNoftificationsDialog(final Conversation conversation) { protected void throttleNoisyNoftificationsDialog(final Conversation conversation) {
final AlertDialog.Builder builder = new AlertDialog.Builder(activity); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.pref_noisy_notifications_throttling); builder.setTitle(R.string.pref_noisy_notifications_throttling);
final int[] durations = activity.getResources().getIntArray(R.array.notification_throttling_periods_values); final int[] durations = activity.getResources().getIntArray(R.array.notification_throttling_periods_values_per_conversation);
final CharSequence[] labels = new CharSequence[durations.length]; final CharSequence[] labels = new CharSequence[durations.length];
int checkedIndex = -1; int checkedIndex = -1;
long period = conversation.getNotificationThrottlingPeriod(); long period = conversation.getNotificationThrottlingPeriod();
@ -2528,6 +2529,8 @@ public class ConversationFragment extends XmppFragment
if (durations[i] == -1) { if (durations[i] == -1) {
labels[i] = activity.getString(R.string.never); labels[i] = activity.getString(R.string.never);
} else if (durations[i] == -2) {
labels[i] = activity.getString(R.string.inherit);
} else { } else {
labels[i] = TimeFrameUtils.resolve(activity, durations[i]); labels[i] = TimeFrameUtils.resolve(activity, durations[i]);
} }

View file

@ -26,7 +26,22 @@
<item>-1</item> <item>-1</item>
</integer-array> </integer-array>
<integer-array name="notification_throttling_periods_values"> <string-array name="notification_throttling_periods_values">
<item>-1</item>
<item>5000</item>
<item>15000</item>
<item>30000</item>
<item>60000</item>
<item>120000</item>
<item>180000</item>
<item>300000</item>
<item>600000</item>
<item>900000</item>
<item>1800000</item>
</string-array>
<integer-array name="notification_throttling_periods_values_per_conversation">
<item>-2</item>
<item>-1</item> <item>-1</item>
<item>5000</item> <item>5000</item>
<item>15000</item> <item>15000</item>
@ -40,6 +55,20 @@
<item>1800000</item> <item>1800000</item>
</integer-array> </integer-array>
<string-array name="notification_throttling_periods">
<item>@string/never</item>
<item>5 sec</item>
<item>15 sec</item>
<item>30 sec</item>
<item>1 min</item>
<item>2 min</item>
<item>3 min</item>
<item>5 min</item>
<item>10 min</item>
<item>15 min</item>
<item>30 min</item>
</string-array>
<string-array name="quick_actions"> <string-array name="quick_actions">
<item>@string/none</item> <item>@string/none</item>
<item>@string/recently_used</item> <item>@string/recently_used</item>

View file

@ -16,7 +16,7 @@
<string name="notification_ringtone">content://settings/system/notification_sound</string> <string name="notification_ringtone">content://settings/system/notification_sound</string>
<string name="incoming_call_ringtone">content://settings/system/ringtone</string> <string name="incoming_call_ringtone">content://settings/system/ringtone</string>
<integer name="grace_period">144</integer> <integer name="grace_period">144</integer>
<integer name="default_notification_throttling_period">0</integer> <integer name="default_notification_throttling_period">-1</integer>
<integer name="auto_accept_filesize">524288</integer> <integer name="auto_accept_filesize">524288</integer>
<string name="picture_compression">auto</string> <string name="picture_compression">auto</string>
<bool name="use_green_background">true</bool> <bool name="use_green_background">true</bool>

View file

@ -418,6 +418,7 @@
<string name="modified_conference_options">Modified group chat options!</string> <string name="modified_conference_options">Modified group chat options!</string>
<string name="could_not_modify_conference_options">Could not modify group chat options</string> <string name="could_not_modify_conference_options">Could not modify group chat options</string>
<string name="never">Never</string> <string name="never">Never</string>
<string name="inherit">Inherit</string>
<string name="until_further_notice">Until further notice</string> <string name="until_further_notice">Until further notice</string>
<string name="snooze">Snooze</string> <string name="snooze">Snooze</string>
<string name="reply">Reply</string> <string name="reply">Reply</string>

View file

@ -79,6 +79,13 @@
android:key="grace_period_length" android:key="grace_period_length"
android:summary="@string/pref_notification_grace_period_summary" android:summary="@string/pref_notification_grace_period_summary"
android:title="@string/pref_notification_grace_period" /> android:title="@string/pref_notification_grace_period" />
<ListPreference
android:defaultValue="@integer/default_notification_throttling_period"
android:entries="@array/notification_throttling_periods"
android:entryValues="@array/notification_throttling_periods_values"
android:key="notification_throttling_period"
android:summary="@string/pref_noisy_notifications_throttling_summary"
android:title="@string/pref_noisy_notifications_throttling" />
<PreferenceScreen <PreferenceScreen
android:key="quiet_hours" android:key="quiet_hours"
android:summary="@string/pref_quiet_hours_summary" android:summary="@string/pref_quiet_hours_summary"