Skip to content

Commit

Permalink
Point at the replaced addon component classes
Browse files Browse the repository at this point in the history
  • Loading branch information
interfect committed Aug 29, 2020
1 parent 18dc288 commit 06921f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ 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 network.novak.fenix.components.PagedAddonsManagerAdapter
import network.novak.fenix.components.PagedAddonInstallationDialogFragment
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
Expand All @@ -47,7 +49,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
* Whether or not an add-on installation is in progress.
*/
private var isInstallationInProgress = false
private var adapter: AddonsManagerAdapter? = null
private var adapter: PagedAddonsManagerAdapter? = null

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand Down Expand Up @@ -87,7 +89,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
lifecycleScope.launch(Dispatchers.Main) {
runIfFragmentIsAttached {
if (!shouldRefresh) {
adapter = AddonsManagerAdapter(
adapter = PagedAddonsManagerAdapter(
requireContext().components.addonCollectionProvider,
managementView,
addons,
Expand Down Expand Up @@ -120,8 +122,8 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
}
}

private fun createAddonStyle(context: Context): AddonsManagerAdapter.Style {
return AddonsManagerAdapter.Style(
private fun createAddonStyle(context: Context): PagedAddonsManagerAdapter.Style {
return PagedAddonsManagerAdapter.Style(
sectionsTextColor = ThemeManager.resolveAttribute(R.attr.primaryText, context),
addonNameTextColor = ThemeManager.resolveAttribute(R.attr.primaryText, context),
addonSummaryTextColor = ThemeManager.resolveAttribute(R.attr.secondaryText, context),
Expand All @@ -140,7 +142,7 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)

private fun hasExistingAddonInstallationDialogFragment(): Boolean {
return parentFragmentManager.findFragmentByTag(INSTALLATION_DIALOG_FRAGMENT_TAG)
as? AddonInstallationDialogFragment != null
as? PagedAddonInstallationDialogFragment != null
}

private fun showPermissionDialog(addon: Addon) {
Expand Down Expand Up @@ -171,10 +173,10 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management)
requireComponents.analytics.metrics.track(Event.AddonInstalled(addon.id))
val addonCollectionProvider = requireContext().components.addonCollectionProvider

val dialog = AddonInstallationDialogFragment.newInstance(
val dialog = PagedAddonInstallationDialogFragment.newInstance(
addon = addon,
addonCollectionProvider = addonCollectionProvider,
promptsStyling = AddonInstallationDialogFragment.PromptsStyling(
promptsStyling = PagedAddonInstallationDialogFragment.PromptsStyling(
gravity = Gravity.BOTTOM,
shouldWidthMatchParent = true,
confirmButtonBackgroundColor = ThemeManager.resolveAttribute(
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/org/mozilla/fenix/components/Components.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import android.content.Intent
import androidx.core.content.getSystemService
import androidx.core.net.toUri
import mozilla.components.feature.addons.AddonManager
import mozilla.components.feature.addons.AddonsProvider
import mozilla.components.feature.addons.amo.AddonCollectionProvider
import mozilla.components.feature.addons.migration.DefaultSupportedAddonsChecker
import mozilla.components.feature.addons.migration.SupportedAddonsChecker
import mozilla.components.feature.addons.update.AddonUpdater
import mozilla.components.feature.addons.update.DefaultAddonUpdater
import mozilla.components.lib.publicsuffixlist.PublicSuffixList
import mozilla.components.support.migration.state.MigrationStore
import network.novak.fenix.components.PagedAddonCollectionProvider
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.components.metrics.AppStartupTelemetry
Expand Down Expand Up @@ -72,15 +74,15 @@ class Components(private val context: Context) {

val addonCollectionProvider by lazy {
if (!BuildConfig.AMO_COLLECTION.isNullOrEmpty()) {
AddonCollectionProvider(
PagedAddonCollectionProvider(
context,
core.client,
collectionAccount = BuildConfig.AMO_ACCOUNT,
collectionName = BuildConfig.AMO_COLLECTION,
maxCacheAgeInMinutes = DAY_IN_MINUTES
)
} else {
AddonCollectionProvider(context, core.client, maxCacheAgeInMinutes = DAY_IN_MINUTES)
PagedAddonCollectionProvider(context, core.client, maxCacheAgeInMinutes = DAY_IN_MINUTES)
}
}

Expand Down

0 comments on commit 06921f2

Please sign in to comment.