# coding:utf8

__author__ = 'dong'

import os
import logging
import xml.dom.minidom
import re
import shutil
import glob
from xml.etree.ElementTree import ElementTree, Element
import distutils.dir_util
from xml.etree import ElementTree as ET

ANDROID_NS = 'http://schemas.android.com/apk/res/android'


def script_last(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
    handle_style(extract_dir)
    return


def handle_style(decompile_dir_path):
    style_xml_path = os.path.join(decompile_dir_path, 'res', 'values', 'styles.xml')
    xml_tree = ET.parse(style_xml_path)
    xml_root = xml_tree.getroot()
    style_roots = xml_root.findall('./style')
    for style_root in style_roots:
        if style_root.get('name') == 'AppTheme':
            print(style_root.get('parent'))
            style_root.set('parent', '@style/Theme.AppCompat.Light.NoActionBar')
            xml_tree.write(style_xml_path, encoding='utf-8', xml_declaration=True)
            break


if __name__ == '__main__':
    d="D:/work/guanyu"
    handle_style(d)
    # replace_super_application("D:\work\wzdq")
    # modify_manifest("E:\\apk\\youhua\\youhua.zip.out", "requestLegacyExternalStorage")
