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

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

Add link to an app's permission usages from its list of permissions.

Add a link at the bottom of the list of allowed permissions in
AppPermissionsFragment that points to AppPermissionUsageFragment.

Also modified AppPermissionUsageFragment so that when there are no
usages it says "No permission usages" instead of "No permissions".

Test: Click new link.
Test: View usage screen screen with and without usages.
Change-Id: I7b0e66ed92de1651b82c8bbf67eb6e45a1591378
parent 1ce1a950
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -378,6 +378,9 @@
    <!-- Header for denied permissions/apps [CHAR LIMIT=40] -->
    <string name="denied_header">Denied</string>

    <!-- Permission entry to show detailed permission usage information by an app [CHAR LIMIT=40] -->
    <string name="detailed_usage_link">See detailed usage</string>

    <!-- Time in days -->
    <plurals name="days">
        <item quantity="one">1 day</item>
+5 −0
Original line number Diff line number Diff line
@@ -127,6 +127,11 @@ public class AppPermissionUsageFragment extends SettingsWithButtonHeader {
        return super.onOptionsItemSelected(item);
    }

    @Override
    public int getEmptyViewString() {
        return R.string.no_permission_usages;
    }

    private static ApplicationInfo getApplicationInfo(@NonNull Activity activity,
            @NonNull String packageName) {
        try {
+12 −1
Original line number Diff line number Diff line
@@ -259,7 +259,18 @@ public final class AppPermissionsFragment extends SettingsWithButtonHeader {
            category.addPreference(extraPerms);
        }

        if (allowed.getPreferenceCount() == 0) {
        if (allowed.getPreferenceCount() > 0) {
            Preference details = new Preference(context);
            details.setTitle(R.string.detailed_usage_link);
            details.setOnPreferenceClickListener(preference -> {
                Intent intent = new Intent(Intent.ACTION_REVIEW_APP_PERMISSION_USAGE);
                intent.putExtra(Intent.EXTRA_PACKAGE_NAME,
                        getArguments().getString(Intent.EXTRA_PACKAGE_NAME));
                context.startActivity(intent);
                return true;
            });
            allowed.addPreference(details);
        } else {
            Preference empty = new Preference(context);
            empty.setTitle(getString(R.string.no_permissions_allowed));
            allowed.addPreference(empty);