Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a59d7b6c authored by Joel Galenson's avatar Joel Galenson
Browse files

Fix a crash when fewer than four groups have been used.

Test: Open Permissions Hub, see only three bars in chart.
Change-Id: If0b3a7c8550a2d1b5fb3a41b981be76ed9cb6df6
parent f2e137a4
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -105,9 +105,9 @@ public class PermissionUsageFragment extends PermissionsFrameFragment implements
            + KEY_SPINNER_SORT_INDEX;

    /**
     * The number of columns shown in the bar chart.
     * The maximum number of columns shown in the bar chart.
     */
    private static final int BAR_CHART_COLUMN_COUNT = 4;
    private static final int MAXIMUM_NUM_BARS = 4;

    private @NonNull PermissionUsages mPermissionUsages;

@@ -556,7 +556,8 @@ public class PermissionUsageFragment extends PermissionsFrameFragment implements
            return y.hashCode() - x.hashCode();
        });

        for (int i = 0; i < BAR_CHART_COLUMN_COUNT; i++) {
        int numBarsToShow = Math.min(groups.size(), MAXIMUM_NUM_BARS);
        for (int i = 0; i < numBarsToShow; i++) {
            final AppPermissionGroup group = groups.get(i);
            final Drawable icon = Utils.loadDrawable(context.getPackageManager(),
                    group.getIconPkg(), group.getIconResId());