Added starting recording on app launch (#20)

This commit is contained in:
Agnieszka C 2021-10-18 20:08:28 +02:00
parent 76d785be89
commit beb330c35a
23 changed files with 64 additions and 0 deletions

View file

@ -34,6 +34,15 @@ class MainActivity : SimpleActivity() {
finish()
}
}
if (config.recordAfterLaunch && !RecorderService.isRunning) {
Intent(this@MainActivity, RecorderService::class.java).apply {
try {
startService(this)
} catch (ignored: Exception) {
}
}
}
}
override fun onResume() {

View file

@ -32,6 +32,7 @@ class SettingsActivity : SimpleActivity() {
setupSaveRecordingsFolder()
setupExtension()
setupBitrate()
setupRecordAfterLaunch()
updateTextColors(settings_scrollview)
}
@ -126,4 +127,12 @@ class SettingsActivity : SimpleActivity() {
}
private fun getBitrateText(value: Int): String = getString(R.string.bitrate_value).format(value / 1000)
private fun setupRecordAfterLaunch() {
settings_record_after_launch.isChecked = config.recordAfterLaunch
settings_record_after_launch_holder.setOnClickListener {
settings_record_after_launch.toggle()
config.recordAfterLaunch = settings_record_after_launch.isChecked
}
}
}

View file

@ -26,6 +26,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(BITRATE, DEFAULT_BITRATE)
set(bitrate) = prefs.edit().putInt(BITRATE, bitrate).apply()
var recordAfterLaunch: Boolean
get() = prefs.getBoolean(RECORD_AFTER_LAUNCH, false)
set(recordAfterLaunch) = prefs.edit().putBoolean(RECORD_AFTER_LAUNCH, recordAfterLaunch).apply()
fun getExtensionText() = context.getString(when (extension) {
EXTENSION_M4A -> R.string.m4a
EXTENSION_OGG -> R.string.ogg

View file

@ -33,6 +33,7 @@ const val HIDE_NOTIFICATION = "hide_notification"
const val SAVE_RECORDINGS = "save_recordings"
const val EXTENSION = "extension"
const val BITRATE = "bitrate"
const val RECORD_AFTER_LAUNCH = "record_after_launch"
@SuppressLint("InlinedApi")
fun getAudioFileContentUri(id: Long): Uri {

View file

@ -218,5 +218,28 @@
android:clickable="false" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_record_after_launch_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_record_after_launch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingStart="@dimen/medium_margin"
android:text="@string/record_after_launch"
app:switchPadding="@dimen/medium_margin" />
</RelativeLayout>
</LinearLayout>
</ScrollView>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Forsøg at skjule notifikation under optagelse</string>
<string name="save_recordings_in">Gem optagelser i</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Kan jeg skjule notifikationsikonet under optagelse?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Versuche die Aufnahmebenachrichtigung auszublenden</string>
<string name="save_recordings_in">Speichere Aufnahme in</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Kann ich das Benachrichtigungssymbol während der Aufnahme ausblenden?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Δοκιμάστε να αποκρύψετε την ειδοποίηση εγγραφής</string>
<string name="save_recordings_in">Αποθήκευση εγγραφών σε</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Μπορώ να αποκρύψω το εικονίδιο ειδοποίησης κατά την εγγραφή;</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Tratar de ocultar la notificación de grabación</string>
<string name="save_recordings_in">Guardar grabaciones en</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">¿Puedo ocultar el ícono de notificación durante la grabación?</string>

View file

@ -19,6 +19,7 @@
<string name="try_hiding_notification">Yritä piilottaa tallennusilmoitus</string>
<string name="save_recordings_in">Tallenna tallenteet</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Voinko piilottaa ilmoituskuvakkeen tallennuksen aikana?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Coba sembunyikan pemberitahuan rekaman</string>
<string name="save_recordings_in">Simpan rekaman di</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Bisakah saya menyembunyikan ikon notifikasi selama merekam?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Prova a nascondere la notifica di registrazione</string>
<string name="save_recordings_in">Salva le registrazioni in</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Posso nascondere la notifica durante la registrazione?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">録音通知を隠す</string>
<string name="save_recordings_in">録音を保存する</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">録音中に通知を非表示にすることは出来ますか?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Pabandyti paslėpti įrašymo pranešimą</string>
<string name="save_recordings_in">Išsaugoti įrašus</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Ar galiu paslėpti pranešimo ikonėlę įrašinėjant?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Tijdens de opname proberen de notificatie te verbergen</string>
<string name="save_recordings_in">Opnames opslaan in</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Kan ik de notificatie tijdens het opnemen verbergen?</string>

View file

@ -19,6 +19,7 @@
<string name="try_hiding_notification">Spróbuj ukrywać powiadomienie o nagrywaniu</string>
<string name="save_recordings_in">Zapisuj nagrania w</string>
<string name="bitrate">Przepływność</string>
<string name="record_after_launch">Rozpoczynaj nagrywanie automatycznie przy uruchomieniu aplikacji</string>
<!-- FAQ -->
<string name="faq_1_title">Czy mogę ukryć ikonę powiadomienia podczas nagrywania?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Tentar ocultar a notificação da gravação</string>
<string name="save_recordings_in">Guardar gravações em</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Can I hide the notification icon during recording?</string>

View file

@ -19,6 +19,7 @@
<string name="try_hiding_notification">Пытаться скрыть уведомление о записи</string>
<string name="save_recordings_in">Место хранения записей</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Можно ли скрыть значок уведомления во время записи?</string>

View file

@ -19,6 +19,7 @@
<string name="try_hiding_notification">Skúsiť ukryť nahrávaciu notifikáciu</string>
<string name="save_recordings_in">Ukladať nahrávky do</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Viem nejakým spôsobom ukryť notifikačnú ikonku počas nahrávania?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Kayıt bildirimini gizlemeyi dene</string>
<string name="save_recordings_in">Kayıt klasörü:</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Kayıt sırasında bildirim simgesini gizleyebilir miyim?</string>

View file

@ -19,6 +19,7 @@
<string name="try_hiding_notification">Намагатися приховати сповіщення про запис</string>
<string name="save_recordings_in">Місце зберігання записів</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Чи можна приховати значок сповіщення під час запису?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">尝试隐藏录音通知提示</string>
<string name="save_recordings_in">保存录音至</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">在录音过程中我可以隐藏通知提示图标么?</string>

View file

@ -18,6 +18,7 @@
<string name="try_hiding_notification">Try hiding the recording notification</string>
<string name="save_recordings_in">Save recordings in</string>
<string name="bitrate">Bitrate</string>
<string name="record_after_launch">Start recording automatically after launching the app</string>
<!-- FAQ -->
<string name="faq_1_title">Can I hide the notification icon during recording?</string>