chenquincy / app-info-parser

A javascript parser for parsing .ipa or .apk files. IPA/APK文件 js 解析器
MIT License
492 stars 116 forks source link

feat(apk): add support for adaptive icon parsing #92

Open Klowner opened 1 year ago

Klowner commented 1 year ago

This change adds support for Android adaptive icons as discussed in #91.

If application.icon is an XML resource, it is assumed to be an adaptive icon file. The individual components are parsed from it and assigned to apkInfo in the format:

icon: {
   foreground: '<base64 encoded png>',
   background: '<base64 encoded png>',
   monochrome: '<base64 encoded png>',
}

If any of foreground, background, or monochrome are not present in the XML or cannot be mapped to valid resources, those keys are omitted from the result object.

Please feel free to request any modifications! Thank you! -Mark

chenquincy commented 1 year ago

@Klowner I haven't reviewed the code yet, but have a comment about the output. The icon's type is changed from string to object, that brings a break-change to this library. Maybe store the adaptive icon output to a new key like adaptiveIcons is better. In addition, could you provide a package with adaptive icon for testing?

Klowner commented 1 year ago

Thank you for the feedback, @chenquincy.

I've changed it so the adaptive icons are exposed via {adaptiveIcons: {}} rather than reusing {icon}.

Here's an example apk containing adaptive icon specification (this example only contains a "foreground" image). adaptive-icon-example.zip (Change extension from .zip to .apk)