# 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


def script_pre(SDK, decompileDir, channelSdkInfo, new_game_channel_info, gameInfo):
    mipmap = os.path.join(decompileDir, "res/mipmap-anydpi-v26")
    values = os.path.join(decompileDir, "res/values-anydpi-v26")
    if os.path.exists(mipmap):
        distutils.dir_util.remove_tree(mipmap)
    if os.path.exists(values):
        distutils.dir_util.remove_tree(values)
    logging.info("-----debug-----")


def script_after(workspace_sdk_dir, extract_dir, channel_sdk_info, new_game_channel_info, game_info):
    # ic_launcher_foreground.png
    list_ic_launcher_foreground = [
        "drawable",
        "drawable-hdpi-v4",
        "drawable-ldpi-v4",
        "drawable-mdpi-v4",
        "drawable-xhdpi-v4",
        "drawable-xxhdpi-v4",
        "drawable-xxxhdpi-v4",
        "mipmap",
        "mipmap-hdpi-v4",
        "mipmap-ldpi-v4",
        "mipmap-mdpi-v4",
        "mipmap-xhdpi-v4",
        "mipmap-xxhdpi-v4",
        "mipmap-xxxhdpi-v4",
    ]
    icon_src = os.path.join(extract_dir, "res", "drawable", "ic_launcher.png")
    for dpi in list_ic_launcher_foreground:
        icon = os.path.join(extract_dir, "res", dpi, "ic_launcher_foreground.png")
        if os.path.exists(icon):
            shutil.copyfile(icon_src, icon)


if __name__ == '__main__':
    script_after("", "d:\\sanguo", "", "", "")
