From 40fc9c108531add956f925550073f82bb0a49e47 Mon Sep 17 00:00:00 2001 From: Mugurell Date: Fri, 15 Jan 2021 17:33:47 +0200 Subject: [PATCH] For #12414 - Support sharing images through ShareDownloadFeature Register a ViewBoundFeatureWrapper that will respond to "Share image" from the browser contextual menu --- .../mozilla/fenix/browser/BaseBrowserFragment.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt index 7aa83991e2..392dc54588 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -58,6 +58,7 @@ import mozilla.components.feature.contextmenu.ContextMenuCandidate import mozilla.components.feature.contextmenu.ContextMenuFeature import mozilla.components.feature.downloads.DownloadsFeature import mozilla.components.feature.downloads.manager.FetchDownloadManager +import mozilla.components.feature.downloads.share.ShareDownloadFeature import mozilla.components.feature.intent.ext.EXTRA_SESSION_ID import mozilla.components.feature.media.fullscreen.MediaSessionFullscreenFeature import mozilla.components.feature.privatemode.feature.SecureWindowFeature @@ -161,6 +162,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit private val sessionFeature = ViewBoundFeatureWrapper() private val contextMenuFeature = ViewBoundFeatureWrapper() private val downloadsFeature = ViewBoundFeatureWrapper() + private val shareDownloadsFeature = ViewBoundFeatureWrapper() private val appLinksFeature = ViewBoundFeatureWrapper() private val promptsFeature = ViewBoundFeatureWrapper() private val findInPageIntegration = ViewBoundFeatureWrapper() @@ -429,6 +431,13 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit ) } + val shareDownloadFeature = ShareDownloadFeature( + context = context.applicationContext, + httpClient = context.components.core.client, + store = store, + tabId = customTabSessionId + ) + val downloadFeature = DownloadsFeature( context.applicationContext, store = store, @@ -508,6 +517,12 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit store, view, context, toolbarHeight ) + shareDownloadsFeature.set( + shareDownloadFeature, + owner = this, + view = view + ) + downloadsFeature.set( downloadFeature, owner = this,