(feat) custom typography schemes

This commit is contained in:
MM20
2025-06-18 22:28:13 +02:00
parent 4bf9ee8b0c
commit da8416a58c
31 changed files with 2856 additions and 117 deletions
@@ -10,6 +10,7 @@ import androidx.room.TypeConverters
import androidx.sqlite.db.SupportSQLiteDatabase
import de.mm20.launcher2.database.daos.PluginDao
import de.mm20.launcher2.database.daos.ThemeDao
import de.mm20.launcher2.database.entities.ColorsEntity
import de.mm20.launcher2.database.entities.CurrencyEntity
import de.mm20.launcher2.database.entities.CustomAttributeEntity
import de.mm20.launcher2.database.entities.ForecastEntity
@@ -18,9 +19,9 @@ import de.mm20.launcher2.database.entities.IconPackEntity
import de.mm20.launcher2.database.entities.PluginEntity
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.TypographyEntity
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
@@ -41,6 +42,7 @@ 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_29_30
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
@@ -62,7 +64,8 @@ import java.util.UUID
PluginEntity::class,
ShapesEntity::class,
TransparenciesEntity::class,
], version = 29, exportSchema = true
TypographyEntity::class,
], version = 30, exportSchema = true
)
@TypeConverters(ComponentNameConverter::class)
abstract class AppDatabase : RoomDatabase() {
@@ -164,6 +167,7 @@ abstract class AppDatabase : RoomDatabase() {
Migration_26_27(),
Migration_27_28(),
Migration_28_29(),
Migration_29_30(),
).build()
if (_instance == null) _instance = instance
return instance
@@ -7,6 +7,7 @@ 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 de.mm20.launcher2.database.entities.TypographyEntity
import kotlinx.coroutines.flow.Flow
import java.util.UUID
@@ -21,6 +22,9 @@ interface ThemeDao {
@Query("SELECT * FROM Transparencies")
fun getAllTransparencies(): Flow<List<TransparenciesEntity>>
@Query("SELECT * FROM Typography")
fun getAllTypographies(): Flow<List<TypographyEntity>>
@Query("SELECT * FROM Theme WHERE id = :id LIMIT 1")
fun getColors(id: UUID): Flow<ColorsEntity?>
@@ -30,6 +34,9 @@ interface ThemeDao {
@Query("SELECT * FROM Transparencies WHERE id = :id LIMIT 1")
fun getTransparencies(id: UUID): Flow<TransparenciesEntity?>
@Query("SELECT * FROM Typography WHERE id = :id LIMIT 1")
fun getTypography(id: UUID): Flow<TypographyEntity?>
@Insert
suspend fun insertColors(colors: ColorsEntity)
@@ -39,6 +46,9 @@ interface ThemeDao {
@Insert
suspend fun insertTransparencies(transparencies: TransparenciesEntity)
@Insert
suspend fun insertTypography(typography: TypographyEntity)
@Update
suspend fun updateColors(colors: ColorsEntity)
@@ -48,6 +58,9 @@ interface ThemeDao {
@Update
suspend fun updateTransparencies(transparencies: TransparenciesEntity)
@Update
suspend fun updateTypography(typography: TypographyEntity)
@Query("DELETE FROM Theme WHERE id = :id")
suspend fun deleteColors(id: UUID)
@@ -57,6 +70,9 @@ interface ThemeDao {
@Query("DELETE FROM Transparencies WHERE id = :id")
suspend fun deleteTransparencies(id: UUID)
@Query("DELETE FROM Typography WHERE id = :id")
suspend fun deleteTypography(id: UUID)
@Query("DELETE FROM Theme")
suspend fun deleteAllColors()
@@ -66,6 +82,9 @@ interface ThemeDao {
@Query("DELETE FROM Transparencies")
suspend fun deleteAllTransparencies()
@Query("DELETE FROM Typography")
suspend fun deleteAllTypographies()
@Insert
fun insertAllColors(colors: List<ColorsEntity>)
@@ -74,4 +93,7 @@ interface ThemeDao {
@Insert
fun insertAllTransparencies(transparencies: List<TransparenciesEntity>)
@Insert
fun insertAllTypographies(typography: List<TypographyEntity>)
}
@@ -0,0 +1,43 @@
package de.mm20.launcher2.database.entities
import androidx.room.Entity
import androidx.room.PrimaryKey
import java.util.UUID
@Entity(tableName = "Typography")
data class TypographyEntity(
@PrimaryKey val id: UUID,
val name: String,
val fonts: String? = null,
val displayLarge: String? = null,
val displayMedium: String? = null,
val displaySmall: String? = null,
val headlineLarge: String? = null,
val headlineMedium: String? = null,
val headlineSmall: String? = null,
val titleLarge: String? = null,
val titleMedium: String? = null,
val titleSmall: String? = null,
val bodyLarge: String? = null,
val bodyMedium: String? = null,
val bodySmall: String? = null,
val labelLarge: String? = null,
val labelMedium: String? = null,
val labelSmall: String? = null,
val emphasizedDisplayLarge: String? = null,
val emphasizedDisplayMedium: String? = null,
val emphasizedDisplaySmall: String? = null,
val emphasizedHeadlineLarge: String? = null,
val emphasizedHeadlineMedium: String? = null,
val emphasizedHeadlineSmall: String? = null,
val emphasizedTitleLarge: String? = null,
val emphasizedTitleMedium: String? = null,
val emphasizedTitleSmall: String? = null,
val emphasizedBodyLarge: String? = null,
val emphasizedBodyMedium: String? = null,
val emphasizedBodySmall: String? = null,
val emphasizedLabelLarge: String? = null,
val emphasizedLabelMedium: String? = null,
val emphasizedLabelSmall: String? = null,
)
@@ -0,0 +1,50 @@
package de.mm20.launcher2.database.migrations
import androidx.room.migration.Migration
import androidx.sqlite.SQLiteConnection
import androidx.sqlite.execSQL
class Migration_29_30 : Migration(29, 30) {
override fun migrate(connection: SQLiteConnection) {
connection.execSQL(
"""
CREATE TABLE IF NOT EXISTS `Typography` (
`id` BLOB NOT NULL PRIMARY KEY,
`name` TEXT NOT NULL,
`fonts` TEXT,
`displayLarge` TEXT,
`displayMedium` TEXT,
`displaySmall` TEXT,
`headlineLarge` TEXT,
`headlineMedium` TEXT,
`headlineSmall` TEXT,
`titleLarge` TEXT,
`titleMedium` TEXT,
`titleSmall` TEXT,
`bodyLarge` TEXT,
`bodyMedium` TEXT,
`bodySmall` TEXT,
`labelLarge` TEXT,
`labelMedium` TEXT,
`labelSmall` TEXT,
`emphasizedDisplayLarge` TEXT,
`emphasizedDisplayMedium` TEXT,
`emphasizedDisplaySmall` TEXT,
`emphasizedHeadlineLarge` TEXT,
`emphasizedHeadlineMedium` TEXT,
`emphasizedHeadlineSmall` TEXT,
`emphasizedTitleLarge` TEXT,
`emphasizedTitleMedium` TEXT,
`emphasizedTitleSmall` TEXT,
`emphasizedBodyLarge` TEXT,
`emphasizedBodyMedium` TEXT,
`emphasizedBodySmall` TEXT,
`emphasizedLabelLarge` TEXT,
`emphasizedLabelMedium` TEXT,
`emphasizedLabelSmall` TEXT
)
""".trimIndent()
)
}
}