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

Commit 90f57c1a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add a permission usage learn more link."

parents a9d9dd51 b46f5c3a
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -254,6 +254,14 @@
                        android:text="@string/permission_justification_footer"
                        style="@style/FooterText"/>

                    <TextView
                        android:id="@+id/justification_info_intent"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        style="@style/FooterText"
                        android:textColor="?android:attr/colorAccent"
                        android:clickable="true"/>

                </LinearLayout>

                <TextView
@@ -262,7 +270,8 @@
                    android:layout_height="wrap_content"
                    style="@style/FooterText"
                    android:textColor="?android:attr/colorAccent"
                    android:clickable="true" />
                    android:clickable="true"
                    android:text="@string/app_permission_footer_usage_link"/>

            </LinearLayout>

+3 −0
Original line number Diff line number Diff line
@@ -428,6 +428,9 @@
    <!-- Footer for permission justifications [CHAR LIMIT=none] -->
    <string name="permission_justification_footer">If you don\u2019t like how this app developer is using your data you can deny the permission.</string>

    <!-- Text for permission justifications intent allowing users to get more information from an app on how it is using a permission [CHAR LIMIT=none] -->
    <string name="permission_justification_info_intent">Go to <xliff:g id="app_name" example="Gmail">%s</xliff:g> for more information.</string>

    <!-- Permission justification entry for data being sent off the device [CHAR LIMIT=none] -->
    <string name="permission_justification_data_sent_off_device">Uploaded to cloud</string>

+18 −5
Original line number Diff line number Diff line
@@ -202,9 +202,7 @@ public class AppPermissionFragment extends SettingsWithButtonHeader {
                            timeDiffStr));
        }

        TextView usageLink = root.requireViewById(R.id.usage_link);
        usageLink.setText(context.getString(R.string.app_permission_footer_usage_link));
        usageLink.setOnClickListener((v) -> {
        root.requireViewById(R.id.usage_link).setOnClickListener((v) -> {
            Intent intent = new Intent(Intent.ACTION_REVIEW_APP_PERMISSION_USAGE);
            intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mGroup.getApp().packageName);
            context.startActivity(intent);
@@ -219,7 +217,7 @@ public class AppPermissionFragment extends SettingsWithButtonHeader {
        mPermissionDetails = root.requireViewById(R.id.permission_details);

        updateButtons();
        updateJustification(context, root);
        updateJustification(context, root, appLabel);

        return root;
    }
@@ -403,7 +401,7 @@ public class AppPermissionFragment extends SettingsWithButtonHeader {
        }
    }

    private void updateJustification(Context context, ViewGroup root) {
    private void updateJustification(Context context, ViewGroup root, @NonNull String appLabel) {
        // Collect the names of the permissions of the group.
        ArrayList<Permission> groupPerms = mGroup.getPermissions();
        ArraySet<String> permissions = new ArraySet(groupPerms.size());
@@ -497,6 +495,21 @@ public class AppPermissionFragment extends SettingsWithButtonHeader {
                                R.string.permission_justification_data_retention_unlimited));
            }
        }

        TextView infoIntentView = root.requireViewById(R.id.justification_info_intent);
        Intent infoIntent = new Intent(Intent.ACTION_PERMISSION_USAGE_DETAILS);
        infoIntent.setPackage(mGroup.getApp().packageName);
        if (infoIntent.resolveActivity(context.getPackageManager()) != null) {
            infoIntentView.setText(context.getString(R.string.permission_justification_info_intent,
                    appLabel));
            infoIntentView.setOnClickListener((v) -> {
                infoIntent.putExtra(Intent.EXTRA_PERMISSION_USAGE_PERMISSIONS,
                        permissions.toArray(new String[permissions.size()]));
                context.startActivity(infoIntent);
            });
        } else {
            infoIntentView.setVisibility(View.GONE);
        }
    }

    /**