diff --git a/app/build.gradle b/app/build.gradle index 43f79a8b53..6c07f551d3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -246,7 +246,6 @@ android { buildTypes { release { signingConfig signingConfigs.release - debuggable true minifyEnabled false } debug { diff --git a/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt index 130c63d8c8..9b56dbb0b4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/calls/WebRtcCallActivity.kt @@ -90,6 +90,11 @@ class WebRtcCallActivity: PassphraseRequiredActionBarActivity() { wantsToAnswer = true } + microphoneButton.setOnClickListener { + val audioEnabledIntent = WebRtcCallService.microphoneIntent(this, !viewModel.microphoneEnabled) + startService(audioEnabledIntent) + } + speakerPhoneButton.setOnClickListener { val command = AudioManagerCommand.SetUserDevice( if (viewModel.isSpeaker) EARPIECE else SPEAKER_PHONE) WebRtcCallService.sendAudioManagerCommand(this, command) @@ -200,6 +205,15 @@ class WebRtcCallActivity: PassphraseRequiredActionBarActivity() { } } + launch { + viewModel.localAudioEnabledState.collect { isEnabled -> + microphoneButton.setImageResource( + if (isEnabled) R.drawable.ic_baseline_mic_off_24 + else R.drawable.ic_baseline_mic_24 + ) + } + } + launch { viewModel.localVideoEnabledState.collect { isEnabled -> local_renderer.removeAllViews() diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt b/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt index b8a34782ef..5d6d0319fe 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt @@ -92,8 +92,9 @@ class WebRtcCallService: Service(), CallManager.WebRtcListener { fun acceptCallIntent(context: Context) = Intent(context, WebRtcCallService::class.java) .setAction(ACTION_ANSWER_CALL) - fun speakerIntent(context: Context, enable: Boolean) = Intent(context, WebRtcCallService::class.java) - .setAction(ACTION_UPDATE_AUDIO) + fun microphoneIntent(context: Context, enabled: Boolean) = Intent(context, WebRtcCallService::class.java) + .setAction(ACTION_SET_MUTE_AUDIO) + .putExtra(EXTRA_MUTE, !enabled) fun createCall(context: Context, recipient: Recipient) = Intent(context, WebRtcCallService::class.java) .setAction(ACTION_OUTGOING_CALL) diff --git a/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallViewModel.kt index a9fd8ec6da..f1265fee40 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallViewModel.kt @@ -22,6 +22,11 @@ class CallViewModel @Inject constructor(private val callManager: CallManager): V val videoEnabled: Boolean get() = _videoEnabled + private var _microphoneEnabled: Boolean = true + + val microphoneEnabled: Boolean + get() = _microphoneEnabled + private var _isSpeaker: Boolean = false val isSpeaker: Boolean get() = _isSpeaker @@ -52,6 +57,7 @@ class CallViewModel @Inject constructor(private val callManager: CallManager): V val localAudioEnabledState get() = callManager.audioEvents.map { it.isEnabled } + .onEach { _microphoneEnabled = it } val localVideoEnabledState get() = callManager.videoEvents diff --git a/app/src/main/res/drawable/ic_baseline_mic_off_24.xml b/app/src/main/res/drawable/ic_baseline_mic_off_24.xml new file mode 100644 index 0000000000..8e199f115a --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_mic_off_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_outline_mic_none_24.xml b/app/src/main/res/drawable/ic_outline_mic_none_24.xml new file mode 100644 index 0000000000..2810bc9a2e --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_mic_none_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_outline_mic_off_24.xml b/app/src/main/res/drawable/ic_outline_mic_off_24.xml new file mode 100644 index 0000000000..631ced9615 --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_mic_off_24.xml @@ -0,0 +1,10 @@ + + +