diff --git a/app/src/main/java/at/techbee/jtx/database/locals/StoredListSetting.kt b/app/src/main/java/at/techbee/jtx/database/locals/StoredListSetting.kt index 8b37881ac..d6b72e4ea 100644 --- a/app/src/main/java/at/techbee/jtx/database/locals/StoredListSetting.kt +++ b/app/src/main/java/at/techbee/jtx/database/locals/StoredListSetting.kt @@ -64,6 +64,7 @@ data class StoredListSettingData( var searchResourcesAnyAllNone: AnyAllNone = AnyAllNone.ANY, var searchStatus: List = emptyList(), var searchClassification: List = emptyList(), + var searchPriority: List = emptyList(), var searchCollection: List = emptyList(), var searchAccount: List = emptyList(), var orderBy: OrderBy = OrderBy.CREATED, @@ -115,6 +116,7 @@ data class StoredListSettingData( searchResourcesAnyAllNone = listSettings.searchResourcesAnyAllNone.value, searchStatus = listSettings.searchStatus, searchClassification = listSettings.searchClassification, + searchPriority = listSettings.searchPriority, searchCollection = listSettings.searchCollection, searchAccount = listSettings.searchAccount, orderBy = listSettings.orderBy.value, @@ -161,6 +163,7 @@ data class StoredListSettingData( listSettings.searchResourcesAnyAllNone.value = searchResourcesAnyAllNone listSettings.searchStatus.addAll(searchStatus) listSettings.searchClassification.addAll(searchClassification) + listSettings.searchPriority.addAll(searchPriority) listSettings.searchCollection.addAll(searchCollection) listSettings.searchAccount.addAll(searchAccount) listSettings.orderBy.value = orderBy diff --git a/app/src/main/java/at/techbee/jtx/database/views/ICal4List.kt b/app/src/main/java/at/techbee/jtx/database/views/ICal4List.kt index 9c82229cc..6a524bcfd 100644 --- a/app/src/main/java/at/techbee/jtx/database/views/ICal4List.kt +++ b/app/src/main/java/at/techbee/jtx/database/views/ICal4List.kt @@ -319,6 +319,7 @@ data class ICal4List( searchStatus: List = emptyList(), searchXStatus: List = emptyList(), searchClassification: List = emptyList(), + searchPriority: List = emptyList(), searchCollection: List = emptyList(), searchAccount: List = emptyList(), orderBy: OrderBy = OrderBy.CREATED, @@ -516,6 +517,17 @@ data class ICal4List( queryString += ") " } + //PRIORITY + if (searchPriority.isNotEmpty()) { + queryString += "AND (" + queryString += searchPriority.joinToString(separator = "OR ", transform = { "$COLUMN_PRIORITY = ? " }) + args.addAll(searchPriority.map { it?.toString() ?: "0"}) + + if(searchPriority.contains(null) || searchPriority.contains(0)) + queryString += "OR $COLUMN_PRIORITY IS NULL" + queryString += ") " + } + //Hide biometric protected hideBiometricProtected.forEach { if(it == Classification.NO_CLASSIFICATION) { diff --git a/app/src/main/java/at/techbee/jtx/ui/list/ListActiveFiltersRow.kt b/app/src/main/java/at/techbee/jtx/ui/list/ListActiveFiltersRow.kt index 5b83a1fdf..5412141a1 100644 --- a/app/src/main/java/at/techbee/jtx/ui/list/ListActiveFiltersRow.kt +++ b/app/src/main/java/at/techbee/jtx/ui/list/ListActiveFiltersRow.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.Label import androidx.compose.material.icons.outlined.AccountBalance +import androidx.compose.material.icons.outlined.AssignmentLate import androidx.compose.material.icons.outlined.FolderOpen import androidx.compose.material.icons.outlined.PrivacyTip import androidx.compose.material.icons.outlined.PublishedWithChanges @@ -29,6 +30,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringArrayResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -157,6 +159,17 @@ fun ListActiveFiltersRow( isAccessibilityMode = isAccessibilityMode ) } + listSettings.searchPriority.forEach { priorityInt -> + if(priorityInt in 0..9) { + ListBadge( + icon = Icons.Outlined.AssignmentLate, + iconDesc = stringResource(R.string.priority), + text = stringArrayResource(id = R.array.priority)[priorityInt?:0], + modifier = Modifier.padding(vertical = 2.dp), + isAccessibilityMode = isAccessibilityMode + ) + } + } AnimatedVisibility(listSettings.isExcludeDone.value) { ListBadge( text = stringResource(R.string.list_hide_completed_tasks), diff --git a/app/src/main/java/at/techbee/jtx/ui/list/ListOptionsFilter.kt b/app/src/main/java/at/techbee/jtx/ui/list/ListOptionsFilter.kt index aa4f4a6d4..038571c4d 100644 --- a/app/src/main/java/at/techbee/jtx/ui/list/ListOptionsFilter.kt +++ b/app/src/main/java/at/techbee/jtx/ui/list/ListOptionsFilter.kt @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.Label import androidx.compose.material.icons.outlined.AccountBalance +import androidx.compose.material.icons.outlined.AssignmentLate import androidx.compose.material.icons.outlined.CalendarMonth import androidx.compose.material.icons.outlined.Close import androidx.compose.material.icons.outlined.DashboardCustomize @@ -44,6 +45,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringArrayResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import at.techbee.jtx.R @@ -877,6 +879,43 @@ fun ListOptionsFilter( } + ////// Priority + val priorities = stringArrayResource(id = R.array.priority) + if(module == Module.TODO) { + FilterSection( + icon = Icons.Outlined.AssignmentLate, + headline = stringResource(id = R.string.priority), + onResetSelection = { + listSettings.searchPriority.clear() + onListSettingsChanged() + }, + onInvertSelection = { + priorities.forEachIndexed { index, _ -> + if (listSettings.searchPriority.contains(index)) + listSettings.searchPriority.remove(index) + else + listSettings.searchPriority.add(index) + } + onListSettingsChanged() + }) + { + priorities.forEachIndexed { index, prio -> + FilterChip( + selected = listSettings.searchPriority.contains(index), + onClick = { + if (listSettings.searchPriority.contains(index)) + listSettings.searchPriority.remove(index) + else + listSettings.searchPriority.add(index) + onListSettingsChanged() + }, + label = { Text(prio) } + ) + } + } + } + + ////// RESOURCES if (module == Module.TODO) { FilterSection( diff --git a/app/src/main/java/at/techbee/jtx/ui/list/ListSettings.kt b/app/src/main/java/at/techbee/jtx/ui/list/ListSettings.kt index f94f5e08d..17aad98ea 100644 --- a/app/src/main/java/at/techbee/jtx/ui/list/ListSettings.kt +++ b/app/src/main/java/at/techbee/jtx/ui/list/ListSettings.kt @@ -36,6 +36,7 @@ class ListSettings { var searchStatus = mutableStateListOf() var searchXStatus = mutableStateListOf() var searchClassification = mutableStateListOf() + var searchPriority = mutableStateListOf() var searchCollection = mutableStateListOf() var searchAccount = mutableStateListOf() var orderBy: MutableState = mutableStateOf(OrderBy.DRAG_AND_DROP) @@ -107,6 +108,7 @@ class ListSettings { private const val PREFS_RESOURCES = "prefsResources" private const val PREFS_RESOURCES_ANYALLNONE = "prefsResourcesAnyAllNone" private const val PREFS_CLASSIFICATION = "prefsClassification" + private const val PREFS_PRIORITY = "prefsPriority" private const val PREFS_STATUS = "prefsStatus" private const val PREFS_EXTENDED_STATUS = "prefsXStatus" private const val PREFS_EXCLUDE_DONE = "prefsExcludeDone" @@ -208,6 +210,7 @@ class ListSettings { searchStatus.addAll(Status.getListFromStringList(prefs.getStringSet(PREFS_STATUS, null))) searchXStatus.addAll(prefs.getStringSet(PREFS_EXTENDED_STATUS, emptySet())?.toList() ?: emptyList()) searchClassification.addAll(Classification.getListFromStringList(prefs.getStringSet(PREFS_CLASSIFICATION, null))) + searchPriority.addAll(prefs.getStringSet(PREFS_PRIORITY, null)?.map { it.toIntOrNull() } ?: emptyList()) searchCollection.addAll(prefs.getStringSet(PREFS_COLLECTION, emptySet())?.toList() ?: emptyList()) searchAccount.addAll(prefs.getStringSet(PREFS_ACCOUNT, emptySet())?.toList() ?: emptyList()) @@ -277,6 +280,7 @@ class ListSettings { searchStatus.addAll(listWidgetConfig.searchStatus) searchXStatus.addAll(listWidgetConfig.searchXStatus) searchClassification.addAll(listWidgetConfig.searchClassification) + searchPriority.addAll(listWidgetConfig.searchPriority) searchCollection.addAll(listWidgetConfig.searchCollection) searchAccount.addAll(listWidgetConfig.searchAccount) @@ -367,6 +371,7 @@ class ListSettings { putStringSet(PREFS_STATUS, Status.getStringSetFromList(searchStatus)) putStringSet(PREFS_EXTENDED_STATUS, searchXStatus.toSet()) putStringSet(PREFS_CLASSIFICATION, Classification.getStringSetFromList(searchClassification)) + putStringSet(PREFS_PRIORITY, searchPriority.map { it.toString() }.toSet()) putStringSet(PREFS_COLLECTION, searchCollection.toSet()) putStringSet(PREFS_ACCOUNT, searchAccount.toSet()) @@ -397,6 +402,7 @@ class ListSettings { searchStatus.clear() searchXStatus.clear() searchClassification.clear() + searchPriority.clear() searchCollection.clear() searchAccount.clear() isExcludeDone.value = false @@ -435,6 +441,7 @@ class ListSettings { || searchStatus.isNotEmpty() || searchXStatus.isNotEmpty() || searchClassification.isNotEmpty() + || searchPriority.isNotEmpty() || searchCollection.isNotEmpty() || searchAccount.isNotEmpty() || isExcludeDone.value diff --git a/app/src/main/java/at/techbee/jtx/ui/list/ListViewModel.kt b/app/src/main/java/at/techbee/jtx/ui/list/ListViewModel.kt index 49bc7f3a6..248284ac5 100644 --- a/app/src/main/java/at/techbee/jtx/ui/list/ListViewModel.kt +++ b/app/src/main/java/at/techbee/jtx/ui/list/ListViewModel.kt @@ -149,6 +149,7 @@ open class ListViewModel(application: Application, val module: Module) : Android searchStatus = listSettings.searchStatus, searchXStatus = listSettings.searchXStatus, searchClassification = listSettings.searchClassification, + searchPriority = listSettings.searchPriority, searchCollection = listSettings.searchCollection, searchAccount = listSettings.searchAccount, orderBy = listSettings.orderBy.value, diff --git a/app/src/main/java/at/techbee/jtx/widgets/ListWidget.kt b/app/src/main/java/at/techbee/jtx/widgets/ListWidget.kt index 2fd749650..fd9b0aec3 100644 --- a/app/src/main/java/at/techbee/jtx/widgets/ListWidget.kt +++ b/app/src/main/java/at/techbee/jtx/widgets/ListWidget.kt @@ -78,6 +78,7 @@ class ListWidget : GlanceAppWidget() { searchResources = listWidgetConfig.searchResources, searchStatus = listWidgetConfig.searchStatus, searchClassification = listWidgetConfig.searchClassification, + searchPriority = listWidgetConfig.searchPriority, searchCollection = listWidgetConfig.searchCollection, searchAccount = listWidgetConfig.searchAccount, orderBy = listWidgetConfig.orderBy, diff --git a/app/src/main/java/at/techbee/jtx/widgets/ListWidgetConfigContent.kt b/app/src/main/java/at/techbee/jtx/widgets/ListWidgetConfigContent.kt index 5fa1064c9..972f4c76b 100644 --- a/app/src/main/java/at/techbee/jtx/widgets/ListWidgetConfigContent.kt +++ b/app/src/main/java/at/techbee/jtx/widgets/ListWidgetConfigContent.kt @@ -9,7 +9,6 @@ package at.techbee.jtx.widgets import android.widget.Toast -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth @@ -64,7 +63,7 @@ import at.techbee.jtx.ui.list.ViewMode import kotlinx.coroutines.launch -@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class) +@OptIn(ExperimentalMaterial3Api::class) @Composable fun ListWidgetConfigContent( initialConfig: ListWidgetConfig, @@ -233,6 +232,7 @@ fun ListWidgetConfigContent( searchStatus = listSettings.searchStatus searchXStatus = listSettings.searchXStatus searchClassification = listSettings.searchClassification + searchPriority = listSettings.searchPriority searchCollection = listSettings.searchCollection searchAccount = listSettings.searchAccount orderBy = listSettings.orderBy.value @@ -332,6 +332,7 @@ data class ListWidgetConfig( var searchStatus: List = emptyList(), var searchXStatus: List = emptyList(), var searchClassification: List = emptyList(), + var searchPriority: List = emptyList(), var searchCollection: List = emptyList(), var searchAccount: List = emptyList(), var orderBy: OrderBy = OrderBy.CREATED,