diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/SettingsActivity.kt
index ae108d1..9415233 100644
--- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/SettingsActivity.kt
@@ -11,6 +11,7 @@ import com.simplemobiletools.commons.helpers.isTiramisuPlus
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.voicerecorder.R
import com.simplemobiletools.voicerecorder.extensions.config
+import com.simplemobiletools.voicerecorder.helpers.AUDIO_SOURCE
import com.simplemobiletools.voicerecorder.helpers.BITRATES
import com.simplemobiletools.voicerecorder.helpers.EXTENSION_M4A
import com.simplemobiletools.voicerecorder.helpers.EXTENSION_MP3
@@ -39,6 +40,7 @@ class SettingsActivity : SimpleActivity() {
setupSaveRecordingsFolder()
setupExtension()
setupBitrate()
+ setupAudioSource()
setupRecordAfterLaunch()
updateTextColors(settings_nested_scrollview)
@@ -172,4 +174,16 @@ class SettingsActivity : SimpleActivity() {
config.recordAfterLaunch = settings_record_after_launch.isChecked
}
}
+
+ private fun setupAudioSource() {
+ settings_audio_source.text = config.getAudioSourceText(config.audio_source)
+ settings_audio_source_holder.setOnClickListener {
+ val items = AUDIO_SOURCE.map { RadioItem(it, config.getAudioSourceText(it)) } as ArrayList
+
+ RadioGroupDialog(this@SettingsActivity, items, config.audio_source) {
+ config.audio_source = it as Int
+ settings_audio_source.text = config.getAudioSourceText(config.audio_source)
+ }
+ }
+ }
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Config.kt
index 63e7f30..171e162 100644
--- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Config.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Config.kt
@@ -23,6 +23,20 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(EXTENSION, EXTENSION_M4A)
set(extension) = prefs.edit().putInt(EXTENSION, extension).apply()
+ var audio_source: Int
+ get() = prefs.getInt(AUDIO_SRC, DEFAULT_AUDIO_SOURCE)
+ set(audio_source) = prefs.edit().putInt(AUDIO_SRC, audio_source).apply()
+
+ fun getAudioSourceText(audio_source: Int) = context.getString(when (audio_source) {
+ MediaRecorder.AudioSource.CAMCORDER -> R.string.audio_source_camcorder
+ MediaRecorder.AudioSource.DEFAULT -> R.string.audio_source_default
+ MediaRecorder.AudioSource.UNPROCESSED -> R.string.audio_source_unprocessed
+ MediaRecorder.AudioSource.MIC -> R.string.audio_source_microphone
+ MediaRecorder.AudioSource.VOICE_COMMUNICATION -> R.string.audio_source_voice_communication
+ MediaRecorder.AudioSource.VOICE_PERFORMANCE -> R.string.audio_source_voice_performance
+ else -> R.string.audio_source_camcorder
+ })
+
var bitrate: Int
get() = prefs.getInt(BITRATE, DEFAULT_BITRATE)
set(bitrate) = prefs.edit().putInt(BITRATE, bitrate).apply()
diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Constants.kt
index 731d73c..98fb80a 100644
--- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Constants.kt
@@ -2,6 +2,7 @@ package com.simplemobiletools.voicerecorder.helpers
import android.annotation.SuppressLint
import android.content.ContentUris
+import android.media.MediaRecorder
import android.net.Uri
import android.provider.MediaStore
import android.provider.MediaStore.Audio.Media
@@ -18,6 +19,15 @@ const val EXTENSION_M4A = 0
const val EXTENSION_MP3 = 1
const val EXTENSION_OGG = 2
+val AUDIO_SOURCE = arrayListOf(
+ MediaRecorder.AudioSource.CAMCORDER,
+ MediaRecorder.AudioSource.DEFAULT,
+ MediaRecorder.AudioSource.UNPROCESSED,
+ MediaRecorder.AudioSource.MIC,
+ MediaRecorder.AudioSource.VOICE_COMMUNICATION,
+ MediaRecorder.AudioSource.VOICE_PERFORMANCE)
+const val DEFAULT_AUDIO_SOURCE = MediaRecorder.AudioSource.CAMCORDER
+
val BITRATES = arrayListOf(32000, 64000, 96000, 128000, 160000, 192000, 256000, 320000)
const val DEFAULT_BITRATE = 128000
const val SAMPLE_RATE = 44100
@@ -33,6 +43,7 @@ const val TOGGLE_WIDGET_UI = "toggle_widget_ui"
const val HIDE_NOTIFICATION = "hide_notification"
const val SAVE_RECORDINGS = "save_recordings"
const val EXTENSION = "extension"
+const val AUDIO_SRC = "audio_source"
const val BITRATE = "bitrate"
const val RECORD_AFTER_LAUNCH = "record_after_launch"
diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/recorder/MediaRecorderWrapper.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/recorder/MediaRecorderWrapper.kt
index 5c2df45..5032853 100644
--- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/recorder/MediaRecorderWrapper.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/recorder/MediaRecorderWrapper.kt
@@ -10,7 +10,7 @@ import java.io.FileDescriptor
class MediaRecorderWrapper(val context: Context) : Recorder {
private var recorder = MediaRecorder().apply {
- setAudioSource(MediaRecorder.AudioSource.CAMCORDER)
+ setAudioSource(context.config.audio_source)
setOutputFormat(context.config.getOutputFormat())
setAudioEncoder(context.config.getAudioEncoder())
setAudioEncodingBitRate(context.config.bitrate)
diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/recorder/Mp3Recorder.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/recorder/Mp3Recorder.kt
index a2c4bcd..4e235c0 100644
--- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/recorder/Mp3Recorder.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/recorder/Mp3Recorder.kt
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.content.Context
import android.media.AudioFormat
import android.media.AudioRecord
-import android.media.MediaRecorder
import com.naman14.androidlame.AndroidLame
import com.naman14.androidlame.LameBuilder
import com.simplemobiletools.commons.extensions.showErrorToast
@@ -33,7 +32,7 @@ class Mp3Recorder(val context: Context) : Recorder {
@SuppressLint("MissingPermission")
private val audioRecord = AudioRecord(
- MediaRecorder.AudioSource.CAMCORDER,
+ context.config.audio_source,
SAMPLE_RATE,
AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT,
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index ba02c79..fe82616 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -235,6 +235,27 @@
+
+
+
+
+
Try hiding the recording notification
Save recordings in
+ Audio Source
Bitrate
Start recording automatically after launching the app
Can I hide the notification icon during recording?
Well, it depends. While you use your device it is no longer possible to fully hide the notifications of apps like this.
If you check the proper setting item, the app will do its best to hide it. You can hide it on the lockscreen though, if you disable the displaying of sensitive notifications in your device settings.
+
+ Camera (default)
+ Android default
+ Unprocessed
+ Microphone
+ Voice communication
+ Voice performance