mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-05 21:20:45 +00:00
This commit is contained in:
parent
cfccb997fd
commit
744f1be0a9
@ -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
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
8
app/src/main/res/color/state_list_text_color.xml
Normal file
8
app/src/main/res/color/state_list_text_color.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- 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/. -->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:color="@color/disabled_text" />
|
||||
<item android:color="?primaryText"/>
|
||||
</selector>
|
13
app/src/main/res/drawable/ic_camera_disabled.xml
Normal file
13
app/src/main/res/drawable/ic_camera_disabled.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- 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/. -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/disabled_text"
|
||||
android:pathData="M21.46,6.16L8.63,19h5.55A1.88,1.88 0,0 0,16 17.06v-2.73l4.4,3.41A1,1 0,0 0,22 17L22,7a1,1 0,0 0,-0.54 -0.84zM21.71,2.29a1,1 0,0 0,-1.42 0L16,6.62A1.84,1.84 0,0 0,14.18 5L3.81,5A1.88,1.88 0,0 0,2 6.94v10.12A1.89,1.89 0,0 0,3.61 19l-1.32,1.29a1,1 0,0 0,0 1.42,1 1,0 0,0 1.42,0l18,-18a1,1 0,0 0,0 -1.42z"/>
|
||||
</vector>
|
@ -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/. -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="?primaryText"
|
||||
android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z"/>
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="?primaryText"
|
||||
android:pathData="M12,9a3,3 0,1 0,3 3,3 3,0 0,0 -3,-3zM21,11h-1.07A8,8 0,0 0,13 4.07L13,3a1,1 0,0 0,-2 0v1.07A8,8 0,0 0,4.07 11L3,11a1,1 0,0 0,0 2h1.07A8,8 0,0 0,11 19.93L11,21a1,1 0,0 0,2 0v-1.07A8,8 0,0 0,19.93 13L21,13a1,1 0,0 0,0 -2zM12,18a6,6 0,1 1,6 -6,6 6,0 0,1 -6,6z"/>
|
||||
</vector>
|
||||
|
13
app/src/main/res/drawable/ic_location_disabled.xml
Normal file
13
app/src/main/res/drawable/ic_location_disabled.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- 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/. -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/disabled_text"
|
||||
android:pathData="M21.71,2.29a1,1 0,0 0,-1.42 0l-3.4,3.41A7.92,7.92 0,0 0,13 4.07L13,3a1,1 0,0 0,-2 0v1.07A8,8 0,0 0,4.07 11L3,11a1,1 0,0 0,0 2h1.07a7.92,7.92 0,0 0,1.63 3.89l-3.41,3.4a1,1 0,0 0,0 1.42,1 1,0 0,0 1.42,0l18,-18a1,1 0,0 0,0 -1.42zM13.29,9.29A3,3 0,0 0,12 9a3,3 0,0 0,-3 3,3 3,0 0,0 0.3,1.29l-2.18,2.18a6,6 0,0 1,8.35 -8.35zM21,11h-1.07a8,8 0,0 0,-0.76 -2.54L17.64,10a5.88,5.88 0,0 1,0.36 2,6 6,0 0,1 -6,6 5.88,5.88 0,0 1,-2 -0.36l-1.54,1.53a8,8 0,0 0,2.54 0.76L11,21a1,1 0,0 0,2 0v-1.07A8,8 0,0 0,19.93 13L21,13a1,1 0,0 0,0 -2z"/>
|
||||
</vector>
|
14
app/src/main/res/drawable/ic_microphone_disabled.xml
Normal file
14
app/src/main/res/drawable/ic_microphone_disabled.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- 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/. -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/disabled_text"
|
||||
android:pathData="M5,11v-1c0,-0.552 0.448,-1 1,-1s1,0.448 1,1v1c0,1.275 0.477,2.44 1.263,3.322l1.419,-1.418C9.256,12.386 9,11.723 9,11L9,5c0,-1.657 1.343,-3 3,-3s3,1.343 3,3v2.586l5.293,-5.293c0.39,-0.39 1.024,-0.39 1.414,0 0.39,0.39 0.39,1.024 0,1.414l-18,18c-0.39,0.39 -1.024,0.39 -1.414,0 -0.39,-0.39 -0.39,-1.024 0,-1.414l4.554,-4.555C5.7,14.492 5,12.828 5,11zM17,10.414l1.35,-1.35c0.38,0.141 0.65,0.507 0.65,0.936v1c0,3.526 -2.608,6.444 -6,6.93L13,21c0,0.552 -0.448,1 -1,1s-1,-0.448 -1,-1v-3.07c-0.422,-0.061 -0.831,-0.159 -1.225,-0.291l1.67,-1.67c0.182,0.02 0.367,0.031 0.555,0.031 2.761,0 5,-2.239 5,-5v-0.586z"
|
||||
/>
|
||||
</vector>
|
13
app/src/main/res/drawable/ic_notifications_disabled.xml
Normal file
13
app/src/main/res/drawable/ic_notifications_disabled.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- 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/. -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/disabled_text"
|
||||
android:pathData="M21.759,4.824L20,6.583L20,14a1,1 0,0 1,-1 1h-2a1,1 0,0 0,-1 1v1.586l-2.293,-2.293A1,1 0,0 0,13 15h-1.417l-2,2h3l3.707,3.707A1,1 0,0 0,17 21a0.987,0.987 0,0 0,0.383 -0.076A1,1 0,0 0,18 20v-3h1a3,3 0,0 0,3 -3L22,6a2.979,2.979 0,0 0,-0.241 -1.176zM20.207,2.793a1,1 0,0 0,-1.414 0L18.586,3L5,3a3,3 0,0 0,-3 3v8a2.994,2.994 0,0 0,2.624 2.962l-0.831,0.831a1,1 0,1 0,1.414 1.414l15,-15a1,1 0,0 0,0 -1.414zM13.586,8L7.5,8a0.5,0.5 0,0 0,0 1h5.086l-2,2L7.5,11a0.5,0.5 0,0 0,0 1h2.086l-3,3L5,15a1,1 0,0 1,-1 -1L4,6a1,1 0,0 1,1 -1h11.586z"/>
|
||||
</vector>
|
@ -130,6 +130,7 @@
|
||||
<color name="light_grey_05">#FBFBFE</color>
|
||||
<color name="dark_grey_90">#15141A</color>
|
||||
<color name="neutral_text">@color/white_color</color>
|
||||
<color name="disabled_text">#cccccc</color>
|
||||
|
||||
<!-- Reader View colors -->
|
||||
<color name="mozac_feature_readerview_text_color">@color/primary_text_light_theme</color>
|
||||
|
@ -207,7 +207,7 @@
|
||||
</style>
|
||||
|
||||
<style name="QuickSettingsText">
|
||||
<item name="android:textColor">?primaryText</item>
|
||||
<item name="android:textColor">@color/state_list_text_color</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:paddingStart">16dp</item>
|
||||
<item name="android:gravity">center_vertical</item>
|
||||
@ -223,6 +223,6 @@
|
||||
<item name="android:paddingEnd">24dp</item>
|
||||
<item name="android:gravity">end|center_vertical</item>
|
||||
<item name="android:background">?android:attr/selectableItemBackground</item>
|
||||
<item name="android:textColor">@color/photonBlue50</item>
|
||||
<item name="android:textColor">?accentBright</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user