1 Star 0 Fork 3

gumqii/android_packages_apps_Settings

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
wrap_alpha.py 1.28 KB
一键复制 编辑 原始数据 按行查看 历史
#!/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
if not before.startswith("ic_settings_"): 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]
alpha_clause = '\n android:tint="?android:attr/colorAccent"'
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))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gumqii/android_packages_apps_Settings.git
git@gitee.com:gumqii/android_packages_apps_Settings.git
gumqii
android_packages_apps_Settings
android_packages_apps_Settings
mkq-mr1

搜索帮助

0d507c66 1850385 C8b1a773 1850385