Tags editor

This commit is contained in:
MM20
2022-09-21 21:42:31 +02:00
parent cc4df325ad
commit 5073cb0297
6 changed files with 246 additions and 5 deletions
@@ -3,6 +3,7 @@ package de.mm20.launcher2.database
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Transaction
import de.mm20.launcher2.database.entities.CustomAttributeEntity
import kotlinx.coroutines.flow.Flow
@@ -17,9 +18,18 @@ interface CustomAttrsDao {
@Insert
fun setCustomAttribute(entity: CustomAttributeEntity)
@Insert
suspend fun insertCustomAttributes(entities: List<CustomAttributeEntity>)
@Query("SELECT * FROM CustomAttributes WHERE type = :type AND key IN (:keys)")
fun getCustomAttributes(keys: List<String>, type: String) : Flow<List<CustomAttributeEntity>>
@Query("SELECT DISTINCT key FROM CustomAttributes WHERE (type = 'label' OR type = 'tag') AND value LIKE :query")
fun search(query: String): Flow<List<String>>
@Transaction
suspend fun setTags(key: String, tags: List<CustomAttributeEntity>) {
clearCustomAttribute(key, "tag")
insertCustomAttributes(tags)
}
}