-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_buttons.py
More file actions
35 lines (27 loc) · 1.3 KB
/
Copy pathfix_buttons.py
File metadata and controls
35 lines (27 loc) · 1.3 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
#!/usr/bin/env python3
"""
Script to fix button styling in the Android layout
"""
import re
# Read the layout file
with open('app/src/main/res/layout/activity_main.xml', 'r') as f:
content = f.read()
# Define button patterns and their replacements
button_patterns = [
# Min buttons
(r'(<Button\s+android:id="@\+id/btnServo\d+Min"[^>]*android:text="@string/servo_min"[^>]*)(>)',
r'\1\n android:textColor="@color/white"\n android:backgroundTint="@color/purple_500"\2'),
# Max buttons
(r'(<Button\s+android:id="@\+id/btnServo\d+Max"[^>]*android:text="@string/servo_max"[^>]*)(>)',
r'\1\n android:textColor="@color/white"\n android:backgroundTint="@color/teal_700"\2'),
# Set buttons
(r'(<Button\s+android:id="@\+id/btnServo\d+Set"[^>]*android:text="@string/servo_custom"[^>]*)(>)',
r'\1\n android:textColor="@color/white"\n android:backgroundTint="@color/purple_700"\2'),
]
# Apply the patterns
for pattern, replacement in button_patterns:
content = re.sub(pattern, replacement, content)
# Write the updated content back
with open('app/src/main/res/layout/activity_main.xml', 'w') as f:
f.write(content)
print("Button styling updated successfully!")