screen_densities = ['640', '480', '320', '240', '160', '120']
+all_screen_densities = ['0'] + screen_densities
+
def dpi_to_px(density):
return (int(density) * 48) / 160
def get_icon_dir(repodir, density):
- if density is None:
+ if density == '0':
return os.path.join(repodir, "icons")
return os.path.join(repodir, "icons-%s" % density)
def get_icon_dirs(repodir):
for density in screen_densities:
yield get_icon_dir(repodir, density)
- yield os.path.join(repodir, "icons")
+
+
+def get_all_icon_dirs(repodir):
+ for density in all_screen_densities:
+ yield get_icon_dir(repodir, density)
def update_wiki(apps, sortedids, apks):
cachechanged = False
- icon_dirs = get_icon_dirs(repodir)
- for icon_dir in icon_dirs:
+ for icon_dir in get_all_icon_dirs(repodir):
if os.path.exists(icon_dir):
if options.clean:
shutil.rmtree(icon_dir)
if '-1' in thisinfo['icons_src']:
iconsrc = thisinfo['icons_src']['-1']
iconpath = os.path.join(
- get_icon_dir(repodir, None), iconfilename)
+ get_icon_dir(repodir, '0'), iconfilename)
with open(iconpath, 'wb') as f:
f.write(apk.read(iconsrc))
try:
# Copy from icons-mdpi to icons since mdpi is the baseline density
baseline = os.path.join(get_icon_dir(repodir, '160'), iconfilename)
if os.path.isfile(baseline):
+ thisinfo['icons']['0'] = iconfilename
shutil.copyfile(baseline,
- os.path.join(get_icon_dir(repodir, None), iconfilename))
+ os.path.join(get_icon_dir(repodir, '0'), iconfilename))
# Record in known apks, getting the added date at the same time..
added = knownapks.recordapk(thisinfo['apkname'], thisinfo['id'])
logging.info("Moving " + apk['apkname'] + " to archive")
move_file(repodir, archivedir, apk['apkname'], False)
move_file(repodir, archivedir, apk['apkname'] + '.asc', True)
+ for density in all_screen_densities:
+ repo_icon_dir = get_icon_dir(repodir, density)
+ archive_icon_dir = get_icon_dir(archivedir, density)
+ if density not in apk['icons']:
+ continue
+ move_file(repo_icon_dir, archive_icon_dir, apk['icons'][density], True)
if 'srcname' in apk:
move_file(repodir, archivedir, apk['srcname'], False)
archapks.append(apk)
logging.info("Moving " + apk['apkname'] + " from archive")
move_file(archivedir, repodir, apk['apkname'], False)
move_file(archivedir, repodir, apk['apkname'] + '.asc', True)
+ for density in all_screen_densities:
+ repo_icon_dir = get_icon_dir(repodir, density)
+ archive_icon_dir = get_icon_dir(archivedir, density)
+ if density not in apk['icons']:
+ continue
+ move_file(archive_icon_dir, repo_icon_dir, apk['icons'][density], True)
if 'srcname' in apk:
move_file(archivedir, repodir, apk['srcname'], False)
archapks.remove(apk)