You've already forked android-client
mirror of
https://github.com/netbirdio/android-client.git
synced 2026-05-22 17:10:49 -07:00
Announce theme picker selection to screen readers
Theme picker rows now expose: - contentDescription with the theme label - stateDescription "Selected" on the active row (Android R+) - isSelected=true on the active row for accessibility services After picking, announce "<theme> theme selected" on the sheet root so TalkBack confirms the change before the sheet dismisses.
This commit is contained in:
@@ -46,12 +46,31 @@ public class ThemePickerSheet extends BottomSheetDialogFragment {
|
||||
binding.themeCheckSystem.setVisibility(mode == AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM ? View.VISIBLE : View.INVISIBLE);
|
||||
binding.themeCheckLight.setVisibility(mode == AppCompatDelegate.MODE_NIGHT_NO ? View.VISIBLE : View.INVISIBLE);
|
||||
binding.themeCheckDark.setVisibility(mode == AppCompatDelegate.MODE_NIGHT_YES ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
applyRowAccessibility(binding.themeRowSystem, mode == AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM,
|
||||
getString(io.netbird.client.R.string.advanced_theme_system));
|
||||
applyRowAccessibility(binding.themeRowLight, mode == AppCompatDelegate.MODE_NIGHT_NO,
|
||||
getString(io.netbird.client.R.string.advanced_theme_light));
|
||||
applyRowAccessibility(binding.themeRowDark, mode == AppCompatDelegate.MODE_NIGHT_YES,
|
||||
getString(io.netbird.client.R.string.advanced_theme_dark));
|
||||
}
|
||||
|
||||
private void applyRowAccessibility(View row, boolean selected, String label) {
|
||||
row.setContentDescription(label);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
|
||||
row.setStateDescription(selected ? getString(io.netbird.client.R.string.theme_picker_selected) : null);
|
||||
}
|
||||
row.setSelected(selected);
|
||||
}
|
||||
|
||||
private void pick(int mode) {
|
||||
SharedPreferences prefs = requireContext().getSharedPreferences("settings", 0);
|
||||
prefs.edit().putInt("theme_mode", mode).apply();
|
||||
AppCompatDelegate.setDefaultNightMode(mode);
|
||||
if (binding != null) {
|
||||
binding.getRoot().announceForAccessibility(
|
||||
getString(io.netbird.client.R.string.theme_picker_announce, labelFor(requireContext(), mode)));
|
||||
}
|
||||
if (getParentFragment() instanceof OnThemeChangedListener) {
|
||||
((OnThemeChangedListener) getParentFragment()).onThemeChanged(mode);
|
||||
}
|
||||
|
||||
@@ -114,6 +114,9 @@
|
||||
|
||||
<string name="dialog_always_on_desc"><![CDATA[You have a VPN app that has Always On turned on. To enable the NetBird app, you first need to go to your <b>Network & Internet settings</b> → <b>Advanced</b> → Check the <b>gear icon</b> for all the apps listed here on this page. Disable Always On for the apps that are not NetBird.]]></string>
|
||||
|
||||
<string name="theme_picker_selected">Selected</string>
|
||||
<string name="theme_picker_announce">%1$s theme selected</string>
|
||||
|
||||
<string name="advanced_theme_system">System</string>
|
||||
<string name="advanced_theme_title">Theme Mode</string>
|
||||
<string name="advanced_theme_dark">Dark</string>
|
||||
|
||||
Reference in New Issue
Block a user