Repository navigation
Expand file tree
/
Copy pathclean_strings.py
More file actions
56 lines (52 loc) · 2 KB
/
Copy pathclean_strings.py
File metadata and controls
56 lines (52 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import re
keys_to_remove = [
"title_seekbar_long_press_flat_region",
"summary_seekbar_long_press_flat_region",
"suffix_seekbar_flat_region_pixels",
"title_seekbar_keyboard_toggle_fingers_native_touch",
"summary_seekbar_keyboard_toggle_fingers_native_touch",
"suffix_seekbar_keyboard_toggle_fingers_native_touch",
"category_enhanced_touch_settings",
"title_checkbox_enable_enhanced_touch",
"summary_checkbox_enable_enhanced_touch",
"title_checkbox_enable_keyboard_toggle_in_native_touch",
"summary_checkbox_enable_keyboard_toggle_in_native_touch",
"title_checkbox_sync_touch_event_with_display",
"summary_checkbox_sync_touch_event_with_display",
"title_checkbox_enhanced_touch_on_which_side",
"summary_checkbox_enhanced_touch_on_which_side",
"title_enhanced_touch_zone_divider",
"summary_enhanced_touch_zone_divider",
"dialog_title_enhanced_touch_zone_divider",
"suffix_enhanced_touch_zone_divider",
"title_pointer_velocity_factor",
"summary_pointer_velocity_factor",
"dialog_title_pointer_velocity_factor",
"suffix_pointer_velocity_factor",
"title_fixed_x_velocity",
"summary_fixed_x_velocity",
"dialog_title_fixed_x_velocity",
"suffix_fixed_x_velocity"
]
res_dir = 'app/src/main/res'
for root, dirs, files in os.walk(res_dir):
if 'strings.xml' in files:
file_path = os.path.join(root, 'strings.xml')
with open(file_path, 'r', encoding='utf-8') as f:
lines = f.readlines()
new_lines = []
skip = False
for line in lines:
if any(f'name="{key}"' in line for key in keys_to_remove):
if not '</string>' in line:
skip = True
continue
if skip:
if '</string>' in line:
skip = False
continue
new_lines.append(line)
with open(file_path, 'w', encoding='utf-8') as f:
f.writelines(new_lines)
print("Cleaned!")