mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-16 16:27:23 +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.humanizePath
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.notes.R
|
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.helpers.TYPE_NOTE
|
||||||
import com.simplemobiletools.notes.models.Note
|
import com.simplemobiletools.notes.models.Note
|
||||||
import kotlinx.android.synthetic.main.dialog_open_file.view.*
|
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 {
|
.create().apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.open_file)
|
activity.setupDialogStuff(view, this, R.string.open_file)
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
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 filename = path.getFilenameFromPath()
|
||||||
val content = file.readText()
|
val note = Note(0, filename, storeContent, TYPE_NOTE, storePath)
|
||||||
val note = Note(0, filename, content, TYPE_NOTE, path)
|
|
||||||
callback.invoke(note)
|
callback.invoke(note)
|
||||||
dismiss()
|
dismiss()
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user