From 0e7e32baf2cd1b7db1b3be89cb3b12c29599d27b Mon Sep 17 00:00:00 2001 From: Agnieszka C <85929121+Aga-C@users.noreply.github.com> Date: Sun, 3 Oct 2021 13:09:21 +0200 Subject: [PATCH] Added bitrate setting (#26) --- .../activities/SettingsActivity.kt | 19 +++++++++-- .../voicerecorder/helpers/Config.kt | 4 +++ .../voicerecorder/helpers/Constants.kt | 4 +++ .../voicerecorder/services/RecorderService.kt | 2 +- app/src/main/res/layout/activity_settings.xml | 32 +++++++++++++++++++ app/src/main/res/values-da/strings.xml | 2 ++ app/src/main/res/values-de/strings.xml | 2 ++ app/src/main/res/values-el/strings.xml | 2 ++ app/src/main/res/values-es/strings.xml | 2 ++ app/src/main/res/values-fi/strings.xml | 2 ++ app/src/main/res/values-id/strings.xml | 2 ++ app/src/main/res/values-it/strings.xml | 2 ++ app/src/main/res/values-ja/strings.xml | 2 ++ app/src/main/res/values-lt/strings.xml | 2 ++ app/src/main/res/values-nl/strings.xml | 2 ++ app/src/main/res/values-pl/strings.xml | 2 ++ app/src/main/res/values-pt/strings.xml | 2 ++ app/src/main/res/values-ru/strings.xml | 2 ++ app/src/main/res/values-sk/strings.xml | 2 ++ app/src/main/res/values-tr/strings.xml | 2 ++ app/src/main/res/values-uk/strings.xml | 2 ++ app/src/main/res/values-zh-rCN/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 23 files changed, 94 insertions(+), 3 deletions(-) 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 9e2db66..5932425 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/SettingsActivity.kt @@ -10,10 +10,10 @@ import com.simplemobiletools.commons.helpers.isQPlus import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.voicerecorder.R import com.simplemobiletools.voicerecorder.extensions.config -import com.simplemobiletools.voicerecorder.helpers.EXTENSION_M4A -import com.simplemobiletools.voicerecorder.helpers.EXTENSION_MP3 +import com.simplemobiletools.voicerecorder.helpers.* import kotlinx.android.synthetic.main.activity_settings.* import java.util.* +import kotlin.collections.ArrayList class SettingsActivity : SimpleActivity() { @@ -32,6 +32,7 @@ class SettingsActivity : SimpleActivity() { setupHideNotification() setupSaveRecordingsFolder() setupExtension() + setupBitrate() updateTextColors(settings_scrollview) } @@ -107,4 +108,18 @@ class SettingsActivity : SimpleActivity() { } } } + + private fun setupBitrate() { + settings_bitrate.text = getBitrateText(config.bitrate) + settings_bitrate_holder.setOnClickListener { + val items = BITRATES.map { RadioItem(it, getBitrateText(it)) } as ArrayList + + RadioGroupDialog(this@SettingsActivity, items, config.bitrate) { + config.bitrate = it as Int + settings_bitrate.text = getBitrateText(config.bitrate) + } + } + } + + private fun getBitrateText(value: Int): String = getString(R.string.bitrate_value).format(value / 1000) } 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 b7acf9f..d175a63 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Config.kt @@ -21,6 +21,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getInt(EXTENSION, EXTENSION_M4A) set(extension) = prefs.edit().putInt(EXTENSION, extension).apply() + var bitrate: Int + get() = prefs.getInt(BITRATE, DEFAULT_BITRATE) + set(bitrate) = prefs.edit().putInt(BITRATE, bitrate).apply() + fun getExtensionText() = context.getString(when (extension) { EXTENSION_M4A -> R.string.m4a else -> R.string.mp3 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 f00baaf..9c10fcd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Constants.kt @@ -17,6 +17,9 @@ const val TOGGLE_PAUSE = PATH + "TOGGLE_PAUSE" const val EXTENSION_M4A = 0 const val EXTENSION_MP3 = 1 +val BITRATES = arrayListOf(320000, 256000, 192000, 160000, 128000, 96000, 64000, 32000) +const val DEFAULT_BITRATE = 128000 + const val RECORDING_RUNNING = 0 const val RECORDING_STOPPED = 1 const val RECORDING_PAUSED = 2 @@ -25,6 +28,7 @@ const val RECORDING_PAUSED = 2 const val HIDE_NOTIFICATION = "hide_notification" const val SAVE_RECORDINGS = "save_recordings" const val EXTENSION = "extension" +const val BITRATE = "BITRATE" @SuppressLint("InlinedApi") fun getAudioFileContentUri(id: Long): Uri { diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/services/RecorderService.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/services/RecorderService.kt index b9a2b60..1fd6a80 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/services/RecorderService.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/services/RecorderService.kt @@ -76,7 +76,7 @@ class RecorderService : Service() { setAudioSource(MediaRecorder.AudioSource.CAMCORDER) setOutputFormat(MediaRecorder.OutputFormat.MPEG_4) setAudioEncoder(MediaRecorder.AudioEncoder.AAC) - setAudioEncodingBitRate(128000) + setAudioEncodingBitRate(config.bitrate) setAudioSamplingRate(44100) try { diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 9d567f4..dd6d731 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -186,5 +186,37 @@ android:clickable="false" /> + + + + + + + + diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 09b2cf0..f98cf3e 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -17,6 +17,8 @@ Forsøg at skjule notifikation under optagelse Gem optagelser i + Quality (bitrate) + %d kbps Kan jeg skjule notifikationsikonet under optagelse? diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 6b8f1ba..ea7d785 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -17,6 +17,8 @@ Versuche die Aufnahmebenachrichtigung auszublenden Speichere Aufnahme in + Quality (bitrate) + %d kbps Kann ich das Benachrichtigungssymbol während der Aufnahme ausblenden? diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index ddd741d..cb4eaba 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -17,6 +17,8 @@ Δοκιμάστε να αποκρύψετε την ειδοποίηση εγγραφής Αποθήκευση εγγραφών σε + Quality (bitrate) + %d kbps Μπορώ να αποκρύψω το εικονίδιο ειδοποίησης κατά την εγγραφή; diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index be01213..adaa51a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -17,6 +17,8 @@ Tratar de ocultar la notificación de grabación Guardar grabaciones en + Quality (bitrate) + %d kbps ¿Puedo ocultar el ícono de notificación durante la grabación? diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 0a64794..f99ff8b 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -18,6 +18,8 @@ Yritä piilottaa tallennusilmoitus Tallenna tallenteet + Quality (bitrate) + %d kbps Voinko piilottaa ilmoituskuvakkeen tallennuksen aikana? diff --git a/app/src/main/res/values-id/strings.xml b/app/src/main/res/values-id/strings.xml index 9210097..f727201 100644 --- a/app/src/main/res/values-id/strings.xml +++ b/app/src/main/res/values-id/strings.xml @@ -17,6 +17,8 @@ Coba sembunyikan pemberitahuan rekaman Simpan rekaman di + Quality (bitrate) + %d kbps Bisakah saya menyembunyikan ikon notifikasi selama merekam? diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 7caf24c..899cc34 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -17,6 +17,8 @@ Prova a nascondere la notifica di registrazione Salva le registrazioni in + Quality (bitrate) + %d kbps Posso nascondere la notifica durante la registrazione? diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 6b4bcac..88fe398 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -17,6 +17,8 @@ 録音通知を隠す 録音を保存する + Quality (bitrate) + %d kbps 録音中に通知を非表示にすることは出来ますか? diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 1ea0d80..ee09122 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -17,6 +17,8 @@ Pabandyti paslėpti įrašymo pranešimą Išsaugoti įrašus + Quality (bitrate) + %d kbps Ar galiu paslėpti pranešimo ikonėlę įrašinėjant? diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index c6efc26..6b48815 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -17,6 +17,8 @@ Tijdens de opname proberen de notificatie te verbergen Opnames opslaan in + Quality (bitrate) + %d kbps Kan ik de notificatie tijdens het opnemen verbergen? diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index c109bcd..15fff10 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -18,6 +18,8 @@ Spróbuj ukrywać powiadomienie o nagrywaniu Zapisuj nagrania w + Jakość (przepływność) + %d kbps Czy mogę ukryć ikonę powiadomienia podczas nagrywania? diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index c21ddd4..491e3e7 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -17,6 +17,8 @@ Tentar ocultar a notificação da gravação Guardar gravações em + Quality (bitrate) + %d kbps Can I hide the notification icon during recording? diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 686ff6d..5b7dd96 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -18,6 +18,8 @@ Пытаться скрыть уведомление о записи Место хранения записей + Quality (bitrate) + %d kbps Можно ли скрыть значок уведомления во время записи? diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 12101fa..439e3ec 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -18,6 +18,8 @@ Skúsiť ukryť nahrávaciu notifikáciu Ukladať nahrávky do + Quality (bitrate) + %d kbps Viem nejakým spôsobom ukryť notifikačnú ikonku počas nahrávania? diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index fd0bee2..0ce1a48 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -17,6 +17,8 @@ Kayıt bildirimini gizlemeyi dene Kayıt klasörü: + Quality (bitrate) + %d kbps Kayıt sırasında bildirim simgesini gizleyebilir miyim? diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 6ec1948..70d4f2d 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -18,6 +18,8 @@ Намагатися приховати сповіщення про запис Місце зберігання записів + Quality (bitrate) + %d kbps Чи можна приховати значок сповіщення під час запису? diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 25c7e3a..eecf95a 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -17,6 +17,8 @@ 尝试隐藏录音通知提示 保存录音至 + Quality (bitrate) + %d kbps 在录音过程中我可以隐藏通知提示图标么? diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bf1e387..6e06791 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -17,6 +17,8 @@ Try hiding the recording notification Save recordings in + Quality (bitrate) + %d kbps Can I hide the notification icon during recording?