Skip to content

Commit fd14f01

Browse files
authored
Merge pull request #463 from Aga-C/move-setting-to-sort-dialog
Moved done checklist setting to the sorting dialog (#462)
2 parents 86b43ed + 47364d1 commit fd14f01

File tree

6 files changed

+39
-37
lines changed

6 files changed

+39
-37
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/SettingsActivity.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class SettingsActivity : SimpleActivity() {
3838
setupMonospacedFont()
3939
setupShowKeyboard()
4040
setupShowNotePicker()
41-
setupMoveUndoneChecklistItems()
4241
setupShowWordCount()
4342
setupEnableLineWrap()
4443
setupFontSize()
@@ -133,14 +132,6 @@ class SettingsActivity : SimpleActivity() {
133132
}
134133
}
135134

136-
private fun setupMoveUndoneChecklistItems() {
137-
settings_move_undone_checklist_items.isChecked = config.moveDoneChecklistItems
138-
settings_move_undone_checklist_items_holder.setOnClickListener {
139-
settings_move_undone_checklist_items.toggle()
140-
config.moveDoneChecklistItems = settings_move_undone_checklist_items.isChecked
141-
}
142-
}
143-
144135
private fun setupShowWordCount() {
145136
settings_show_word_count.isChecked = config.showWordCount
146137
settings_show_word_count_holder.setOnClickListener {

app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/WidgetAdapter.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
106106

107107
// checklist title can be null only because of the glitch in upgrade to 6.6.0, remove this check in the future
108108
checklistItems = checklistItems.filter { it.title != null }.toMutableList() as ArrayList<ChecklistItem>
109-
if (context.config.moveDoneChecklistItems) {
110-
checklistItems.sortBy { it.isDone }
111-
}
112109
}
113110
}
114111

app/src/main/kotlin/com/simplemobiletools/notes/pro/dialogs/SortChecklistDialog.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class SortChecklistDialog(private val activity: SimpleActivity, private val call
1818
init {
1919
setupSortRadio()
2020
setupOrderRadio()
21+
setupMoveUndoneChecklistItems()
2122
AlertDialog.Builder(activity)
2223
.setPositiveButton(R.string.ok) { _, _ -> dialogConfirmed() }
2324
.setNegativeButton(R.string.cancel, null)
@@ -48,6 +49,13 @@ class SortChecklistDialog(private val activity: SimpleActivity, private val call
4849
orderBtn.isChecked = true
4950
}
5051

52+
private fun setupMoveUndoneChecklistItems() {
53+
view.settings_move_undone_checklist_items.isChecked = config.moveDoneChecklistItems
54+
view.settings_move_undone_checklist_items_holder.setOnClickListener {
55+
view.settings_move_undone_checklist_items.toggle()
56+
}
57+
}
58+
5159
private fun dialogConfirmed() {
5260
val sortingRadio = view.sorting_dialog_radio_sorting
5361
var sorting = when (sortingRadio.checkedRadioButtonId) {
@@ -61,7 +69,9 @@ class SortChecklistDialog(private val activity: SimpleActivity, private val call
6169

6270
if (currSorting != sorting) {
6371
config.sorting = sorting
64-
callback()
6572
}
73+
74+
config.moveDoneChecklistItems = view.settings_move_undone_checklist_items.isChecked
75+
callback()
6676
}
6777
}

app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
160160
updateUIVisibility()
161161
ChecklistItem.sorting = requireContext().config.sorting
162162
items.sort()
163+
if (context?.config?.moveDoneChecklistItems == true) {
164+
items.sortBy { it.isDone }
165+
}
163166
ChecklistAdapter(
164167
activity = activity as SimpleActivity,
165168
items = items,

app/src/main/res/layout/activity_settings.xml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -346,29 +346,6 @@
346346

347347
</RelativeLayout>
348348

349-
<RelativeLayout
350-
android:id="@+id/settings_move_undone_checklist_items_holder"
351-
android:layout_width="match_parent"
352-
android:layout_height="wrap_content"
353-
android:layout_marginTop="@dimen/medium_margin"
354-
android:background="?attr/selectableItemBackground"
355-
android:paddingStart="@dimen/normal_margin"
356-
android:paddingTop="@dimen/activity_margin"
357-
android:paddingEnd="@dimen/normal_margin"
358-
android:paddingBottom="@dimen/activity_margin">
359-
360-
<com.simplemobiletools.commons.views.MySwitchCompat
361-
android:id="@+id/settings_move_undone_checklist_items"
362-
android:layout_width="match_parent"
363-
android:layout_height="wrap_content"
364-
android:background="@null"
365-
android:clickable="false"
366-
android:paddingStart="@dimen/medium_margin"
367-
android:text="@string/move_done_checklist_items"
368-
app:switchPadding="@dimen/medium_margin" />
369-
370-
</RelativeLayout>
371-
372349
<com.simplemobiletools.commons.views.MyTextView
373350
android:id="@+id/saving_label"
374351
android:layout_width="wrap_content"

app/src/main/res/layout/dialog_sort_checklist.xml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
34
android:id="@+id/dialog_holder"
45
android:layout_width="match_parent"
56
android:layout_height="match_parent"
@@ -39,7 +40,8 @@
3940
android:id="@+id/sorting_dialog_radio_order"
4041
android:layout_width="match_parent"
4142
android:layout_height="wrap_content"
42-
android:layout_marginTop="@dimen/medium_margin">
43+
android:layout_marginTop="@dimen/medium_margin"
44+
android:layout_marginBottom="@dimen/medium_margin">
4345

4446
<com.simplemobiletools.commons.views.MyCompatRadioButton
4547
android:id="@+id/sorting_dialog_radio_ascending"
@@ -59,4 +61,26 @@
5961
android:text="@string/descending" />
6062

6163
</RadioGroup>
64+
65+
<include layout="@layout/divider" />
66+
67+
<RelativeLayout
68+
android:id="@+id/settings_move_undone_checklist_items_holder"
69+
android:layout_width="match_parent"
70+
android:layout_height="wrap_content"
71+
android:layout_marginTop="@dimen/medium_margin"
72+
android:background="?attr/selectableItemBackground"
73+
android:paddingTop="@dimen/medium_margin"
74+
android:paddingBottom="@dimen/medium_margin">
75+
76+
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
77+
android:id="@+id/settings_move_undone_checklist_items"
78+
android:layout_width="match_parent"
79+
android:layout_height="wrap_content"
80+
android:background="@null"
81+
android:clickable="false"
82+
android:text="@string/move_done_checklist_items"
83+
app:switchPadding="@dimen/medium_margin" />
84+
85+
</RelativeLayout>
6286
</LinearLayout>

0 commit comments

Comments
 (0)