Also store icons of launchable system apps
This commit is contained in:
parent
a0a3e871e0
commit
1ac613f588
1 changed files with 12 additions and 0 deletions
|
@ -42,12 +42,24 @@ internal class IconManager(
|
|||
val packageManager = context.packageManager
|
||||
ZipOutputStream(outputStream).use { zip ->
|
||||
zip.setLevel(BEST_SPEED)
|
||||
val entries = mutableSetOf<String>()
|
||||
packageService.allUserPackages.forEach {
|
||||
val drawable = packageManager.getApplicationIcon(it.applicationInfo)
|
||||
if (packageManager.isDefaultApplicationIcon(drawable)) return@forEach
|
||||
val entry = ZipEntry(it.packageName)
|
||||
zip.putNextEntry(entry)
|
||||
drawable.toBitmap(ICON_SIZE, ICON_SIZE).compress(WEBP_LOSSY, ICON_QUALITY, zip)
|
||||
entries.add(it.packageName)
|
||||
zip.closeEntry()
|
||||
}
|
||||
packageService.launchableSystemApps.forEach {
|
||||
val drawable = it.loadIcon(packageManager)
|
||||
if (packageManager.isDefaultApplicationIcon(drawable)) return@forEach
|
||||
// check for duplicates (e.g. updated launchable system app)
|
||||
if (it.activityInfo.packageName in entries) return@forEach
|
||||
val entry = ZipEntry(it.activityInfo.packageName)
|
||||
zip.putNextEntry(entry)
|
||||
drawable.toBitmap(ICON_SIZE, ICON_SIZE).compress(WEBP_LOSSY, ICON_QUALITY, zip)
|
||||
zip.closeEntry()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue