mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-02 03:40:16 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/10195, https://github.com/mozilla-mobile/fenix/issues/10196: Allow private browsing mode switch to sync with enable state
This commit is contained in:
parent
66a7cfb692
commit
6fbf233d88
@ -88,10 +88,12 @@ class InstalledAddonDetailsFragment : Fragment() {
|
|||||||
@SuppressWarnings("LongMethod")
|
@SuppressWarnings("LongMethod")
|
||||||
private fun bindEnableSwitch(view: View) {
|
private fun bindEnableSwitch(view: View) {
|
||||||
val switch = view.enable_switch
|
val switch = view.enable_switch
|
||||||
|
val privateBrowsingSwitch = view.allow_in_private_browsing_switch
|
||||||
switch.setState(addon.isEnabled())
|
switch.setState(addon.isEnabled())
|
||||||
switch.setOnCheckedChangeListener { v, isChecked ->
|
switch.setOnCheckedChangeListener { v, isChecked ->
|
||||||
val addonManager = v.context.components.addonManager
|
val addonManager = v.context.components.addonManager
|
||||||
switch.isClickable = false
|
switch.isClickable = false
|
||||||
|
privateBrowsingSwitch.isClickable = false
|
||||||
view.remove_add_on.isEnabled = false
|
view.remove_add_on.isEnabled = false
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
addonManager.enableAddon(
|
addonManager.enableAddon(
|
||||||
@ -100,6 +102,9 @@ class InstalledAddonDetailsFragment : Fragment() {
|
|||||||
runIfFragmentIsAttached {
|
runIfFragmentIsAttached {
|
||||||
this.addon = it
|
this.addon = it
|
||||||
switch.isClickable = true
|
switch.isClickable = true
|
||||||
|
privateBrowsingSwitch.isChecked = it.isAllowedInPrivateBrowsing()
|
||||||
|
privateBrowsingSwitch.isClickable = it.isAllowedInPrivateBrowsing()
|
||||||
|
privateBrowsingSwitch.isVisible = it.isEnabled()
|
||||||
switch.setText(R.string.mozac_feature_addons_enabled)
|
switch.setText(R.string.mozac_feature_addons_enabled)
|
||||||
view.settings.isVisible = shouldSettingsBeVisible()
|
view.settings.isVisible = shouldSettingsBeVisible()
|
||||||
view.remove_add_on.isEnabled = true
|
view.remove_add_on.isEnabled = true
|
||||||
@ -115,6 +120,7 @@ class InstalledAddonDetailsFragment : Fragment() {
|
|||||||
onError = {
|
onError = {
|
||||||
runIfFragmentIsAttached {
|
runIfFragmentIsAttached {
|
||||||
switch.isClickable = true
|
switch.isClickable = true
|
||||||
|
privateBrowsingSwitch.isClickable = true
|
||||||
view.remove_add_on.isEnabled = true
|
view.remove_add_on.isEnabled = true
|
||||||
switch.setState(addon.isEnabled())
|
switch.setState(addon.isEnabled())
|
||||||
showSnackBar(
|
showSnackBar(
|
||||||
@ -133,10 +139,12 @@ class InstalledAddonDetailsFragment : Fragment() {
|
|||||||
addon,
|
addon,
|
||||||
onSuccess = {
|
onSuccess = {
|
||||||
runIfFragmentIsAttached {
|
runIfFragmentIsAttached {
|
||||||
|
this.addon = it
|
||||||
switch.isClickable = true
|
switch.isClickable = true
|
||||||
|
privateBrowsingSwitch.isClickable = true
|
||||||
|
privateBrowsingSwitch.isVisible = it.isEnabled()
|
||||||
switch.setText(R.string.mozac_feature_addons_disabled)
|
switch.setText(R.string.mozac_feature_addons_disabled)
|
||||||
view.remove_add_on.isEnabled = true
|
view.remove_add_on.isEnabled = true
|
||||||
this.addon = it
|
|
||||||
showSnackBar(
|
showSnackBar(
|
||||||
view,
|
view,
|
||||||
getString(
|
getString(
|
||||||
@ -149,6 +157,7 @@ class InstalledAddonDetailsFragment : Fragment() {
|
|||||||
onError = {
|
onError = {
|
||||||
runIfFragmentIsAttached {
|
runIfFragmentIsAttached {
|
||||||
switch.isClickable = true
|
switch.isClickable = true
|
||||||
|
privateBrowsingSwitch.isClickable = true
|
||||||
view.remove_add_on.isEnabled = true
|
view.remove_add_on.isEnabled = true
|
||||||
switch.setState(addon.isEnabled())
|
switch.setState(addon.isEnabled())
|
||||||
showSnackBar(
|
showSnackBar(
|
||||||
@ -216,10 +225,13 @@ class InstalledAddonDetailsFragment : Fragment() {
|
|||||||
|
|
||||||
private fun bindAllowInPrivateBrowsingSwitch(view: View) {
|
private fun bindAllowInPrivateBrowsingSwitch(view: View) {
|
||||||
val switch = view.allow_in_private_browsing_switch
|
val switch = view.allow_in_private_browsing_switch
|
||||||
|
val enableSwitch = view.enable_switch
|
||||||
switch.isChecked = addon.isAllowedInPrivateBrowsing()
|
switch.isChecked = addon.isAllowedInPrivateBrowsing()
|
||||||
|
switch.isVisible = addon.isEnabled()
|
||||||
switch.setOnCheckedChangeListener { v, isChecked ->
|
switch.setOnCheckedChangeListener { v, isChecked ->
|
||||||
val addonManager = v.context.components.addonManager
|
val addonManager = v.context.components.addonManager
|
||||||
switch.isClickable = false
|
switch.isClickable = false
|
||||||
|
enableSwitch.isClickable = false
|
||||||
view.remove_add_on.isEnabled = false
|
view.remove_add_on.isEnabled = false
|
||||||
addonManager.setAddonAllowedInPrivateBrowsing(
|
addonManager.setAddonAllowedInPrivateBrowsing(
|
||||||
addon,
|
addon,
|
||||||
@ -228,13 +240,15 @@ class InstalledAddonDetailsFragment : Fragment() {
|
|||||||
runIfFragmentIsAttached {
|
runIfFragmentIsAttached {
|
||||||
this.addon = it
|
this.addon = it
|
||||||
switch.isClickable = true
|
switch.isClickable = true
|
||||||
|
enableSwitch.isClickable = true
|
||||||
view.remove_add_on.isEnabled = true
|
view.remove_add_on.isEnabled = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError = {
|
onError = {
|
||||||
switch.isChecked = addon.isAllowedInPrivateBrowsing()
|
|
||||||
runIfFragmentIsAttached {
|
runIfFragmentIsAttached {
|
||||||
|
switch.isChecked = addon.isAllowedInPrivateBrowsing()
|
||||||
switch.isClickable = true
|
switch.isClickable = true
|
||||||
|
enableSwitch.isClickable = true
|
||||||
view.remove_add_on.isEnabled = true
|
view.remove_add_on.isEnabled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user