Added option to suppress notifications when calling

This commit is contained in:
M66B 2022-06-14 07:02:38 +02:00
parent 64c0b5fa95
commit 0712055726
7 changed files with 51 additions and 2 deletions

View File

@ -4,6 +4,12 @@
### [Juratyrant](https://en.wikipedia.org/wiki/Juratyrant)
### Next version
* Added option to suppress new message notifications when calling
* Small improvements and minor bug fixes
* Updated translations
### 1.1915 - 2022-06-14
* Fixed initializing option values

View File

@ -4,6 +4,12 @@
### [Juratyrant](https://en.wikipedia.org/wiki/Juratyrant)
### Next version
* Added option to suppress new message notifications when calling
* Small improvements and minor bug fixes
* Updated translations
### 1.1915 - 2022-06-14
* Fixed initializing option values

View File

@ -4942,6 +4942,7 @@ class Core {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean badge = prefs.getBoolean("badge", true);
boolean notify_background_only = prefs.getBoolean("notify_background_only", false);
boolean notify_suppress_in_call = prefs.getBoolean("notify_suppress_in_call", false);
boolean notify_summary = prefs.getBoolean("notify_summary", false);
boolean notify_preview = prefs.getBoolean("notify_preview", true);
boolean notify_preview_only = prefs.getBoolean("notify_preview_only", false);
@ -4996,6 +4997,14 @@ class Core {
continue;
}
if (notify_suppress_in_call && message.notifying == 0 &&
MediaPlayerHelper.isInCall(context)) {
Log.i("Notify call=" + message.id);
if (!message.ui_ignored)
db.message().setMessageUiIgnored(message.id, true);
continue;
}
long group = (pro && message.accountNotify ? message.account : 0);
if (!message.folderUnified)
group = -message.folder;

View File

@ -91,6 +91,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private SwitchCompat swUnseenIgnored;
private SwitchCompat swNotifyBackgroundOnly;
private SwitchCompat swNotifyKnownOnly;
private SwitchCompat swNotifySuppressInCall;
private TextView tvNotifyKnownPro;
private SwitchCompat swNotifySummary;
private SwitchCompat swNotifyRemove;
@ -121,7 +122,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
"notify_flag", "notify_seen", "notify_hide", "notify_snooze",
"light", "sound", "notify_screen_on",
"badge", "unseen_ignored",
"notify_background_only", "notify_known", "notify_summary", "notify_remove", "notify_clear",
"notify_background_only", "notify_known", "notify_suppress_in_call", "notify_summary", "notify_remove", "notify_clear",
"notify_subtext", "notify_preview", "notify_preview_all", "notify_preview_only", "notify_transliterate",
"wearable_preview",
"notify_messaging",
@ -172,6 +173,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swUnseenIgnored = view.findViewById(R.id.swUnseenIgnored);
swNotifyBackgroundOnly = view.findViewById(R.id.swNotifyBackgroundOnly);
swNotifyKnownOnly = view.findViewById(R.id.swNotifyKnownOnly);
swNotifySuppressInCall = view.findViewById(R.id.swNotifySuppressInCall);
tvNotifyKnownPro = view.findViewById(R.id.tvNotifyKnownPro);
swNotifySummary = view.findViewById(R.id.swNotifySummary);
swNotifyRemove = view.findViewById(R.id.swNotifyRemove);
@ -467,6 +469,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
swNotifySuppressInCall.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_suppress_in_call", checked).apply();
}
});
swNotifySummary.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -675,6 +684,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swUnseenIgnored.setChecked(prefs.getBoolean("unseen_ignored", false));
swNotifyBackgroundOnly.setChecked(prefs.getBoolean("notify_background_only", false));
swNotifyKnownOnly.setChecked(prefs.getBoolean("notify_known", false));
swNotifySuppressInCall.setChecked(prefs.getBoolean("notify_suppress_in_call", false));
swNotifySummary.setChecked(prefs.getBoolean("notify_summary", false));
swNotifyRemove.setChecked(prefs.getBoolean("notify_remove", true));
swNotifyClear.setChecked(prefs.getBoolean("notify_clear", false));

View File

@ -538,6 +538,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyKnownOnly" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifySuppressInCall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_notify_suppress_in_call"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyKnownPro"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifySummary"
android:layout_width="0dp"
@ -546,7 +557,7 @@
android:text="@string/title_advanced_notify_summary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyKnownPro"
app:layout_constraintTop_toBottomOf="@id/swNotifySuppressInCall"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -617,6 +617,7 @@
<string name="title_advanced_unseen_ignored">Let the number of new messages match the number of notifications</string>
<string name="title_advanced_notify_background">Show notifications when in the background only</string>
<string name="title_advanced_notify_known">Show notifications for contacts only</string>
<string name="title_advanced_notify_suppress_in_call">Suppress notifications when calling</string>
<string name="title_advanced_notify_summary">Show summary notification only</string>
<string name="title_advanced_notify_preview">Show message preview in notifications</string>
<string name="title_advanced_notify_preview_all">Preview all text</string>

View File

@ -4,6 +4,12 @@
### [Juratyrant](https://en.wikipedia.org/wiki/Juratyrant)
### Next version
* Added option to suppress new message notifications when calling
* Small improvements and minor bug fixes
* Updated translations
### 1.1915 - 2022-06-14
* Fixed initializing option values