allow creating notes of a new type, Checklist

This commit is contained in:
tibbi 2018-12-07 21:55:21 +01:00
parent d9993f46cf
commit 2d36835ebb
3 changed files with 18 additions and 4 deletions

View File

@ -312,8 +312,8 @@ class MainActivity : SimpleActivity() {
private fun displayNewNoteDialog(value: String = "") { private fun displayNewNoteDialog(value: String = "") {
NewNoteDialog(this) { NewNoteDialog(this) {
val newNote = Note(null, it, value, TYPE_NOTE) it.value = value
addNewNote(newNote) addNewNote(it)
} }
} }

View File

@ -9,9 +9,12 @@ import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.value import com.simplemobiletools.commons.extensions.value
import com.simplemobiletools.notes.pro.R import com.simplemobiletools.notes.pro.R
import com.simplemobiletools.notes.pro.extensions.notesDB import com.simplemobiletools.notes.pro.extensions.notesDB
import com.simplemobiletools.notes.pro.helpers.TYPE_CHECKLIST
import com.simplemobiletools.notes.pro.helpers.TYPE_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: (title: String) -> Unit) { class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) {
init { init {
val view = activity.layoutInflater.inflate(R.layout.dialog_new_note, null) val view = activity.layoutInflater.inflate(R.layout.dialog_new_note, null)
@ -28,7 +31,9 @@ class NewNoteDialog(val activity: Activity, callback: (title: String) -> Unit) {
title.isEmpty() -> activity.toast(R.string.no_title) title.isEmpty() -> activity.toast(R.string.no_title)
activity.notesDB.getNoteIdWithTitle(title) != null -> activity.toast(R.string.title_taken) activity.notesDB.getNoteIdWithTitle(title) != null -> activity.toast(R.string.title_taken)
else -> { else -> {
callback(title) val type = if (view.note_checklist.isChecked) TYPE_CHECKLIST else TYPE_NOTE
val newNote = Note(null, title, "", type)
callback(newNote)
dismiss() dismiss()
} }
} }

View File

@ -18,4 +18,13 @@
android:textCursorDrawable="@null" android:textCursorDrawable="@null"
android:textSize="@dimen/normal_text_size"/> android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/note_checklist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/checklist"/>
</LinearLayout> </LinearLayout>