From fa63a699b8a40cec4dd2ba5280330b408e33e123 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 7 Dec 2019 15:32:32 +0100 Subject: [PATCH] implement the undone checklist item moving --- .../simplemobiletools/notes/pro/adapters/WidgetAdapter.kt | 3 +++ .../notes/pro/fragments/ChecklistFragment.kt | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt index 8af6c80a..2c26db62 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt @@ -94,6 +94,9 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi if (note?.type == TYPE_CHECKLIST) { val checklistItemType = object : TypeToken>() {}.type checklistItems = Gson().fromJson>(note!!.value, checklistItemType) ?: ArrayList(1) + if (context.config.moveUndoneChecklistItems) { + checklistItems .sortBy { it.isDone } + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt index 4f2b2be2..383e57dc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt @@ -13,6 +13,7 @@ import com.simplemobiletools.notes.pro.R import com.simplemobiletools.notes.pro.activities.SimpleActivity import com.simplemobiletools.notes.pro.adapters.ChecklistAdapter import com.simplemobiletools.notes.pro.dialogs.NewChecklistItemDialog +import com.simplemobiletools.notes.pro.extensions.config import com.simplemobiletools.notes.pro.extensions.notesDB import com.simplemobiletools.notes.pro.extensions.updateWidgets import com.simplemobiletools.notes.pro.helpers.NOTE_ID @@ -44,6 +45,10 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener { val checklistItemType = object : TypeToken>() {}.type items = Gson().fromJson>(note!!.value, checklistItemType) ?: ArrayList(1) + if (config!!.moveUndoneChecklistItems) { + items.sortBy { it.isDone } + } + context!!.updateTextColors(view.checklist_holder) setupFragment() }