mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 09:49:21 +02:00
make in-chat-sounds respect notification- and mute-settings
This commit is contained in:
parent
f30da6e912
commit
050c358859
4 changed files with 15 additions and 13 deletions
|
@ -53,6 +53,7 @@
|
|||
|
||||
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
|
||||
android:key="pref_key_inthread_notifications"
|
||||
android:dependency="pref_key_enable_notifications"
|
||||
android:title="@string/pref_in_chat_sounds"
|
||||
android:defaultValue="true" />
|
||||
|
||||
|
|
|
@ -93,7 +93,6 @@ import org.thoughtcrime.securesms.mms.GlideRequests;
|
|||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.notifications.InChatSounds;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
|
@ -1443,7 +1442,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
else {
|
||||
processComposeControls(ACTION_SEND_OUT);
|
||||
InChatSounds.getInstance(ConversationActivity.this).playSendSound();
|
||||
dcContext.notificationCenter.maybePlaySendSound(dcChat);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,7 @@ public class InChatSounds {
|
|||
|
||||
public void playSendSound() {
|
||||
try {
|
||||
if (Prefs.isInChatNotifications(appContext)) {
|
||||
soundPool.play(soundOut, 1.0f, 1.0f, 1, 0, 1.0f);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Log.e(TAG, "cannot play send sound", e);
|
||||
}
|
||||
|
@ -51,9 +49,7 @@ public class InChatSounds {
|
|||
|
||||
public void playIncomingSound() {
|
||||
try {
|
||||
if (Prefs.isInChatNotifications(appContext)) {
|
||||
soundPool.play(soundIn, 1.0f, 1.0f, 1, 0, 1.0f);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Log.e(TAG, "cannot play incoming sound", e);
|
||||
}
|
||||
|
|
|
@ -289,14 +289,14 @@ public class NotificationCenter {
|
|||
|
||||
DcChat dcChat = dcContext.getChat(chatId);
|
||||
|
||||
if (chatId == visibleChatId) {
|
||||
// in-chat sounds are not related to notifications,
|
||||
// they can be enabled/disabled independently
|
||||
InChatSounds.getInstance(context).playIncomingSound();
|
||||
if (!Prefs.isNotificationsEnabled(context) || dcChat.isMuted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Prefs.isNotificationsEnabled(context) || dcChat.isMuted()) {
|
||||
if (chatId == visibleChatId) {
|
||||
if (Prefs.isInChatNotifications(context)) {
|
||||
InChatSounds.getInstance(context).playIncomingSound();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -482,4 +482,10 @@ public class NotificationCenter {
|
|||
|
||||
});
|
||||
}
|
||||
|
||||
public void maybePlaySendSound(DcChat dcChat) {
|
||||
if (Prefs.isNotificationsEnabled(context) && !dcChat.isMuted()) {
|
||||
InChatSounds.getInstance(context).playSendSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue