allow adding new items to checklists

This commit is contained in:
tibbi
2018-12-07 23:37:03 +01:00
parent c0acb525ad
commit d021a9d0fd
30 changed files with 120 additions and 31 deletions

View File

@ -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()
}
}
}
}
}
}
}

View File

@ -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)

View File

@ -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()