mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-25 04:50:20 +01:00
Allow opening files as Checklists
This commit is contained in:
parent
8bdac0e761
commit
6733a9f263
@ -497,8 +497,8 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun displayNewNoteDialog(value: String = "") {
|
private fun displayNewNoteDialog(value: String = "", title: String? = null) {
|
||||||
NewNoteDialog(this) {
|
NewNoteDialog(this, title) {
|
||||||
it.value = value
|
it.value = value
|
||||||
addNewNote(it)
|
addNewNote(it)
|
||||||
}
|
}
|
||||||
@ -545,12 +545,13 @@ class MainActivity : SimpleActivity() {
|
|||||||
val fileText = it.readText().trim()
|
val fileText = it.readText().trim()
|
||||||
val checklistItems = fileText.parseChecklistItems()
|
val checklistItems = fileText.parseChecklistItems()
|
||||||
if (checklistItems != null) {
|
if (checklistItems != null) {
|
||||||
val note = Note(null, it.absolutePath.getFilenameFromPath().substringBeforeLast('.'), fileText, NoteType.TYPE_CHECKLIST.value)
|
val title = it.absolutePath.getFilenameFromPath().substringBeforeLast('.')
|
||||||
addNewNote(note)
|
val note = Note(null, title, fileText, NoteType.TYPE_CHECKLIST.value)
|
||||||
|
displayNewNoteDialog(note.value, title = title)
|
||||||
} else {
|
} else {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
OpenFileDialog(this, it.path) {
|
OpenFileDialog(this, it.path) {
|
||||||
addNewNote(it)
|
displayNewNoteDialog(it.value, title = it.title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,14 @@ import com.simplemobiletools.notes.pro.helpers.NoteType
|
|||||||
import com.simplemobiletools.notes.pro.models.Note
|
import com.simplemobiletools.notes.pro.models.Note
|
||||||
import kotlinx.android.synthetic.main.dialog_new_note.view.*
|
import kotlinx.android.synthetic.main.dialog_new_note.view.*
|
||||||
|
|
||||||
class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) {
|
class NewNoteDialog(val activity: Activity, title: String? = null, callback: (note: Note) -> Unit) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_new_note, null).apply {
|
val view = activity.layoutInflater.inflate(R.layout.dialog_new_note, null).apply {
|
||||||
new_note_type.check(if (activity.config.lastCreatedNoteType == NoteType.TYPE_TEXT.value) type_text_note.id else type_checklist.id)
|
new_note_type.check(if (activity.config.lastCreatedNoteType == NoteType.TYPE_TEXT.value) type_text_note.id else type_checklist.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view.note_title.setText(title)
|
||||||
|
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user