summaryrefslogtreecommitdiff
path: root/wrap_alpha.py
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@android.com> 2014-08-08 13:08:56 -0700
committer Jeff Sharkey <jsharkey@google.com> 2014-08-08 22:22:39 +0000
commit34c5409fb31d0aae417db265dce4f49ee8a93227 (patch)
treee54a577f1a3378d221a3ca2251321fab0b75434a /wrap_alpha.py
parentcb8fac398a8b35dae2c64c7c97e5b34ebf8df297 (diff)
More material updates to DocumentsUI.
All assets cut as alpha variants so we apply desired tinting at runtime. Small script to automatically generate XML resources. Bug: 15836082, 16658537 Change-Id: I803b3f0bf6f121194a5445fd1c6600fabaf28f60
Diffstat (limited to 'wrap_alpha.py')
-rw-r--r--wrap_alpha.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/wrap_alpha.py b/wrap_alpha.py
new file mode 100644
index 000000000..92a3d59af
--- /dev/null
+++ b/wrap_alpha.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python
+
+import os
+
+"""
+# assume everything needs alpha suffixes
+for root, dirs, files in os.walk('.'):
+ if "res/drawable-" not in root: continue
+
+ for before in files:
+ if "_alpha.png" in before: continue
+
+ after = before.replace(".png", "_alpha.png")
+ os.rename(os.path.join(root, before), os.path.join(root, after))
+"""
+
+# build xml redirection
+for root, dirs, files in os.walk('.'):
+ if "res/drawable-" not in root: continue
+
+ for src in files:
+ if not src.endswith(".png"): continue
+ src = src[0:-4]
+
+ src_clause = '\n android:src="@drawable/%s"' % (src)
+
+ alpha = src.endswith("_alpha")
+ if alpha:
+ src = src[0:-6]
+ if "ic_doc" in src or "ic_root" in src or "ic_grid_folder" in src:
+ alpha_clause = '\n android:tint="@*android:color/secondary_text_material_light"'
+ else:
+ alpha_clause = '\n android:tint="?android:attr/colorControlNormal"'
+ else:
+ alpha_clause = ''
+
+ am = src.endswith("_am")
+ if am:
+ src = src[0:-3]
+ am_clause = '\n android:autoMirrored="true"'
+ else:
+ am_clause = ''
+
+ with open("res/drawable/%s.xml" % (src), 'w') as xml:
+ xml.write("""<?xml version="1.0" encoding="utf-8"?>
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"%s%s%s />
+""" % (src_clause, alpha_clause, am_clause))