chiark / gitweb /
update: find PNG when recommended icon is an XML file
authorHans-Christoph Steiner <hans@eds.org>
Tue, 4 Jul 2017 15:40:02 +0000 (17:40 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Thu, 6 Jul 2017 10:25:48 +0000 (12:25 +0200)
APKs can now use XML files for vector graphics like the app icon. `aapt`
returns the XML file by default, and perhaps also androguard.  This
checks if the icon is an XML file, and if so, it tries to find a PNG in
the APK with the same name and density to use instead

closes #322

This should also ultimately make the XML file available as an icon source
as well fdroidclient#1091

fdroidserver/update.py

index 1ccec78a8b482382e14e1e62cd093e484a5b62d4..286a5510371cc630a4278e3e0ce50242f2b7c27b 100644 (file)
@@ -1386,6 +1386,13 @@ def extract_apk_icons(icon_filename, apk, apkzip, repo_dir):
         icon_dest = os.path.join(icon_dir, icon_filename)
 
         # Extract the icon files per density
+        if icon_src.endswith('.xml'):
+            png = os.path.basename(icon_src)[:-4] + '.png'
+            for f in apkzip.namelist():
+                if f.endswith(png):
+                    m = re.match(r'res/drawable-(x*[hlm]dpi).*/', f)
+                    if m and screen_resolutions[m.group(1)] == density:
+                        icon_src = f
         try:
             with open(icon_dest, 'wb') as f:
                 f.write(get_icon_bytes(apkzip, icon_src))