blob: 53db4eb4ce6ca5a5fab64b771aa3a0f217211a07 [file] [log] [blame]
Alan Viverette257d13b2015-04-10 15:46:18 -07001#!/usr/bin/python
2
3import os
4
5# assume everything needs alpha suffixes
6for root, dirs, files in os.walk('.'):
7 if "res/drawable-" not in root: continue
8
9 for before in files:
10 if "_alpha.png" in before: continue
11 if not before.startswith("ic_settings_"): continue
12
13 after = before.replace(".png", "_alpha.png")
14 os.rename(os.path.join(root, before), os.path.join(root, after))
15
16# build xml redirection
17for root, dirs, files in os.walk('.'):
18 if "res/drawable-" not in root: continue
19
20 for src in files:
21 if not src.endswith(".png"): continue
22 src = src[0:-4]
23
24 src_clause = '\n android:src="@drawable/%s"' % (src)
25
26 alpha = src.endswith("_alpha")
27 if alpha:
28 src = src[0:-6]
29 alpha_clause = '\n android:tint="?android:attr/colorAccent"'
30 else:
31 alpha_clause = ''
32
33 am = src.endswith("_am")
34 if am:
35 src = src[0:-3]
36 am_clause = '\n android:autoMirrored="true"'
37 else:
38 am_clause = ''
39
40 with open("res/drawable/%s.xml" % (src), 'w') as xml:
41 xml.write("""<?xml version="1.0" encoding="utf-8"?>
42<bitmap xmlns:android="http://schemas.android.com/apk/res/android"%s%s%s />
43""" % (src_clause, alpha_clause, am_clause))