mirror of
				https://github.com/SimpleMobileTools/Simple-Notes.git
				synced 2025-06-05 17:00:23 +02:00 
			
		
		
		
	allow creating notes of a new type, Checklist
This commit is contained in:
		| @@ -312,8 +312,8 @@ class MainActivity : SimpleActivity() { | ||||
|  | ||||
|     private fun displayNewNoteDialog(value: String = "") { | ||||
|         NewNoteDialog(this) { | ||||
|             val newNote = Note(null, it, value, TYPE_NOTE) | ||||
|             addNewNote(newNote) | ||||
|             it.value = value | ||||
|             addNewNote(it) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -9,9 +9,12 @@ import com.simplemobiletools.commons.extensions.toast | ||||
| import com.simplemobiletools.commons.extensions.value | ||||
| import com.simplemobiletools.notes.pro.R | ||||
| 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.* | ||||
|  | ||||
| class NewNoteDialog(val activity: Activity, callback: (title: String) -> Unit) { | ||||
| class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) { | ||||
|     init { | ||||
|         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) | ||||
|                                     activity.notesDB.getNoteIdWithTitle(title) != null -> activity.toast(R.string.title_taken) | ||||
|                                     else -> { | ||||
|                                         callback(title) | ||||
|                                         val type = if (view.note_checklist.isChecked) TYPE_CHECKLIST else TYPE_NOTE | ||||
|                                         val newNote = Note(null, title, "", type) | ||||
|                                         callback(newNote) | ||||
|                                         dismiss() | ||||
|                                     } | ||||
|                                 } | ||||
|   | ||||
| @@ -18,4 +18,13 @@ | ||||
|         android:textCursorDrawable="@null" | ||||
|         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> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user