mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-12 22:50:07 +01:00
allow adding new items to checklists
This commit is contained in:
parent
c0acb525ad
commit
d021a9d0fd
@ -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()
|
||||
|
@ -10,14 +10,18 @@ import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
||||
import com.simplemobiletools.commons.extensions.isBlackAndWhiteTheme
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.notes.pro.dialogs.NewChecklistItemDialog
|
||||
import com.simplemobiletools.notes.pro.helpers.NOTE_ID
|
||||
import com.simplemobiletools.notes.pro.helpers.NotesHelper
|
||||
import com.simplemobiletools.notes.pro.models.ChecklistItem
|
||||
import com.simplemobiletools.notes.pro.models.Note
|
||||
import kotlinx.android.synthetic.main.fragment_checklist.view.*
|
||||
|
||||
class ChecklistFragment : NoteFragment() {
|
||||
private var noteId = 0L
|
||||
private var note: Note? = null
|
||||
private var items = ArrayList<ChecklistItem>()
|
||||
|
||||
lateinit var view: ViewGroup
|
||||
|
||||
@ -44,7 +48,10 @@ class ChecklistFragment : NoteFragment() {
|
||||
setImageDrawable(plusIcon)
|
||||
background.applyColorFilter(context!!.getAdjustedPrimaryColor())
|
||||
setOnClickListener {
|
||||
|
||||
NewChecklistItemDialog(activity as SimpleActivity) {
|
||||
val checklistItem = ChecklistItem(it, false)
|
||||
items.add(checklistItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
package com.simplemobiletools.notes.pro.models
|
||||
|
||||
data class ChecklistItem(val title: String, val isDone: Boolean)
|
21
app/src/main/res/layout/dialog_new_checklist_item.xml
Normal file
21
app/src/main/res/layout/dialog_new_checklist_item.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/dialog_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/checklist_item_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:inputType="textCapSentences"
|
||||
android:textCursorDrawable="@null"
|
||||
android:textSize="@dimen/normal_text_size"/>
|
||||
|
||||
</LinearLayout>
|
@ -10,7 +10,7 @@
|
||||
android:paddingRight="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/note_name"
|
||||
android:id="@+id/note_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
|
@ -8,7 +8,7 @@
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/note_name"
|
||||
android:id="@+id/note_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Cız sarğısını göstər</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Bütün qeydləri fayl şəklində çıxar</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Aktiver tekstombrydning</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Eksporter alle noter som filer</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Zeilenumbruch aktivieren</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Alle Notizen als Dateien exportieren</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Activar ajuste de línea</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Exportar todas las notas como archivos</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Activer le retour à la ligne</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Exporter toutes les notes en tant que fichiers</string>
|
||||
|
@ -48,8 +48,9 @@
|
||||
<string name="enable_line_wrap">Habilitar sangrado de liña</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Exportar todas as notas como ficheiros</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Omogući omotavanje linije</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Izvezi sve bilješke kao datoteke</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Enable line wrap</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Export all notes as files</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Abilita a capo automatico</string>
|
||||
<string name="use_incognito_mode">Usa la modalità incognito per le tastiere</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Esporta le note come file</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Enable line wrap</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Export all notes as files</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">naudoti eilutės perkėlimą</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Eksportuoti visus užrašus kaip bylas</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Enable line wrap</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Export all notes as files</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Zawijanie linii</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Eksportuj wszystkie notatki jako pliki</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Ativar quebra de linha</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Exportar todas as notas como arquivo</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Ativar quebra de linha</string>
|
||||
<string name="use_incognito_mode">Utilizar modo incógnito no teclado</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Exportar todas as notas como ficheiros</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Переносить строки</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Экспортировать все заметки в файлы</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Povoliť zalamovanie riadkov</string>
|
||||
<string name="use_incognito_mode">Použiť Inkognito mód klávesníc</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<string name="checklist">Zoznam vecí</string>
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Zoznam položiek</string>
|
||||
<string name="add_new_checklist_item">Pridať do zoznamu novú položku</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Exportovať všetky poznámky ako súbory</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Aktivera radbrytning</string>
|
||||
<string name="use_incognito_mode">Använd tangentbordets inkognitoläge</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Exportera alla anteckningar som filer</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Sözcük kaydırmayı etkinleştir</string>
|
||||
<string name="use_incognito_mode">Klavyelerin Gizli modunu kullan</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Tüm notları dosya olarak dışa aktar</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Enable line wrap</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Export all notes as files</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">自動換行</string>
|
||||
<string name="use_incognito_mode">使用無痕模式的鍵盤</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">將全部筆記匯出成檔案</string>
|
||||
|
@ -46,8 +46,9 @@
|
||||
<string name="enable_line_wrap">Enable line wrap</string>
|
||||
<string name="use_incognito_mode">Use Incognito mode of keyboards</string>
|
||||
|
||||
<!-- Checklist -->
|
||||
<!-- Checklists -->
|
||||
<string name="checklist">Checklist</string>
|
||||
<string name="add_new_checklist_item">Add a new checklist item</string>
|
||||
|
||||
<!-- Import / Export -->
|
||||
<string name="export_all_notes">Export all notes as files</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user