mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-01-30 14:04:48 +01:00
fix #148, remember the last used note save folder
This commit is contained in:
parent
ddaaaa57f7
commit
d82950fd70
@ -1,6 +1,5 @@
|
|||||||
package com.simplemobiletools.notes.dialogs
|
package com.simplemobiletools.notes.dialogs
|
||||||
|
|
||||||
import android.os.Environment
|
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
@ -15,7 +14,7 @@ import java.io.File
|
|||||||
class ExportAsDialog(val activity: SimpleActivity, val note: Note, val callback: (exportPath: String) -> Unit) {
|
class ExportAsDialog(val activity: SimpleActivity, val note: Note, val callback: (exportPath: String) -> Unit) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
var realPath = File(note.path).parent ?: Environment.getExternalStorageDirectory().toString()
|
var realPath = File(note.path).parent ?: activity.config.lastUsedSavePath
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_export_as, null).apply {
|
val view = activity.layoutInflater.inflate(R.layout.dialog_export_as, null).apply {
|
||||||
file_path.text = activity.humanizePath(realPath)
|
file_path.text = activity.humanizePath(realPath)
|
||||||
|
|
||||||
@ -52,6 +51,7 @@ class ExportAsDialog(val activity: SimpleActivity, val note: Note, val callback:
|
|||||||
}
|
}
|
||||||
|
|
||||||
activity.config.lastUsedExtension = extension
|
activity.config.lastUsedExtension = extension
|
||||||
|
activity.config.lastUsedSavePath = realPath
|
||||||
callback(newFile.absolutePath)
|
callback(newFile.absolutePath)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.simplemobiletools.notes.helpers
|
package com.simplemobiletools.notes.helpers
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Environment
|
||||||
import com.simplemobiletools.commons.helpers.BaseConfig
|
import com.simplemobiletools.commons.helpers.BaseConfig
|
||||||
|
|
||||||
class Config(context: Context) : BaseConfig(context) {
|
class Config(context: Context) : BaseConfig(context) {
|
||||||
@ -51,4 +52,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
var lastUsedExtension: String
|
var lastUsedExtension: String
|
||||||
get() = prefs.getString(LAST_USED_EXTENSION, "txt")
|
get() = prefs.getString(LAST_USED_EXTENSION, "txt")
|
||||||
set(lastUsedExtension) = prefs.edit().putString(LAST_USED_EXTENSION, lastUsedExtension).apply()
|
set(lastUsedExtension) = prefs.edit().putString(LAST_USED_EXTENSION, lastUsedExtension).apply()
|
||||||
|
|
||||||
|
var lastUsedSavePath: String
|
||||||
|
get() = prefs.getString(LAST_USED_SAVE_PATH, Environment.getExternalStorageDirectory().toString())
|
||||||
|
set(lastUsedSavePath) = prefs.edit().putString(LAST_USED_SAVE_PATH, lastUsedSavePath).apply()
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ val FONT_SIZE = "font_size"
|
|||||||
val GRAVITY = "gravity"
|
val GRAVITY = "gravity"
|
||||||
val CURSOR_PLACEMENT = "cursor_placement"
|
val CURSOR_PLACEMENT = "cursor_placement"
|
||||||
val LAST_USED_EXTENSION = "last_used_extension"
|
val LAST_USED_EXTENSION = "last_used_extension"
|
||||||
|
val LAST_USED_SAVE_PATH = "last_used_save_path"
|
||||||
|
|
||||||
// gravity
|
// gravity
|
||||||
val GRAVITY_LEFT = 0
|
val GRAVITY_LEFT = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user