From a187db5288ecb621b2442378c068d685aec1ed2a Mon Sep 17 00:00:00 2001 From: rahulsainani Date: Mon, 20 Feb 2023 15:05:26 +0530 Subject: [PATCH] Bug 1817726 - Add Recents url sharing --- app/src/main/java/org/mozilla/fenix/HomeActivity.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt index 574970ca6a..7f4de4949f 100644 --- a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -4,11 +4,13 @@ package org.mozilla.fenix +import android.app.assist.AssistContent import android.content.Context import android.content.Intent import android.content.Intent.ACTION_MAIN import android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT import android.content.res.Configuration +import android.net.Uri import android.os.Build import android.os.Bundle import android.os.StrictMode @@ -25,6 +27,7 @@ import android.view.ViewConfiguration import android.view.WindowManager.LayoutParams.FLAG_SECURE import androidx.annotation.CallSuper import androidx.annotation.IdRes +import androidx.annotation.RequiresApi import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting.Companion.PROTECTED import androidx.appcompat.app.ActionBar @@ -46,6 +49,7 @@ import mozilla.components.browser.state.action.ContentAction import mozilla.components.browser.state.action.SearchAction import mozilla.components.browser.state.search.SearchEngine import mozilla.components.browser.state.selector.getNormalOrPrivateTabs +import mozilla.components.browser.state.selector.selectedTab import mozilla.components.browser.state.state.SessionState import mozilla.components.browser.state.state.WebExtensionState import mozilla.components.concept.engine.EngineSession @@ -523,6 +527,13 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { BrowsersCache.resetAll() } + @RequiresApi(Build.VERSION_CODES.M) + override fun onProvideAssistContent(outContent: AssistContent?) { + super.onProvideAssistContent(outContent) + val currentTabUrl = components.core.store.state.selectedTab?.content?.url + outContent?.webUri = currentTabUrl?.let { Uri.parse(it) } + } + private fun getBookmarkCount(node: BookmarkNode): Int { val children = node.children return if (children == null) {