diff --git a/CHANGELOG.md b/CHANGELOG.md
index 34baa2ddb7..818bde7fe5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- #2308 - Update the deprecated BitmapDrawable constructor
- #1311 - Enable downloads in custom tabs.
- #1874 - Added TOP info panel dialog for custom tabs.
+- #1411 - Added disabled style for disabled permissions items in site info panel.
- #1735 - Adds API to see the release channel
### Changed
diff --git a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsUIView.kt b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsUIView.kt
index df4139a2eb..0c01b868e4 100644
--- a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsUIView.kt
+++ b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsUIView.kt
@@ -4,6 +4,7 @@
package org.mozilla.fenix.settings.quicksettings
+import android.graphics.drawable.Drawable
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
@@ -17,6 +18,7 @@ import io.reactivex.Observable
import io.reactivex.Observer
import io.reactivex.functions.Consumer
import mozilla.components.feature.sitepermissions.SitePermissions
+import mozilla.components.feature.sitepermissions.SitePermissions.Status.BLOCKED
import mozilla.components.feature.sitepermissions.SitePermissions.Status.NO_DECISION
import mozilla.components.support.ktx.android.net.hostWithoutCommonPrefixes
import mozilla.components.support.ktx.kotlin.toUri
@@ -76,17 +78,13 @@ class QuickSettingsUIView(
bindSecurityInfo(state.mode.isSecured)
bindReportProblemAction(state.mode.url)
bindTrackingProtectionInfo(state.mode.isTrackingProtectionOn)
- bindPhoneFeatureItem(cameraActionLabel, CAMERA, state.mode.sitePermissions)
- bindPhoneFeatureItem(microphoneActionLabel, MICROPHONE, state.mode.sitePermissions)
- bindPhoneFeatureItem(notificationActionLabel, NOTIFICATION, state.mode.sitePermissions)
- bindPhoneFeatureItem(locationActionLabel, LOCATION, state.mode.sitePermissions)
+ bindPhoneFeatureItem(CAMERA, state.mode.sitePermissions)
+ bindPhoneFeatureItem(MICROPHONE, state.mode.sitePermissions)
+ bindPhoneFeatureItem(NOTIFICATION, state.mode.sitePermissions)
+ bindPhoneFeatureItem(LOCATION, state.mode.sitePermissions)
}
is QuickSettingsState.Mode.ActionLabelUpdated -> {
- bindPhoneFeatureItem(
- state.mode.phoneFeature.labelAndAction.second,
- state.mode.phoneFeature,
- state.mode.sitePermissions
- )
+ bindPhoneFeatureItem(state.mode.phoneFeature, state.mode.sitePermissions)
}
is QuickSettingsState.Mode.CheckPendingFeatureBlockedByAndroid -> {
checkFeaturesBlockedByAndroid(state.mode.sitePermissions)
@@ -144,20 +142,16 @@ class QuickSettingsUIView(
securityInfoLabel.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null)
}
- private fun bindPhoneFeatureItem(
- actionLabel: TextView,
- phoneFeature: PhoneFeature,
- sitePermissions: SitePermissions? = null
- ) {
+ private fun bindPhoneFeatureItem(phoneFeature: PhoneFeature, sitePermissions: SitePermissions? = null) {
if (phoneFeature.shouldBeHidden(sitePermissions)) {
hide(phoneFeature)
return
}
show(phoneFeature)
if (!phoneFeature.isAndroidPermissionGranted(context)) {
- handleBlockedByAndroidAction(actionLabel, phoneFeature)
+ handleBlockedByAndroidAction(phoneFeature)
} else {
- bindPhoneAction(actionLabel, phoneFeature, sitePermissions)
+ bindPhoneAction(phoneFeature, sitePermissions)
}
}
@@ -177,10 +171,16 @@ class QuickSettingsUIView(
return getStatus(sitePermissions, settings) == NO_DECISION
}
- private fun handleBlockedByAndroidAction(actionLabel: TextView, phoneFeature: PhoneFeature) {
- actionLabel.setText(R.string.phone_feature_blocked_by_android)
- actionLabel.tag = phoneFeature
- actionLabel.setOnClickListener {
+ private fun PhoneFeature.isPermissionBlocked(sitePermissions: SitePermissions?): Boolean {
+ return getStatus(sitePermissions, settings) == BLOCKED
+ }
+
+ private fun handleBlockedByAndroidAction(phoneFeature: PhoneFeature) {
+ val (label, action) = phoneFeature.labelAndAction
+
+ action.setText(R.string.phone_feature_blocked_by_android)
+ action.tag = phoneFeature
+ action.setOnClickListener {
val feature = it.tag as PhoneFeature
actionEmitter.onNext(
QuickSettingsAction.SelectBlockedByAndroid(
@@ -188,27 +188,37 @@ class QuickSettingsUIView(
)
)
}
+ label.setCompoundDrawablesWithIntrinsicBounds(phoneFeature.disabledIcon, null, null, null)
+ label.isEnabled = false
blockedByAndroidPhoneFeatures.add(phoneFeature)
}
- private fun bindPhoneAction(
- actionLabel: TextView,
- phoneFeature: PhoneFeature,
- sitePermissions: SitePermissions? = null
- ) {
- actionLabel.text = phoneFeature.getActionLabel(
+ private fun bindPhoneAction(phoneFeature: PhoneFeature, sitePermissions: SitePermissions? = null) {
+ val (label, action) = phoneFeature.labelAndAction
+
+ action.text = phoneFeature.getActionLabel(
context = context,
sitePermissions = sitePermissions,
settings = settings
)
- actionLabel.tag = phoneFeature
- actionLabel.setOnClickListener {
+ action.tag = phoneFeature
+ action.setOnClickListener {
val feature = it.tag as PhoneFeature
actionEmitter.onNext(
QuickSettingsAction.TogglePermission(feature)
)
}
+
+ val icon = if (phoneFeature.isPermissionBlocked(sitePermissions)) {
+ label.isEnabled = false
+ phoneFeature.disabledIcon
+ } else {
+ label.isEnabled = true
+ phoneFeature.enabledIcon
+ }
+
+ label.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null)
blockedByAndroidPhoneFeatures.remove(phoneFeature)
}
@@ -216,8 +226,7 @@ class QuickSettingsUIView(
val clonedList = blockedByAndroidPhoneFeatures.toTypedArray()
clonedList.forEach { phoneFeature ->
if (phoneFeature.isAndroidPermissionGranted(context)) {
- val actionLabel = phoneFeature.labelAndAction.second
- bindPhoneAction(actionLabel, phoneFeature, sitePermissions)
+ bindPhoneAction(phoneFeature, sitePermissions)
}
}
}
@@ -231,4 +240,26 @@ class QuickSettingsUIView(
NOTIFICATION -> notificationLabel to notificationActionLabel
}
}
+
+ private val PhoneFeature.enabledIcon
+ get(): Drawable {
+ val drawableId = when (this) {
+ CAMERA -> R.drawable.ic_camera
+ LOCATION -> R.drawable.ic_location
+ MICROPHONE -> R.drawable.ic_microphone
+ NOTIFICATION -> R.drawable.ic_notification
+ }
+ return requireNotNull(AppCompatResources.getDrawable(context, drawableId))
+ }
+
+ private val PhoneFeature.disabledIcon
+ get(): Drawable {
+ val drawableId = when (this) {
+ CAMERA -> R.drawable.ic_camera_disabled
+ LOCATION -> R.drawable.ic_location_disabled
+ MICROPHONE -> R.drawable.ic_microphone_disabled
+ NOTIFICATION -> R.drawable.ic_notifications_disabled
+ }
+ return requireNotNull(AppCompatResources.getDrawable(context, drawableId))
+ }
}
diff --git a/app/src/main/res/color/state_list_text_color.xml b/app/src/main/res/color/state_list_text_color.xml
new file mode 100644
index 0000000000..4b29becb11
--- /dev/null
+++ b/app/src/main/res/color/state_list_text_color.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_camera_disabled.xml b/app/src/main/res/drawable/ic_camera_disabled.xml
new file mode 100644
index 0000000000..b14b293cc2
--- /dev/null
+++ b/app/src/main/res/drawable/ic_camera_disabled.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_location.xml b/app/src/main/res/drawable/ic_location.xml
index a6cc455c9f..8c75cf47ae 100644
--- a/app/src/main/res/drawable/ic_location.xml
+++ b/app/src/main/res/drawable/ic_location.xml
@@ -3,11 +3,11 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
diff --git a/app/src/main/res/drawable/ic_location_disabled.xml b/app/src/main/res/drawable/ic_location_disabled.xml
new file mode 100644
index 0000000000..f7071487b9
--- /dev/null
+++ b/app/src/main/res/drawable/ic_location_disabled.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_microphone_disabled.xml b/app/src/main/res/drawable/ic_microphone_disabled.xml
new file mode 100644
index 0000000000..7788b8a9b3
--- /dev/null
+++ b/app/src/main/res/drawable/ic_microphone_disabled.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_notifications_disabled.xml b/app/src/main/res/drawable/ic_notifications_disabled.xml
new file mode 100644
index 0000000000..db6e9b78f7
--- /dev/null
+++ b/app/src/main/res/drawable/ic_notifications_disabled.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index a28434b5a3..f1da49bf0f 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -130,6 +130,7 @@
#FBFBFE
#15141A
@color/white_color
+ #cccccc
@color/primary_text_light_theme
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 0eea5501dc..788ed6caf2 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -207,7 +207,7 @@