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

Commit 47364188 authored by Nate Myren's avatar Nate Myren Committed by Android (Google) Code Review
Browse files

Merge "Update Auto revoke toggle and screen strings" into rvc-dev

parents 825024b5 ddd1e3cb
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -333,10 +333,16 @@
    <string name="auto_revoke_label">Remove permissions if app isn\u2019t used</string>

    <!-- Summary for stating that permissions will be removed [CHAR LIMIT=none] -->
    <string name="auto_revoke_summary">To protect your data, permissions for this app will be removed if the app isn\u2019t used for a few months.</string>
    <string name="auto_revoke_summary">To protect your data, permissions for this app will be removed if the app is unused for a few months.</string>

    <!-- Summary for stating that permissions will be removed, which includes a list of permissions which will be removed [CHAR LIMIT=none] -->
    <string name="auto_revoke_summary_with_permissions">To protect your data, if the app hasn\u2019 been used for a few months, the following permissions will be removed: <xliff:g id="perms" example="location, contacts, and phone">%1$s</xliff:g>.</string>
    <string name="auto_revoke_summary_with_permissions">To protect your data, if the app is unused for a few months, the following permissions will be removed: <xliff:g id="perms" example="location, contacts, and phone">%1$s</xliff:g></string>

    <!-- Summary for the screen that shows all apps that have had permissions removed [CHAR LIMIT=none] -->
    <string name="auto_revoked_apps_page_summary">To protect your data, permissions have been removed from apps that you haven\u2019t used in a few months.</string>

    <!-- Message which tells users to open an app to grant permissions [CHAR LIMIT=none]-->
    <string name="auto_revoke_open_app_message">If you want to allow permissions again, open the app</string>

    <!-- Summary for stating that auto revoke is disabled for the current app [CHAR LIMIT=none] -->
    <string name="auto_revoke_disabled">Automatic removal is currently disabled for this app.</string>
@@ -530,6 +536,12 @@
    <!-- Summary explaining that permissions for unused apps have be removed [CHAR LIMIT=none] -->
    <string name="unused_app_permissions_removed_summary">To protect your data, permissions have been removed from apps that you haven\u2019t used in a few months</string>

    <!-- Summary listing that one app is unused [CHAR LIMIT=none] -->
    <string name="one_unused_app_summary">1 app hasen\u2019t been used for a few months</string>

    <!-- Summary listing how many apps are unused [CHAR LIMIT=none] -->
    <string name="num_unused_apps_summary"><xliff:g id="number_of_apps" example="4">%s</xliff:g> apps haven\u2019t been used for a few months</string>

    <!-- Subtitle for the preference that is currently granted only when the app is in the foreground. [CHAR LIMIT=60] -->
    <string name="permission_subtitle_only_in_foreground">Only while app is in use</string>

+13 −2
Original line number Diff line number Diff line
@@ -23,4 +23,15 @@
    <PreferenceCategory
        android:key="six_months"/>

    <PreferenceCategory
        android:key="info_msg_category">
        <Preference
            android:key="info_msg_one"
            android:summary="@string/auto_revoked_apps_page_summary"
            android:icon="@drawable/ic_info_outline"/>
        <Preference
            android:key="info_msg_two"
            android:summary="@string/auto_revoke_open_app_message"/>
    </PreferenceCategory>

</PreferenceScreen>
+2 −18
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ public final class AppPermissionGroupsFragment extends SettingsWithLargeHeader {
    private static final String AUTO_REVOKE_CATEGORY_KEY = "_AUTO_REVOKE_KEY";
    private static final String AUTO_REVOKE_SWITCH_KEY = "_AUTO_REVOKE_SWITCH_KEY";
    private static final String AUTO_REVOKE_SUMMARY_KEY = "_AUTO_REVOKE_SUMMARY_KEY";
    private static final String AUTO_REVOKE_PERMS_KEY = "_AUTO_REVOKE_PERMS_KEY";

    static final String EXTRA_HIDE_INFO_BUTTON = "hideInfoButton";

@@ -348,12 +347,7 @@ public final class AppPermissionGroupsFragment extends SettingsWithLargeHeader {
        autoRevokeSummary.setIcon(Utils.applyTint(getActivity(), R.drawable.ic_info_outline,
                android.R.attr.colorControlNormal));
        autoRevokeSummary.setKey(AUTO_REVOKE_SUMMARY_KEY);
        autoRevokeSummary.setSummary(R.string.auto_revoke_summary);
        autoRevokeCategory.addPreference(autoRevokeSummary);

        Preference autoRevokePerms = new Preference(context);
        autoRevokePerms.setKey(AUTO_REVOKE_PERMS_KEY);
        autoRevokeCategory.addPreference(autoRevokePerms);
    }

    private void setAutoRevokeToggleState(AutoRevokeState state) {
@@ -366,17 +360,14 @@ public final class AppPermissionGroupsFragment extends SettingsWithLargeHeader {
                .findPreference(AUTO_REVOKE_CATEGORY_KEY);
        SwitchPreference autoRevokeSwitch = autoRevokeCategory.findPreference(
                AUTO_REVOKE_SWITCH_KEY);
        Preference autoRevokePerms = autoRevokeCategory.findPreference(AUTO_REVOKE_PERMS_KEY);
        Preference autoRevokeSummary = autoRevokeCategory.findPreference(AUTO_REVOKE_SUMMARY_KEY);

        if (!state.isEnabledGlobal() || !state.getShouldShowSwitch()) {
            autoRevokeSwitch.setVisible(false);
            autoRevokePerms.setVisible(false);
            autoRevokeSummary.setVisible(false);
            return;
        }
        autoRevokeSwitch.setVisible(true);
        autoRevokePerms.setVisible(true);
        autoRevokeSummary.setVisible(true);
        autoRevokeSwitch.setChecked(state.isEnabledForApp());

@@ -392,16 +383,9 @@ public final class AppPermissionGroupsFragment extends SettingsWithLargeHeader {

        groupLabels.sort(mCollator);
        if (groupLabels.isEmpty()) {
            autoRevokePerms.setSummary(R.string.auto_revocable_permissions_none);
        } else if (groupLabels.size() == 1) {
            autoRevokePerms.setSummary(getString(R.string.auto_revocable_permissions_one,
                    groupLabels.get(0)));
        } else if (groupLabels.size() == 2) {
            autoRevokePerms.setSummary(getString(R.string.auto_revocable_permissions_two,
                    groupLabels.get(0), groupLabels.get(1)));

            autoRevokeSummary.setSummary(R.string.auto_revoke_summary);
        } else {
            autoRevokePerms.setSummary(getString(R.string.auto_revocable_permissions_many,
            autoRevokeSummary.setSummary(getString(R.string.auto_revoke_summary_with_permissions,
                    ListFormatter.getInstance().format(groupLabels)));
        }
    }
+10 −7
Original line number Diff line number Diff line
@@ -30,9 +30,6 @@ import com.android.permissioncontroller.permission.ui.model.ManageStandardPermis
import com.android.permissioncontroller.permission.ui.model.ManageStandardPermissionsViewModelFactory;
import com.android.permissioncontroller.permission.utils.Utils;

import java.util.Objects;


/**
 * Fragment that allows the user to manage standard permissions.
 */
@@ -85,7 +82,7 @@ public final class ManageStandardPermissionsFragment extends ManagePermissionsFr
        });

        mViewModel.getNumCustomPermGroups().observe(this, permNames -> updatePermissionsUi());
        mViewModel.getShouldShowAutoRevoke().observe(this, show -> updatePermissionsUi());
        mViewModel.getNumAutoRevoked().observe(this, show -> updatePermissionsUi());
    }

    @Override
@@ -146,9 +143,9 @@ public final class ManageStandardPermissionsFragment extends ManagePermissionsFr
                    numExtraPermissions));
        }

        Boolean showAutoRevoke = mViewModel.getShouldShowAutoRevoke().getValue();
        Integer numAutoRevoked = mViewModel.getNumAutoRevoked().getValue();
        Preference autoRevokePreference = screen.findPreference(AUTO_REVOKE_KEY);
        if (Objects.equals(showAutoRevoke, true)) {
        if (numAutoRevoked != null && numAutoRevoked != 0) {
            if (autoRevokePreference == null) {
                autoRevokePreference = new Preference(getPreferenceManager().getContext());
                autoRevokePreference.setOrder(-1);
@@ -157,6 +154,12 @@ public final class ManageStandardPermissionsFragment extends ManagePermissionsFr
                        R.string.auto_revoke_permission_reminder_notification_title);
                autoRevokePreference.setSingleLineTitle(false);
                autoRevokePreference.setIcon(R.drawable.ic_info_outline);
                if (numAutoRevoked == 1) {
                    autoRevokePreference.setSummary(R.string.one_unused_app_summary);
                } else {
                    autoRevokePreference.setSummary(getString(R.string.num_unused_apps_summary,
                            numAutoRevoked));
                }
                autoRevokePreference.setOnPreferenceClickListener(preference -> {
                    mViewModel.showAutoRevoke(this,
                            AutoRevokeFragment.createArgs(
@@ -166,7 +169,7 @@ public final class ManageStandardPermissionsFragment extends ManagePermissionsFr

                screen.addPreference(autoRevokePreference);
            }
        } else if (showAutoRevoke != null && autoRevokePreference != null) {
        } else if (numAutoRevoked != null && autoRevokePreference != null) {
            screen.removePreference(autoRevokePreference);
        }
        return screen;
+2 −2
Original line number Diff line number Diff line
@@ -45,8 +45,8 @@ class ManageStandardPermissionsViewModel(
    val uiDataLiveData = PermGroupsPackagesUiInfoLiveData(app,
        StandardPermGroupNamesLiveData)
    val numCustomPermGroups = NumCustomPermGroupsWithPackagesLiveData()
    val shouldShowAutoRevoke = Transformations.map(AutoRevokedPackagesLiveData) {
        it != null && it.isNotEmpty()
    val numAutoRevoked = Transformations.map(AutoRevokedPackagesLiveData) {
        it?.size ?: 0
    }

    /**