mirror of
https://github.com/ev-map/EVMap.git
synced 2026-04-30 11:04:16 -04:00
AA/AAOS FilterScreen: add delete button to rows
This commit is contained in:
@@ -204,6 +204,37 @@ class FilterScreen(ctx: CarContext, val session: EVMapSession) : Screen(ctx) {
|
||||
Row.IMAGE_TYPE_ICON
|
||||
)
|
||||
setOnClickListener { onItemClick(it.id) }
|
||||
if (carContext.carAppApiLevel >= 6) {
|
||||
// Delete action
|
||||
addAction(Action.Builder().apply {
|
||||
setIcon(
|
||||
CarIcon.Builder(
|
||||
IconCompat.createWithResource(
|
||||
carContext,
|
||||
R.drawable.ic_delete
|
||||
)
|
||||
).build()
|
||||
|
||||
)
|
||||
setOnClickListener {
|
||||
lifecycleScope.launch {
|
||||
db.filterProfileDao().delete(it)
|
||||
if (prefs.filterStatus == it.id) {
|
||||
prefs.filterStatus = FILTERS_DISABLED
|
||||
}
|
||||
CarToast.makeText(
|
||||
carContext,
|
||||
carContext.getString(
|
||||
R.string.deleted_filterprofile,
|
||||
it.name
|
||||
),
|
||||
CarToast.LENGTH_SHORT
|
||||
).show()
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
}.build())
|
||||
}
|
||||
}.build())
|
||||
}
|
||||
if (page < paginatedProfiles.size - 1) {
|
||||
@@ -293,7 +324,8 @@ class EditFiltersScreen(ctx: CarContext) : Screen(ctx) {
|
||||
|
||||
setActionStrip(ActionStrip.Builder().apply {
|
||||
val currentProfile = vm.filterProfile.value
|
||||
if (currentProfile != null) {
|
||||
if (currentProfile != null && carContext.carAppApiLevel < 6) {
|
||||
// Delete action (when row actions are not available)
|
||||
addAction(Action.Builder().apply {
|
||||
setIcon(
|
||||
CarIcon.Builder(
|
||||
|
||||
Reference in New Issue
Block a user