[Android Themes] Kdio:
Could you criticise the below:

test.py

import os
import shutil

input_folder = 'c:\\gimp\\Phone'

output_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), "out")
if not os.path.isdir(output_folder):
os.mkdir(output_folder)

tokens = {}
xmlExist = {}

for root, dirs, files in os.walk(input_folder):
for f in files:
inputFile = os.path.join(root, f)
filename, ext = os.path.splitext(inputFile)

if (ext != '.xml'):
continue

xmlExist[os.path.basename(inputFile)] = 1

with open(inputFile, 'r') as f:
for line in f:
token = ''
read_token = False
for c in line:
if (c == '@'):
read_token = True
continue

if (read_token is True):
if (c == '"'):
read_token = False
tokens[token] = 1
token = ''
else:
token += c
f.close()

xmls = {}
for token in sorted(tokens):
if (token == 'null'):
continue
if (':' in token):
continue
#token = token.split(':')[-1]
head, tail = token.split('/')
if (head == 'anim'):
continue

if ((tail + '.xml') in xmlExist.keys()):
continue

if (not head in xmls.keys()):
xmls[head] = {}
xmls[head][tail] = 1

#for xml in xmls:
# for res in xmls[xml]:
# print(xml + ' -> ' + res)

for xml in xmls:

xmlText = '<?xml version="1.0" encoding="utf-8"?>\n<resources>\n'

for res in xmls[xml]:
if (xml == 'bool'):
xmlText += ' <bool name="' + res + '">false</bool>\n'

if ((xml == 'id') or (xml == 'drawable') or (xml == 'style') or (xml == 'layout')):
xmlText += ' <item type="' + xml + '" name="' + res + '">false</item>\n'

if (xml == 'array'):
xmlText += ' <string-array name="' + res + '">\n <item>array-dummy</item>\n </string-array>\n'

if (xml == 'attr'):
xmlText += ' <attr name="' + res + '" format="string" />\n'

if (xml == 'color'):
xmlText += ' <color name="'+ res + '">#00000000</color>\n'

if (xml == 'dimen'):
xmlText += ' <dimen name="' + res + '">1.0dip</dimen>\n'

if (xml == 'integer'):
xmlText += ' <integer name="' + res + '">1</integer>\n'

if (xml == 'plural'):
xmlText += ' <plurals name="' + res + '">\n <item quantity="other">a</item>\n <item quantity="one">b</item>\n </plurals>\n'

if (xml == 'string'):
xmlText += ' <string name="' + res + '">a</string>\n'

if (xml == 'fraction'):
xmlText += ' <fraction name="' + res + '">1%</fraction>\n'

xmlText += '</resources>\n'

f = open(os.path.join(output_folder, xml + 's.xml'), 'w')
f.write(xmlText)
f.close

Edit input_folder at line 4 accordingly.

- Decompíled HTC Phone.apk

- left inside only res\drawable*\*.xml & res\layout*\*.xml

- Runned the above code pointing the cleaned Phone folder

- It will generate in the 'out' folder all the xml's needed to be placed in the res\values\ folder

BUT << (there is at least one ever)

aapt doesn't complete its duty as there are still references to external resources unresolved. (piece of the log)

EDIT: [MENTION=5537766]Modding.MyMind[/MENTION] We can't dummy external resources ... Can we?

c:\apk\Dummy\res\layout\common_add_cellbroadcast_dialog.xml:5: error: Error: No resource found that matches the given name (at 'background' with value '@com.htc:drawable/common_list_item_background').
c:\apk\Dummy\res\layout\common_add_cellbroadcast_dialog.xml:6: error: Error: No resource found that matches the given name (at 'style' with value '@com.htc:style/input_default_m').
c:\apk\Dummy\res\layout\common_add_cellbroadcast_dialog.xml:9: error: Error: No resource found that matches the given name (at 'background' with value '@com.htc:drawable/common_list_item_background').
c:\apk\Dummy\res\layout\common_add_cellbroadcast_dialog.xml:10: error: Error: No resource found that matches the given name (at 'style' with value '@com.htc:style/input_default_m').
c:\apk\Dummy\res\layout\common_adn_list.xml:4: error: Error: No resource found that matches the given name (at 'style' with value '@com.htc:style/HtcListView').
c:\apk\Dummy\res\layout\common_carmode_cmd_bar_7.xml:5: error: No resource identifier found for attribute 'backgroundMode' in package 'com.htc'
c:\apk\Dummy\res\layout\common_carmode_cmd_bar_7.xml:6: error: No resource identifier found for attribute 'isContentMultiply' in package 'com.htc'
c:\apk\Dummy\res\layout\common_carmode_cmd_bar_7.xml:6: error: No resource identifier found for attribute 'extAnimationMode' in package 'com.htc'
c:\apk\Dummy\res\layout\common_carmode_cmd_bar_7.xml:7: error: No resource identifier found for attribute 'backgroundMode' in package 'com.htc'
c:\apk\Dummy\res\layout\common_cmd_bar_center.xml:5: error: No resource identifier found for attribute 'isContentMultiply' in package 'com.htc'
c:\apk\Dummy\res\layout\common_cmd_bar_center.xml:5: error: No resource identifier found for attribute 'extAnimationMode' in package 'com.htc'
c:\apk\Dummy\res\layout\common_cmd_bar_center.xml:6: error: No resource identifier found for attribute 'isContentMultiply' in package 'com.htc'
c:\apk\Dummy\res\layout\common_cmd_bar_center.xml:6: error: No resource identifier found for attribute 'extAnimationMode' in package 'com.htc'
c:\apk\Dummy\res\layout\common_cmd_bar_center.xml:7: error: No resource identifier found for attribute 'isContentMultiply' in package 'com.htc'
c:\apk\Dummy\res\layout\common_cmd_bar_center.xml:7: error: No resource identifier found for attribute 'extAnimationMode' in package 'com.htc'

...

c:\apk\Dummy\res\layout\specific_htc_dialpad.xml:13: error: No resource identifier found for attribute 'number' in package 'com.android.phone'
c:\apk\Dummy\res\layout\specific_htc_dialpad.xml:13: error: No resource identifier found for attribute 'number_style' in package 'com.android.phone'
c:\apk\Dummy\res\layout\specific_htc_dialpad.xml:13: error: No resource identifier found for attribute 'alphabet' in package 'com.android.phone'
c:\apk\Dummy\res\layout\specific_htc_dialpad.xml:13: error: No resource identifier found for attribute 'alphabet_style' in package 'com.android.phone'
c:\apk\Dummy\res\layout\specific_htc_dialpad.xml:13: error: No resource identifier found for attribute 'phoneticAlphabet' in package 'com.android.phone'
c:\apk\Dummy\res\layout\specific_htc_dialpad.xml:14: error: No resource identifier found for attribute 'alphabet_style' in package 'com.android.phone'
c:\apk\Dummy\res\layout\specific_htc_dialpad.xml:14: error: No resource identifier found for attribute 'phoneticAlphabet' in package 'com.android.phone'
c:\apk\Dummy\res\layout\specific_htc_dialpad.xml:14: error: No resource identifier found for attribute 'primaryIcon' in package

...

c:\apk\Dummy\res\layout\specific_phone_action_bar.xml:6: error: No resource identifier found for attribute 'backgroundMode' in package 'com.htc'
c:\apk\Dummy\res\layout\specific_phone_action_bar.xml:13: error: No resource identifier found for attribute 'backgroundMode' in package 'com.htc'
c:\apk\Dummy\res\layout\specific_pref_dialog_edit_enhanced_plus_code_prefix.xml:5: error: Error: No resource found that matches the given name (at 'layout_marginLeft' with value '@com.htc:dimen/margin_m').
c:\apk\Dummy\res\layout\specific_pref_dialog_edit_enhanced_plus_code_prefix.xml:5: error: Error: No resource found that matches the given name (at 'layout_marginTop' with value '@com.htc:dimen/margin_s').
c:\apk\Dummy\res\layout\specific_pref_dialog_edit_enhanced_plus_code_prefix.xml:5: error: Error: No resource found that matches the given name (at 'layout_marginRight' with value '@com.htc:dimen/margin_m').

...

c:\apk\Dummy\res\layout\specific_task_panel.xml:6: error: Error: No resource found that matches the given name (at 'layout_marginRight' with value '@com.htc:dimen/margin_m').
c:\apk\Dummy\res\layout\specific_task_panel.xml:6: error: Error: No resource found that matches the given name (at 'style' with value '@com.htc:style/list_body_primary_xs').

At this point I need orientation. Not sure if it's possible to compile xml's just 'dummying' resources.

Where to go now ?

.