Merge pull request 'If possible set privacy option and microphone direction for voice recordings' (#177) from p42ity/monocles_chat:voice_recorder into master

Reviewed-on: https://codeberg.org/monocles/monocles_chat/pulls/177
This commit is contained in:
Arne-Brün Vogelsang 2024-04-07 20:40:55 +00:00
commit d2efe93e48

View file

@ -41,6 +41,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.graphics.Typeface;
import android.media.MediaRecorder;
import android.media.MicrophoneDirection;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -3347,6 +3348,12 @@ public class ConversationFragment extends XmppFragment
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
mRecorder.setPreferredMicrophoneDirection(MicrophoneDirection.MIC_DIRECTION_TOWARDS_USER);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
mRecorder.setPrivacySensitive(true);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && activity.xmppConnectionService.getBooleanPreference("alternative_voice_settings", R.bool.alternative_voice_settings)) {
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.WEBM);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.OPUS);