Closes #1429: Updated site permissions ui for MVP
parent
2f3d38b51f
commit
5b2417826e
|
@ -18,4 +18,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- #627 - Sets engine preferred color scheme based on light/dark theme
|
||||
- #904 - Added tab counter in browser toolbar
|
||||
### Changed
|
||||
- #1429 - Updated site permissions ui for MVP
|
||||
### Removed
|
|
@ -457,11 +457,8 @@ class BrowserFragment : Fragment(), BackHandler {
|
|||
private fun assignSitePermissionsRules() {
|
||||
val settings = Settings.getInstance(requireContext())
|
||||
|
||||
val rules: SitePermissionsRules = if (settings.shouldRecommendedSettingsBeActivated) {
|
||||
settings.getSitePermissionsRecommendedSettingsRules()
|
||||
} else {
|
||||
settings.getSitePermissionsCustomSettingsRules()
|
||||
}
|
||||
val rules: SitePermissionsRules = settings.getSitePermissionsCustomSettingsRules()
|
||||
|
||||
sitePermissionsFeature.withFeature {
|
||||
it.sitePermissionsRules = rules
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
package org.mozilla.fenix.settings
|
||||
|
||||
import android.os.Bundle
|
||||
import android.preference.PreferenceManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.Navigation
|
||||
import androidx.preference.Preference
|
||||
|
@ -21,10 +20,6 @@ import org.mozilla.fenix.utils.Settings
|
|||
@SuppressWarnings("TooManyFunctions")
|
||||
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).supportActionBar?.show()
|
||||
|
@ -41,49 +36,10 @@ class SitePermissionsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
private fun setupPreferences() {
|
||||
|
||||
bindRadioRecommendedSettings()
|
||||
|
||||
bindRadioCustomSettings()
|
||||
|
||||
bindCategoryPhoneFeatures()
|
||||
|
||||
setupRadioGroups()
|
||||
}
|
||||
|
||||
private fun setupRadioGroups() {
|
||||
radioRecommendSettings.addToRadioGroup(radioCustomSettings)
|
||||
radioCustomSettings.addToRadioGroup(radioRecommendSettings)
|
||||
}
|
||||
|
||||
private fun bindRadioCustomSettings() {
|
||||
val keyCustomSettings = getString(R.string.pref_key_custom_settings)
|
||||
radioCustomSettings = requireNotNull(findPreference(keyCustomSettings))
|
||||
|
||||
radioCustomSettings.onClickListener {
|
||||
categoryPhoneFeatures.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindRadioRecommendedSettings() {
|
||||
val keyRecommendSettings = getString(R.string.pref_key_recommended_settings)
|
||||
radioRecommendSettings = requireNotNull(findPreference(keyRecommendSettings))
|
||||
|
||||
radioRecommendSettings.onClickListener {
|
||||
categoryPhoneFeatures.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindCategoryPhoneFeatures() {
|
||||
val keyCategoryPhoneFeatures = getString(R.string.pref_key_category_phone_feature)
|
||||
|
||||
categoryPhoneFeatures = requireNotNull(findPreference(keyCategoryPhoneFeatures))
|
||||
|
||||
val isCategoryActivate = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
.getBoolean(radioCustomSettings.key, false)
|
||||
if (isCategoryActivate) {
|
||||
categoryPhoneFeatures.isVisible = true
|
||||
}
|
||||
|
||||
val settings = Settings.getInstance(requireContext())
|
||||
|
||||
val cameraAction = settings
|
||||
|
|
|
@ -55,9 +55,6 @@ class Settings private constructor(context: Context) {
|
|||
val shouldAutoBounceQuickActionSheet: Boolean
|
||||
get() = autoBounceQuickActionSheetCount < autoBounceMaximumCount
|
||||
|
||||
val shouldRecommendedSettingsBeActivated: Boolean
|
||||
get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_recommended_settings), true)
|
||||
|
||||
val shouldUseLightTheme: Boolean
|
||||
get() = preferences.getBoolean(
|
||||
appContext.getPreferenceKey(R.string.pref_key_light_theme),
|
||||
|
@ -117,12 +114,8 @@ class Settings private constructor(context: Context) {
|
|||
}
|
||||
|
||||
fun getSitePermissionsPhoneFeatureCameraAction(): SitePermissionsRules.Action {
|
||||
return if (shouldRecommendedSettingsBeActivated) {
|
||||
getSitePermissionsRecommendedSettingsRules().camera
|
||||
} else {
|
||||
preferences.getInt(appContext.getPreferenceKey(R.string.pref_key_phone_feature_camera), 1)
|
||||
.toSitePermissionsRulesAction()
|
||||
}
|
||||
return preferences.getInt(appContext.getPreferenceKey(R.string.pref_key_phone_feature_camera), 1)
|
||||
.toSitePermissionsRulesAction()
|
||||
}
|
||||
|
||||
fun setSitePermissionsPhoneFeatureMicrophoneAction(action: SitePermissionsRules.Action) {
|
||||
|
@ -132,12 +125,8 @@ class Settings private constructor(context: Context) {
|
|||
}
|
||||
|
||||
fun getSitePermissionsPhoneFeatureMicrophoneAction(): SitePermissionsRules.Action {
|
||||
return if (shouldRecommendedSettingsBeActivated) {
|
||||
getSitePermissionsRecommendedSettingsRules().microphone
|
||||
} else {
|
||||
preferences.getInt(appContext.getPreferenceKey(R.string.pref_key_phone_feature_microphone), 1)
|
||||
return preferences.getInt(appContext.getPreferenceKey(R.string.pref_key_phone_feature_microphone), 1)
|
||||
.toSitePermissionsRulesAction()
|
||||
}
|
||||
}
|
||||
|
||||
fun setSitePermissionsPhoneFeatureNotificationAction(action: SitePermissionsRules.Action) {
|
||||
|
@ -147,12 +136,8 @@ class Settings private constructor(context: Context) {
|
|||
}
|
||||
|
||||
fun getSitePermissionsPhoneFeatureNotificationAction(): SitePermissionsRules.Action {
|
||||
return if (shouldRecommendedSettingsBeActivated) {
|
||||
getSitePermissionsRecommendedSettingsRules().notification
|
||||
} else {
|
||||
return preferences.getInt(appContext.getPreferenceKey(R.string.pref_key_phone_feature_notification), 1)
|
||||
return preferences.getInt(appContext.getPreferenceKey(R.string.pref_key_phone_feature_notification), 1)
|
||||
.toSitePermissionsRulesAction()
|
||||
}
|
||||
}
|
||||
|
||||
fun setSitePermissionsPhoneFeatureLocation(action: SitePermissionsRules.Action) {
|
||||
|
@ -162,21 +147,10 @@ class Settings private constructor(context: Context) {
|
|||
}
|
||||
|
||||
fun getSitePermissionsPhoneFeatureLocation(): SitePermissionsRules.Action {
|
||||
return if (shouldRecommendedSettingsBeActivated) {
|
||||
getSitePermissionsRecommendedSettingsRules().location
|
||||
} else {
|
||||
preferences.getInt(appContext.getPreferenceKey(R.string.pref_key_phone_feature_location), 1)
|
||||
return preferences.getInt(appContext.getPreferenceKey(R.string.pref_key_phone_feature_location), 1)
|
||||
.toSitePermissionsRulesAction()
|
||||
}
|
||||
}
|
||||
|
||||
fun getSitePermissionsRecommendedSettingsRules() = SitePermissionsRules(
|
||||
camera = SitePermissionsRules.Action.ASK_TO_ALLOW,
|
||||
notification = SitePermissionsRules.Action.ASK_TO_ALLOW,
|
||||
location = SitePermissionsRules.Action.ASK_TO_ALLOW,
|
||||
microphone = SitePermissionsRules.Action.ASK_TO_ALLOW
|
||||
)
|
||||
|
||||
fun getSitePermissionsCustomSettingsRules(): SitePermissionsRules {
|
||||
return SitePermissionsRules(
|
||||
notification = getSitePermissionsPhoneFeatureNotificationAction(),
|
||||
|
|
|
@ -3,62 +3,34 @@
|
|||
- 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/. -->
|
||||
<androidx.preference.PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.preference.SwitchPreference
|
||||
android:icon="@drawable/ic_energy"
|
||||
android:key="@string/pref_key_optimize"
|
||||
android:title="@string/preference_optimize"
|
||||
android:summary="@string/preference_optimize_summary"
|
||||
android:defaultValue="false"/>
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<androidx.preference.Preference
|
||||
android:icon="@drawable/ic_internet"
|
||||
android:key="@string/pref_key_show_site_exceptions"
|
||||
android:title="@string/preference_exceptions"/>
|
||||
android:icon="@drawable/ic_internet"
|
||||
android:key="@string/pref_key_show_site_exceptions"
|
||||
android:title="@string/preference_exceptions"/>
|
||||
|
||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||
android:key="@string/pref_key_recommended_settings"
|
||||
android:title="@string/preference_recommended_settings"
|
||||
android:summary="@string/preference_recommended_settings_summary"
|
||||
android:defaultValue="true"/>
|
||||
|
||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||
android:key="@string/pref_key_custom_settings"
|
||||
android:title="@string/preference_custom_settings"
|
||||
android:defaultValue="false"/>
|
||||
|
||||
<androidx.preference.PreferenceCategory
|
||||
android:key="@string/pref_key_category_phone_feature"
|
||||
android:title="@string/preference_category_phone_feature"
|
||||
app:iconSpaceReserved="false"
|
||||
app:isPreferenceVisible="false">
|
||||
|
||||
<androidx.preference.Preference
|
||||
<androidx.preference.Preference
|
||||
android:icon="@drawable/ic_camera"
|
||||
android:key="@string/pref_key_phone_feature_camera"
|
||||
android:title="@string/preference_phone_feature_camera"
|
||||
android:summary="@string/preference_option_phone_feature_ask_to_allow"/>
|
||||
|
||||
<androidx.preference.Preference
|
||||
<androidx.preference.Preference
|
||||
android:icon="@drawable/ic_location"
|
||||
android:key="@string/pref_key_phone_feature_location"
|
||||
android:title="@string/preference_phone_feature_location"
|
||||
android:summary="@string/preference_option_phone_feature_ask_to_allow"/>
|
||||
|
||||
<androidx.preference.Preference
|
||||
<androidx.preference.Preference
|
||||
android:icon="@drawable/ic_microphone"
|
||||
android:key="@string/pref_key_phone_feature_microphone"
|
||||
android:title="@string/preference_phone_feature_microphone"
|
||||
android:summary="@string/preference_option_phone_feature_ask_to_allow"/>
|
||||
|
||||
<androidx.preference.Preference
|
||||
<androidx.preference.Preference
|
||||
android:icon="@drawable/ic_notification"
|
||||
android:key="@string/pref_key_phone_feature_notification"
|
||||
android:title="@string/preference_phone_feature_notification"
|
||||
android:summary="@string/preference_option_phone_feature_ask_to_allow"/>
|
||||
|
||||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
Reference in New Issue