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

Commit 6165e8f5 authored by Joel Galenson's avatar Joel Galenson
Browse files

After filtering Permissions Hub by permission, make the back button return to the unfiltered view.

Previously, filtering by a permission group simply changed the filter
in the current fragment.  Thus pressing the back button returned to
the previous screen instead of undoing the filter.  This changes that
behavior.

Also update the string for removing the filter.

Fixes: 129415632
Test: Open Permissions Hub, filter by group, press back, see
Permissions Hub.
Test: Open filtered view, press "See all", press back, see filtered
view.
Test: Launch filtered view initially, press back, return to parent.
Change-Id: Id77b24bb30986ddbe8826297cd2d6187f1786a41
parent 965c73d4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -344,7 +344,7 @@
    <string name="app_permission_usage_filter_label">Filtered by: <xliff:g id="perm" example="Location">%1$s</xliff:g> </string>

    <!-- Label for the text that removes the filter by permission to view all usages [CHAR LIMIT=none] -->
    <string name="app_permission_usage_remove_filter">Remove filter</string>
    <string name="app_permission_usage_remove_filter">See all in Dashboard</string>

    <!-- Label for the title of the dialog allowing filtering by permissions [CHAR LIMIT=none] -->
    <string name="filter_by_title">Filter by</string>
+10 −12
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;

@@ -200,6 +201,8 @@ public class PermissionUsageFragment extends SettingsWithLargeHeader implements
            setProgressBarVisible(true);
        }

        hideHeader();

        reloadData();
    }

@@ -417,7 +420,6 @@ public class PermissionUsageFragment extends SettingsWithLargeHeader implements
        // Update header.
        if (mFilterGroup == null) {
            screen.addPreference(createBarChart(usages, timeFilterItem, context));
            hideHeader();
        } else {
            AppPermissionGroup group = getGroup(mFilterGroup);
            if (group != null) {
@@ -426,9 +428,7 @@ public class PermissionUsageFragment extends SettingsWithLargeHeader implements
                        context.getString(R.string.app_permission_usage_filter_label,
                                group.getLabel()), null);
                setSummary(context.getString(R.string.app_permission_usage_remove_filter), v -> {
                    mFilterGroup = null;
                    // We already loaded all data, so don't reload
                    updateUI();
                    onPermissionGroupSelected(null);
                });
            }
        }
@@ -602,11 +602,7 @@ public class PermissionUsageFragment extends SettingsWithLargeHeader implements
            BarViewInfo barViewInfo = new BarViewInfo(icon, count, group.getLabel(),
                    context.getResources().getQuantityString(R.plurals.permission_usage_bar_label,
                            count, count), group.getLabel());
            barViewInfo.setClickListener(v -> {
                mFilterGroup = group.getName();
                // We already loaded all data, so don't reload
                updateUI();
            });
            barViewInfo.setClickListener(v -> onPermissionGroupSelected(group.getName()));
            builder.addBarViewInfo(barViewInfo);
        }

@@ -873,9 +869,11 @@ public class PermissionUsageFragment extends SettingsWithLargeHeader implements
     *                      all entries.
     */
    private void onPermissionGroupSelected(@Nullable String selectedGroup) {
        mFilterGroup = selectedGroup;
        // We already loaded all data, so don't reload
        updateUI();
        Fragment frag = newInstance(selectedGroup, mFilterTimes.get(mFilterTimeIndex).getTime());
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, frag)
                .addToBackStack("PermissionUsage")
                .commit();
    }

    /**