Merge pull request #629 from Aga-C/add-widget-sorting

Added sorting to the widget (#624)
This commit is contained in:
Tibor Kaputa 2023-07-17 20:23:44 +02:00 committed by GitHub
commit 01db7c05df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -1275,6 +1275,7 @@ class MainActivity : SimpleActivity() {
private fun displaySortChecklistDialog() {
SortChecklistDialog(this) {
getPagerAdapter().refreshChecklist(view_pager.currentItem)
updateWidgets()
}
}
}

View File

@ -9,6 +9,7 @@ import android.widget.RemoteViewsService
import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.setText
import com.simplemobiletools.commons.extensions.setTextSize
import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM
import com.simplemobiletools.commons.helpers.WIDGET_TEXT_COLOR
import com.simplemobiletools.notes.pro.R
import com.simplemobiletools.notes.pro.R.id.widget_text_holder
@ -129,6 +130,13 @@ class WidgetAdapter(val context: Context, val intent: Intent) : RemoteViewsServi
// checklist title can be null only because of the glitch in upgrade to 6.6.0, remove this check in the future
checklistItems = checklistItems.filter { it.title != null }.toMutableList() as ArrayList<ChecklistItem>
val sorting = context.config?.sorting ?: 0
if (sorting and SORT_BY_CUSTOM == 0) {
checklistItems.sort()
if (context?.config?.moveDoneChecklistItems == true) {
checklistItems.sortBy { it.isDone }
}
}
}
}