diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt index 6a083b19..6d7a1044 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/ChecklistAdapter.kt @@ -15,6 +15,7 @@ import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor import com.simplemobiletools.commons.extensions.removeBit +import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM import com.simplemobiletools.commons.interfaces.ItemMoveCallback import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract import com.simplemobiletools.commons.interfaces.StartReorderDragListener @@ -209,6 +210,7 @@ class ChecklistAdapter(activity: BaseSimpleActivity, var items: ArrayList + val isCustomSorting = checkedId == fieldRadio.sorting_dialog_radio_custom.id + view.sorting_dialog_radio_order.beGoneIf(isCustomSorting) + view.sorting_dialog_order_divider.beGoneIf(isCustomSorting) + view.move_undone_checklist_items_divider.beGoneIf(isCustomSorting) + view.settings_move_undone_checklist_items_holder.beGoneIf(isCustomSorting) + } + var fieldBtn = fieldRadio.sorting_dialog_radio_title if (currSorting and SORT_BY_DATE_CREATED != 0) { fieldBtn = fieldRadio.sorting_dialog_radio_date_created } + if (currSorting and SORT_BY_CUSTOM != 0) { + fieldBtn = fieldRadio.sorting_dialog_radio_custom + } + fieldBtn.isChecked = true } @@ -60,10 +74,13 @@ class SortChecklistDialog(private val activity: SimpleActivity, private val call val sortingRadio = view.sorting_dialog_radio_sorting var sorting = when (sortingRadio.checkedRadioButtonId) { R.id.sorting_dialog_radio_date_created -> SORT_BY_DATE_CREATED + R.id.sorting_dialog_radio_custom -> SORT_BY_CUSTOM else -> SORT_BY_TITLE } - if (view.sorting_dialog_radio_order.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) { + if (sortingRadio.checkedRadioButtonId != R.id.sorting_dialog_radio_custom + && view.sorting_dialog_radio_order.checkedRadioButtonId == R.id.sorting_dialog_radio_descending + ) { sorting = sorting or SORT_DESCENDING } 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 6e5b2e9c..f9d0d511 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 @@ -7,6 +7,7 @@ import android.view.ViewGroup import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.notes.pro.R import com.simplemobiletools.notes.pro.activities.SimpleActivity @@ -65,7 +66,8 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener { migrateCheckListOnFailure(storedNote) } - if (config?.moveDoneChecklistItems == true) { + val sorting = config?.sorting ?: 0 + if (sorting and SORT_BY_CUSTOM == 0 && config?.moveDoneChecklistItems == true) { items.sortBy { it.isDone } } @@ -159,9 +161,11 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener { private fun setupAdapter() { updateUIVisibility() ChecklistItem.sorting = requireContext().config.sorting - items.sort() - if (context?.config?.moveDoneChecklistItems == true) { - items.sortBy { it.isDone } + if (ChecklistItem.sorting and SORT_BY_CUSTOM == 0) { + items.sort() + if (context?.config?.moveDoneChecklistItems == true) { + items.sortBy { it.isDone } + } } ChecklistAdapter( activity = activity as SimpleActivity, @@ -217,6 +221,7 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener { } override fun refreshItems() { + loadNoteById(noteId) setupAdapter() } } diff --git a/app/src/main/res/layout/dialog_sort_checklist.xml b/app/src/main/res/layout/dialog_sort_checklist.xml index cf2b42a7..042dad42 100644 --- a/app/src/main/res/layout/dialog_sort_checklist.xml +++ b/app/src/main/res/layout/dialog_sort_checklist.xml @@ -32,9 +32,19 @@ android:paddingBottom="@dimen/normal_margin" android:text="@string/date_created" /> + + - + - +