Skip to content

Commit 7376a4d

Browse files
committed
Added sorting to the widget (#624)
1 parent b1bc7f5 commit 7376a4d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,7 @@ class MainActivity : SimpleActivity() {
14871487
private fun displaySortChecklistDialog() {
14881488
SortChecklistDialog(this) {
14891489
getPagerAdapter().refreshChecklist(view_pager.currentItem)
1490+
updateWidgets()
14901491
}
14911492
}
14921493
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.google.gson.reflect.TypeToken
1111
import com.simplemobiletools.commons.extensions.adjustAlpha
1212
import com.simplemobiletools.commons.extensions.setText
1313
import com.simplemobiletools.commons.extensions.setTextSize
14+
import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM
1415
import com.simplemobiletools.commons.helpers.WIDGET_TEXT_COLOR
1516
import com.simplemobiletools.notes.pro.R
1617
import com.simplemobiletools.notes.pro.R.id.widget_text_holder
@@ -129,6 +130,13 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
129130

130131
// checklist title can be null only because of the glitch in upgrade to 6.6.0, remove this check in the future
131132
checklistItems = checklistItems.filter { it.title != null }.toMutableList() as ArrayList<ChecklistItem>
133+
val sorting = context.config?.sorting ?: 0
134+
if (sorting and SORT_BY_CUSTOM == 0) {
135+
checklistItems.sort()
136+
if (context?.config?.moveDoneChecklistItems == true) {
137+
checklistItems.sortBy { it.isDone }
138+
}
139+
}
132140
}
133141
}
134142

0 commit comments

Comments
 (0)