mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-24 19:56:00 +00:00
Prevent notification sound when voice recording.
This commit is contained in:
committed by
Michelle Tang
parent
e7140a14a3
commit
f3857ed933
@@ -13,6 +13,7 @@ import org.signal.core.util.ThreadUtil;
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.components.voice.VoiceNoteDraft;
|
||||
import org.thoughtcrime.securesms.notifications.v2.InChatNotificationSoundSuppressor;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
@@ -99,6 +100,7 @@ public class AudioRecorder {
|
||||
}
|
||||
recorder.start(fds[1]);
|
||||
this.recordingSubject = recordingSingle;
|
||||
InChatNotificationSoundSuppressor.suppressNotification();
|
||||
} catch (IOException | RuntimeException e) {
|
||||
Log.w(TAG, e);
|
||||
recordingUriFuture = null;
|
||||
@@ -120,6 +122,7 @@ public class AudioRecorder {
|
||||
Log.e(TAG, "MediaRecorder was never initialized successfully!");
|
||||
return;
|
||||
}
|
||||
InChatNotificationSoundSuppressor.allowNotification();
|
||||
audioFocusManager.abandonAudioFocus();
|
||||
recorder.stop();
|
||||
recordingUriFuture.cancel(true);
|
||||
@@ -138,7 +141,7 @@ public class AudioRecorder {
|
||||
Log.e(TAG, "MediaRecorder was never initialized successfully!");
|
||||
return;
|
||||
}
|
||||
|
||||
InChatNotificationSoundSuppressor.allowNotification();
|
||||
audioFocusManager.abandonAudioFocus();
|
||||
recorder.stop();
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.thoughtcrime.securesms.notifications.v2
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
|
||||
/**
|
||||
* Suppressor for notification sounds.
|
||||
*/
|
||||
object InChatNotificationSoundSuppressor {
|
||||
private val TAG = Log.tag(InChatNotificationSoundSuppressor::class.java)
|
||||
var isSuppressed: Boolean = false
|
||||
|
||||
@JvmStatic
|
||||
fun suppressNotification() {
|
||||
isSuppressed = true
|
||||
Log.d(TAG, "Notification is suppressed.")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun allowNotification() {
|
||||
isSuppressed = false
|
||||
Log.d(TAG, "Notification is allowed.")
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,8 @@ object NotificationFactory {
|
||||
if (!NotificationChannels.getInstance().areNotificationsEnabled() ||
|
||||
!SignalStore.settings.isMessageNotificationsInChatSoundsEnabled ||
|
||||
ServiceUtil.getAudioManager(context).ringerMode != AudioManager.RINGER_MODE_NORMAL ||
|
||||
(System.currentTimeMillis() - lastAudibleNotification) < DefaultMessageNotifier.MIN_AUDIBLE_PERIOD_MILLIS
|
||||
(System.currentTimeMillis() - lastAudibleNotification) < DefaultMessageNotifier.MIN_AUDIBLE_PERIOD_MILLIS ||
|
||||
InChatNotificationSoundSuppressor.isSuppressed
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user