(feat) transparency schemes
This commit is contained in:
@@ -20,6 +20,7 @@ import de.mm20.launcher2.database.entities.SavedSearchableEntity
|
||||
import de.mm20.launcher2.database.entities.SearchActionEntity
|
||||
import de.mm20.launcher2.database.entities.ColorsEntity
|
||||
import de.mm20.launcher2.database.entities.ShapesEntity
|
||||
import de.mm20.launcher2.database.entities.TransparenciesEntity
|
||||
import de.mm20.launcher2.database.entities.WidgetEntity
|
||||
import de.mm20.launcher2.database.migrations.Migration_10_11
|
||||
import de.mm20.launcher2.database.migrations.Migration_11_12
|
||||
@@ -39,6 +40,7 @@ import de.mm20.launcher2.database.migrations.Migration_24_25
|
||||
import de.mm20.launcher2.database.migrations.Migration_25_26
|
||||
import de.mm20.launcher2.database.migrations.Migration_26_27
|
||||
import de.mm20.launcher2.database.migrations.Migration_27_28
|
||||
import de.mm20.launcher2.database.migrations.Migration_28_29
|
||||
import de.mm20.launcher2.database.migrations.Migration_6_7
|
||||
import de.mm20.launcher2.database.migrations.Migration_7_8
|
||||
import de.mm20.launcher2.database.migrations.Migration_8_9
|
||||
@@ -59,7 +61,8 @@ import java.util.UUID
|
||||
ColorsEntity::class,
|
||||
PluginEntity::class,
|
||||
ShapesEntity::class,
|
||||
], version = 28, exportSchema = true
|
||||
TransparenciesEntity::class,
|
||||
], version = 29, exportSchema = true
|
||||
)
|
||||
@TypeConverters(ComponentNameConverter::class)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
@@ -160,6 +163,7 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
Migration_25_26(),
|
||||
Migration_26_27(),
|
||||
Migration_27_28(),
|
||||
Migration_28_29(),
|
||||
).build()
|
||||
if (_instance == null) _instance = instance
|
||||
return instance
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.room.Query
|
||||
import androidx.room.Update
|
||||
import de.mm20.launcher2.database.entities.ColorsEntity
|
||||
import de.mm20.launcher2.database.entities.ShapesEntity
|
||||
import de.mm20.launcher2.database.entities.TransparenciesEntity
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import java.util.UUID
|
||||
|
||||
@@ -17,39 +18,60 @@ interface ThemeDao {
|
||||
@Query("SELECT * FROM Shapes")
|
||||
fun getAllShapes(): Flow<List<ShapesEntity>>
|
||||
|
||||
@Query("SELECT * FROM Transparencies")
|
||||
fun getAllTransparencies(): Flow<List<TransparenciesEntity>>
|
||||
|
||||
@Query("SELECT * FROM Theme WHERE id = :id LIMIT 1")
|
||||
fun getColors(id: UUID): Flow<ColorsEntity?>
|
||||
|
||||
@Query("SELECT * FROM Shapes WHERE id = :id LIMIT 1")
|
||||
fun getShapes(id: UUID): Flow<ShapesEntity?>
|
||||
|
||||
@Query("SELECT * FROM Transparencies WHERE id = :id LIMIT 1")
|
||||
fun getTransparencies(id: UUID): Flow<TransparenciesEntity?>
|
||||
|
||||
@Insert
|
||||
suspend fun insertColors(colors: ColorsEntity)
|
||||
|
||||
@Insert
|
||||
suspend fun insertShapes(shapes: ShapesEntity)
|
||||
|
||||
@Insert
|
||||
suspend fun insertTransparencies(transparencies: TransparenciesEntity)
|
||||
|
||||
@Update
|
||||
suspend fun updateColors(colors: ColorsEntity)
|
||||
|
||||
@Update
|
||||
suspend fun updateShapes(shapes: ShapesEntity)
|
||||
|
||||
@Update
|
||||
suspend fun updateTransparencies(transparencies: TransparenciesEntity)
|
||||
|
||||
@Query("DELETE FROM Theme WHERE id = :id")
|
||||
suspend fun deleteColors(id: UUID)
|
||||
|
||||
@Query("DELETE FROM Shapes WHERE id = :id")
|
||||
suspend fun deleteShapes(id: UUID)
|
||||
|
||||
@Query("DELETE FROM Transparencies WHERE id = :id")
|
||||
suspend fun deleteTransparencies(id: UUID)
|
||||
|
||||
@Query("DELETE FROM Theme")
|
||||
suspend fun deleteAllColors()
|
||||
|
||||
@Query("DELETE FROM Shapes")
|
||||
suspend fun deleteAllShapes()
|
||||
|
||||
@Query("DELETE FROM Transparencies")
|
||||
suspend fun deleteAllTransparencies()
|
||||
|
||||
@Insert
|
||||
fun insertAllColors(colors: List<ColorsEntity>)
|
||||
|
||||
@Insert
|
||||
fun insertAllShapes(shapes: List<ShapesEntity>)
|
||||
|
||||
@Insert
|
||||
fun insertAllTransparencies(transparencies: List<TransparenciesEntity>)
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package de.mm20.launcher2.database.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import java.util.UUID
|
||||
|
||||
@Entity(tableName = "Transparencies")
|
||||
data class TransparenciesEntity(
|
||||
@PrimaryKey val id: UUID,
|
||||
val name: String,
|
||||
|
||||
val background: Float?,
|
||||
val surface: Float?,
|
||||
val elevatedSurface: Float?,
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
package de.mm20.launcher2.database.migrations
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.SQLiteConnection
|
||||
import androidx.sqlite.execSQL
|
||||
|
||||
class Migration_28_29: Migration(28, 29) {
|
||||
|
||||
override fun migrate(connection: SQLiteConnection) {
|
||||
connection.execSQL(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS `Transparencies` (
|
||||
`id` BLOB NOT NULL PRIMARY KEY,
|
||||
`name` TEXT NOT NULL,
|
||||
`background` REAL,
|
||||
`surface` REAL,
|
||||
`elevatedSurface` REAL
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user