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 0f23a48..94a9f76 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/SettingsActivity.kt @@ -1,10 +1,9 @@ package com.simplemobiletools.voicerecorder.activities import android.os.Bundle -import com.simplemobiletools.commons.extensions.beVisibleIf -import com.simplemobiletools.commons.extensions.isThankYouInstalled -import com.simplemobiletools.commons.extensions.launchPurchaseThankYouIntent -import com.simplemobiletools.commons.extensions.updateTextColors +import com.simplemobiletools.commons.dialogs.FilePickerDialog +import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.helpers.isQPlus import com.simplemobiletools.voicerecorder.R import com.simplemobiletools.voicerecorder.extensions.config import kotlinx.android.synthetic.main.activity_settings.* @@ -24,6 +23,7 @@ class SettingsActivity : SimpleActivity() { setupCustomizeColors() setupUseEnglish() setupHideNotification() + setupSaveRecordingsFolder() updateTextColors(settings_scrollview) } @@ -57,4 +57,20 @@ class SettingsActivity : SimpleActivity() { config.hideNotification = settings_hide_notification.isChecked } } + + private fun setupSaveRecordingsFolder() { + settings_save_recordings_holder.beGoneIf(isQPlus()) + settings_save_recordings.text = humanizePath(config.saveRecordingsFolder) + settings_save_recordings_holder.setOnClickListener { + FilePickerDialog(this, config.saveRecordingsFolder, false, showFAB = true) { + val path = it + handleSAFDialog(it) { + if (it) { + config.saveRecordingsFolder = path + settings_save_recordings.text = humanizePath(config.saveRecordingsFolder) + } + } + } + } + } } 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 51f9023..eb05841 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Config.kt @@ -2,6 +2,7 @@ package com.simplemobiletools.voicerecorder.helpers import android.content.Context import com.simplemobiletools.commons.helpers.BaseConfig +import com.simplemobiletools.voicerecorder.R class Config(context: Context) : BaseConfig(context) { companion object { @@ -11,4 +12,8 @@ class Config(context: Context) : BaseConfig(context) { var hideNotification: Boolean get() = prefs.getBoolean(HIDE_NOTIFICATION, false) set(hideNotification) = prefs.edit().putBoolean(HIDE_NOTIFICATION, hideNotification).apply() + + var saveRecordingsFolder: String + get() = prefs.getString(SAVE_RECORDINGS, "$internalStoragePath/${context.getString(R.string.app_name)}")!! + set(saveRecordingsFolder) = prefs.edit().putString(SAVE_RECORDINGS, saveRecordingsFolder).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 27390ee..dbd84e7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/helpers/Constants.kt @@ -8,3 +8,4 @@ const val STOP_AMPLITUDE_UPDATE = PATH + "STOP_AMPLITUDE_UPDATE" // shared preferences const val HIDE_NOTIFICATION = "hide_notification" +const val SAVE_RECORDINGS = "save_recordings" 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 3bc0823..fde0236 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/services/RecorderService.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/services/RecorderService.kt @@ -63,7 +63,7 @@ class RecorderService : Service() { val baseFolder = if (isQPlus()) { cacheDir } else { - val defaultFolder = File("$internalStoragePath/${getString(R.string.app_name)}") + val defaultFolder = File(config.saveRecordingsFolder) if (!defaultFolder.exists()) { defaultFolder.mkdir() } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index dfb6a5e..80ae3d7 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -98,5 +98,37 @@ app:switchPadding="@dimen/medium_margin" /> + + + + + + + +