From c437ba1997e79d957c02922449148253ebe1e537 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Wed, 10 Apr 2019 13:26:07 -0400 Subject: [PATCH] Convert Privacy Types to use PermissionGroup icons PrivacyType now uses the icons defined in the framework for the permission groups. Also, fixes icon size and min width of chip. This requires that the icons be right aligned when there's no background so there is no extra black space to the right of a single icons. Remove unnecessary references to whether the device is secured as those were only needed when exposing apps. Still needed to change the icons in PhoneStatusBarPolicy, need to address the sizing of icons correctly. Bug: 129677355 Fixes: 130179014 Test: manual: changing theme changes the icon Test: visual Change-Id: Iededc1132caa37cca05112f635ddad8aa04e6ea4 --- core/res/res/values/symbols.xml | 5 +++++ .../SystemUI/res/layout/ongoing_privacy_chip.xml | 9 ++++----- packages/SystemUI/res/values/dimens.xml | 2 +- .../android/systemui/privacy/OngoingPrivacyChip.kt | 12 ++++++------ .../src/com/android/systemui/privacy/PrivacyItem.kt | 12 ++++++++---- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index e9ce6ac93973f..94b5da6baa071 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3751,4 +3751,9 @@ + + + + + diff --git a/packages/SystemUI/res/layout/ongoing_privacy_chip.xml b/packages/SystemUI/res/layout/ongoing_privacy_chip.xml index b16e06207ca36..49c16bee7b1f7 100644 --- a/packages/SystemUI/res/layout/ongoing_privacy_chip.xml +++ b/packages/SystemUI/res/layout/ongoing_privacy_chip.xml @@ -23,21 +23,20 @@ android:layout_width="wrap_content" android:layout_marginLeft="@dimen/ongoing_appops_chip_margin" android:layout_marginRight="@dimen/ongoing_appops_chip_margin" - android:layout_gravity="center_vertical|start" + android:layout_gravity="center_vertical|end" android:gravity="center_vertical" android:orientation="horizontal" - android:focusable="true"> + android:focusable="true" > + android:minWidth="48dp" + android:layout_width="wrap_content" > diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 74924fb5562ce..bfdb21877277f 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1044,7 +1044,7 @@ 2dp - @*android:dimen/status_bar_icon_size + @dimen/status_bar_icon_drawing_size 16dp diff --git a/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyChip.kt b/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyChip.kt index 23742c0953bb5..a5a915b88cad6 100644 --- a/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyChip.kt +++ b/packages/SystemUI/src/com/android/systemui/privacy/OngoingPrivacyChip.kt @@ -16,13 +16,12 @@ package com.android.systemui.privacy import android.content.Context import android.util.AttributeSet +import android.view.Gravity import android.view.ViewGroup import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout -import com.android.systemui.Dependency import com.android.systemui.R -import com.android.systemui.statusbar.policy.KeyguardMonitor class OngoingPrivacyChip @JvmOverloads constructor( context: Context, @@ -51,8 +50,7 @@ class OngoingPrivacyChip @JvmOverloads constructor( updateView() } } - @Suppress("DEPRECATION") - private val keyguardMonitor = Dependency.get(KeyguardMonitor::class.java) + var builder = PrivacyDialogBuilder(context, emptyList()) var privacyList = emptyList() set(value) { @@ -94,14 +92,16 @@ class OngoingPrivacyChip @JvmOverloads constructor( if (!privacyList.isEmpty()) { generateContentDescription() setIcons(builder, iconsContainer) + val lp = iconsContainer.layoutParams as FrameLayout.LayoutParams + lp.gravity = Gravity.CENTER_VERTICAL or + (if (expanded) Gravity.CENTER_HORIZONTAL else Gravity.END) + iconsContainer.layoutParams = lp } else { iconsContainer.removeAllViews() } requestLayout() } - private fun amISecure() = keyguardMonitor.isShowing && keyguardMonitor.isSecure - private fun generateContentDescription() { val typesText = builder.joinTypes() contentDescription = context.getString( diff --git a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt index 3f581c4de5fb3..290942412eedf 100644 --- a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt +++ b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItem.kt @@ -24,10 +24,14 @@ import com.android.systemui.R typealias Privacy = PrivacyType -enum class PrivacyType(val nameId: Int, val iconId: Int) { - TYPE_CAMERA(R.string.privacy_type_camera, R.drawable.stat_sys_camera), - TYPE_MICROPHONE(R.string.privacy_type_microphone, R.drawable.stat_sys_mic_none), - TYPE_LOCATION(R.string.privacy_type_location, R.drawable.stat_sys_location); +enum class PrivacyType(private val nameId: Int, val iconId: Int) { + // This is uses the icons used by the corresponding permission groups in the AndroidManifest + TYPE_CAMERA(R.string.privacy_type_camera, + com.android.internal.R.drawable.perm_group_camera), + TYPE_MICROPHONE(R.string.privacy_type_microphone, + com.android.internal.R.drawable.perm_group_microphone), + TYPE_LOCATION(R.string.privacy_type_location, + com.android.internal.R.drawable.perm_group_location); fun getName(context: Context) = context.resources.getString(nameId)