Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion app/src/main/java/eu/faircode/netguard/AdapterRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ public void onBindViewHolder(final ViewHolder holder, int position) {
// Show if Internet access blocked
final ImageView iv = holder.ivIcon;
InternetBlocklist internetBlocklist = InternetBlocklist.getInstance(context);
setGreyscale(iv, rule.internet && active && internetBlocklist.blockedInternet(rule.uid));
boolean blockedInternet = internetBlocklist.blockedInternet(rule.uid);
setGreyscale(iv, rule.internet && active && blockedInternet);
updateToggleContentDescription(iv, context, rule, active, blockedInternet);
holder.ivIcon.setOnClickListener(view -> {
if (!rule.internet)
return;
Expand All @@ -282,6 +284,7 @@ public void onBindViewHolder(final ViewHolder holder, int position) {
Toast.makeText(context, R.string.internet_blocked, Toast.LENGTH_SHORT).show();
}
setGreyscale(iv, !wasBlocked);
updateToggleContentDescription(iv, context, rule, true, !wasBlocked);
});

boolean pastWeekOnly = !("trackers_all".equals(cachedSort));
Expand Down Expand Up @@ -322,6 +325,26 @@ public void onBindViewHolder(final ViewHolder holder, int position) {
// click listeners on hidden views) was the primary cause of scroll jank.
}

/**
* Sets a screen-reader-friendly content description on the app icon /
* Internet toggle button, reflecting the app's name and current
* block/allow state (accessibility fix for #231).
*/
private void updateToggleContentDescription(ImageView iv, Context context, Rule rule,
boolean active, boolean blocked) {
final String description;
if (!rule.internet)
description = context.getString(R.string.toggle_no_internet_description, rule.name);
else if (!active)
description = context.getString(R.string.toggle_internet_unavailable_description,
rule.name);
else if (blocked)
description = context.getString(R.string.toggle_allow_internet_description, rule.name);
else
description = context.getString(R.string.toggle_block_internet_description, rule.name);
iv.setContentDescription(description);
}

private void setGreyscale(ImageView iv, boolean on) {
if (on) {
iv.setColorFilter(GREYSCALE_FILTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder _holder, int posit
holder.mUncertain.setVisibility(trackerCategory.isUncertain() ? View.VISIBLE : View.GONE);

// Add data to view
holder.mTrackerCategoryName.setText(trackerCategory.getDisplayName(mContext));
String categoryDisplayName = trackerCategory.getDisplayName(mContext);
holder.mTrackerCategoryName.setText(categoryDisplayName);
holder.mSwitchTracker.setContentDescription(
String.format(mContext.getString(R.string.toggle_block_category_description),
categoryDisplayName));
final ArrayAdapter<Tracker> trackersAdapter = new ArrayAdapter<Tracker>(mContext,
R.layout.list_item_trackers_details, trackerCategory.getChildren()) {
@Override
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/layout/list_item_trackers_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
android:layout_height="wrap_content"
android:minHeight="0dp"
android:textColor="?android:textColorPrimary"
android:contentDescription="@string/vpn_exclude"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/vpn_exclude_name" />

Expand Down Expand Up @@ -281,6 +282,7 @@
android:layout_height="wrap_content"
android:minHeight="0dp"
android:textColor="?android:textColorPrimary"
android:contentDescription="@string/exclude_vpn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/root_name" />

Expand Down Expand Up @@ -327,6 +329,7 @@
android:layout_height="wrap_content"
android:minHeight="0dp"
android:textColor="?android:textColorPrimary"
android:contentDescription="@string/internet_access"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/root_name2" />

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,13 @@ Your internet traffic is not being sent to a remote VPN server.</string>
<!-- App Overview -->
<string name="tracked_app_icon">Disable internet access for this application</string>
<string name="tracked_app_name">Application Name</string>
<!-- Dynamic content descriptions for the app-icon Internet toggle in the app list (issue #231) -->
<string name="toggle_block_internet_description">Block internet access for %1$s</string>
<string name="toggle_allow_internet_description">Allow internet access for %1$s</string>
<string name="toggle_no_internet_description">%1$s has no internet access</string>
<string name="toggle_internet_unavailable_description">Internet access control unavailable for %1$s</string>
<!-- Dynamic content description for the per-category tracker-blocking switch -->
<string name="toggle_block_category_description">Tracker blocking for category %1$s</string>
<plurals name="n_companies_found_week">
<item quantity="one">contacted %d company last week</item>
<item quantity="other">contacted %d companies last week</item>
Expand Down