Skip to content

Commit

Permalink
Also store icons of launchable system apps
Browse files Browse the repository at this point in the history
  • Loading branch information
grote committed May 22, 2024
1 parent 8521b71 commit 5b4bd98
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/com/stevesoltys/seedvault/worker/IconManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down

0 comments on commit 5b4bd98

Please sign in to comment.