소스 검색

Merge remote-tracking branch 'origin/master'

Alex 1 년 전
부모
커밋
d4472aee5b
5개의 변경된 파일200개의 추가작업 그리고 87개의 파일을 삭제
  1. 3 51
      custom_day_night.py
  2. 6 33
      file_processer.py
  3. 90 0
      lany192.py
  4. 50 0
      utils/action_utils.py
  5. 51 3
      utils/other_utils.py

+ 3 - 51
custom_day_night.py

@@ -1,54 +1,6 @@
-import os
-import re
-
-from file_processer import replace_file_by_path
-from utils.module_utils import get_modules_from_settings_file
-from utils.other_utils import unify_path_separator, get_excluded_dirs
-
-parse_included_files = set()
-
-
-def replace_action(project_dir: str, included_files: set, included_pattern: set, included_keywords: set):
-    print("任务开始执行-------------------------------------------\n")
-    modules = get_modules_from_settings_file(project_dir)
-    result_paths = set()
-
-    for module in modules:
-        print("-------------------------------------------\n")
-        module_dir = project_dir + os.path.sep + module.replace(":", os.path.sep)
-        print(f"检测{module}模块:{module_dir}")
-        for root, dirs, files in os.walk(module_dir):
-            excluded_dirs = get_excluded_dirs()
-            dirs[:] = [d for d in dirs if d not in excluded_dirs]
-            for file in files:
-                path = os.path.join(root, file)
-                file_path = unify_path_separator(path)
-                # 是否指定文件名称
-                file_name = os.path.basename(file_path)
-                if file_name in included_files:
-                    result_paths.add(file_path)
-                # 是否指定正则表达式
-                for keyword in included_pattern:
-                    pattern = re.compile(keyword)
-                    if pattern.search(file_path):
-                        result_paths.add(file_path)
-                # 指定关键字
-                for keyword in included_keywords:
-                    tmp = unify_path_separator(keyword)
-                    if tmp in file_path:
-                        result_paths.add(file_path)
-    for path in result_paths:
-        # 处理文件
-        print(f"处理文件{path}")
-        replace_file_by_path(path, lambda layout_name: {
-            parse_included_files.add(layout_name)
-        })
-    if parse_included_files.__len__() != 0:
-        print(f"处理遍历进来的布局文件{parse_included_files}")
-        temp = parse_included_files.copy()
-        parse_included_files.clear()
-        replace_action(project_dir, temp, set(), set())
-
+#!/usr/bin/python
+# -*- coding: UTF-8 -*-
+from utils.action_utils import replace_action
 
 if __name__ == '__main__':
     project_dir = 'D:\\workspace/android/hykb'

+ 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)
 

+ 90 - 0
lany192.py

@@ -0,0 +1,90 @@
+#!/usr/bin/python
+# -*- coding: UTF-8 -*-
+from utils.action_utils import replace_action
+
+if __name__ == '__main__':
+    project_dir = 'D:\\workspace/android/hykb'
+
+    included_files = set()
+    included_pattern = set()
+    included_keywords = set()
+
+    # 首页
+    # included_files.add("GameRecommendFragment.java")
+    # included_files.add("fragment_game_recommend.xml")
+    # included_files.add("item_jingxuan_gaosu.xml")
+    # included_keywords.add('/com/xmcy/hykb/app/ui/gamerecommend/')
+    # 首页精选
+    # included_files.add("HomeIndexFragment.java")
+    # included_pattern.add(r"item_homeindex_.*\.xml")
+    # included_pattern.add(r"item_home_.*\.xml")
+    # included_keywords.add('/com/xmcy/hykb/app/ui/homeindex/')
+
+    # 首页精选负二楼
+    # included_pattern.add(r"item_two_.*\.xml")
+    # included_keywords.add('/com/xmcy/hykb/app/ui/gamerecommend/twoleveladapter/')
+
+    # 分类-分类tab
+    # included_files.add("XinQiFragment.java")
+    # included_pattern.add(r"item_xinqi_.*\.xml")
+
+    included_files.add("SettingActivity.java")
+    included_files.add("TestActivity.java")
+    included_files.add("DownloadInstallActivity.java")
+    included_files.add("AccountSafeActivity.java")
+
+    included_files.add("activity_account_safe.xml")
+    included_files.add("account_safe_root_view.xml")
+    included_files.add("activity_close_account.xml")
+    included_files.add("activity_close_account_result.xml")
+    included_files.add("activity_game_time_bind.xml")
+    included_files.add("game_time_bind_root_view.xml")
+    included_files.add("activity_phone_and_third_bind.xml")
+    included_files.add("activity_download_install.xml")
+    included_files.add("activity_net_permission_check.xml")
+    included_files.add("activity_teen_mode_setting.xml")
+    included_files.add("activity_modify_area.xml")
+    included_files.add("item_modify_area.xml")
+    included_files.add("activity_bind_phone.xml")
+    included_files.add("activity_clip_image.xml")
+    included_files.add("activity_clip_image.xml")
+    included_files.add("dialog_modify_nick_name.xml")
+    included_files.add("dialog_modify_signature.xml")
+    included_files.add("activity_clip_square_image.xml")
+    included_files.add("activity_clip_rectangle_image.xml")
+    included_files.add("activity_clip_image.xml")
+    included_files.add("activity_h5_webview.xml")
+    included_files.add("activity_privacy_manager.xml")
+    included_files.add("activity_person_info.xml")
+    included_files.add("include_person_info_base.xml")
+    included_files.add("include_person_info_form.xml")
+    included_files.add("PersonInfoView.java")
+    included_files.add("PersonInfoItemView.java")
+    included_files.add("view_person_info.xml")
+    included_files.add("include_navigate_back_and_title_white.xml")
+
+    included_files.add("common_toolbar_2.xml")
+    included_files.add("layout_teen_mode_setting.xml")
+    included_files.add("layout_teen_mode_password.xml")
+    included_files.add("layout_teen_mode_forget_pws.xml")
+    included_files.add("btn_disable_22dp.xml")
+    included_files.add("btn_enable_22dp.xml")
+
+    included_files.add("bg_default_item_click_eb23c268.xml")
+
+    included_files.add("SelectImageBottomDialog.java")
+    included_files.add("dialog_select_image.xml")
+
+    included_files.add("SplashActivity.java")
+    included_files.add("SplashButton.java")
+    included_files.add("GuideActivity.java")
+
+    included_keywords.add('/com/xmcy/hykb/app/ui/setting/')
+    included_keywords.add('/com/xmcy/hykb/app/ui/userinfo/')
+    included_keywords.add('/com/xmcy/hykb/app/ui/accountsafe/')
+    included_keywords.add('/com/xmcy/hykb/app/ui/teen_mode/')
+    included_keywords.add('/com/xmcy/hykb/app/ui/netpermissioncheck/')
+
+    # 开始处理
+    replace_action(project_dir, included_files, included_pattern, included_keywords)
+    print("任务结束-------------------------------------------\n")

+ 50 - 0
utils/action_utils.py

@@ -0,0 +1,50 @@
+import os
+import re
+
+from file_processer import replace_file_by_path
+from utils.module_utils import get_modules_from_settings_file
+from utils.other_utils import unify_path_separator, get_excluded_dirs
+
+parse_included_files = set()
+
+
+def replace_action(project_dir: str, included_files: set, included_pattern: set, included_keywords: set):
+    print("任务开始执行-------------------------------------------\n")
+    modules = get_modules_from_settings_file(project_dir)
+    result_paths = set()
+
+    for module in modules:
+        print("-------------------------------------------\n")
+        module_dir = project_dir + os.path.sep + module.replace(":", os.path.sep)
+        print(f"检测{module}模块:{module_dir}")
+        for root, dirs, files in os.walk(module_dir):
+            excluded_dirs = get_excluded_dirs()
+            dirs[:] = [d for d in dirs if d not in excluded_dirs]
+            for file in files:
+                path = os.path.join(root, file)
+                file_path = unify_path_separator(path)
+                # 是否指定文件名称
+                file_name = os.path.basename(file_path)
+                if file_name in included_files:
+                    result_paths.add(file_path)
+                # 是否指定正则表达式
+                for keyword in included_pattern:
+                    pattern = re.compile(keyword)
+                    if pattern.search(file_path):
+                        result_paths.add(file_path)
+                # 指定关键字
+                for keyword in included_keywords:
+                    tmp = unify_path_separator(keyword)
+                    if tmp in file_path:
+                        result_paths.add(file_path)
+    for path in result_paths:
+        # 处理文件
+        print(f"处理文件{path}")
+        replace_file_by_path(path, lambda layout_name: {
+            parse_included_files.add(layout_name)
+        })
+    if parse_included_files.__len__() != 0:
+        print(f"处理遍历进来的布局文件{parse_included_files}")
+        temp = parse_included_files.copy()
+        parse_included_files.clear()
+        replace_action(project_dir, temp, set(), set())

+ 51 - 3
utils/other_utils.py

@@ -9,7 +9,7 @@ from 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