chiark / gitweb /
have fallback for XML icons also consider res/mipmap*
authorIzzy <izzysoft@qumran.org>
Sun, 16 Jul 2017 22:54:33 +0000 (00:54 +0200)
committerIzzy <izzysoft@qumran.org>
Sun, 16 Jul 2017 22:54:33 +0000 (00:54 +0200)
several apps (e.g.
[FastHub](http://apt.qumran.org/fdroid/index/apk/com.fastaccess.github)
and [Monety](http://apt.qumran.org/fdroid/index/apk/open.currency)) have
their ic_launcher.png files not in res/drawable*dpi/, but in
res/mipmap*/ -- so the regex has been adjusted by this patch.

Additionally: if the only icon for a given resolution was an XML without
existing fallback-PNG, it should be considered "non existent" (ie.
"empty_density").

fdroidserver/update.py

index f463b55de1877a7a0ffbec08cd9b6113f9749e7f..0892e810a37e4c32807669429a53a691d33fc7c3 100644 (file)
@@ -1391,9 +1391,12 @@ def extract_apk_icons(icon_filename, apk, apkzip, repo_dir):
             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:
+                    m = re.match(r'res/(drawable|mipmap)-(x*[hlm]dpi).*/', f)
+                    if m and screen_resolutions[m.group(2)] == density:
                         icon_src = f
+            if icon_src.endswith('.xml'):
+                empty_densities.append(density)
+                continue
         try:
             with open(icon_dest, 'wb') as f:
                 f.write(get_icon_bytes(apkzip, icon_src))