For #8202: Remove settings if add-on disabled
- Also fixes the crash described in #8202.
This commit is contained in:
parent
8a92e15667
commit
142104dc86
|
@ -9,9 +9,11 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Switch
|
import android.widget.Switch
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
|
import kotlinx.android.synthetic.main.activity_addons.view.*
|
||||||
import kotlinx.android.synthetic.main.fragment_installed_add_on_details.view.*
|
import kotlinx.android.synthetic.main.fragment_installed_add_on_details.view.*
|
||||||
import mozilla.components.feature.addons.Addon
|
import mozilla.components.feature.addons.Addon
|
||||||
import mozilla.components.feature.addons.ui.translate
|
import mozilla.components.feature.addons.ui.translate
|
||||||
|
@ -64,6 +66,7 @@ class InstalledAddonDetailsFragment : Fragment() {
|
||||||
runIfFragmentIsAttached {
|
runIfFragmentIsAttached {
|
||||||
switch.isClickable = true
|
switch.isClickable = true
|
||||||
switch.setText(R.string.mozac_feature_addons_settings_on)
|
switch.setText(R.string.mozac_feature_addons_settings_on)
|
||||||
|
view.settings.isVisible = true
|
||||||
this.addon = it
|
this.addon = it
|
||||||
showSnackBar(
|
showSnackBar(
|
||||||
view,
|
view,
|
||||||
|
@ -94,6 +97,7 @@ class InstalledAddonDetailsFragment : Fragment() {
|
||||||
runIfFragmentIsAttached {
|
runIfFragmentIsAttached {
|
||||||
switch.isClickable = true
|
switch.isClickable = true
|
||||||
switch.setText(R.string.mozac_feature_addons_settings_off)
|
switch.setText(R.string.mozac_feature_addons_settings_off)
|
||||||
|
view.settings.isVisible = false
|
||||||
this.addon = it
|
this.addon = it
|
||||||
showSnackBar(
|
showSnackBar(
|
||||||
view,
|
view,
|
||||||
|
@ -123,7 +127,7 @@ class InstalledAddonDetailsFragment : Fragment() {
|
||||||
|
|
||||||
private fun bindSettings(view: View) {
|
private fun bindSettings(view: View) {
|
||||||
view.settings.apply {
|
view.settings.apply {
|
||||||
isEnabled = addon.installedState?.optionsPageUrl != null
|
isVisible = !addon.installedState?.optionsPageUrl.isNullOrEmpty()
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
val directions =
|
val directions =
|
||||||
InstalledAddonDetailsFragmentDirections.actionInstalledAddonFragmentToAddonInternalSettingsFragment(
|
InstalledAddonDetailsFragmentDirections.actionInstalledAddonFragmentToAddonInternalSettingsFragment(
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
<!-- 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
|
- 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/. -->
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -79,4 +79,4 @@
|
||||||
android:text="@string/mozac_feature_addons_remove"
|
android:text="@string/mozac_feature_addons_remove"
|
||||||
android:textColor="@color/photonRed50" />
|
android:textColor="@color/photonRed50" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</ScrollView>
|
</FrameLayout>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user