Fix some chip issues caused by sorting

pull/2282/head
Alex Baker 3 years ago
parent 18242e5284
commit 1d6d8e87d1

@ -69,6 +69,9 @@ class TaskViewHolder internal constructor(
setOnClickListener { onCompleteBoxClick() } setOnClickListener { onCompleteBoxClick() }
} }
private val chipGroup: ComposeView = binding.chipGroup private val chipGroup: ComposeView = binding.chipGroup
private val pagedQueries: Boolean = preferences.usePagedQueries()
private val alwaysDisplayFullDate: Boolean = preferences.alwaysDisplayFullDate
private val showGroupHeaders = preferences.showGroupHeaders()
lateinit var task: TaskContainer lateinit var task: TaskContainer
@ -141,7 +144,11 @@ class TaskViewHolder internal constructor(
markdown.setMarkdown(nameView, task.title) markdown.setMarkdown(nameView, task.title)
setupTitleAndCheckbox() setupTitleAndCheckbox()
setupDueDate(sortMode == SORT_DUE) setupDueDate(sortMode == SORT_DUE)
setupChips(filter, sortMode == SORT_START, sortMode == SORT_LIST) setupChips(
filter = filter,
sortByStartDate = sortMode == SORT_START && showGroupHeaders,
sortByList = sortMode == SORT_LIST && showGroupHeaders
)
if (preferences.getBoolean(R.string.p_show_description, true)) { if (preferences.getBoolean(R.string.p_show_description, true)) {
markdown.setMarkdown(description, task.notes) markdown.setMarkdown(description, task.notes)
description.visibility = if (task.hasNotes()) View.VISIBLE else View.GONE description.visibility = if (task.hasNotes()) View.VISIBLE else View.GONE
@ -201,13 +208,13 @@ class TaskViewHolder internal constructor(
} }
val dateValue: String? = if (sortByDueDate val dateValue: String? = if (sortByDueDate
&& task.sortGroup >= now().startOfDay() && task.sortGroup >= now().startOfDay()
&& preferences.showGroupHeaders() && showGroupHeaders
) { ) {
task.takeIf { it.hasDueTime() }?.let { task.takeIf { it.hasDueTime() }?.let {
DateUtilities.getTimeString(context, newDateTime(task.dueDate)) DateUtilities.getTimeString(context, newDateTime(task.dueDate))
} }
} else { } else {
DateUtilities.getRelativeDateTime(context, task.dueDate, locale, FormatStyle.MEDIUM, preferences.alwaysDisplayFullDate, false) DateUtilities.getRelativeDateTime(context, task.dueDate, locale, FormatStyle.MEDIUM, alwaysDisplayFullDate, false)
} }
dueDate.text = dateValue dueDate.text = dateValue
dueDate.visibility = View.VISIBLE dueDate.visibility = View.VISIBLE
@ -236,7 +243,7 @@ class TaskViewHolder internal constructor(
place = task.location?.place, place = task.location?.place,
list = task.caldav, list = task.caldav,
tagsString = task.tagsString, tagsString = task.tagsString,
isSubtask = task.hasParent(), isSubtask = task.hasParent() && !pagedQueries,
isGoogleTask = task.isGoogleTask, isGoogleTask = task.isGoogleTask,
sortByStartDate = sortByStartDate, sortByStartDate = sortByStartDate,
sortByList = sortByList, sortByList = sortByList,

Loading…
Cancel
Save