Merge "[permissions-ui] remove one title from detailed permission usage page" into sc-dev am: 0c4e037cde
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Permission/+/15006996
Change-Id: I440765cd687ebe6aad3cb04cb60a0c99e9b02cc0
diff --git a/PermissionController/res/layout/permission_group_preference.xml b/PermissionController/res/layout/permission_group_preference.xml
deleted file mode 100644
index 740bb60..0000000
--- a/PermissionController/res/layout/permission_group_preference.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<!--
- ~ Copyright (C) 2021 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:gravity="left">
-
- <ImageView
- android:id="@+id/icon"
- style="@style/PermissionReviewTitleIcon"
- android:layout_marginLeft="16dp"
- android:layout_marginTop="44dp" />
-
- <TextView
- android:id="@+id/title"
- android:textAppearance="@style/TextAppearance.EntityHeaderTitle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="16dp"
- android:layout_marginTop="16dp"
- android:textSize="36sp" />
-
- <TextView
- android:id="@+id/subtitle"
- android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
- android:layout_marginBottom="16dp"
- android:layout_marginLeft="16dp"
- android:layout_marginRight="24dp"
- android:textSize="14sp"
- android:gravity="left" />
-
-</LinearLayout>
diff --git a/PermissionController/src/com/android/permissioncontroller/permission/debug/PermissionDetailsFragment.java b/PermissionController/src/com/android/permissioncontroller/permission/debug/PermissionDetailsFragment.java
index ce39e0b..61b1901 100644
--- a/PermissionController/src/com/android/permissioncontroller/permission/debug/PermissionDetailsFragment.java
+++ b/PermissionController/src/com/android/permissioncontroller/permission/debug/PermissionDetailsFragment.java
@@ -42,6 +42,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
@@ -52,7 +53,6 @@
import com.android.permissioncontroller.permission.model.AppPermissionUsage;
import com.android.permissioncontroller.permission.model.legacy.PermissionApps;
import com.android.permissioncontroller.permission.ui.ManagePermissionsActivity;
-import com.android.permissioncontroller.permission.ui.handheld.PermissionGroupPreference;
import com.android.permissioncontroller.permission.ui.handheld.PermissionHistoryPreference;
import com.android.permissioncontroller.permission.ui.handheld.SettingsWithLargeHeader;
import com.android.permissioncontroller.permission.utils.KotlinUtils;
@@ -184,7 +184,12 @@
@Override
public void onStart() {
super.onStart();
- getActivity().setTitle(R.string.permission_history_title);
+ CharSequence title = getString(R.string.permission_history_title);
+ if (mFilterGroup != null) {
+ title = getResources().getString(R.string.permission_group_usage_title,
+ KotlinUtils.INSTANCE.getPermGroupLabel(getActivity(), mFilterGroup));
+ }
+ getActivity().setTitle(title);
}
@Override
@@ -271,9 +276,12 @@
Set<String> exemptedPackages = Utils.getExemptedPackages(mRoleManager);
- PermissionGroupPreference permissionPreference = new PermissionGroupPreference(context,
- getResources(), mFilterGroup);
- screen.addPreference(permissionPreference);
+ Preference subtitlePreference = new Preference(context);
+ subtitlePreference.setSummary(
+ getResources().getString(R.string.permission_group_usage_subtitle,
+ KotlinUtils.INSTANCE.getPermGroupLabel(getActivity(), mFilterGroup)));
+ subtitlePreference.setSelectable(false);
+ screen.addPreference(subtitlePreference);
AtomicBoolean seenSystemApp = new AtomicBoolean(false);
@@ -516,7 +524,7 @@
*
* @param groupName The name of the permission group.
*
- * @return an AppPermissionGroup rerepsenting the given permission group or null if no such
+ * @return an AppPermissionGroup representing the given permission group or null if no such
* AppPermissionGroup is found.
*/
private @Nullable AppPermissionGroup getGroup(@NonNull String groupName) {
diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/PermissionGroupPreference.kt b/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/PermissionGroupPreference.kt
deleted file mode 100644
index dd91cbc..0000000
--- a/PermissionController/src/com/android/permissioncontroller/permission/ui/handheld/PermissionGroupPreference.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.permissioncontroller.permission.ui.handheld
-
-import android.content.Context
-import android.content.res.Resources
-import android.widget.ImageView
-import android.widget.TextView
-import androidx.preference.Preference
-import androidx.preference.PreferenceViewHolder
-import com.android.permissioncontroller.R
-import com.android.permissioncontroller.permission.utils.KotlinUtils
-
-/**
- * A Preference for the permission group. Has icon, title and subtitle.
- */
-class PermissionGroupPreference(
- context: Context,
- private val resources: Resources,
- private val permGroupName: String
-) : Preference(context) {
-
- init {
- layoutResource = R.layout.permission_group_preference
- }
-
- override fun onBindViewHolder(holder: PreferenceViewHolder) {
- super.onBindViewHolder(holder)
-
- (holder.findViewById(R.id.icon) as ImageView).setImageDrawable(
- KotlinUtils.getPermGroupIcon(context, permGroupName))
- (holder.findViewById(R.id.icon) as ImageView).contentDescription =
- KotlinUtils.getPermGroupLabel(context, permGroupName)
- (holder.findViewById(R.id.title) as TextView).text =
- resources.getString(R.string.permission_group_usage_title,
- KotlinUtils.getPermGroupLabel(context, permGroupName))
- (holder.findViewById(R.id.subtitle) as TextView).text =
- resources.getString(R.string.permission_group_usage_subtitle,
- KotlinUtils.getPermGroupLabel(context, permGroupName))
- }
-}
\ No newline at end of file