mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] Fix add-on translation braking changes
This commit is contained in:
parent
a224f0c546
commit
d3faecd59c
@ -16,7 +16,7 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import mozilla.components.feature.addons.Addon
|
||||
import mozilla.components.feature.addons.ui.showInformationDialog
|
||||
import mozilla.components.feature.addons.ui.translatedName
|
||||
import mozilla.components.feature.addons.ui.translateName
|
||||
import mozilla.components.feature.addons.update.DefaultAddonUpdater.UpdateAttemptStorage
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
@ -34,7 +34,10 @@ class AddonDetailsFragment : Fragment(R.layout.fragment_add_on_details), AddonDe
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
showToolbar(title = args.addon.translatedName)
|
||||
context?.let {
|
||||
showToolbar(title = args.addon.translateName(it))
|
||||
}
|
||||
|
||||
AddonDetailsView(view, interactor = this).bind(args.addon)
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ import androidx.core.text.getSpans
|
||||
import kotlinx.android.extensions.LayoutContainer
|
||||
import kotlinx.android.synthetic.main.fragment_add_on_details.*
|
||||
import mozilla.components.feature.addons.Addon
|
||||
import mozilla.components.feature.addons.ui.translatedDescription
|
||||
import mozilla.components.feature.addons.ui.translateDescription
|
||||
import mozilla.components.feature.addons.ui.updatedAtDate
|
||||
import org.mozilla.fenix.R
|
||||
import java.text.DateFormat
|
||||
@ -100,7 +100,7 @@ class AddonDetailsView(
|
||||
}
|
||||
|
||||
private fun bindDetails(addon: Addon) {
|
||||
val detailsText = addon.translatedDescription
|
||||
val detailsText = addon.translateDescription(containerView.context)
|
||||
|
||||
val parsedText = detailsText.replace("\n", "<br/>")
|
||||
val text = HtmlCompat.fromHtml(parsedText, HtmlCompat.FROM_HTML_MODE_COMPACT)
|
||||
|
@ -11,7 +11,7 @@ import android.view.ViewGroup
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import kotlinx.android.synthetic.main.fragment_add_on_internal_settings.*
|
||||
import mozilla.components.feature.addons.ui.translatedName
|
||||
import mozilla.components.feature.addons.ui.translateName
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.showToolbar
|
||||
|
||||
@ -33,7 +33,9 @@ class AddonInternalSettingsFragment : AddonPopupBaseFragment() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
showToolbar(args.addon.translatedName)
|
||||
context?.let {
|
||||
showToolbar(args.addon.translateName(it))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -9,7 +9,7 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import mozilla.components.feature.addons.ui.translatedName
|
||||
import mozilla.components.feature.addons.ui.translateName
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
@ -25,7 +25,9 @@ class AddonPermissionsDetailsFragment : Fragment(R.layout.fragment_add_on_permis
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
showToolbar(args.addon.translatedName)
|
||||
context?.let {
|
||||
showToolbar(args.addon.translateName(it))
|
||||
}
|
||||
AddonPermissionsDetailsView(view, interactor = this).bind(args.addon)
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ import mozilla.components.feature.addons.AddonManagerException
|
||||
import mozilla.components.feature.addons.ui.AddonInstallationDialogFragment
|
||||
import mozilla.components.feature.addons.ui.AddonsManagerAdapter
|
||||
import mozilla.components.feature.addons.ui.PermissionsDialogFragment
|
||||
import mozilla.components.feature.addons.ui.translatedName
|
||||
import mozilla.components.feature.addons.ui.translateName
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.ext.components
|
||||
@ -230,14 +230,16 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
|
||||
// No need to display an error message if installation was cancelled by the user.
|
||||
if (e !is CancellationException) {
|
||||
val rootView = activity?.getRootView() ?: view
|
||||
context?.let {
|
||||
showSnackBar(
|
||||
rootView,
|
||||
getString(
|
||||
R.string.mozac_feature_addons_failed_to_install,
|
||||
addon.translatedName
|
||||
addon.translateName(it)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
addonProgressOverlay?.visibility = View.GONE
|
||||
isInstallationInProgress = false
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import mozilla.components.feature.addons.Addon
|
||||
import mozilla.components.feature.addons.AddonManagerException
|
||||
import mozilla.components.feature.addons.ui.translatedName
|
||||
import mozilla.components.feature.addons.ui.translateName
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.components
|
||||
@ -85,7 +85,7 @@ class InstalledAddonDetailsFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun bindUI(view: View) {
|
||||
val title = addon.translatedName
|
||||
val title = addon.translateName(view.context)
|
||||
showToolbar(title)
|
||||
|
||||
bindEnableSwitch(view)
|
||||
@ -117,29 +117,33 @@ class InstalledAddonDetailsFragment : Fragment() {
|
||||
switch.setText(R.string.mozac_feature_addons_enabled)
|
||||
view.settings.isVisible = shouldSettingsBeVisible()
|
||||
view.remove_add_on.isEnabled = true
|
||||
context?.let {
|
||||
showSnackBar(
|
||||
view,
|
||||
getString(
|
||||
R.string.mozac_feature_addons_successfully_enabled,
|
||||
addon.translatedName
|
||||
addon.translateName(it)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
onError = {
|
||||
runIfFragmentIsAttached {
|
||||
switch.isClickable = true
|
||||
view.remove_add_on.isEnabled = true
|
||||
switch.setState(addon.isEnabled())
|
||||
context?.let {
|
||||
showSnackBar(
|
||||
view,
|
||||
getString(
|
||||
R.string.mozac_feature_addons_failed_to_enable,
|
||||
addon.translatedName
|
||||
addon.translateName(it)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
view.settings.isVisible = false
|
||||
@ -152,14 +156,16 @@ class InstalledAddonDetailsFragment : Fragment() {
|
||||
privateBrowsingSwitch.isVisible = it.isEnabled()
|
||||
switch.setText(R.string.mozac_feature_addons_disabled)
|
||||
view.remove_add_on.isEnabled = true
|
||||
context?.let {
|
||||
showSnackBar(
|
||||
view,
|
||||
getString(
|
||||
R.string.mozac_feature_addons_successfully_disabled,
|
||||
addon.translatedName
|
||||
addon.translateName(it)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
onError = {
|
||||
runIfFragmentIsAttached {
|
||||
@ -167,15 +173,17 @@ class InstalledAddonDetailsFragment : Fragment() {
|
||||
privateBrowsingSwitch.isClickable = true
|
||||
view.remove_add_on.isEnabled = true
|
||||
switch.setState(addon.isEnabled())
|
||||
context?.let {
|
||||
showSnackBar(
|
||||
view,
|
||||
getString(
|
||||
R.string.mozac_feature_addons_failed_to_disable,
|
||||
addon.translatedName
|
||||
addon.translateName(it)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -263,28 +271,32 @@ class InstalledAddonDetailsFragment : Fragment() {
|
||||
onSuccess = {
|
||||
runIfFragmentIsAttached {
|
||||
setAllInteractiveViewsClickable(view, true)
|
||||
context?.let {
|
||||
showSnackBar(
|
||||
view,
|
||||
getString(
|
||||
R.string.mozac_feature_addons_successfully_uninstalled,
|
||||
addon.translatedName
|
||||
addon.translateName(it)
|
||||
)
|
||||
)
|
||||
}
|
||||
view.findNavController().popBackStack()
|
||||
}
|
||||
},
|
||||
onError = { _, _ ->
|
||||
runIfFragmentIsAttached {
|
||||
setAllInteractiveViewsClickable(view, true)
|
||||
context?.let {
|
||||
showSnackBar(
|
||||
view,
|
||||
getString(
|
||||
R.string.mozac_feature_addons_failed_to_uninstall,
|
||||
addon.translatedName
|
||||
addon.translateName(it)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user