mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
allow adding new items to checklists
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
package com.simplemobiletools.notes.pro.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.DialogInterface.BUTTON_POSITIVE
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import kotlinx.android.synthetic.main.dialog_new_checklist_item.view.*
|
||||
|
||||
class NewChecklistItemDialog(val activity: Activity, callback: (title: String) -> Unit) {
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_new_checklist_item, null)
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.add_new_checklist_item) {
|
||||
showKeyboard(view.checklist_item_title)
|
||||
getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.checklist_item_title.value
|
||||
when {
|
||||
title.isEmpty() -> activity.toast(R.string.no_title)
|
||||
else -> {
|
||||
callback(title)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -23,9 +23,9 @@ class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) {
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.new_note) {
|
||||
showKeyboard(view.note_name)
|
||||
showKeyboard(view.note_title)
|
||||
getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.note_name.value
|
||||
val title = view.note_title.value
|
||||
Thread {
|
||||
when {
|
||||
title.isEmpty() -> activity.toast(R.string.no_title)
|
||||
|
@ -15,16 +15,16 @@ class RenameNoteDialog(val activity: SimpleActivity, val note: Note, val callbac
|
||||
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_rename_note, null)
|
||||
view.note_name.setText(note.title)
|
||||
view.note_title.setText(note.title)
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.rename_note) {
|
||||
showKeyboard(view.note_name)
|
||||
showKeyboard(view.note_title)
|
||||
getButton(BUTTON_POSITIVE).setOnClickListener {
|
||||
val title = view.note_name.value
|
||||
val title = view.note_title.value
|
||||
Thread {
|
||||
newTitleConfirmed(title, this)
|
||||
}.start()
|
||||
|
Reference in New Issue
Block a user