Skip to content

Commit d82950f

Browse files
committed
fix #148, remember the last used note save folder
1 parent ddaaaa5 commit d82950f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/dialogs/ExportAsDialog.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.simplemobiletools.notes.dialogs
22

3-
import android.os.Environment
43
import android.support.v7.app.AlertDialog
54
import android.view.WindowManager
65
import com.simplemobiletools.commons.dialogs.FilePickerDialog
@@ -15,7 +14,7 @@ import java.io.File
1514
class ExportAsDialog(val activity: SimpleActivity, val note: Note, val callback: (exportPath: String) -> Unit) {
1615

1716
init {
18-
var realPath = File(note.path).parent ?: Environment.getExternalStorageDirectory().toString()
17+
var realPath = File(note.path).parent ?: activity.config.lastUsedSavePath
1918
val view = activity.layoutInflater.inflate(R.layout.dialog_export_as, null).apply {
2019
file_path.text = activity.humanizePath(realPath)
2120

@@ -52,6 +51,7 @@ class ExportAsDialog(val activity: SimpleActivity, val note: Note, val callback:
5251
}
5352

5453
activity.config.lastUsedExtension = extension
54+
activity.config.lastUsedSavePath = realPath
5555
callback(newFile.absolutePath)
5656
dismiss()
5757
}

app/src/main/kotlin/com/simplemobiletools/notes/helpers/Config.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.simplemobiletools.notes.helpers
22

33
import android.content.Context
4+
import android.os.Environment
45
import com.simplemobiletools.commons.helpers.BaseConfig
56

67
class Config(context: Context) : BaseConfig(context) {
@@ -51,4 +52,8 @@ class Config(context: Context) : BaseConfig(context) {
5152
var lastUsedExtension: String
5253
get() = prefs.getString(LAST_USED_EXTENSION, "txt")
5354
set(lastUsedExtension) = prefs.edit().putString(LAST_USED_EXTENSION, lastUsedExtension).apply()
55+
56+
var lastUsedSavePath: String
57+
get() = prefs.getString(LAST_USED_SAVE_PATH, Environment.getExternalStorageDirectory().toString())
58+
set(lastUsedSavePath) = prefs.edit().putString(LAST_USED_SAVE_PATH, lastUsedSavePath).apply()
5459
}

app/src/main/kotlin/com/simplemobiletools/notes/helpers/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ val FONT_SIZE = "font_size"
1515
val GRAVITY = "gravity"
1616
val CURSOR_PLACEMENT = "cursor_placement"
1717
val LAST_USED_EXTENSION = "last_used_extension"
18+
val LAST_USED_SAVE_PATH = "last_used_save_path"
1819

1920
// gravity
2021
val GRAVITY_LEFT = 0

0 commit comments

Comments
 (0)