lany 1 rok pred
rodič
commit
29993aa840
2 zmenil súbory, kde vykonal 58 pridanie a 37 odobranie
  1. 6 33
      file_processer.py
  2. 52 4
      utils/other_utils.py

+ 6 - 33
file_processer.py

@@ -8,7 +8,8 @@ from utils.other_utils import get_file_suffix, extract_codes_colors, replace_old
     add_import_R, bg_homeindex_item_10, unify_path_separator, \
     get_included_suffix, get_excluded_files, update_deprecated, bg_btn_white_topr10, \
     bg_btn_white_topr12, bg_btn_white_topr16, replace_xml_imageview, replace_xml_textview, \
-    replace_system_bar, delete_xml_remark, replace_icon, replace_background, hykb_dimens
+    replace_system_bar, delete_xml_remark, replace_background, hykb_dimens, replace_back_icon, \
+    replace_arrow_icon
 
 
 # 替换java/kotlin/xml文件中的颜色硬编码
@@ -33,9 +34,6 @@ def replace_file_by_path(file_path: str, auto_include_callback=None):
     with open(file_path, 'r', encoding='utf-8') as f:
         text = f.read()
 
-    text = text.replace("\"#ffffffff\"", "\"#ffffff\"")
-    text = text.replace("\"#FFFFFFFF\"", "\"#ffffff\"")
-
     # 自动解析include
     auto_parse_include(text, suffix, auto_include_callback)
     # fix过时方法
@@ -47,9 +45,9 @@ def replace_file_by_path(file_path: str, auto_include_callback=None):
     # 更新主题
     text = update_themes(text)
     # 删除xml注释
-    text = delete_xml_remark(text)
+    # text = delete_xml_remark(text)
     # 替换旧的dimen
-    text = hykb_dimens(text)
+    # text = hykb_dimens(text)
 
     text = bg_white_radius10(text)
     text = bg_homeindex_item_10(text)
@@ -63,32 +61,10 @@ def replace_file_by_path(file_path: str, auto_include_callback=None):
 
     text = replace_xml_imageview(text)
     text = replace_xml_textview(text)
-    text = replace_icon(text)
+    text = replace_arrow_icon(text)
+    text = replace_back_icon(text)
     text = replace_background(text)
 
-    # 错误校正,非必须
-    text = text.replace("green_brandDark", "green_brand")
-    text = text.replace("green_brand_brand", "green_brand")
-    text = text.replace("green_brand_brandDark", "green_brand")
-    text = text.replace("green_brandDark", "green_brand")
-    text = text.replace("green_brand_08", "green_brand_7")
-    text = text.replace("green_brand_brand_word", "green_word")
-    text = text.replace("green_brand_word", "green_word")
-    text = text.replace("green_brand_hover", "green_hover")
-    text = text.replace("green_brand_line", "green_line")
-    text = text.replace("green_brand_e0fce7", "green_e0fce7")
-    text = text.replace("bg_light_00", "transparent")
-    text = text.replace("font_color_ff131715", "black_h1")
-    text = text.replace("green_brand_bg", "green_bg")
-    text = text.replace("color_ff131715", "black_h1")
-    text = text.replace("color_green_", "green_brand_")
-
-    # text = text.replace("Color.parseColor(\"#ffffff\")", "ResUtils.getColor(R.color.white)")
-    # text = text.replace("Color.parseColor(\"#ffffffff\")", "ResUtils.getColor(R.color.white)")
-    # text = text.replace("android:textColor=\"#ffffffff\"", "android:textColor=\"@color/white\"")
-    # text = text.replace("android:background=\"#ffffffff\"", "android:background=\"@color/bg_white\"")
-    # text = text.replace("setImageDrawable(ContextCompat.getDrawable(mActivity, ", "setImageResource((")
-
     # 添加xml头信息
     text = add_xml_res_auto(text)
     # 替换旧方法
@@ -100,9 +76,6 @@ def replace_file_by_path(file_path: str, auto_include_callback=None):
     # 删除xml多余空白行
     # text = delete_xml_blank_line(text, suffix)
 
-    text = text.replace("color_333333", "black_h2")
-    text = text.replace("color_999999", "black_h4")
-
     # 处理状态栏
     text = replace_system_bar(text)
 

+ 52 - 4
utils/other_utils.py

@@ -4,12 +4,12 @@ import os
 import re
 from pathlib import Path
 
-from utils.color_set import get_new_colors, get_old_colors, get_old_dimens
+from colors.utils.color_set import get_new_colors, get_old_colors, get_old_dimens
 
 
 # 需要忽略的文件
 def get_excluded_files():
-    return {'colors.xml', 'colors_alpha.xml', 'strings.xml',
+    return {'colors.xml', 'colors_alpha.xml', 'colors_hyif.xml', 'colors_wsy.xml', 'strings.xml',
             'TimeSpendDetailFragment.kt', 'TimeSpendDetailDialog.kt', 'PostTypeHelper.java',
             'ProduceDataRecycleViewScrollBar.java', 'DefaultTitleDialog.java', 'GlideUtils.java'}
 
@@ -222,6 +222,9 @@ def replace_old_color(text):
     new_colors = get_new_colors()
     old_colors = get_old_colors()
 
+    text = text.replace("\"#ffffffff\"", "\"#ffffff\"")
+    text = text.replace("\"#FFFFFFFF\"", "\"#ffffff\"")
+
     for new_color in new_colors:
         new_color_name = new_color[0]
         new_color_code = new_color[1]
@@ -237,6 +240,42 @@ def replace_old_color(text):
                 # print(f"新旧颜色装换{old_color_name}->{new_color_name}->{new_color_code}")
                 text = text.replace(f"@color/{old_color_name}", f"@color/{new_color_name}")
                 text = text.replace(f"R.color.{old_color_name}", f"R.color.{new_color_name}")
+
+    text = text.replace("@android:color/white", "@color/white")
+    text = text.replace("@android:color/black", "@color/black")
+    text = text.replace("android.R.color.white", "R.color.white")
+    text = text.replace("android.R.color.black", "R.color.black")
+
+    text = text.replace("bg_pressed", "green_brand_8")
+    text = text.replace("menu_item_bg_pressed_eb23c268", "green_brand_8")
+    text = text.replace("menu_item_bg_pressed", "green_brand_8")
+
+    # 错误校正,非必须
+    text = text.replace("green_brandDark", "green_brand")
+    text = text.replace("green_brand_brand", "green_brand")
+    text = text.replace("green_brand_brandDark", "green_brand")
+    text = text.replace("green_brandDark", "green_brand")
+    text = text.replace("green_brand_08", "green_brand_7")
+    text = text.replace("green_brand_brand_word", "green_word")
+    text = text.replace("green_brand_word", "green_word")
+    text = text.replace("green_brand_hover", "green_hover")
+    text = text.replace("green_brand_line", "green_line")
+    text = text.replace("green_brand_e0fce7", "green_e0fce7")
+    text = text.replace("bg_light_00", "transparent")
+    text = text.replace("font_color_ff131715", "black_h1")
+    text = text.replace("green_brand_bg", "green_bg")
+    text = text.replace("color_ff131715", "black_h1")
+    text = text.replace("color_green_", "green_brand_")
+    text = text.replace("green_brand_8_e623c268", "green_brand_8")
+
+    # text = text.replace("Color.parseColor(\"#ffffff\")", "ResUtils.getColor(R.color.white)")
+    # text = text.replace("Color.parseColor(\"#ffffffff\")", "ResUtils.getColor(R.color.white)")
+    # text = text.replace("android:textColor=\"#ffffffff\"", "android:textColor=\"@color/white\"")
+    # text = text.replace("android:background=\"#ffffffff\"", "android:background=\"@color/bg_white\"")
+    # text = text.replace("setImageDrawable(ContextCompat.getDrawable(mActivity, ", "setImageResource((")
+
+    text = text.replace("color_333333", "black_h2")
+    text = text.replace("color_999999", "black_h4")
     return text
 
 
@@ -401,13 +440,18 @@ def replace_system_bar(text):
     return text
 
 
-def replace_icon(text):
+def replace_back_icon(text):
     text = text.replace("gamedetail_icon_nav_come_back3", "bar_back")
     text = text.replace("icon_back_black", "bar_back")
+    text = text.replace("nav_come_back", "bar_back")
+    return text
+
+
+def replace_arrow_icon(text):
     text = text.replace("accredit_icon_check", "set_sign_tick")
     text = text.replace("gamedetails_icon_into", "set_icon_arrow")
     text = text.replace("home_icon_arrow_gray2", "set_icon_arrow")
-
+    text = text.replace("cloudgame_icon_arrow_big", "set_icon_arrow")
     text = text.replace("android:drawableRight=\"@drawable/icon_more\"",
                         "app:drawableEndCompat=\"@drawable/set_icon_arrow\"")
     text = text.replace("android:src=\"@drawable/icon_more\"",
@@ -425,4 +469,8 @@ def replace_background(text):
     text = text.replace("app:bl_solid_color=\"#ffffff\"", "app:bl_solid_color=\"@color/bg_white\"")
     text = text.replace("app:bl_solid_color=\"#FFFFFFFF\"", "app:bl_solid_color=\"@color/bg_white\"")
     text = text.replace("app:bl_solid_color=\"#FFFFFF\"", "app:bl_solid_color=\"@color/bg_white\"")
+    text = text.replace("android:drawable=\"@color/white\"", "android:drawable=\"@color/bg_white\"")
+    text = text.replace("android:drawable=\"@android:color/white\"", "android:drawable=\"@color/bg_white\"")
+
+    text = text.replace("@drawable/bg_default_navigate_click", "?actionBarItemBackground")
     return text