Add type parameter to calendar list

This commit is contained in:
MM20 2024-08-15 17:55:45 +02:00
parent d263f8cbbc
commit bf29ce6f08
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
7 changed files with 46 additions and 7 deletions

View File

@ -1,5 +1,7 @@
package de.mm20.launcher2.plugin.contracts
import de.mm20.launcher2.search.calendar.CalendarListType
abstract class CalendarPluginContract {
object EventColumns : Columns() {
/**
@ -68,6 +70,7 @@ abstract class CalendarPluginContract {
val Name = column<String>("name")
val Color = column<Int>("color")
val AccountName = column<String>("account_name")
val ContentTypes = column<List<CalendarListType>>("content_types")
}

View File

@ -0,0 +1,6 @@
package de.mm20.launcher2.search.calendar
enum class CalendarListType {
Calendar,
Tasks,
}

View File

@ -71,10 +71,3 @@ internal data class AndroidCalendarEvent(
}
}
data class CalendarList(
val id: String,
val name: String,
val owner: String?,
val color: Int,
val providerId: String,
)

View File

@ -0,0 +1,12 @@
package de.mm20.launcher2.calendar.providers
import de.mm20.launcher2.search.calendar.CalendarListType
data class CalendarList(
val id: String,
val name: String,
val owner: String?,
val color: Int,
val types: List<CalendarListType>,
val providerId: String,
)

View File

@ -174,6 +174,7 @@ class PluginCalendarProvider(
color = cursor[CalendarListColumns.Color] ?: 0,
name = cursor[CalendarListColumns.Name] ?: continue,
owner = cursor[CalendarListColumns.AccountName],
types = cursor[CalendarListColumns.ContentTypes] ?: continue,
providerId = pluginAuthority,
)
}

View File

@ -1,8 +1,31 @@
package de.mm20.launcher2.sdk.calendar
import de.mm20.launcher2.search.calendar.CalendarListType
data class CalendarList(
/**
* A unique identifier for this list.
*/
val id: String,
/**
* The display name of this list.
*/
val name: String,
/**
* The main content type of this list. This has mainly cosmetic purposes (labels, icons).
* It doesn't need to be 100% accurate since the actual type is determined on a per-item basis.
* However, the launcher will hide some settings if it doesn't find any lists that would be
* affected by them.
*/
val contentTypes: List<CalendarListType>,
/**
* The owner account of this list.
*/
val accountName: String? = null,
/**
* The color of this list, in 0xFFAARRGGBB format.
* If null, the launcher will use a default theme color.
* The color is corrected to match the launcher's theme (i.e. for dark mode).
*/
val color: Int? = null,
)

View File

@ -105,6 +105,7 @@ abstract class CalendarProvider(
put(CalendarListColumns.Name, it.name)
put(CalendarListColumns.Color, it.color)
put(CalendarListColumns.AccountName, it.accountName)
put(CalendarListColumns.ContentTypes, it.contentTypes)
}
}
}