allow cusotmizing the save folder
This commit is contained in:
parent
2e7d9d4356
commit
74363046e8
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -98,5 +98,37 @@
|
|||
app:switchPadding="@dimen/medium_margin" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_save_recordings_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/bigger_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/bigger_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_save_recordings_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toStartOf="@+id/settings_save_recordings"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/save_recordings_in" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_save_recordings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in New Issue