Fix add-on translation braking changes

upstream-sync
Arturo Mejia 4 years ago
parent b8fff8cef1
commit 0ae0b89d65

@ -16,7 +16,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import mozilla.components.feature.addons.Addon import mozilla.components.feature.addons.Addon
import mozilla.components.feature.addons.ui.showInformationDialog 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 mozilla.components.feature.addons.update.DefaultAddonUpdater.UpdateAttemptStorage
import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.HomeActivity 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?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
showToolbar(title = args.addon.translatedName) context?.let {
showToolbar(title = args.addon.translateName(it))
}
AddonDetailsView(view, interactor = this).bind(args.addon) AddonDetailsView(view, interactor = this).bind(args.addon)
} }

@ -16,7 +16,7 @@ import androidx.core.text.getSpans
import kotlinx.android.extensions.LayoutContainer import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.fragment_add_on_details.* import kotlinx.android.synthetic.main.fragment_add_on_details.*
import mozilla.components.feature.addons.Addon 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 mozilla.components.feature.addons.ui.updatedAtDate
import org.mozilla.fenix.R import org.mozilla.fenix.R
import java.text.DateFormat import java.text.DateFormat
@ -100,7 +100,7 @@ class AddonDetailsView(
} }
private fun bindDetails(addon: Addon) { private fun bindDetails(addon: Addon) {
val detailsText = addon.translatedDescription val detailsText = addon.translateDescription(containerView.context)
val parsedText = detailsText.replace("\n", "<br/>") val parsedText = detailsText.replace("\n", "<br/>")
val text = HtmlCompat.fromHtml(parsedText, HtmlCompat.FROM_HTML_MODE_COMPACT) 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.findNavController
import androidx.navigation.fragment.navArgs import androidx.navigation.fragment.navArgs
import kotlinx.android.synthetic.main.fragment_add_on_internal_settings.* 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.R
import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.ext.showToolbar
@ -33,7 +33,9 @@ class AddonInternalSettingsFragment : AddonPopupBaseFragment() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
showToolbar(args.addon.translatedName) context?.let {
showToolbar(args.addon.translateName(it))
}
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

@ -9,7 +9,7 @@ import android.os.Bundle
import android.view.View import android.view.View
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.navArgs 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.BrowserDirection
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R 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?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
showToolbar(args.addon.translatedName) context?.let {
showToolbar(args.addon.translateName(it))
}
AddonPermissionsDetailsView(view, interactor = this).bind(args.addon) 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.AddonInstallationDialogFragment
import mozilla.components.feature.addons.ui.AddonsManagerAdapter import mozilla.components.feature.addons.ui.AddonsManagerAdapter
import mozilla.components.feature.addons.ui.PermissionsDialogFragment 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.R
import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
@ -230,13 +230,15 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
// No need to display an error message if installation was cancelled by the user. // No need to display an error message if installation was cancelled by the user.
if (e !is CancellationException) { if (e !is CancellationException) {
val rootView = activity?.getRootView() ?: view val rootView = activity?.getRootView() ?: view
showSnackBar( context?.let {
rootView, showSnackBar(
getString( rootView,
R.string.mozac_feature_addons_failed_to_install, getString(
addon.translatedName R.string.mozac_feature_addons_failed_to_install,
addon.translateName(it)
)
) )
) }
} }
addonProgressOverlay?.visibility = View.GONE addonProgressOverlay?.visibility = View.GONE
isInstallationInProgress = false isInstallationInProgress = false

@ -20,7 +20,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import mozilla.components.feature.addons.Addon import mozilla.components.feature.addons.Addon
import mozilla.components.feature.addons.AddonManagerException 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.HomeActivity
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
@ -85,7 +85,7 @@ class InstalledAddonDetailsFragment : Fragment() {
} }
private fun bindUI(view: View) { private fun bindUI(view: View) {
val title = addon.translatedName val title = addon.translateName(view.context)
showToolbar(title) showToolbar(title)
bindEnableSwitch(view) bindEnableSwitch(view)
@ -117,13 +117,15 @@ class InstalledAddonDetailsFragment : Fragment() {
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
showSnackBar( context?.let {
view, showSnackBar(
getString( view,
R.string.mozac_feature_addons_successfully_enabled, getString(
addon.translatedName R.string.mozac_feature_addons_successfully_enabled,
addon.translateName(it)
)
) )
) }
} }
}, },
onError = { onError = {
@ -131,13 +133,15 @@ class InstalledAddonDetailsFragment : Fragment() {
switch.isClickable = true switch.isClickable = true
view.remove_add_on.isEnabled = true view.remove_add_on.isEnabled = true
switch.setState(addon.isEnabled()) switch.setState(addon.isEnabled())
showSnackBar( context?.let {
view, showSnackBar(
getString( view,
R.string.mozac_feature_addons_failed_to_enable, getString(
addon.translatedName R.string.mozac_feature_addons_failed_to_enable,
addon.translateName(it)
)
) )
) }
} }
} }
) )
@ -152,13 +156,15 @@ class InstalledAddonDetailsFragment : Fragment() {
privateBrowsingSwitch.isVisible = it.isEnabled() 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
showSnackBar( context?.let {
view, showSnackBar(
getString( view,
R.string.mozac_feature_addons_successfully_disabled, getString(
addon.translatedName R.string.mozac_feature_addons_successfully_disabled,
addon.translateName(it)
)
) )
) }
} }
}, },
onError = { onError = {
@ -167,13 +173,15 @@ class InstalledAddonDetailsFragment : Fragment() {
privateBrowsingSwitch.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( context?.let {
view, showSnackBar(
getString( view,
R.string.mozac_feature_addons_failed_to_disable, getString(
addon.translatedName R.string.mozac_feature_addons_failed_to_disable,
addon.translateName(it)
)
) )
) }
} }
} }
) )
@ -263,26 +271,30 @@ class InstalledAddonDetailsFragment : Fragment() {
onSuccess = { onSuccess = {
runIfFragmentIsAttached { runIfFragmentIsAttached {
setAllInteractiveViewsClickable(view, true) setAllInteractiveViewsClickable(view, true)
showSnackBar( context?.let {
view, showSnackBar(
getString( view,
R.string.mozac_feature_addons_successfully_uninstalled, getString(
addon.translatedName R.string.mozac_feature_addons_successfully_uninstalled,
addon.translateName(it)
)
) )
) }
view.findNavController().popBackStack() view.findNavController().popBackStack()
} }
}, },
onError = { _, _ -> onError = { _, _ ->
runIfFragmentIsAttached { runIfFragmentIsAttached {
setAllInteractiveViewsClickable(view, true) setAllInteractiveViewsClickable(view, true)
showSnackBar( context?.let {
view, showSnackBar(
getString( view,
R.string.mozac_feature_addons_failed_to_uninstall, getString(
addon.translatedName R.string.mozac_feature_addons_failed_to_uninstall,
addon.translateName(it)
)
) )
) }
} }
} }
) )

Loading…
Cancel
Save