Skip to content

Commit

Permalink
Added support for own sorting in OpenNoteDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Aga-C committed Nov 30, 2024
1 parent dec0498 commit b57be1b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
17 changes: 7 additions & 10 deletions app/src/main/kotlin/org/fossify/notes/adapters/OpenNoteAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,16 @@ class OpenNoteAdapter(
val taskType = object : TypeToken<List<Task>>() {}.type
var items = Gson().fromJson<List<Task>>(getNoteStoredValue(context), taskType) ?: listOf()
items = items.let {
val sorting = context.config.sorting
val sorting = context.config.getSorting(id)
Task.sorting = sorting
var result = it
if (Task.sorting and SORT_BY_CUSTOM == 0) {
it.sorted().let {
if (context.config.getMoveDoneChecklistItems(null)) {
it.sortedBy { it.isDone }
} else {
it
}
}
} else {
it
result = result.sorted()
}
if (context.config.getMoveDoneChecklistItems(id)) {
result = result.sortedBy { it.isDone }
}
result
}

val linePrefix = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
if (sorting and SORT_BY_CUSTOM == 0) {
Task.sorting = sorting
tasks.sort()
if (context.config.getMoveDoneChecklistItems(noteId)) {
tasks.sortBy { it.isDone }
}
}
if (context.config.getMoveDoneChecklistItems(noteId)) {
tasks.sortBy { it.isDone }
}
}
}
Expand Down

0 comments on commit b57be1b

Please sign in to comment.