diff options
author | 2024-04-05 20:53:03 +0000 | |
---|---|---|
committer | 2024-04-05 20:53:03 +0000 | |
commit | 7f48c9b62bdacf360ed8bc73fd634c3df9624b3f (patch) | |
tree | 64dc1e917e768d6be7567a47aeed3a37e64ae635 | |
parent | 8591d28b188fb9d9211f50ca181fa1935824567c (diff) | |
parent | c4af4a3be55a9dd6cf123fefed50bc4e1b938460 (diff) |
Merge "Accessibility applications now describe permission usage percentages to users" into main
3 files changed, 16 insertions, 2 deletions
diff --git a/PermissionController/res/values/strings.xml b/PermissionController/res/values/strings.xml index 18e0396ec..1932d92e2 100644 --- a/PermissionController/res/values/strings.xml +++ b/PermissionController/res/values/strings.xml @@ -1657,6 +1657,8 @@ Allow <xliff:g id="app_name" example="Gmail">%4$s</xliff:g> to upload a bug repo <string name="privdash_label_24h">Past\n24 hours</string> <!-- Label that describes a "past 7 days" time window, prefer two lines. [CHAR LIMIT=20] --> <string name="privdash_label_7d">Past\n7 days</string> + <!-- This information will aid accessibility applications in describing permission usage percentages to users. While the chart visually represents permission usage, accessibility tools will convey the specific percentages for those who need auditory assistance. Examples would be "Microphone 40 percent" or "Location 75 percent" [CHAR LIMIT=none] --> + <string name="privdash_usage_percent"><xliff:g id="permission_name" example="camera">%1$s</xliff:g> <xliff:g id="percent" example="25">%2$d</xliff:g> percent</string> <!-- Info label for status bar indicator permissions (Mic and Camera) for apps holding special exempted roles. [CHAR LIMIT=none] --> <string name="exempt_mic_camera_info_label"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> is protected by Android. Because your data is processed on this device, this app’s permission usage isn’t shown on the status bar or your privacy dashboard. </string> diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/v31/CompositeCircleView.java b/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/v31/CompositeCircleView.java index 64346c4aa..5965cfcf5 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/v31/CompositeCircleView.java +++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/v31/CompositeCircleView.java @@ -19,10 +19,13 @@ package com.android.permissioncontroller.permission.ui.handheld.v31; import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.android.permissioncontroller.R; + /** * Configured to draw a set of contiguous partial circles via {@link PartialCircleView}, which * are generated from the relative weight of values and corresponding colors given to @@ -73,8 +76,10 @@ public class CompositeCircleView extends FrameLayout { * @param values relative weights, used to size the partial circles * @param colors colors corresponding to relative weights * @param strokeWidth stroke width to apply to all contained partial circles + * @param labels the permission labels to set the ContentDescription with % value */ - public void configure(float startAngle, int[] values, int[] colors, int strokeWidth) { + public void configure(float startAngle, int[] values, int[] colors, int strokeWidth, + TextView[] labels) { removeAllViews(); mValues = values; @@ -121,6 +126,13 @@ public class CompositeCircleView extends FrameLayout { float sweepAngle = (values[i] / total) * allocatedDegrees; pcv.setSweepAngle(sweepAngle); + if (labels[i] != null) { + int percentage = Math.round((values[i] / total) * 100); + String contextDescription = getContext().getString( + R.string.privdash_usage_percent, labels[i].getText(), percentage); + labels[i].setContentDescription(contextDescription); + } + mPartialCircleCenterAngles[i] = (startAngle + (sweepAngle * 0.5f)) % 360; if (i > 0) { float angleDiff = diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/v31/PermissionUsageGraphicPreference.java b/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/v31/PermissionUsageGraphicPreference.java index d0a98d9e9..39bb4ed2b 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/v31/PermissionUsageGraphicPreference.java +++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/v31/PermissionUsageGraphicPreference.java @@ -197,7 +197,7 @@ public class PermissionUsageGraphicPreference extends Preference { // Configure circle and labeler. ccvl.configure(R.id.composite_circle_view, centerLabel, labels, labelRadiusScalar); // Start at angle 300 (top right) to allow for small segments for cam, mic, and loc. - ccv.configure(300, counts, colors, circleStrokeWidth); + ccv.configure(300, counts, colors, circleStrokeWidth, labels); } private int getUsageCount(String group) { |