diff --git a/android-components/components/feature/addons/src/main/res/values/strings.xml b/android-components/components/feature/addons/src/main/res/values/strings.xml
index 152fe15deef2..d767e75d74ff 100644
--- a/android-components/components/feature/addons/src/main/res/values/strings.xml
+++ b/android-components/components/feature/addons/src/main/res/values/strings.xml
@@ -96,7 +96,7 @@
On
- Off
+ Off
Allow in private browsing
@@ -106,7 +106,7 @@
Enabled
- Disabled
+ Disabled
Installed
diff --git a/android-components/samples/browser/src/main/java/org/mozilla/samples/browser/addons/InstalledAddonDetailsActivity.kt b/android-components/samples/browser/src/main/java/org/mozilla/samples/browser/addons/InstalledAddonDetailsActivity.kt
index 2da1923921bc..e029ace967eb 100644
--- a/android-components/samples/browser/src/main/java/org/mozilla/samples/browser/addons/InstalledAddonDetailsActivity.kt
+++ b/android-components/samples/browser/src/main/java/org/mozilla/samples/browser/addons/InstalledAddonDetailsActivity.kt
@@ -81,13 +81,13 @@ class InstalledAddonDetailsActivity : AppCompatActivity() {
private fun bindEnableSwitch(addon: Addon) {
val switch = findViewById(R.id.enable_switch)
- switch.setState(addon.isEnabled())
+ switch.isChecked = addon.isEnabled()
switch.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) {
this.components.addonManager.enableAddon(
addon,
onSuccess = {
- switch.setState(true)
+ switch.isChecked = true
showAddonToast(
addonsR.string.mozac_feature_addons_successfully_enabled,
addon,
@@ -104,7 +104,7 @@ class InstalledAddonDetailsActivity : AppCompatActivity() {
this.components.addonManager.disableAddon(
addon,
onSuccess = {
- switch.setState(false)
+ switch.isChecked = false
showAddonToast(
addonsR.string.mozac_feature_addons_successfully_disabled,
addon,
@@ -197,14 +197,4 @@ class InstalledAddonDetailsActivity : AppCompatActivity() {
Toast.LENGTH_SHORT,
).show()
}
-
- private fun SwitchCompat.setState(checked: Boolean) {
- val text = if (checked) {
- addonsR.string.mozac_feature_addons_enabled
- } else {
- addonsR.string.mozac_feature_addons_disabled
- }
- setText(text)
- isChecked = checked
- }
}
diff --git a/android-components/samples/browser/src/main/res/layout/activity_installed_add_on_details.xml b/android-components/samples/browser/src/main/res/layout/activity_installed_add_on_details.xml
index 1ef10e051f82..1c713c13b307 100644
--- a/android-components/samples/browser/src/main/res/layout/activity_installed_add_on_details.xml
+++ b/android-components/samples/browser/src/main/res/layout/activity_installed_add_on_details.xml
@@ -24,7 +24,7 @@
android:checked="true"
android:clickable="true"
android:focusable="true"
- android:text="@string/mozac_feature_addons_settings_off"
+ android:text="@string/mozac_feature_addons_enabled"
android:padding="16dp"
android:textSize="18sp"/>
diff --git a/fenix/app/src/main/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragment.kt b/fenix/app/src/main/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragment.kt
index f5a873c36738..f99c24b45578 100644
--- a/fenix/app/src/main/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragment.kt
+++ b/fenix/app/src/main/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragment.kt
@@ -15,7 +15,6 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.Navigation
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
-import com.google.android.material.switchmaterial.SwitchMaterial
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import mozilla.components.concept.engine.webextension.EnableSource
@@ -140,7 +139,7 @@ class InstalledAddonDetailsFragment : Fragment() {
internal fun bindEnableSwitch() {
val switch = provideEnableSwitch()
val privateBrowsingSwitch = providePrivateBrowsingSwitch()
- switch.setState(addon.isEnabled())
+ switch.isChecked = addon.isEnabled()
// When the ad-on is blocklisted or not correctly signed, we do not want to enable the toggle switch
// because users shouldn't be able to re-enable an add-on in this state.
if (
@@ -162,7 +161,6 @@ class InstalledAddonDetailsFragment : Fragment() {
runIfFragmentIsAttached {
this.addon = it
switch.isClickable = true
- switch.setText(R.string.mozac_feature_addons_enabled)
privateBrowsingSwitch.isVisible = it.isEnabled()
privateBrowsingSwitch.isChecked =
it.incognito != Addon.Incognito.NOT_ALLOWED && it.isAllowedInPrivateBrowsing()
@@ -183,7 +181,7 @@ class InstalledAddonDetailsFragment : Fragment() {
runIfFragmentIsAttached {
switch.isClickable = true
enableButtons()
- switch.setState(addon.isEnabled())
+ switch.isChecked = addon.isEnabled()
context?.let {
showSnackBar(
binding.root,
@@ -204,7 +202,6 @@ class InstalledAddonDetailsFragment : Fragment() {
runIfFragmentIsAttached {
this.addon = it
switch.isClickable = true
- switch.setText(R.string.mozac_feature_addons_disabled)
privateBrowsingSwitch.isVisible = it.isEnabled()
enableButtons()
context?.let {
@@ -221,7 +218,7 @@ class InstalledAddonDetailsFragment : Fragment() {
onError = {
runIfFragmentIsAttached {
switch.isClickable = true
- switch.setState(addon.isEnabled())
+ switch.isChecked = addon.isEnabled()
enableButtons()
context?.let {
showSnackBar(
@@ -424,15 +421,5 @@ class InstalledAddonDetailsFragment : Fragment() {
binding.reportAddOn.isEnabled = false
}
- private fun SwitchMaterial.setState(checked: Boolean) {
- val text = if (checked) {
- R.string.mozac_feature_addons_enabled
- } else {
- R.string.mozac_feature_addons_disabled
- }
- setText(text)
- isChecked = checked
- }
-
private fun shouldSettingsBeVisible() = !addon.installedState?.optionsPageUrl.isNullOrEmpty()
}