diff --git a/app/src/main/java/org/mozilla/fenix/settings/RadioButtonPreference.kt b/app/src/main/java/org/mozilla/fenix/settings/RadioButtonPreference.kt
index 42982a37a..21141a0ab 100644
--- a/app/src/main/java/org/mozilla/fenix/settings/RadioButtonPreference.kt
+++ b/app/src/main/java/org/mozilla/fenix/settings/RadioButtonPreference.kt
@@ -19,6 +19,8 @@ class RadioButtonPreference : Preference {
private lateinit var summaryView: TextView
private lateinit var radioButton: RadioButton
+ private var clickListener: (() -> Unit)? = null
+
init {
layoutResource = R.layout.preference_widget_radiobutton
}
@@ -35,6 +37,10 @@ class RadioButtonPreference : Preference {
radioGroups.add(radioPreference)
}
+ fun onClickListener(listener: (() -> Unit)) {
+ clickListener = listener
+ }
+
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
@@ -48,6 +54,7 @@ class RadioButtonPreference : Preference {
updateRadioValue(true)
toggleRadioGroups()
+ clickListener?.invoke()
true
}
}
diff --git a/app/src/main/java/org/mozilla/fenix/settings/SitePermissionsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/SitePermissionsFragment.kt
index 28d58e973..378e9adaa 100644
--- a/app/src/main/java/org/mozilla/fenix/settings/SitePermissionsFragment.kt
+++ b/app/src/main/java/org/mozilla/fenix/settings/SitePermissionsFragment.kt
@@ -6,11 +6,17 @@ package org.mozilla.fenix.settings
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
+import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
+import org.jetbrains.anko.support.v4.defaultSharedPreferences
import org.mozilla.fenix.R
class SitePermissionsFragment : PreferenceFragmentCompat() {
+ private lateinit var categoryPhoneFeatures: Preference
+ private lateinit var radioRecommendSettings: RadioButtonPreference
+ private lateinit var radioCustomSettings: RadioButtonPreference
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activity as AppCompatActivity).title = getString(R.string.preferences_site_permissions)
@@ -21,18 +27,57 @@ class SitePermissionsFragment : PreferenceFragmentCompat() {
setPreferencesFromResource(R.xml.site_permissions_preferences, rootKey)
}
+ override fun onResume() {
+ super.onResume()
+ setupPreferences()
+ }
+
private fun setupPreferences() {
- val keyRecommendSettings = getString(R.string.pref_key_recommended_settings)
- val keyCustomSettings = getString(R.string.pref_key_custom_settings)
- val radioRecommendSettings: RadioButtonPreference = requireNotNull(findPreference(keyRecommendSettings))
- val radioCustomSettings: RadioButtonPreference = requireNotNull(findPreference(keyCustomSettings))
+ bindRadioRecommendedSettings()
+
+ bindRadioCustomSettings()
+
+ bindCategoryPhoneFeatures()
+
+ setupRadioGroups()
+ }
+
+ private fun setupRadioGroups() {
radioRecommendSettings.addToRadioGroup(radioCustomSettings)
radioCustomSettings.addToRadioGroup(radioRecommendSettings)
}
- override fun onResume() {
- super.onResume()
- setupPreferences()
+ private fun bindRadioCustomSettings() {
+ val keyCustomSettings = getString(R.string.pref_key_custom_settings)
+ radioCustomSettings = requireNotNull(findPreference(keyCustomSettings))
+
+ radioCustomSettings.onClickListener {
+ toggleCategoryPhoneFeatureVisibility()
+ }
+ }
+
+ private fun bindRadioRecommendedSettings() {
+ val keyRecommendSettings = getString(R.string.pref_key_recommended_settings)
+ radioRecommendSettings = requireNotNull(findPreference(keyRecommendSettings))
+
+ radioRecommendSettings.onClickListener {
+ toggleCategoryPhoneFeatureVisibility()
+ }
+ }
+
+ private fun bindCategoryPhoneFeatures() {
+ val keyCategoryPhoneFeatures = getString(R.string.pref_key_category_phone_feature)
+
+ categoryPhoneFeatures = requireNotNull(findPreference(keyCategoryPhoneFeatures))
+
+ val isCategoryActivate = defaultSharedPreferences.getBoolean(radioCustomSettings.key, false)
+ if (isCategoryActivate) {
+ categoryPhoneFeatures.isVisible = true
+ }
+ }
+
+ private fun toggleCategoryPhoneFeatureVisibility() {
+ categoryPhoneFeatures.isVisible = !categoryPhoneFeatures.isVisible
}
}
diff --git a/app/src/main/res/drawable/ic_camera.xml b/app/src/main/res/drawable/ic_camera.xml
new file mode 100644
index 000000000..e4400e1d4
--- /dev/null
+++ b/app/src/main/res/drawable/ic_camera.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
new file mode 100644
index 000000000..1660006f6
--- /dev/null
+++ b/app/src/main/res/drawable/ic_location.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_microphone.xml b/app/src/main/res/drawable/ic_microphone.xml
new file mode 100644
index 000000000..916f8a7fd
--- /dev/null
+++ b/app/src/main/res/drawable/ic_microphone.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_notification.xml b/app/src/main/res/drawable/ic_notification.xml
new file mode 100644
index 000000000..77691cf3e
--- /dev/null
+++ b/app/src/main/res/drawable/ic_notification.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml
index 2f062a7c5..3383ac1d3 100644
--- a/app/src/main/res/values/preference_keys.xml
+++ b/app/src/main/res/values/preference_keys.xml
@@ -43,5 +43,10 @@
pref_key_show_site_exceptions
pref_key_recommended_settings
pref_key_custom_settings
+ pref_key_phone_feature_camera
+ pref_key_phone_feature_location
+ pref_key_phone_feature_microphone
+ pref_key_phone_feature_notification
+ pref_key_category_phone_feature
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 01430014b..381ea5c29 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -137,6 +137,18 @@
Blocked\n Ads, autoplay sound and video (block playing media with sound), cookies (block third-party trackers cookies), trackers (allow some trackers), pop-up, website redirects. \n\n Ask to allow \n Camera, location, microphone and notification. \n\n Allowed \n DRM audio and video, JavaScript, cache and site data, images.
Use custom settings
+
+ Phone Feature
+
+ Camera
+
+ Microphone
+
+ Location
+
+ Notification
+
+ Ask to allow
diff --git a/app/src/main/res/xml/site_permissions_preferences.xml b/app/src/main/res/xml/site_permissions_preferences.xml
index 6ecc38e90..547baf155 100644
--- a/app/src/main/res/xml/site_permissions_preferences.xml
+++ b/app/src/main/res/xml/site_permissions_preferences.xml
@@ -28,4 +28,36 @@
android:title="@string/preference_custom_settings"
android:defaultValue="false"/>
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file