Skip to content

Commit aae2022

Browse files
Merge pull request #19 from appdevforall/feat/theming-share
feat(controller): migrate Share/Sync screen to semantic colour tokens (theming)
2 parents 4474cd2 + 003aec7 commit aae2022

7 files changed

Lines changed: 83 additions & 55 deletions

File tree

‎controller/app/src/main/java/org/iiab/controller/SyncFragment.java‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.util.List;
4949

5050
import android.widget.RadioButton;
51+
import androidx.core.content.ContextCompat;
5152

5253
public class SyncFragment extends Fragment {
5354

@@ -318,14 +319,14 @@ private void startShareDaemon(File rootfsDir) {
318319
qrDisplaySection.setVisibility(View.VISIBLE);
319320
qrCardContainer.setVisibility(View.VISIBLE);
320321
imgQrCode.setAlpha(1f);
321-
cardShareSystem.setBackgroundTintList(android.content.res.ColorStateList.valueOf(android.graphics.Color.parseColor("#173317")));
322+
cardShareSystem.setBackgroundTintList(android.content.res.ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.surface_active_success)));
322323

323324
rgNetworkSelector.setVisibility((wifiIp != null && hotspotIp != null) ? View.VISIBLE : View.GONE);
324325
showingWifi = (wifiIp != null);
325326
updateQrDisplayRsync();
326327

327328
btnStartServer.setText(getString(R.string.sync_btn_stop_server));
328-
btnStartServer.setBackgroundTintList(android.content.res.ColorStateList.valueOf(android.graphics.Color.parseColor("#F44336"))); // Red
329+
btnStartServer.setBackgroundTintList(android.content.res.ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.status_danger))); // Red
329330
btnShareApp.setVisibility(View.GONE);
330331
} else {
331332
Toast.makeText(getContext(), getString(R.string.sync_error_daemon_failed), Toast.LENGTH_SHORT).show();
@@ -341,7 +342,7 @@ private void updateQrDisplayRsync() {
341342

342343
String baseText = showingWifi ? getString(R.string.sync_share_status_wifi) : getString(R.string.sync_share_status_hotspot);
343344
txtShareStatus.setText(baseText);
344-
txtShareStatus.setTextColor(android.graphics.Color.parseColor("#AAAAAA"));
345+
txtShareStatus.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_secondary));
345346
}
346347

347348
private void stopShareDaemon() {
@@ -352,13 +353,13 @@ private void stopShareDaemon() {
352353

353354
qrDisplaySection.setVisibility(View.GONE);
354355
btnStartServer.setText(getString(R.string.sync_btn_start_server));
355-
cardShareSystem.setBackgroundTintList(android.content.res.ColorStateList.valueOf(android.graphics.Color.parseColor("#222222")));
356+
cardShareSystem.setBackgroundTintList(android.content.res.ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.surface_card)));
356357

357358
btnStartServer.setText(getString(R.string.sync_btn_start_server));
358-
btnStartServer.setBackgroundTintList(android.content.res.ColorStateList.valueOf(android.graphics.Color.parseColor("#008000"))); // Green
359+
btnStartServer.setBackgroundTintList(android.content.res.ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.status_success))); // Green
359360
btnShareApp.setVisibility(View.VISIBLE);
360361
txtShareStatus.setText(getString(R.string.sync_share_status_off));
361-
txtShareStatus.setTextColor(android.graphics.Color.parseColor("#FF9800")); // Orange
362+
txtShareStatus.setTextColor(ContextCompat.getColor(requireContext(), R.color.status_warning)); // Orange
362363
}
363364

364365
// --- APK SERVER METHODS ---
@@ -375,14 +376,14 @@ private void startApkServer() {
375376
qrCardContainer.setVisibility(View.VISIBLE);
376377
updateCardOrder(true);
377378
imgQrCode.setAlpha(1f);
378-
cardShareApk.setBackgroundTintList(android.content.res.ColorStateList.valueOf(android.graphics.Color.parseColor("#17263A")));
379+
cardShareApk.setBackgroundTintList(android.content.res.ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.surface_active_info)));
379380

380381
rgNetworkSelector.setVisibility((wifiIp != null && hotspotIp != null) ? View.VISIBLE : View.GONE);
381382
showingWifi = (wifiIp != null);
382383
updateQrDisplayApk();
383384

384385
btnShareApp.setText(getString(R.string.sync_btn_stop_app));
385-
btnShareApp.setBackgroundTintList(android.content.res.ColorStateList.valueOf(android.graphics.Color.parseColor("#F44336"))); // Red
386+
btnShareApp.setBackgroundTintList(android.content.res.ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.status_danger))); // Red
386387
btnStartServer.setVisibility(View.GONE);
387388

388389
} catch (Exception e) {
@@ -400,7 +401,7 @@ private void updateQrDisplayApk() {
400401

401402
String baseText = showingWifi ? getString(R.string.sync_app_status_wifi) : getString(R.string.sync_app_status_hotspot);
402403
txtShareStatus.setText(baseText);
403-
txtShareStatus.setTextColor(android.graphics.Color.parseColor("#AAAAAA"));
404+
txtShareStatus.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_secondary));
404405
}
405406

406407
private void stopApkServer() {
@@ -413,13 +414,13 @@ private void stopApkServer() {
413414

414415
qrDisplaySection.setVisibility(View.GONE);
415416
btnShareApp.setText(getString(R.string.sync_btn_share_app));
416-
cardShareApk.setBackgroundTintList(android.content.res.ColorStateList.valueOf(android.graphics.Color.parseColor("#222222")));
417+
cardShareApk.setBackgroundTintList(android.content.res.ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.surface_card)));
417418

418419
btnShareApp.setText(getString(R.string.sync_btn_share_app));
419-
btnShareApp.setBackgroundTintList(android.content.res.ColorStateList.valueOf(android.graphics.Color.parseColor("#0055A4"))); // Blue
420+
btnShareApp.setBackgroundTintList(android.content.res.ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.status_info))); // Blue
420421
btnStartServer.setVisibility(View.VISIBLE);
421422
txtShareStatus.setText(getString(R.string.sync_share_status_off));
422-
txtShareStatus.setTextColor(android.graphics.Color.parseColor("#FF9800")); // Orange
423+
txtShareStatus.setTextColor(ContextCompat.getColor(requireContext(), R.color.status_warning)); // Orange
423424
}
424425

425426
// --- CLIENT (RECEIVER) METHODS ---
@@ -776,16 +777,16 @@ private void showArchCompatibilitySuccess(Runnable onComplete) {
776777
}
777778

778779
if (txtGuestArchLabel != null) {
779-
txtGuestArchLabel.setBackgroundTintList(android.content.res.ColorStateList.valueOf(android.graphics.Color.parseColor("#00E676")));
780-
txtGuestArchLabel.setTextColor(android.graphics.Color.BLACK);
780+
txtGuestArchLabel.setBackgroundTintList(android.content.res.ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.status_success)));
781+
txtGuestArchLabel.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_on_warning));
781782
}
782783

783784
Snackbar.make(requireView(), getString(R.string.sync_msg_arch_compatible), Snackbar.LENGTH_SHORT).show();
784785

785786
new Handler(Looper.getMainLooper()).postDelayed(() -> {
786787
if (txtGuestArchLabel != null) {
787-
txtGuestArchLabel.setBackgroundTintList(android.content.res.ColorStateList.valueOf(android.graphics.Color.parseColor("#1A1A1A")));
788-
txtGuestArchLabel.setTextColor(android.graphics.Color.parseColor("#4CAF50"));
788+
txtGuestArchLabel.setBackgroundTintList(android.content.res.ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.surface_section)));
789+
txtGuestArchLabel.setTextColor(ContextCompat.getColor(requireContext(), R.color.status_success));
789790
}
790791
onComplete.run();
791792
}, 1500);

‎controller/app/src/main/res/drawable/radio_selector_bg.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<item android:state_checked="true">
44
<shape android:shape="rectangle">
55
<corners android:radius="8dp" />
6-
<solid android:color="#444444" /> </shape>
6+
<solid android:color="@color/toggle_selected" /> </shape>
77
</item>
88
<item>
99
<shape android:shape="rectangle">

‎controller/app/src/main/res/layout/activity_qr.xml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
55
android:orientation="vertical"
6-
android:background="#DD000000"
6+
android:background="@color/overlay_scrim"
77
android:padding="24dp">
88

99
<LinearLayout
@@ -18,7 +18,7 @@
1818
android:layout_height="wrap_content"
1919
android:orientation="vertical"
2020
android:background="@drawable/rounded_button"
21-
android:backgroundTint="#1A1A1A"
21+
android:backgroundTint="@color/surface_card"
2222
android:elevation="8dp"
2323
android:padding="16dp">
2424

@@ -35,7 +35,7 @@
3535
android:layout_centerVertical="true"
3636
android:layout_toStartOf="@+id/btn_flip_qr"
3737
android:text="@string/qr_title_wifi"
38-
android:textColor="#FFFFFF"
38+
android:textColor="@color/text_primary"
3939
android:textSize="22sp"
4040
android:textStyle="bold" />
4141

@@ -48,7 +48,7 @@
4848
android:background="?android:attr/selectableItemBackgroundBorderless"
4949
android:src="@android:drawable/ic_popup_sync"
5050
android:contentDescription="@string/qr_flip_network"
51-
android:tint="#FFFFFF"
51+
android:tint="@color/text_primary"
5252
android:scaleType="fitCenter"
5353
android:padding="8dp"
5454
android:visibility="gone" />
@@ -59,7 +59,7 @@
5959
android:layout_width="match_parent"
6060
android:layout_height="wrap_content"
6161
android:text="http://---"
62-
android:textColor="#AAAAAA"
62+
android:textColor="@color/text_secondary"
6363
android:textSize="16sp"
6464
android:layout_marginBottom="16dp" />
6565

@@ -69,7 +69,7 @@
6969
android:layout_height="wrap_content"
7070
android:adjustViewBounds="true"
7171
android:scaleType="fitCenter"
72-
android:background="#FFFFFF"
72+
android:background="@color/qr_background"
7373
android:padding="16dp" />
7474

7575
</LinearLayout>
@@ -82,6 +82,6 @@
8282
android:layout_marginTop="24dp"
8383
android:text="@string/qr_btn_close"
8484
android:backgroundTint="@color/btn_danger"
85-
android:textColor="#FFFFFF" />
85+
android:textColor="@color/text_on_accent" />
8686

8787
</LinearLayout>

‎controller/app/src/main/res/layout/fragment_sync.xml‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
77
android:fillViewport="true"
8-
android:background="?android:attr/windowBackground">
8+
android:background="@color/surface_background">
99

1010
<LinearLayout
1111
android:layout_width="match_parent"
@@ -19,7 +19,7 @@
1919
android:layout_height="48dp"
2020
android:orientation="horizontal"
2121
android:background="@drawable/rounded_button"
22-
android:backgroundTint="#333333"
22+
android:backgroundTint="@color/surface_section"
2323
android:layout_marginBottom="24dp">
2424

2525
<RadioButton
@@ -70,7 +70,7 @@
7070
android:layout_width="220dp"
7171
android:layout_height="220dp"
7272
android:layout_marginBottom="16dp"
73-
android:background="#FFFFFF"
73+
android:background="@color/qr_background"
7474
android:padding="8dp">
7575

7676
<ImageView
@@ -86,7 +86,7 @@
8686
android:layout_height="40dp"
8787
android:orientation="horizontal"
8888
android:background="@drawable/rounded_button"
89-
android:backgroundTint="#333333"
89+
android:backgroundTint="@color/surface_section"
9090
android:layout_marginBottom="16dp"
9191
android:visibility="gone"
9292
tools:visibility="visible">
@@ -122,7 +122,7 @@
122122
android:layout_width="match_parent"
123123
android:layout_height="wrap_content"
124124
android:text="@string/sync_share_status_init"
125-
android:textColor="#FF9800"
125+
android:textColor="@color/status_warning"
126126
android:textSize="14sp"
127127
android:textAlignment="center"
128128
android:layout_marginBottom="16dp" />
@@ -133,12 +133,12 @@
133133
android:layout_height="wrap_content"
134134
android:layout_marginBottom="24dp"
135135
android:background="@drawable/rounded_button"
136-
android:backgroundTint="#1A1A1A"
136+
android:backgroundTint="@color/surface_section"
137137
android:paddingStart="16dp"
138138
android:paddingTop="6dp"
139139
android:paddingEnd="16dp"
140140
android:paddingBottom="6dp"
141-
android:textColor="#4CAF50"
141+
android:textColor="@color/status_success"
142142
android:textSize="14sp"
143143
android:textStyle="bold"
144144
android:fontFamily="monospace"
@@ -152,15 +152,15 @@
152152
android:layout_height="wrap_content"
153153
android:orientation="vertical"
154154
android:background="@drawable/rounded_button"
155-
android:backgroundTint="#222222"
155+
android:backgroundTint="@color/dash_module_bg"
156156
android:padding="16dp"
157157
android:layout_marginBottom="16dp">
158158

159159
<TextView
160160
android:layout_width="match_parent"
161161
android:layout_height="wrap_content"
162162
android:text="@string/sync_card_title_system"
163-
android:textColor="#FFFFFF"
163+
android:textColor="@color/text_primary"
164164
android:textSize="18sp"
165165
android:textStyle="bold"
166166
android:layout_marginBottom="8dp" />
@@ -169,7 +169,7 @@
169169
android:layout_width="match_parent"
170170
android:layout_height="wrap_content"
171171
android:text="@string/sync_card_desc_system"
172-
android:textColor="#AAAAAA"
172+
android:textColor="@color/text_secondary"
173173
android:textSize="14sp"
174174
android:layout_marginBottom="16dp" />
175175

@@ -180,9 +180,9 @@
180180
android:text="@string/sync_btn_start_server"
181181
android:textSize="16sp"
182182
android:textStyle="bold"
183-
android:textColor="#FFFFFF"
183+
android:textColor="@color/text_on_accent"
184184
android:background="@drawable/rounded_button"
185-
android:backgroundTint="#008000"
185+
android:backgroundTint="@color/status_success"
186186
android:textAllCaps="false" />
187187
</LinearLayout>
188188

@@ -192,15 +192,15 @@
192192
android:layout_height="wrap_content"
193193
android:orientation="vertical"
194194
android:background="@drawable/rounded_button"
195-
android:backgroundTint="#222222"
195+
android:backgroundTint="@color/dash_module_bg"
196196
android:padding="16dp"
197197
android:layout_marginBottom="16dp">
198198

199199
<TextView
200200
android:layout_width="match_parent"
201201
android:layout_height="wrap_content"
202202
android:text="@string/sync_card_title_apk"
203-
android:textColor="#FFFFFF"
203+
android:textColor="@color/text_primary"
204204
android:textSize="18sp"
205205
android:textStyle="bold"
206206
android:layout_marginBottom="8dp" />
@@ -209,7 +209,7 @@
209209
android:layout_width="match_parent"
210210
android:layout_height="wrap_content"
211211
android:text="@string/sync_card_desc_apk"
212-
android:textColor="#AAAAAA"
212+
android:textColor="@color/text_secondary"
213213
android:textSize="14sp"
214214
android:layout_marginBottom="16dp" />
215215

@@ -220,9 +220,9 @@
220220
android:text="@string/sync_btn_share_app"
221221
android:textSize="16sp"
222222
android:textStyle="bold"
223-
android:textColor="#FFFFFF"
223+
android:textColor="@color/text_on_accent"
224224
android:background="@drawable/rounded_button"
225-
android:backgroundTint="#0055A4"
225+
android:backgroundTint="@color/status_info"
226226
android:textAllCaps="false" />
227227
</LinearLayout>
228228
</LinearLayout>
@@ -241,15 +241,15 @@
241241
android:layout_height="wrap_content"
242242
android:orientation="vertical"
243243
android:background="@drawable/rounded_button"
244-
android:backgroundTint="#222222"
244+
android:backgroundTint="@color/dash_module_bg"
245245
android:padding="16dp"
246246
android:layout_marginBottom="16dp">
247247

248248
<TextView
249249
android:layout_width="match_parent"
250250
android:layout_height="wrap_content"
251251
android:text="@string/sync_card_title_receive"
252-
android:textColor="#FFFFFF"
252+
android:textColor="@color/text_primary"
253253
android:textSize="18sp"
254254
android:textStyle="bold"
255255
android:layout_marginBottom="8dp" />
@@ -258,7 +258,7 @@
258258
android:layout_width="match_parent"
259259
android:layout_height="wrap_content"
260260
android:text="@string/sync_card_desc_receive"
261-
android:textColor="#AAAAAA"
261+
android:textColor="@color/text_secondary"
262262
android:textSize="14sp"
263263
android:layout_marginBottom="16dp" />
264264

@@ -269,9 +269,9 @@
269269
android:text="@string/sync_btn_scan_qr"
270270
android:textSize="16sp"
271271
android:textStyle="bold"
272-
android:textColor="#FFFFFF"
272+
android:textColor="@color/text_on_accent"
273273
android:background="@drawable/rounded_button"
274-
android:backgroundTint="#2196F3"
274+
android:backgroundTint="@color/status_info"
275275
android:textAllCaps="false"
276276
app:icon="@android:drawable/ic_menu_camera"
277277
app:iconGravity="textStart" />
@@ -336,8 +336,8 @@
336336
android:layout_marginTop="16dp"
337337
android:text="@string/sync_btn_cancel_transfer"
338338
android:background="@drawable/rounded_button"
339-
android:backgroundTint="#F44336"
340-
android:textColor="#FFFFFF"
339+
android:backgroundTint="@color/status_danger"
340+
android:textColor="@color/text_on_accent"
341341
android:textStyle="bold"
342342
android:textAllCaps="false" />
343343
</LinearLayout>
@@ -351,12 +351,12 @@
351351
android:layout_marginTop="16dp"
352352
android:layout_marginBottom="32dp"
353353
android:background="@drawable/rounded_button"
354-
android:backgroundTint="#1A1A1A"
354+
android:backgroundTint="@color/surface_section"
355355
android:paddingStart="16dp"
356356
android:paddingTop="6dp"
357357
android:paddingEnd="16dp"
358358
android:paddingBottom="6dp"
359-
android:textColor="#4CAF50"
359+
android:textColor="@color/status_success"
360360
android:textSize="14sp"
361361
android:textStyle="bold"
362362
android:fontFamily="monospace"

0 commit comments

Comments
 (0)