mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-13 15:02:05 +02:00
add note path only if we want to update the file content itself
This commit is contained in:
parent
4b0f90a20a
commit
c0617d518a
@ -8,6 +8,7 @@ import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
||||
import com.simplemobiletools.commons.extensions.humanizePath
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.notes.R
|
||||
import com.simplemobiletools.notes.R.id.open_file_update_file
|
||||
import com.simplemobiletools.notes.helpers.TYPE_NOTE
|
||||
import com.simplemobiletools.notes.models.Note
|
||||
import kotlinx.android.synthetic.main.dialog_open_file.view.*
|
||||
@ -25,10 +26,12 @@ class OpenFileDialog(val activity: Activity, val path: String, val callback: (no
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.open_file)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
||||
val file = File(path)
|
||||
val updateFileOnEdit = view.open_file_type.checkedRadioButtonId == open_file_update_file
|
||||
val storePath = if (updateFileOnEdit) path else ""
|
||||
val storeContent = if (updateFileOnEdit) "" else File(path).readText()
|
||||
|
||||
val filename = path.getFilenameFromPath()
|
||||
val content = file.readText()
|
||||
val note = Note(0, filename, content, TYPE_NOTE, path)
|
||||
val note = Note(0, filename, storeContent, TYPE_NOTE, storePath)
|
||||
callback.invoke(note)
|
||||
dismiss()
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user