Store themed attribute per icon pack icon
This commit is contained in:
parent
f4c1bcf5aa
commit
c71fec59ac
@ -2,7 +2,7 @@
|
|||||||
"formatVersion": 1,
|
"formatVersion": 1,
|
||||||
"database": {
|
"database": {
|
||||||
"version": 20,
|
"version": 20,
|
||||||
"identityHash": "0e23c747bfe32759849ee85dcd5d23cb",
|
"identityHash": "5b1104c3916482efde9b715c1f3c1273",
|
||||||
"entities": [
|
"entities": [
|
||||||
{
|
{
|
||||||
"tableName": "forecasts",
|
"tableName": "forecasts",
|
||||||
@ -222,7 +222,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tableName": "Icons",
|
"tableName": "Icons",
|
||||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`type` TEXT NOT NULL, `componentName` TEXT, `drawable` TEXT, `iconPack` TEXT NOT NULL, `name` TEXT, `id` INTEGER PRIMARY KEY AUTOINCREMENT)",
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`type` TEXT NOT NULL, `componentName` TEXT, `drawable` TEXT, `iconPack` TEXT NOT NULL, `name` TEXT, `themed` INTEGER NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT)",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"fieldPath": "type",
|
"fieldPath": "type",
|
||||||
@ -254,6 +254,12 @@
|
|||||||
"affinity": "TEXT",
|
"affinity": "TEXT",
|
||||||
"notNull": false
|
"notNull": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "themed",
|
||||||
|
"columnName": "themed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldPath": "id",
|
"fieldPath": "id",
|
||||||
"columnName": "id",
|
"columnName": "id",
|
||||||
@ -468,7 +474,7 @@
|
|||||||
"views": [],
|
"views": [],
|
||||||
"setupQueries": [
|
"setupQueries": [
|
||||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '0e23c747bfe32759849ee85dcd5d23cb')"
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5b1104c3916482efde9b715c1f3c1273')"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11,5 +11,6 @@ data class IconEntity(
|
|||||||
val drawable: String?,
|
val drawable: String?,
|
||||||
val iconPack: String,
|
val iconPack: String,
|
||||||
val name: String?,
|
val name: String?,
|
||||||
|
val themed: Boolean = false,
|
||||||
@PrimaryKey(autoGenerate = true) val id : Long? = null
|
@PrimaryKey(autoGenerate = true) val id : Long? = null
|
||||||
)
|
)
|
||||||
@ -13,6 +13,7 @@ class Migration_19_20: Migration(19, 20) {
|
|||||||
`drawable` TEXT,
|
`drawable` TEXT,
|
||||||
`iconPack` TEXT NOT NULL,
|
`iconPack` TEXT NOT NULL,
|
||||||
`name` TEXT,
|
`name` TEXT,
|
||||||
|
`themed` INTEGER NOT NULL DEFAULT 0,
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT)
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT)
|
||||||
""")
|
""")
|
||||||
database.execSQL("INSERT INTO `Icons` (`type`, `componentName`, `drawable`, `iconPack`, `themed`, `name`) SELECT `type`, `componentName`, `drawable`, `iconPack`, null FROM `Icons_old`")
|
database.execSQL("INSERT INTO `Icons` (`type`, `componentName`, `drawable`, `iconPack`, `themed`, `name`) SELECT `type`, `componentName`, `drawable`, `iconPack`, null FROM `Icons_old`")
|
||||||
|
|||||||
@ -8,6 +8,7 @@ data class IconPackIcon(
|
|||||||
val componentName: ComponentName?,
|
val componentName: ComponentName?,
|
||||||
val drawable: String?,
|
val drawable: String?,
|
||||||
val iconPack: String,
|
val iconPack: String,
|
||||||
|
val themed: Boolean = false,
|
||||||
val name: String? = null,
|
val name: String? = null,
|
||||||
) {
|
) {
|
||||||
constructor(entity: IconEntity) : this(
|
constructor(entity: IconEntity) : this(
|
||||||
@ -16,6 +17,7 @@ data class IconPackIcon(
|
|||||||
drawable = entity.drawable,
|
drawable = entity.drawable,
|
||||||
iconPack = entity.iconPack,
|
iconPack = entity.iconPack,
|
||||||
name = entity.name,
|
name = entity.name,
|
||||||
|
themed = entity.themed,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun toDatabaseEntity(): IconEntity {
|
fun toDatabaseEntity(): IconEntity {
|
||||||
@ -25,6 +27,7 @@ data class IconPackIcon(
|
|||||||
drawable = drawable,
|
drawable = drawable,
|
||||||
iconPack = iconPack,
|
iconPack = iconPack,
|
||||||
name = name,
|
name = name,
|
||||||
|
themed = themed,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +60,6 @@ class IconPackManager(
|
|||||||
suspend fun getIcon(
|
suspend fun getIcon(
|
||||||
iconPack: String,
|
iconPack: String,
|
||||||
componentName: ComponentName,
|
componentName: ComponentName,
|
||||||
themed: Boolean = false
|
|
||||||
): LauncherIcon? {
|
): LauncherIcon? {
|
||||||
val res = try {
|
val res = try {
|
||||||
context.packageManager.getResourcesForApplication(iconPack)
|
context.packageManager.getResourcesForApplication(iconPack)
|
||||||
@ -75,7 +74,7 @@ class IconPackManager(
|
|||||||
val drawableName = icon.drawable ?: return null
|
val drawableName = icon.drawable ?: return null
|
||||||
|
|
||||||
if (icon.type == "calendar") {
|
if (icon.type == "calendar") {
|
||||||
return getIconPackCalendarIcon(context, iconPack, drawableName, themed)
|
return getIconPackCalendarIcon(context, iconPack, drawableName, icon.themed)
|
||||||
}
|
}
|
||||||
val resId = res.getIdentifier(drawableName, "drawable", iconPack).takeIf { it != 0 }
|
val resId = res.getIdentifier(drawableName, "drawable", iconPack).takeIf { it != 0 }
|
||||||
?: return null
|
?: return null
|
||||||
@ -85,7 +84,7 @@ class IconPackManager(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return when {
|
return when {
|
||||||
themed && drawable is AdaptiveIconDrawable -> {
|
icon.themed && drawable is AdaptiveIconDrawable -> {
|
||||||
if (isAtLeastApiLevel(33) && drawable.monochrome != null) {
|
if (isAtLeastApiLevel(33) && drawable.monochrome != null) {
|
||||||
return StaticLauncherIcon(
|
return StaticLauncherIcon(
|
||||||
foregroundLayer = StaticIconLayer(
|
foregroundLayer = StaticIconLayer(
|
||||||
|
|||||||
@ -122,6 +122,7 @@ class IconPackInstaller(
|
|||||||
drawable = drawable,
|
drawable = drawable,
|
||||||
iconPack = pkgName,
|
iconPack = pkgName,
|
||||||
name = name,
|
name = name,
|
||||||
|
themed = iconPack.themed,
|
||||||
type = "app"
|
type = "app"
|
||||||
)
|
)
|
||||||
icons.add(icon)
|
icons.add(icon)
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class IconPackIconProvider(
|
|||||||
if (searchable !is LauncherApp) return null
|
if (searchable !is LauncherApp) return null
|
||||||
|
|
||||||
val component = ComponentName(searchable.`package`, searchable.activity)
|
val component = ComponentName(searchable.`package`, searchable.activity)
|
||||||
return iconPackManager.getIcon(iconPack.packageName, component, iconPack.themed)
|
return iconPackManager.getIcon(iconPack.packageName, component)
|
||||||
?: iconPackManager.generateIcon(
|
?: iconPackManager.generateIcon(
|
||||||
context,
|
context,
|
||||||
iconPack.packageName,
|
iconPack.packageName,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user