mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-23 03:50:07 +01:00
Merge pull request #340 from SimpleMobileTools/request_1
Allow opening files as Checklists
This commit is contained in:
commit
0d17a94d41
@ -497,8 +497,8 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun displayNewNoteDialog(value: String = "") {
|
||||
NewNoteDialog(this) {
|
||||
private fun displayNewNoteDialog(value: String = "", title: String? = null) {
|
||||
NewNoteDialog(this, title) {
|
||||
it.value = value
|
||||
addNewNote(it)
|
||||
}
|
||||
@ -545,12 +545,13 @@ class MainActivity : SimpleActivity() {
|
||||
val fileText = it.readText().trim()
|
||||
val checklistItems = fileText.parseChecklistItems()
|
||||
if (checklistItems != null) {
|
||||
val note = Note(null, it.absolutePath.getFilenameFromPath().substringBeforeLast('.'), fileText, NoteType.TYPE_CHECKLIST.value)
|
||||
addNewNote(note)
|
||||
val title = it.absolutePath.getFilenameFromPath().substringBeforeLast('.')
|
||||
val note = Note(null, title, fileText, NoteType.TYPE_CHECKLIST.value)
|
||||
displayNewNoteDialog(note.value, title = title)
|
||||
} else {
|
||||
runOnUiThread {
|
||||
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 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 {
|
||||
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)
|
||||
}
|
||||
|
||||
view.note_title.setText(title)
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user