everything build but untested & migration not finished
This commit is contained in:
@@ -1,4 +1,35 @@
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
# This file configures the static analysis results for your project (errors,
|
||||
# warnings, and lints).
|
||||
#
|
||||
# This enables the 'recommended' set of lints from `package:lints`.
|
||||
# This set helps identify many issues that may lead to problems when running
|
||||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
|
||||
# style and format.
|
||||
#
|
||||
# If you want a smaller set of lints you can change this to specify
|
||||
# 'package:lints/core.yaml'. These are just the most critical lints
|
||||
# (the recommended set includes the core lints).
|
||||
# The core lints are also what is used by pub.dev for scoring packages.
|
||||
|
||||
# Additional information about this file can be found at
|
||||
include: package:lint/package.yaml
|
||||
# Uncomment the following section to specify additional rules.
|
||||
|
||||
linter:
|
||||
rules:
|
||||
- unawaited_futures
|
||||
- discarded_futures
|
||||
- collection_methods_unrelated_type
|
||||
|
||||
analyzer:
|
||||
plugins:
|
||||
- custom_lint
|
||||
exclude:
|
||||
- "**.g.dart"
|
||||
- "**.swagger.dart"
|
||||
- "**.freezed.dart"
|
||||
- "**.chopper.dart"
|
||||
# For more information about the core and recommended set of lints, see
|
||||
# https://dart.dev/go/core-lints
|
||||
|
||||
# For additional information about configuring this file, see
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
|
||||
@@ -2,7 +2,7 @@ group = "eu.lensai.flutter_mozilla_components"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = "1.9.20"
|
||||
ext.kotlin_version = "1.9.22"
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
|
||||
+20
-7
@@ -2,13 +2,13 @@ package eu.lensai.flutter_mozilla_components
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoStateEvents
|
||||
import eu.lensai.flutter_mozilla_components.feature.DefaultSelectionActionDelegate
|
||||
import eu.lensai.flutter_mozilla_components.integration.ReaderViewIntegration
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.SelectionAction
|
||||
import mozilla.components.browser.thumbnails.BrowserThumbnails
|
||||
import mozilla.components.concept.engine.EngineView
|
||||
import mozilla.components.feature.media.fullscreen.MediaSessionFullscreenFeature
|
||||
@@ -24,16 +24,16 @@ import mozilla.components.support.ktx.android.view.exitImmersiveMode
|
||||
*/
|
||||
class BrowserFragment(private val context: Context) : BaseBrowserFragment(), UserInteractionHandler {
|
||||
private val thumbnailsFeature = ViewBoundFeatureWrapper<BrowserThumbnails>()
|
||||
private val readerViewFeature = ViewBoundFeatureWrapper<ReaderViewIntegration>()
|
||||
private val fullScreenFeature = ViewBoundFeatureWrapper<FullScreenFeature>()
|
||||
private val mediaSessionFullscreenFeature =
|
||||
ViewBoundFeatureWrapper<MediaSessionFullscreenFeature>()
|
||||
|
||||
override fun createEngine(components: Components): EngineView {
|
||||
return components.engine.createView(context).apply {
|
||||
// selectionActionDelegate = DefaultSelectionActionDelegate(
|
||||
// store = components.store,
|
||||
// context = context,
|
||||
// )
|
||||
selectionActionDelegate = DefaultSelectionActionDelegate(
|
||||
components.selectionAction
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,19 @@ class BrowserFragment(private val context: Context) : BaseBrowserFragment(), Use
|
||||
|
||||
val binding = super.binding
|
||||
|
||||
readerViewFeature.set(
|
||||
feature = ReaderViewIntegration(
|
||||
requireContext(),
|
||||
components.engine,
|
||||
components.store,
|
||||
binding.readerViewBar,
|
||||
components.readerViewEvents,
|
||||
components.readerViewController,
|
||||
),
|
||||
owner = this,
|
||||
view = binding.root,
|
||||
)
|
||||
|
||||
fullScreenFeature.set(
|
||||
feature = FullScreenFeature(
|
||||
components.store,
|
||||
|
||||
+30
-9
@@ -3,32 +3,28 @@ package eu.lensai.flutter_mozilla_components
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import eu.lensai.flutter_mozilla_components.api.ReaderViewEventsImpl
|
||||
import eu.lensai.flutter_mozilla_components.ext.toWebPBytes
|
||||
import eu.lensai.flutter_mozilla_components.middleware.FlutterEventMiddleware
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.FindResultState
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoStateEvents
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.HistoryItem
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.HistoryState
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.ReaderViewController
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.ReaderableState
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.SecurityInfoState
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.SelectionAction
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.TabContentState
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.distinctUntilChangedBy
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
import kotlinx.coroutines.launch
|
||||
import mozilla.components.browser.engine.gecko.GeckoEngine
|
||||
import mozilla.components.browser.icons.BrowserIcons
|
||||
import mozilla.components.browser.session.storage.SessionStorage
|
||||
import mozilla.components.browser.state.engine.EngineMiddleware
|
||||
import mozilla.components.browser.state.engine.middleware.SessionPrioritizationMiddleware
|
||||
import mozilla.components.browser.state.selector.selectedTab
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.browser.thumbnails.ThumbnailsMiddleware
|
||||
import mozilla.components.browser.thumbnails.storage.ThumbnailStorage
|
||||
@@ -75,7 +71,12 @@ private const val DAY_IN_MINUTES = 24 * 60L
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Suppress("LargeClass")
|
||||
open class DefaultComponents(private val applicationContext: Context, private val flutterEvents: GeckoStateEvents) {
|
||||
open class DefaultComponents(
|
||||
private val applicationContext: Context,
|
||||
private val flutterEvents: GeckoStateEvents,
|
||||
val readerViewController: ReaderViewController,
|
||||
val selectionAction: SelectionAction,
|
||||
) {
|
||||
companion object {
|
||||
const val SAMPLE_BROWSER_PREFERENCES = "sample_browser_preferences"
|
||||
const val PREF_LAUNCH_EXTERNAL_APP = "sample_browser_launch_external_app"
|
||||
@@ -277,6 +278,24 @@ open class DefaultComponents(private val applicationContext: Context, private va
|
||||
}
|
||||
}
|
||||
|
||||
this.flowScoped { flow ->
|
||||
flow.mapNotNull { state -> state.tabs }
|
||||
.filterChanged {
|
||||
it.content.findResults
|
||||
}
|
||||
.collect { tab ->
|
||||
tab.content.findResults
|
||||
flutterEvents.onFindResults(
|
||||
tab.id,
|
||||
tab.content.findResults.map { result -> FindResultState(
|
||||
activeMatchOrdinal = result.activeMatchOrdinal.toLong(),
|
||||
numberOfMatches = result.numberOfMatches.toLong(),
|
||||
isDoneCounting = result.isDoneCounting,
|
||||
) }
|
||||
) { _ -> }
|
||||
}
|
||||
}
|
||||
|
||||
WebNotificationFeature(
|
||||
applicationContext,
|
||||
engine,
|
||||
@@ -294,6 +313,8 @@ open class DefaultComponents(private val applicationContext: Context, private va
|
||||
val sessionUseCases by lazy { SessionUseCases(store) }
|
||||
val tabsUseCases by lazy { TabsUseCases(store) }
|
||||
|
||||
val readerViewEvents by lazy { ReaderViewEventsImpl() }
|
||||
|
||||
// Addons
|
||||
val addonManager by lazy {
|
||||
AddonManager(store, engine, addonsProvider, addonUpdater)
|
||||
|
||||
+34
-8
@@ -3,28 +3,30 @@ package eu.lensai.flutter_mozilla_components
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import eu.lensai.flutter_mozilla_components.api.GeckoBrowserApiImpl
|
||||
import eu.lensai.flutter_mozilla_components.api.GeckoCookieApiImpl
|
||||
import eu.lensai.flutter_mozilla_components.api.GeckoEngineSettingsApiImpl
|
||||
import eu.lensai.flutter_mozilla_components.api.GeckoFindApiImpl
|
||||
import eu.lensai.flutter_mozilla_components.api.GeckoIconsApiImpl
|
||||
import eu.lensai.flutter_mozilla_components.api.GeckoSessionApiImpl
|
||||
import eu.lensai.flutter_mozilla_components.api.GeckoTabsApiImpl
|
||||
import eu.lensai.flutter_mozilla_components.feature.CookieManagerFeature
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoBrowserApi
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoCookieApi
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoEngineSettingsApi
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoFindApi
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoIconsApi
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoSessionApi
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoStateEvents
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoTabsApi
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.ReaderViewController
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.ReaderViewEvents
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.SelectionAction
|
||||
|
||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
||||
import mozilla.components.browser.engine.gecko.GeckoEngine
|
||||
import mozilla.components.browser.engine.gecko.fetch.GeckoViewFetchClient
|
||||
import mozilla.components.concept.engine.Engine
|
||||
@@ -32,7 +34,6 @@ import mozilla.components.experiment.NimbusExperimentDelegate
|
||||
import mozilla.components.feature.webcompat.WebCompatFeature
|
||||
import mozilla.components.lib.crash.handler.CrashHandlerService
|
||||
import mozilla.components.support.base.log.Log
|
||||
import mozilla.components.support.base.log.logger.Logger
|
||||
import mozilla.components.support.base.log.sink.AndroidLogSink
|
||||
import org.mozilla.geckoview.GeckoRuntime
|
||||
import org.mozilla.geckoview.GeckoRuntimeSettings
|
||||
@@ -40,7 +41,17 @@ import org.mozilla.geckoview.GeckoRuntimeSettings
|
||||
/**
|
||||
* Helper class for lazily instantiating components needed by the application.
|
||||
*/
|
||||
class Components(private val applicationContext: Context, flutterEvents: GeckoStateEvents) : DefaultComponents(applicationContext, flutterEvents) {
|
||||
class Components(
|
||||
private val applicationContext: Context,
|
||||
flutterEvents: GeckoStateEvents,
|
||||
readerViewController: ReaderViewController,
|
||||
selectionAction: SelectionAction,
|
||||
) : DefaultComponents(
|
||||
applicationContext,
|
||||
flutterEvents,
|
||||
readerViewController,
|
||||
selectionAction
|
||||
) {
|
||||
private val runtime by lazy {
|
||||
// Allow for exfiltrating Gecko metrics through the Glean SDK.
|
||||
val builder = GeckoRuntimeSettings.Builder().aboutConfigEnabled(true)
|
||||
@@ -85,8 +96,16 @@ class FlutterMozillaComponentsPlugin: FlutterPlugin, ActivityAware {
|
||||
_flutterPluginBinding = flutterPluginBinding
|
||||
|
||||
val flutterEvents = GeckoStateEvents(_flutterPluginBinding.binaryMessenger)
|
||||
val readerViewController =
|
||||
ReaderViewController(_flutterPluginBinding.binaryMessenger)
|
||||
val selectionActionDelegate = SelectionAction(_flutterPluginBinding.binaryMessenger)
|
||||
|
||||
GlobalComponents.setUp(flutterPluginBinding.applicationContext, flutterEvents)
|
||||
GlobalComponents.setUp(
|
||||
flutterPluginBinding.applicationContext,
|
||||
flutterEvents,
|
||||
readerViewController,
|
||||
selectionActionDelegate
|
||||
)
|
||||
|
||||
val intent = Intent(flutterPluginBinding.applicationContext, NotificationActivity::class.java)
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -96,10 +115,17 @@ class FlutterMozillaComponentsPlugin: FlutterPlugin, ActivityAware {
|
||||
showNativeFragment()
|
||||
})
|
||||
|
||||
GeckoEngineSettingsApi.setUp(_flutterPluginBinding.binaryMessenger, GeckoEngineSettingsApiImpl())
|
||||
GeckoSessionApi.setUp(_flutterPluginBinding.binaryMessenger, GeckoSessionApiImpl())
|
||||
GeckoTabsApi.setUp(_flutterPluginBinding.binaryMessenger, GeckoTabsApiImpl())
|
||||
GeckoIconsApi.setUp(_flutterPluginBinding.binaryMessenger, GeckoIconsApiImpl())
|
||||
GeckoCookieApi.setUp(_flutterPluginBinding.binaryMessenger, GeckoCookieApiImpl())
|
||||
GeckoFindApi.setUp(_flutterPluginBinding.binaryMessenger, GeckoFindApiImpl())
|
||||
|
||||
ReaderViewEvents.setUp(
|
||||
_flutterPluginBinding.binaryMessenger,
|
||||
GlobalComponents.components!!.readerViewEvents
|
||||
)
|
||||
}
|
||||
|
||||
private fun showNativeFragment() {
|
||||
|
||||
+14
-2
@@ -2,6 +2,8 @@ package eu.lensai.flutter_mozilla_components
|
||||
|
||||
import android.content.Context
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoStateEvents
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.ReaderViewController
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.SelectionAction
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
@@ -29,8 +31,18 @@ object GlobalComponents {
|
||||
.whenSessionsChange()
|
||||
}
|
||||
|
||||
fun setUp(applicationContext: Context, flutterEvents: GeckoStateEvents) {
|
||||
val newComponents = Components(applicationContext, flutterEvents)
|
||||
fun setUp(
|
||||
applicationContext: Context,
|
||||
flutterEvents: GeckoStateEvents,
|
||||
readerViewController: ReaderViewController,
|
||||
selectionAction: SelectionAction
|
||||
) {
|
||||
val newComponents = Components(
|
||||
applicationContext,
|
||||
flutterEvents,
|
||||
readerViewController,
|
||||
selectionAction
|
||||
)
|
||||
|
||||
newComponents.crashReporter.install(applicationContext)
|
||||
Facts.registerProcessor(LogFactProcessor())
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package eu.lensai.flutter_mozilla_components.api
|
||||
|
||||
import eu.lensai.flutter_mozilla_components.GlobalComponents
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoEngineSettingsApi
|
||||
import mozilla.components.concept.engine.Engine
|
||||
|
||||
class GeckoEngineSettingsApiImpl : GeckoEngineSettingsApi {
|
||||
private val engine: Engine by lazy { GlobalComponents.components!!.engine }
|
||||
|
||||
override fun javaScriptEnabled(state: Boolean) {
|
||||
engine.settings.javascriptEnabled = state
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package eu.lensai.flutter_mozilla_components.api
|
||||
|
||||
import eu.lensai.flutter_mozilla_components.GlobalComponents
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.GeckoFindApi
|
||||
import mozilla.components.browser.state.selector.findTabOrCustomTab
|
||||
import mozilla.components.browser.state.state.BrowserState
|
||||
import mozilla.components.concept.engine.EngineSession
|
||||
|
||||
class GeckoFindApiImpl : GeckoFindApi {
|
||||
private val state: BrowserState by lazy { GlobalComponents.components!!.store.state }
|
||||
|
||||
private fun sessionByTabId(tabId: String?) : EngineSession? {
|
||||
val loadSessionId = tabId
|
||||
?: state.selectedTabId
|
||||
|
||||
if (loadSessionId == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
val tab = state.findTabOrCustomTab(loadSessionId)
|
||||
return tab?.engineState?.engineSession
|
||||
}
|
||||
|
||||
override fun findAll(tabId: String?, text: String) {
|
||||
val engineSession = sessionByTabId(tabId)
|
||||
engineSession?.findAll(text)
|
||||
}
|
||||
|
||||
override fun findNext(tabId: String?, forward: Boolean) {
|
||||
val engineSession = sessionByTabId(tabId)
|
||||
engineSession?.findNext(forward)
|
||||
}
|
||||
|
||||
override fun clearMatches(tabId: String?) {
|
||||
val engineSession = sessionByTabId(tabId)
|
||||
engineSession?.clearFindMatches()
|
||||
}
|
||||
}
|
||||
+6
-9
@@ -1,7 +1,5 @@
|
||||
package eu.lensai.flutter_mozilla_components.api
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Build
|
||||
import eu.lensai.flutter_mozilla_components.GlobalComponents
|
||||
import eu.lensai.flutter_mozilla_components.ext.toWebPBytes
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.*
|
||||
@@ -9,7 +7,6 @@ import kotlinx.coroutines.*
|
||||
import mozilla.components.browser.icons.BrowserIcons
|
||||
import mozilla.components.browser.icons.Icon
|
||||
import mozilla.components.concept.engine.manifest.Size as HtmlSize
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
typealias MozillaIconRequest = mozilla.components.browser.icons.IconRequest
|
||||
typealias MozillaIconSize = mozilla.components.browser.icons.IconRequest.Size
|
||||
@@ -86,11 +83,11 @@ class GeckoIconsApiImpl() : GeckoIconsApi {
|
||||
IconType.MANIFEST_ICON -> MozillaIconResourceType.MANIFEST_ICON
|
||||
}
|
||||
|
||||
private fun Icon.Source.toApiSource(): Source = when (this) {
|
||||
Icon.Source.GENERATOR -> Source.GENERATOR
|
||||
Icon.Source.DOWNLOAD -> Source.DOWNLOAD
|
||||
Icon.Source.INLINE -> Source.INLINE
|
||||
Icon.Source.MEMORY -> Source.MEMORY
|
||||
Icon.Source.DISK -> Source.DISK
|
||||
private fun Icon.Source.toApiSource(): IconSource = when (this) {
|
||||
Icon.Source.GENERATOR -> IconSource.GENERATOR
|
||||
Icon.Source.DOWNLOAD -> IconSource.DOWNLOAD
|
||||
Icon.Source.INLINE -> IconSource.INLINE
|
||||
Icon.Source.MEMORY -> IconSource.MEMORY
|
||||
Icon.Source.DISK -> IconSource.DISK
|
||||
}
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package eu.lensai.flutter_mozilla_components.api
|
||||
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.ReaderViewEvents
|
||||
|
||||
// Interface for the listener
|
||||
interface ReaderViewControllerListener {
|
||||
fun onReaderViewToggled(enabled: Boolean)
|
||||
fun onAppearanceButtonTap()
|
||||
}
|
||||
|
||||
class ReaderViewEventsImpl : ReaderViewEvents {
|
||||
|
||||
private val listeners = mutableSetOf<ReaderViewControllerListener>()
|
||||
|
||||
override fun onToggleReaderView(enable: Boolean) {
|
||||
listeners.forEach { it.onReaderViewToggled(enable) }
|
||||
}
|
||||
|
||||
override fun onAppearanceButtonTap() {
|
||||
listeners.forEach { it.onAppearanceButtonTap() }
|
||||
}
|
||||
|
||||
// Method to add a listener
|
||||
fun addListener(listener: ReaderViewControllerListener) {
|
||||
listeners.add(listener)
|
||||
}
|
||||
|
||||
// Method to remove a listener
|
||||
fun removeListener(listener: ReaderViewControllerListener) {
|
||||
listeners.remove(listener)
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package eu.lensai.flutter_mozilla_components.feature
|
||||
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.SelectionAction
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import mozilla.components.concept.engine.selection.SelectionActionDelegate
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
class DefaultSelectionActionDelegate(
|
||||
private val selectionAction: SelectionAction
|
||||
) : SelectionActionDelegate {
|
||||
override fun getActionTitle(id: String): CharSequence? = runBlocking {
|
||||
suspendCancellableCoroutine { continuation ->
|
||||
selectionAction.getActionTitle(id) { result ->
|
||||
continuation.resume(result.getOrNull())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getAllActions(): Array<String> = runBlocking {
|
||||
suspendCancellableCoroutine { continuation ->
|
||||
selectionAction.getAllActions() { result ->
|
||||
continuation.resume(result.getOrNull()!!.toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun isActionAvailable(id: String, selectedText: String): Boolean = runBlocking {
|
||||
suspendCancellableCoroutine { continuation ->
|
||||
selectionAction.isActionAvailable(id, selectedText) { result ->
|
||||
continuation.resume(result.getOrNull()!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun performAction(id: String, selectedText: String): Boolean = runBlocking {
|
||||
suspendCancellableCoroutine { continuation ->
|
||||
selectionAction.performAction(id, selectedText) { result ->
|
||||
continuation.resume(result.getOrNull()!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun sortedActions(actions: Array<String>): Array<String> = runBlocking {
|
||||
suspendCancellableCoroutine { continuation ->
|
||||
selectionAction.sortedActions(actions.toList()) { result ->
|
||||
continuation.resume(result.getOrNull()!!.toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package eu.lensai.flutter_mozilla_components.integration
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.core.content.ContextCompat
|
||||
import eu.lensai.flutter_mozilla_components.GlobalComponents
|
||||
import eu.lensai.flutter_mozilla_components.api.ReaderViewEventsImpl
|
||||
import eu.lensai.flutter_mozilla_components.api.ReaderViewControllerListener
|
||||
import eu.lensai.flutter_mozilla_components.pigeons.ReaderViewController
|
||||
import mozilla.components.browser.state.selector.selectedTab
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.concept.engine.Engine
|
||||
import mozilla.components.feature.readerview.ReaderViewFeature
|
||||
import mozilla.components.feature.readerview.view.ReaderViewControlsView
|
||||
import mozilla.components.support.base.feature.LifecycleAwareFeature
|
||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||
|
||||
@Suppress("UndocumentedPublicClass")
|
||||
class ReaderViewIntegration(
|
||||
context: Context,
|
||||
engine: Engine,
|
||||
store: BrowserStore,
|
||||
view: ReaderViewControlsView,
|
||||
readerViewEvents: ReaderViewEventsImpl,
|
||||
readerViewController: ReaderViewController
|
||||
) : LifecycleAwareFeature, UserInteractionHandler {
|
||||
|
||||
private val controllerListener = object : ReaderViewControllerListener {
|
||||
override fun onReaderViewToggled(enabled: Boolean) {
|
||||
if (enabled) {
|
||||
feature.showReaderView()
|
||||
|
||||
readerViewController.appearanceButtonVisibility(true) { _ -> };
|
||||
} else {
|
||||
feature.hideReaderView()
|
||||
feature.hideControls()
|
||||
|
||||
readerViewController.appearanceButtonVisibility(false) { _ -> };
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAppearanceButtonTap() {
|
||||
feature.showControls()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
readerViewEvents.addListener(controllerListener)
|
||||
}
|
||||
|
||||
private val feature = ReaderViewFeature(context, engine, store, view)
|
||||
// Will be event based in flutter
|
||||
// { available, active ->
|
||||
// readerViewButtonVisible = available
|
||||
// readerViewButton.setSelected(active)
|
||||
//
|
||||
// if (active) readerViewAppearanceButton.show() else readerViewAppearanceButton.hide()
|
||||
// toolbar.invalidateActions()
|
||||
// }
|
||||
|
||||
override fun start() {
|
||||
feature.start()
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
feature.stop()
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
return feature.onBackPressed()
|
||||
}
|
||||
}
|
||||
+387
-1
@@ -1,4 +1,4 @@
|
||||
// Autogenerated from Pigeon (v22.3.0), do not edit directly.
|
||||
// Autogenerated from Pigeon (v22.4.2), do not edit directly.
|
||||
// See also: https://pub.dev/packages/pigeon
|
||||
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")
|
||||
|
||||
@@ -865,6 +865,30 @@ data class TabContentState (
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** Generated class from Pigeon that represents data sent in messages. */
|
||||
data class FindResultState (
|
||||
val activeMatchOrdinal: Long,
|
||||
val numberOfMatches: Long,
|
||||
val isDoneCounting: Boolean
|
||||
)
|
||||
{
|
||||
companion object {
|
||||
fun fromList(pigeonVar_list: List<Any?>): FindResultState {
|
||||
val activeMatchOrdinal = pigeonVar_list[0] as Long
|
||||
val numberOfMatches = pigeonVar_list[1] as Long
|
||||
val isDoneCounting = pigeonVar_list[2] as Boolean
|
||||
return FindResultState(activeMatchOrdinal, numberOfMatches, isDoneCounting)
|
||||
}
|
||||
}
|
||||
fun toList(): List<Any?> {
|
||||
return listOf(
|
||||
activeMatchOrdinal,
|
||||
numberOfMatches,
|
||||
isDoneCounting,
|
||||
)
|
||||
}
|
||||
}
|
||||
private open class GeckoPigeonCodec : StandardMessageCodec() {
|
||||
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
|
||||
return when (type) {
|
||||
@@ -1003,6 +1027,11 @@ private open class GeckoPigeonCodec : StandardMessageCodec() {
|
||||
TabContentState.fromList(it)
|
||||
}
|
||||
}
|
||||
156.toByte() -> {
|
||||
return (readValue(buffer) as? List<Any?>)?.let {
|
||||
FindResultState.fromList(it)
|
||||
}
|
||||
}
|
||||
else -> super.readValueOfType(type, buffer)
|
||||
}
|
||||
}
|
||||
@@ -1116,6 +1145,10 @@ private open class GeckoPigeonCodec : StandardMessageCodec() {
|
||||
stream.write(155)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
is FindResultState -> {
|
||||
stream.write(156)
|
||||
writeValue(stream, value.toList())
|
||||
}
|
||||
else -> super.writeValue(stream, value)
|
||||
}
|
||||
}
|
||||
@@ -1155,6 +1188,40 @@ interface GeckoBrowserApi {
|
||||
}
|
||||
}
|
||||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
||||
interface GeckoEngineSettingsApi {
|
||||
fun javaScriptEnabled(state: Boolean)
|
||||
|
||||
companion object {
|
||||
/** The codec used by GeckoEngineSettingsApi. */
|
||||
val codec: MessageCodec<Any?> by lazy {
|
||||
GeckoPigeonCodec()
|
||||
}
|
||||
/** Sets up an instance of `GeckoEngineSettingsApi` to handle messages through the `binaryMessenger`. */
|
||||
@JvmOverloads
|
||||
fun setUp(binaryMessenger: BinaryMessenger, api: GeckoEngineSettingsApi?, messageChannelSuffix: String = "") {
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoEngineSettingsApi.javaScriptEnabled$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val stateArg = args[0] as Boolean
|
||||
val wrapped: List<Any?> = try {
|
||||
api.javaScriptEnabled(stateArg)
|
||||
listOf(null)
|
||||
} catch (exception: Throwable) {
|
||||
wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
||||
interface GeckoSessionApi {
|
||||
fun loadUrl(tabId: String?, url: String, flags: LoadUrlFlagsValue, additionalHeaders: Map<String, String>?)
|
||||
fun loadData(tabId: String?, data: String, mimeType: String, encoding: String)
|
||||
@@ -1802,6 +1869,80 @@ interface GeckoTabsApi {
|
||||
}
|
||||
}
|
||||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
||||
interface GeckoFindApi {
|
||||
fun findAll(tabId: String?, text: String)
|
||||
fun findNext(tabId: String?, forward: Boolean)
|
||||
fun clearMatches(tabId: String?)
|
||||
|
||||
companion object {
|
||||
/** The codec used by GeckoFindApi. */
|
||||
val codec: MessageCodec<Any?> by lazy {
|
||||
GeckoPigeonCodec()
|
||||
}
|
||||
/** Sets up an instance of `GeckoFindApi` to handle messages through the `binaryMessenger`. */
|
||||
@JvmOverloads
|
||||
fun setUp(binaryMessenger: BinaryMessenger, api: GeckoFindApi?, messageChannelSuffix: String = "") {
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoFindApi.findAll$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val tabIdArg = args[0] as String?
|
||||
val textArg = args[1] as String
|
||||
val wrapped: List<Any?> = try {
|
||||
api.findAll(tabIdArg, textArg)
|
||||
listOf(null)
|
||||
} catch (exception: Throwable) {
|
||||
wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoFindApi.findNext$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val tabIdArg = args[0] as String?
|
||||
val forwardArg = args[1] as Boolean
|
||||
val wrapped: List<Any?> = try {
|
||||
api.findNext(tabIdArg, forwardArg)
|
||||
listOf(null)
|
||||
} catch (exception: Throwable) {
|
||||
wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoFindApi.clearMatches$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val tabIdArg = args[0] as String?
|
||||
val wrapped: List<Any?> = try {
|
||||
api.clearMatches(tabIdArg)
|
||||
listOf(null)
|
||||
} catch (exception: Throwable) {
|
||||
wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
||||
interface GeckoIconsApi {
|
||||
fun loadIcon(request: IconRequest, callback: (Result<IconResult>) -> Unit)
|
||||
|
||||
@@ -2102,4 +2243,249 @@ class GeckoStateEvents(private val binaryMessenger: BinaryMessenger, private val
|
||||
}
|
||||
}
|
||||
}
|
||||
fun onFindResults(idArg: String, resultsArg: List<FindResultState>, callback: (Result<Unit>) -> Unit)
|
||||
{
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
val channelName = "dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onFindResults$separatedMessageChannelSuffix"
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
|
||||
channel.send(listOf(idArg, resultsArg)) {
|
||||
if (it is List<*>) {
|
||||
if (it.size > 1) {
|
||||
callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
|
||||
} else {
|
||||
callback(Result.success(Unit))
|
||||
}
|
||||
} else {
|
||||
callback(Result.failure(createConnectionError(channelName)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
||||
interface ReaderViewEvents {
|
||||
fun onToggleReaderView(enable: Boolean)
|
||||
fun onAppearanceButtonTap()
|
||||
|
||||
companion object {
|
||||
/** The codec used by ReaderViewEvents. */
|
||||
val codec: MessageCodec<Any?> by lazy {
|
||||
GeckoPigeonCodec()
|
||||
}
|
||||
/** Sets up an instance of `ReaderViewEvents` to handle messages through the `binaryMessenger`. */
|
||||
@JvmOverloads
|
||||
fun setUp(binaryMessenger: BinaryMessenger, api: ReaderViewEvents?, messageChannelSuffix: String = "") {
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.ReaderViewEvents.onToggleReaderView$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val enableArg = args[0] as Boolean
|
||||
val wrapped: List<Any?> = try {
|
||||
api.onToggleReaderView(enableArg)
|
||||
listOf(null)
|
||||
} catch (exception: Throwable) {
|
||||
wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.ReaderViewEvents.onAppearanceButtonTap$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { _, reply ->
|
||||
val wrapped: List<Any?> = try {
|
||||
api.onAppearanceButtonTap()
|
||||
listOf(null)
|
||||
} catch (exception: Throwable) {
|
||||
wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */
|
||||
class ReaderViewController(private val binaryMessenger: BinaryMessenger, private val messageChannelSuffix: String = "") {
|
||||
companion object {
|
||||
/** The codec used by ReaderViewController. */
|
||||
val codec: MessageCodec<Any?> by lazy {
|
||||
GeckoPigeonCodec()
|
||||
}
|
||||
}
|
||||
fun appearanceButtonVisibility(visibleArg: Boolean, callback: (Result<Unit>) -> Unit)
|
||||
{
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
val channelName = "dev.flutter.pigeon.flutter_mozilla_components.ReaderViewController.appearanceButtonVisibility$separatedMessageChannelSuffix"
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
|
||||
channel.send(listOf(visibleArg)) {
|
||||
if (it is List<*>) {
|
||||
if (it.size > 1) {
|
||||
callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
|
||||
} else {
|
||||
callback(Result.success(Unit))
|
||||
}
|
||||
} else {
|
||||
callback(Result.failure(createConnectionError(channelName)))
|
||||
}
|
||||
}
|
||||
}
|
||||
fun readerViewButtonVisibility(visibleArg: Boolean, callback: (Result<Unit>) -> Unit)
|
||||
{
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
val channelName = "dev.flutter.pigeon.flutter_mozilla_components.ReaderViewController.readerViewButtonVisibility$separatedMessageChannelSuffix"
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
|
||||
channel.send(listOf(visibleArg)) {
|
||||
if (it is List<*>) {
|
||||
if (it.size > 1) {
|
||||
callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
|
||||
} else {
|
||||
callback(Result.success(Unit))
|
||||
}
|
||||
} else {
|
||||
callback(Result.failure(createConnectionError(channelName)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Generated class from Pigeon that represents Flutter messages that can be called from Kotlin. */
|
||||
class SelectionAction(private val binaryMessenger: BinaryMessenger, private val messageChannelSuffix: String = "") {
|
||||
companion object {
|
||||
/** The codec used by SelectionAction. */
|
||||
val codec: MessageCodec<Any?> by lazy {
|
||||
GeckoPigeonCodec()
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets Strings representing all possible selection actions.
|
||||
*
|
||||
* @returns String IDs for each action that could possibly be shown in the context menu. This
|
||||
* array must include all actions, available or not, and must not change over the class lifetime.
|
||||
*/
|
||||
fun getAllActions(callback: (Result<List<String>>) -> Unit)
|
||||
{
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
val channelName = "dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.getAllActions$separatedMessageChannelSuffix"
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
|
||||
channel.send(null) {
|
||||
if (it is List<*>) {
|
||||
if (it.size > 1) {
|
||||
callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
|
||||
} else if (it[0] == null) {
|
||||
callback(Result.failure(FlutterError("null-error", "Flutter api returned null value for non-null return value.", "")))
|
||||
} else {
|
||||
val output = it[0] as List<String>
|
||||
callback(Result.success(output))
|
||||
}
|
||||
} else {
|
||||
callback(Result.failure(createConnectionError(channelName)))
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if an action can be shown on a new selection context menu.
|
||||
*
|
||||
* @returns whether or not the the custom action with the id of [id] is currently available
|
||||
* which may be informed by [selectedText].
|
||||
*/
|
||||
fun isActionAvailable(idArg: String, selectedTextArg: String, callback: (Result<Boolean>) -> Unit)
|
||||
{
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
val channelName = "dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.isActionAvailable$separatedMessageChannelSuffix"
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
|
||||
channel.send(listOf(idArg, selectedTextArg)) {
|
||||
if (it is List<*>) {
|
||||
if (it.size > 1) {
|
||||
callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
|
||||
} else if (it[0] == null) {
|
||||
callback(Result.failure(FlutterError("null-error", "Flutter api returned null value for non-null return value.", "")))
|
||||
} else {
|
||||
val output = it[0] as Boolean
|
||||
callback(Result.success(output))
|
||||
}
|
||||
} else {
|
||||
callback(Result.failure(createConnectionError(channelName)))
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets a title to be shown in the selection context menu.
|
||||
*
|
||||
* @returns the text that should be shown on the action.
|
||||
*/
|
||||
fun getActionTitle(idArg: String, callback: (Result<String?>) -> Unit)
|
||||
{
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
val channelName = "dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.getActionTitle$separatedMessageChannelSuffix"
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
|
||||
channel.send(listOf(idArg)) {
|
||||
if (it is List<*>) {
|
||||
if (it.size > 1) {
|
||||
callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
|
||||
} else {
|
||||
val output = it[0] as String?
|
||||
callback(Result.success(output))
|
||||
}
|
||||
} else {
|
||||
callback(Result.failure(createConnectionError(channelName)))
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Should perform the action with the id of [id].
|
||||
*
|
||||
* @returns [true] if the action was consumed.
|
||||
*/
|
||||
fun performAction(idArg: String, selectedTextArg: String, callback: (Result<Boolean>) -> Unit)
|
||||
{
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
val channelName = "dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.performAction$separatedMessageChannelSuffix"
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
|
||||
channel.send(listOf(idArg, selectedTextArg)) {
|
||||
if (it is List<*>) {
|
||||
if (it.size > 1) {
|
||||
callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
|
||||
} else if (it[0] == null) {
|
||||
callback(Result.failure(FlutterError("null-error", "Flutter api returned null value for non-null return value.", "")))
|
||||
} else {
|
||||
val output = it[0] as Boolean
|
||||
callback(Result.success(output))
|
||||
}
|
||||
} else {
|
||||
callback(Result.failure(createConnectionError(channelName)))
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Takes in a list of actions and sorts them.
|
||||
*
|
||||
* @returns the sorted list.
|
||||
*/
|
||||
fun sortedActions(actionsArg: List<String>, callback: (Result<List<String>>) -> Unit)
|
||||
{
|
||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
||||
val channelName = "dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.sortedActions$separatedMessageChannelSuffix"
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, channelName, codec)
|
||||
channel.send(listOf(actionsArg)) {
|
||||
if (it is List<*>) {
|
||||
if (it.size > 1) {
|
||||
callback(Result.failure(FlutterError(it[0] as String, it[1] as String, it[2] as String?)))
|
||||
} else if (it[0] == null) {
|
||||
callback(Result.failure(FlutterError("null-error", "Flutter api returned null value for non-null return value.", "")))
|
||||
} else {
|
||||
val output = it[0] as List<String>
|
||||
callback(Result.success(output))
|
||||
}
|
||||
} else {
|
||||
callback(Result.failure(createConnectionError(channelName)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,16 @@
|
||||
android:layout_height="match_parent">
|
||||
<!-- Inject engine here -->
|
||||
</mozilla.components.ui.widgets.VerticalSwipeRefreshLayout>
|
||||
|
||||
<mozilla.components.feature.readerview.view.ReaderViewControlsBar
|
||||
android:id="@+id/readerViewBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="#FFFFFFFF"
|
||||
android:elevation="10dp"
|
||||
android:paddingBottom="55dp"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -18,8 +18,8 @@ pluginManagement {
|
||||
|
||||
plugins {
|
||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||
id "com.android.application" version "8.1.0" apply false
|
||||
id "org.jetbrains.kotlin.android" version "1.9.20" apply false
|
||||
id "com.android.application" version "8.3.1" apply false
|
||||
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
|
||||
}
|
||||
|
||||
include ":app"
|
||||
|
||||
@@ -40,7 +40,7 @@ dev_dependencies:
|
||||
# activated in the `analysis_options.yaml` file located at the root of your
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^4.0.0
|
||||
flutter_lints: ^5.0.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
export 'src/geckoview_widget.dart';
|
||||
//export 'src/domain/services/gecko_browser.dart';
|
||||
export 'src/data/models/load_url_flags.dart';
|
||||
export 'src/data/models/source.dart';
|
||||
export 'src/domain/services/gecko_cookie.dart';
|
||||
export 'src/domain/services/gecko_engine_settings.dart';
|
||||
export 'src/domain/services/gecko_event.dart';
|
||||
export 'src/domain/services/gecko_find_in_page.dart';
|
||||
export 'src/domain/services/gecko_icon.dart';
|
||||
export 'src/domain/services/gecko_readerable.dart';
|
||||
export 'src/domain/services/gecko_session.dart';
|
||||
export 'src/domain/services/gecko_tab.dart';
|
||||
export 'src/domain/services/gecko_icon.dart';
|
||||
export 'src/domain/services/gecko_cookie.dart';
|
||||
export 'src/domain/services/gecko_event.dart';
|
||||
export 'src/geckoview_widget.dart';
|
||||
export 'src/pigeons/gecko.g.dart'
|
||||
show
|
||||
Resource,
|
||||
IconType,
|
||||
ResourceSize,
|
||||
IconSource,
|
||||
CookieSameSiteStatus,
|
||||
TabContentState,
|
||||
HistoryMetadataKey,
|
||||
IconSource,
|
||||
IconType,
|
||||
Resource,
|
||||
ResourceSize,
|
||||
SecurityInfoState,
|
||||
HistoryMetadataKey;
|
||||
TabContentState;
|
||||
|
||||
@@ -39,8 +39,8 @@ class LoadUrlFlags {
|
||||
ALLOW_JAVASCRIPT_URL.value,
|
||||
);
|
||||
|
||||
static LoadUrlFlags select(List<LoadUrlFlags> flags) {
|
||||
int combinedValue = flags.fold(0, (sum, flag) => sum | flag.value);
|
||||
factory LoadUrlFlags.select(List<LoadUrlFlags> flags) {
|
||||
final combinedValue = flags.fold(0, (sum, flag) => sum | flag.value);
|
||||
return LoadUrlFlags._(combinedValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,11 +38,15 @@ abstract class Source {
|
||||
/// Initializes a [Source] of a correct type from its component properties.
|
||||
/// Intended use is for restoring persisted state.
|
||||
static Source restore(
|
||||
int? sourceId, String? packageId, int? packageCategory) {
|
||||
int? sourceId,
|
||||
String? packageId,
|
||||
int? packageCategory,
|
||||
) {
|
||||
final caller = packageId != null
|
||||
? ExternalPackage(
|
||||
packageId: packageId,
|
||||
category: PackageCategory.fromInt(packageCategory).toValue())
|
||||
category: PackageCategory.fromInt(packageCategory).toValue(),
|
||||
)
|
||||
: null;
|
||||
|
||||
switch (sourceId) {
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import 'package:flutter_mozilla_components/src/pigeons/gecko.g.dart';
|
||||
|
||||
final _apiInstance = GeckoEngineSettingsApi();
|
||||
|
||||
class GeckoEngineSettingsService {
|
||||
final GeckoEngineSettingsApi _api;
|
||||
|
||||
GeckoEngineSettingsService({GeckoEngineSettingsApi? api})
|
||||
: _api = api ?? _apiInstance;
|
||||
|
||||
Future<void> javaScriptEnabled(bool state) {
|
||||
return _api.javaScriptEnabled(state);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ typedef ReaderableEvent = ({String tabId, ReaderableState readerable});
|
||||
typedef SecurityInfoEvent = ({String tabId, SecurityInfoState securityInfo});
|
||||
typedef IconEvent = ({String tabId, Uint8List? bytes});
|
||||
typedef ThumbnailEvent = ({String tabId, Uint8List? bytes});
|
||||
typedef FindResultsEvent = ({String tabId, List<FindResultState> results});
|
||||
|
||||
class GeckoEventService extends GeckoStateEvents {
|
||||
// Stream controllers
|
||||
@@ -20,6 +21,7 @@ class GeckoEventService extends GeckoStateEvents {
|
||||
StreamController<SecurityInfoEvent>.broadcast();
|
||||
final _iconController = StreamController<IconEvent>.broadcast();
|
||||
final _thumbnailController = StreamController<ThumbnailEvent>.broadcast();
|
||||
final _findResultsController = StreamController<FindResultsEvent>.broadcast();
|
||||
|
||||
// Event streams
|
||||
Stream<List<String>> get tabListEvents => _tabListController.stream;
|
||||
@@ -31,6 +33,8 @@ class GeckoEventService extends GeckoStateEvents {
|
||||
_securityInfoController.stream;
|
||||
Stream<IconEvent> get iconEvents => _iconController.stream;
|
||||
Stream<ThumbnailEvent> get thumbnailEvents => _thumbnailController.stream;
|
||||
Stream<FindResultsEvent> get findResultsEvent =>
|
||||
_findResultsController.stream;
|
||||
|
||||
// Overridden methods
|
||||
@override
|
||||
@@ -73,21 +77,31 @@ class GeckoEventService extends GeckoStateEvents {
|
||||
_thumbnailController.add((tabId: id, bytes: bytes));
|
||||
}
|
||||
|
||||
@override
|
||||
void onFindResults(String id, List<FindResultState?> results) {
|
||||
_findResultsController.add((tabId: id, results: results.nonNulls.toList()));
|
||||
}
|
||||
|
||||
GeckoEventService.setUp({
|
||||
BinaryMessenger? binaryMessenger,
|
||||
String messageChannelSuffix = '',
|
||||
}) {
|
||||
GeckoStateEvents.setUp(this);
|
||||
GeckoStateEvents.setUp(
|
||||
this,
|
||||
binaryMessenger: binaryMessenger,
|
||||
messageChannelSuffix: messageChannelSuffix,
|
||||
);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_tabListController.close();
|
||||
_selectedTabController.close();
|
||||
_tabContentController.close();
|
||||
_historyController.close();
|
||||
_readerableController.close();
|
||||
_securityInfoController.close();
|
||||
_iconController.close();
|
||||
_thumbnailController.close();
|
||||
unawaited(_tabListController.close());
|
||||
unawaited(_selectedTabController.close());
|
||||
unawaited(_tabContentController.close());
|
||||
unawaited(_historyController.close());
|
||||
unawaited(_readerableController.close());
|
||||
unawaited(_securityInfoController.close());
|
||||
unawaited(_iconController.close());
|
||||
unawaited(_thumbnailController.close());
|
||||
unawaited(_findResultsController.close());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter_mozilla_components/src/pigeons/gecko.g.dart';
|
||||
|
||||
final _apiInstance = GeckoFindApi();
|
||||
|
||||
class GeckoFindInPageService {
|
||||
final GeckoFindApi _api;
|
||||
final String? tabId;
|
||||
|
||||
GeckoFindInPageService({required this.tabId, GeckoFindApi? api})
|
||||
: _api = api ?? _apiInstance;
|
||||
|
||||
GeckoFindInPageService.forActiveTab({GeckoFindApi? api})
|
||||
: _api = api ?? _apiInstance,
|
||||
tabId = null;
|
||||
|
||||
Future<void> findAll(String text) {
|
||||
return _api.findAll(tabId, text);
|
||||
}
|
||||
|
||||
Future<void> findNext(bool forward) {
|
||||
return _api.findNext(tabId, forward);
|
||||
}
|
||||
|
||||
Future<void> clearMatches() {
|
||||
return _api.clearMatches(tabId);
|
||||
}
|
||||
}
|
||||
@@ -7,14 +7,18 @@ class GeckoIconService {
|
||||
|
||||
GeckoIconService({GeckoIconsApi? api}) : _api = api ?? _apiInstance;
|
||||
|
||||
Future<IconResult> loadIcon(
|
||||
{required Uri url, List<Resource> resources = const []}) async {
|
||||
return _api.loadIcon(IconRequest(
|
||||
url: url.toString(),
|
||||
size: IconSize.defaultSize,
|
||||
resources: resources,
|
||||
isPrivate: false,
|
||||
waitOnNetworkLoad: true,
|
||||
));
|
||||
Future<IconResult> loadIcon({
|
||||
required Uri url,
|
||||
List<Resource> resources = const [],
|
||||
}) async {
|
||||
return _api.loadIcon(
|
||||
IconRequest(
|
||||
url: url.toString(),
|
||||
size: IconSize.defaultSize,
|
||||
resources: resources,
|
||||
isPrivate: false,
|
||||
waitOnNetworkLoad: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mozilla_components/src/pigeons/gecko.g.dart';
|
||||
|
||||
class GeckoReaderableService extends ReaderViewController {
|
||||
final ReaderViewEvents _events;
|
||||
|
||||
final _appearanceVisibility = StreamController<bool>.broadcast();
|
||||
final _readerVisibility = StreamController<bool>.broadcast();
|
||||
|
||||
Stream<bool> get appearanceVisibility => _appearanceVisibility.stream;
|
||||
Stream<bool> get readerVisibility => _readerVisibility.stream;
|
||||
|
||||
Future<void> toggleReaderView(bool enable) {
|
||||
return _events.onToggleReaderView(enable);
|
||||
}
|
||||
|
||||
Future<void> onAppearanceButtonTap() {
|
||||
return _events.onAppearanceButtonTap();
|
||||
}
|
||||
|
||||
@override
|
||||
void appearanceButtonVisibility(bool visible) {
|
||||
_appearanceVisibility.add(visible);
|
||||
}
|
||||
|
||||
@override
|
||||
void readerViewButtonVisibility(bool visible) {
|
||||
_readerVisibility.add(visible);
|
||||
}
|
||||
|
||||
GeckoReaderableService.setUp({
|
||||
ReaderViewEvents? readerEvents,
|
||||
BinaryMessenger? binaryMessenger,
|
||||
String messageChannelSuffix = '',
|
||||
}) : _events = readerEvents ??
|
||||
ReaderViewEvents(
|
||||
binaryMessenger: binaryMessenger,
|
||||
messageChannelSuffix: messageChannelSuffix,
|
||||
) {
|
||||
ReaderViewController.setUp(
|
||||
this,
|
||||
binaryMessenger: binaryMessenger,
|
||||
messageChannelSuffix: messageChannelSuffix,
|
||||
);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
unawaited(_appearanceVisibility.close());
|
||||
unawaited(_readerVisibility.close());
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,13 @@ class GeckoSessionService {
|
||||
final String? tabId;
|
||||
final GeckoSessionApi _api;
|
||||
|
||||
GeckoSessionService({required String this.tabId, GeckoSessionApi? api})
|
||||
: _api = api ?? _apiInstance;
|
||||
|
||||
GeckoSessionService.forActiveTab({GeckoSessionApi? api})
|
||||
: _api = api ?? _apiInstance,
|
||||
tabId = null;
|
||||
|
||||
GeckoSessionService({required String this.tabId, GeckoSessionApi? api})
|
||||
: _api = api ?? _apiInstance;
|
||||
|
||||
Future<void> loadUrl({
|
||||
required Uri url,
|
||||
LoadUrlFlags flags = LoadUrlFlags.NONE,
|
||||
|
||||
@@ -71,7 +71,10 @@ class GeckoTabService {
|
||||
RestoreLocation restoreLocation = RestoreLocation.end,
|
||||
}) {
|
||||
return _api.restoreTabsByList(
|
||||
tabs: tabs, selectTabId: selectTabId, restoreLocation: restoreLocation);
|
||||
tabs: tabs,
|
||||
selectTabId: selectTabId,
|
||||
restoreLocation: restoreLocation,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> restoreTabsByBrowserState({
|
||||
@@ -79,7 +82,9 @@ class GeckoTabService {
|
||||
RestoreLocation restoreLocation = RestoreLocation.end,
|
||||
}) {
|
||||
return _api.restoreTabsByBrowserState(
|
||||
state: state, restoreLocation: restoreLocation);
|
||||
state: state,
|
||||
restoreLocation: restoreLocation,
|
||||
);
|
||||
}
|
||||
//The calls with engin storage for restore are not supported at the moment
|
||||
|
||||
@@ -91,7 +96,9 @@ class GeckoTabService {
|
||||
required HistoryMetadataKey historyMetadata,
|
||||
}) {
|
||||
return _api.selectOrAddTabByHistory(
|
||||
url: url.toString(), historyMetadata: historyMetadata);
|
||||
url: url.toString(),
|
||||
historyMetadata: historyMetadata,
|
||||
);
|
||||
}
|
||||
|
||||
/// Selects an already existing tab displaying [url] or otherwise creates a new tab.
|
||||
@@ -116,7 +123,9 @@ class GeckoTabService {
|
||||
bool selectNewTab = true,
|
||||
}) {
|
||||
return _api.duplicateTab(
|
||||
selectTabId: selectTabId, selectNewTab: selectNewTab);
|
||||
selectTabId: selectTabId,
|
||||
selectNewTab: selectNewTab,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> moveTabs({
|
||||
@@ -125,7 +134,10 @@ class GeckoTabService {
|
||||
required bool placeAfter,
|
||||
}) {
|
||||
return _api.moveTabs(
|
||||
tabIds: tabIds, targetTabId: targetTabId, placeAfter: placeAfter);
|
||||
tabIds: tabIds,
|
||||
targetTabId: targetTabId,
|
||||
placeAfter: placeAfter,
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> migratePrivateTabUseCase({
|
||||
@@ -133,6 +145,8 @@ class GeckoTabService {
|
||||
Uri? alternativeUrl,
|
||||
}) {
|
||||
return _api.migratePrivateTabUseCase(
|
||||
tabId: tabId, alternativeUrl: alternativeUrl?.toString());
|
||||
tabId: tabId,
|
||||
alternativeUrl: alternativeUrl?.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ class GeckoView extends StatelessWidget {
|
||||
await GeckoBrowserService().showNativeFragment();
|
||||
});
|
||||
})
|
||||
// ignore: discarded_futures
|
||||
..create();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Autogenerated from Pigeon (v22.3.0), do not edit directly.
|
||||
// Autogenerated from Pigeon (v22.4.2), do not edit directly.
|
||||
// See also: https://pub.dev/packages/pigeon
|
||||
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
|
||||
|
||||
@@ -955,6 +955,37 @@ class TabContentState {
|
||||
}
|
||||
}
|
||||
|
||||
class FindResultState {
|
||||
FindResultState({
|
||||
required this.activeMatchOrdinal,
|
||||
required this.numberOfMatches,
|
||||
required this.isDoneCounting,
|
||||
});
|
||||
|
||||
int activeMatchOrdinal;
|
||||
|
||||
int numberOfMatches;
|
||||
|
||||
bool isDoneCounting;
|
||||
|
||||
Object encode() {
|
||||
return <Object?>[
|
||||
activeMatchOrdinal,
|
||||
numberOfMatches,
|
||||
isDoneCounting,
|
||||
];
|
||||
}
|
||||
|
||||
static FindResultState decode(Object result) {
|
||||
result as List<Object?>;
|
||||
return FindResultState(
|
||||
activeMatchOrdinal: result[0]! as int,
|
||||
numberOfMatches: result[1]! as int,
|
||||
isDoneCounting: result[2]! as bool,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class _PigeonCodec extends StandardMessageCodec {
|
||||
const _PigeonCodec();
|
||||
@@ -1044,6 +1075,9 @@ class _PigeonCodec extends StandardMessageCodec {
|
||||
} else if (value is TabContentState) {
|
||||
buffer.putUint8(155);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is FindResultState) {
|
||||
buffer.putUint8(156);
|
||||
writeValue(buffer, value.encode());
|
||||
} else {
|
||||
super.writeValue(buffer, value);
|
||||
}
|
||||
@@ -1111,6 +1145,8 @@ class _PigeonCodec extends StandardMessageCodec {
|
||||
return SecurityInfoState.decode(readValue(buffer)!);
|
||||
case 155:
|
||||
return TabContentState.decode(readValue(buffer)!);
|
||||
case 156:
|
||||
return FindResultState.decode(readValue(buffer)!);
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
}
|
||||
@@ -1153,6 +1189,42 @@ class GeckoBrowserApi {
|
||||
}
|
||||
}
|
||||
|
||||
class GeckoEngineSettingsApi {
|
||||
/// Constructor for [GeckoEngineSettingsApi]. The [binaryMessenger] named argument is
|
||||
/// available for dependency injection. If it is left null, the default
|
||||
/// BinaryMessenger will be used which routes to the host platform.
|
||||
GeckoEngineSettingsApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
|
||||
: pigeonVar_binaryMessenger = binaryMessenger,
|
||||
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
final BinaryMessenger? pigeonVar_binaryMessenger;
|
||||
|
||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||
|
||||
final String pigeonVar_messageChannelSuffix;
|
||||
|
||||
Future<void> javaScriptEnabled(bool state) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoEngineSettingsApi.javaScriptEnabled$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_channel.send(<Object?>[state]) as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GeckoSessionApi {
|
||||
/// Constructor for [GeckoSessionApi]. The [binaryMessenger] named argument is
|
||||
/// available for dependency injection. If it is left null, the default
|
||||
@@ -1166,7 +1238,7 @@ class GeckoSessionApi {
|
||||
|
||||
final String pigeonVar_messageChannelSuffix;
|
||||
|
||||
Future<void> loadUrl({required String? tabId, required String url, required LoadUrlFlagsValue flags, required Map<String?, String?>? additionalHeaders,}) async {
|
||||
Future<void> loadUrl({required String? tabId, required String url, required LoadUrlFlagsValue flags, required Map<String, String>? additionalHeaders,}) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoSessionApi.loadUrl$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
@@ -1452,7 +1524,7 @@ class GeckoSessionApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> crashRecovery({required List<String?>? tabIds}) async {
|
||||
Future<void> crashRecovery({required List<String>? tabIds}) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoSessionApi.crashRecovery$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
@@ -1576,7 +1648,7 @@ class GeckoTabsApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> addTab({required String url, required bool selectTab, required bool startLoading, required String? parentId, required LoadUrlFlagsValue flags, required String? contextId, required SourceValue source, required bool private, required HistoryMetadataKey? historyMetadata, required Map<String?, String?>? additionalHeaders,}) async {
|
||||
Future<String> addTab({required String url, required bool selectTab, required bool startLoading, required String? parentId, required LoadUrlFlagsValue flags, required String? contextId, required SourceValue source, required bool private, required HistoryMetadataKey? historyMetadata, required Map<String, String>? additionalHeaders,}) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoTabsApi.addTab$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
@@ -1625,7 +1697,7 @@ class GeckoTabsApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> removeTabs({required List<String?> ids}) async {
|
||||
Future<void> removeTabs({required List<String> ids}) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoTabsApi.removeTabs$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
@@ -1713,7 +1785,7 @@ class GeckoTabsApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> restoreTabsByList({required List<RecoverableTab?> tabs, required String? selectTabId, required RestoreLocation restoreLocation,}) async {
|
||||
Future<void> restoreTabsByList({required List<RecoverableTab> tabs, required String? selectTabId, required RestoreLocation restoreLocation,}) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoTabsApi.restoreTabsByList$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
@@ -1841,7 +1913,7 @@ class GeckoTabsApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> moveTabs({required List<String?> tabIds, required String targetTabId, required bool placeAfter,}) async {
|
||||
Future<void> moveTabs({required List<String> tabIds, required String targetTabId, required bool placeAfter,}) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoTabsApi.moveTabs$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
@@ -1891,6 +1963,86 @@ class GeckoTabsApi {
|
||||
}
|
||||
}
|
||||
|
||||
class GeckoFindApi {
|
||||
/// Constructor for [GeckoFindApi]. The [binaryMessenger] named argument is
|
||||
/// available for dependency injection. If it is left null, the default
|
||||
/// BinaryMessenger will be used which routes to the host platform.
|
||||
GeckoFindApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
|
||||
: pigeonVar_binaryMessenger = binaryMessenger,
|
||||
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
final BinaryMessenger? pigeonVar_binaryMessenger;
|
||||
|
||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||
|
||||
final String pigeonVar_messageChannelSuffix;
|
||||
|
||||
Future<void> findAll(String? tabId, String text) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoFindApi.findAll$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_channel.send(<Object?>[tabId, text]) as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> findNext(String? tabId, bool forward) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoFindApi.findNext$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_channel.send(<Object?>[tabId, forward]) as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> clearMatches(String? tabId) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoFindApi.clearMatches$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_channel.send(<Object?>[tabId]) as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GeckoIconsApi {
|
||||
/// Constructor for [GeckoIconsApi]. The [binaryMessenger] named argument is
|
||||
/// available for dependency injection. If it is left null, the default
|
||||
@@ -1972,7 +2124,7 @@ class GeckoCookieApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<Cookie?>> getAllCookies(String? domain, String? firstPartyDomain, String? name, CookiePartitionKey? partitionKey, String? storeId, String url) async {
|
||||
Future<List<Cookie>> getAllCookies(String? domain, String? firstPartyDomain, String? name, CookiePartitionKey? partitionKey, String? storeId, String url) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.GeckoCookieApi.getAllCookies$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
@@ -1995,7 +2147,7 @@ class GeckoCookieApi {
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as List<Object?>?)!.cast<Cookie?>();
|
||||
return (pigeonVar_replyList[0] as List<Object?>?)!.cast<Cookie>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2047,7 +2199,7 @@ class GeckoCookieApi {
|
||||
abstract class GeckoStateEvents {
|
||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||
|
||||
void onTabListChange(List<String?> tabIds);
|
||||
void onTabListChange(List<String> tabIds);
|
||||
|
||||
void onSelectedTabChange(String? id);
|
||||
|
||||
@@ -2063,6 +2215,8 @@ abstract class GeckoStateEvents {
|
||||
|
||||
void onThumbnailChange(String id, Uint8List? bytes);
|
||||
|
||||
void onFindResults(String id, List<FindResultState> results);
|
||||
|
||||
static void setUp(GeckoStateEvents? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) {
|
||||
messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
{
|
||||
@@ -2076,9 +2230,9 @@ abstract class GeckoStateEvents {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onTabListChange was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final List<String?>? arg_tabIds = (args[0] as List<Object?>?)?.cast<String?>();
|
||||
final List<String>? arg_tabIds = (args[0] as List<Object?>?)?.cast<String>();
|
||||
assert(arg_tabIds != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onTabListChange was null, expected non-null List<String?>.');
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onTabListChange was null, expected non-null List<String>.');
|
||||
try {
|
||||
api.onTabListChange(arg_tabIds!);
|
||||
return wrapResponse(empty: true);
|
||||
@@ -2274,5 +2428,313 @@ abstract class GeckoStateEvents {
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onFindResults$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onFindResults was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final String? arg_id = (args[0] as String?);
|
||||
assert(arg_id != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onFindResults was null, expected non-null String.');
|
||||
final List<FindResultState>? arg_results = (args[1] as List<Object?>?)?.cast<FindResultState>();
|
||||
assert(arg_results != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.GeckoStateEvents.onFindResults was null, expected non-null List<FindResultState>.');
|
||||
try {
|
||||
api.onFindResults(arg_id!, arg_results!);
|
||||
return wrapResponse(empty: true);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ReaderViewEvents {
|
||||
/// Constructor for [ReaderViewEvents]. The [binaryMessenger] named argument is
|
||||
/// available for dependency injection. If it is left null, the default
|
||||
/// BinaryMessenger will be used which routes to the host platform.
|
||||
ReaderViewEvents({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
|
||||
: pigeonVar_binaryMessenger = binaryMessenger,
|
||||
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
final BinaryMessenger? pigeonVar_binaryMessenger;
|
||||
|
||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||
|
||||
final String pigeonVar_messageChannelSuffix;
|
||||
|
||||
Future<void> onToggleReaderView(bool enable) async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.ReaderViewEvents.onToggleReaderView$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_channel.send(<Object?>[enable]) as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onAppearanceButtonTap() async {
|
||||
final String pigeonVar_channelName = 'dev.flutter.pigeon.flutter_mozilla_components.ReaderViewEvents.onAppearanceButtonTap$pigeonVar_messageChannelSuffix';
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final List<Object?>? pigeonVar_replyList =
|
||||
await pigeonVar_channel.send(null) as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class ReaderViewController {
|
||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||
|
||||
void appearanceButtonVisibility(bool visible);
|
||||
|
||||
void readerViewButtonVisibility(bool visible);
|
||||
|
||||
static void setUp(ReaderViewController? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) {
|
||||
messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
{
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_mozilla_components.ReaderViewController.appearanceButtonVisibility$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.ReaderViewController.appearanceButtonVisibility was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final bool? arg_visible = (args[0] as bool?);
|
||||
assert(arg_visible != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.ReaderViewController.appearanceButtonVisibility was null, expected non-null bool.');
|
||||
try {
|
||||
api.appearanceButtonVisibility(arg_visible!);
|
||||
return wrapResponse(empty: true);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_mozilla_components.ReaderViewController.readerViewButtonVisibility$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.ReaderViewController.readerViewButtonVisibility was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final bool? arg_visible = (args[0] as bool?);
|
||||
assert(arg_visible != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.ReaderViewController.readerViewButtonVisibility was null, expected non-null bool.');
|
||||
try {
|
||||
api.readerViewButtonVisibility(arg_visible!);
|
||||
return wrapResponse(empty: true);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SelectionAction {
|
||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||
|
||||
/// Gets Strings representing all possible selection actions.
|
||||
///
|
||||
/// @returns String IDs for each action that could possibly be shown in the context menu. This
|
||||
/// array must include all actions, available or not, and must not change over the class lifetime.
|
||||
List<String> getAllActions();
|
||||
|
||||
/// Checks if an action can be shown on a new selection context menu.
|
||||
///
|
||||
/// @returns whether or not the the custom action with the id of [id] is currently available
|
||||
/// which may be informed by [selectedText].
|
||||
bool isActionAvailable(String id, String selectedText);
|
||||
|
||||
/// Gets a title to be shown in the selection context menu.
|
||||
///
|
||||
/// @returns the text that should be shown on the action.
|
||||
String? getActionTitle(String id);
|
||||
|
||||
/// Should perform the action with the id of [id].
|
||||
///
|
||||
/// @returns [true] if the action was consumed.
|
||||
bool performAction(String id, String selectedText);
|
||||
|
||||
/// Takes in a list of actions and sorts them.
|
||||
///
|
||||
/// @returns the sorted list.
|
||||
List<String> sortedActions(List<String> actions);
|
||||
|
||||
static void setUp(SelectionAction? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) {
|
||||
messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
{
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.getAllActions$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
try {
|
||||
final List<String> output = api.getAllActions();
|
||||
return wrapResponse(result: output);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.isActionAvailable$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.isActionAvailable was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final String? arg_id = (args[0] as String?);
|
||||
assert(arg_id != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.isActionAvailable was null, expected non-null String.');
|
||||
final String? arg_selectedText = (args[1] as String?);
|
||||
assert(arg_selectedText != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.isActionAvailable was null, expected non-null String.');
|
||||
try {
|
||||
final bool output = api.isActionAvailable(arg_id!, arg_selectedText!);
|
||||
return wrapResponse(result: output);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.getActionTitle$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.getActionTitle was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final String? arg_id = (args[0] as String?);
|
||||
assert(arg_id != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.getActionTitle was null, expected non-null String.');
|
||||
try {
|
||||
final String? output = api.getActionTitle(arg_id!);
|
||||
return wrapResponse(result: output);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.performAction$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.performAction was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final String? arg_id = (args[0] as String?);
|
||||
assert(arg_id != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.performAction was null, expected non-null String.');
|
||||
final String? arg_selectedText = (args[1] as String?);
|
||||
assert(arg_selectedText != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.performAction was null, expected non-null String.');
|
||||
try {
|
||||
final bool output = api.performAction(arg_id!, arg_selectedText!);
|
||||
return wrapResponse(result: output);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.sortedActions$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.sortedActions was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final List<String>? arg_actions = (args[0] as List<Object?>?)?.cast<String>();
|
||||
assert(arg_actions != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_mozilla_components.SelectionAction.sortedActions was null, expected non-null List<String>.');
|
||||
try {
|
||||
final List<String> output = api.sortedActions(arg_actions!);
|
||||
return wrapResponse(result: output);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,19 +375,20 @@ class Cookie {
|
||||
final String value;
|
||||
|
||||
Cookie(
|
||||
this.domain,
|
||||
this.expirationDate,
|
||||
this.firstPartyDomain,
|
||||
this.hostOnly,
|
||||
this.httpOnly,
|
||||
this.name,
|
||||
this.partitionKey,
|
||||
this.path,
|
||||
this.secure,
|
||||
this.session,
|
||||
this.sameSite,
|
||||
this.storeId,
|
||||
this.value);
|
||||
this.domain,
|
||||
this.expirationDate,
|
||||
this.firstPartyDomain,
|
||||
this.hostOnly,
|
||||
this.httpOnly,
|
||||
this.name,
|
||||
this.partitionKey,
|
||||
this.path,
|
||||
this.secure,
|
||||
this.session,
|
||||
this.sameSite,
|
||||
this.storeId,
|
||||
this.value,
|
||||
);
|
||||
}
|
||||
|
||||
class HistoryItem {
|
||||
@@ -456,20 +457,95 @@ class TabContentState {
|
||||
);
|
||||
}
|
||||
|
||||
@ConfigurePigeon(PigeonOptions(
|
||||
dartOut: 'lib/src/pigeons/gecko.g.dart',
|
||||
dartOptions: DartOptions(),
|
||||
kotlinOut:
|
||||
'android/src/main/kotlin/eu/lensai/flutter_mozilla_components/pigeons/Gecko.g.kt',
|
||||
kotlinOptions:
|
||||
KotlinOptions(package: 'eu.lensai.flutter_mozilla_components.pigeons'),
|
||||
dartPackageName: 'flutter_mozilla_components',
|
||||
))
|
||||
class FindResultState {
|
||||
final int activeMatchOrdinal;
|
||||
final int numberOfMatches;
|
||||
final bool isDoneCounting;
|
||||
|
||||
FindResultState(
|
||||
this.activeMatchOrdinal,
|
||||
this.numberOfMatches,
|
||||
this.isDoneCounting,
|
||||
);
|
||||
}
|
||||
|
||||
// /// Represents all the different supported types of data that can be found from long clicking
|
||||
// /// an element.
|
||||
// sealed class HitResult {
|
||||
// final String src;
|
||||
|
||||
// HitResult(this.src);
|
||||
// }
|
||||
|
||||
// /// Default type if we're unable to match the type to anything. It may or may not have a src.
|
||||
// class UnknownHitResult extends HitResult {
|
||||
// UnknownHitResult(super.src);
|
||||
// }
|
||||
|
||||
// /// If the HTML element was of type 'HTMLImageElement'.
|
||||
// class ImageHitResult extends HitResult {
|
||||
// final String? title;
|
||||
|
||||
// ImageHitResult(super.src, {this.title});
|
||||
// }
|
||||
|
||||
// /// If the HTML element was of type 'HTMLVideoElement'.
|
||||
// class VideoHitResult extends HitResult {
|
||||
// final String? title;
|
||||
|
||||
// VideoHitResult(super.src, {this.title});
|
||||
// }
|
||||
|
||||
// /// If the HTML element was of type 'HTMLAudioElement'.
|
||||
// class AudioHitResult extends HitResult {
|
||||
// final String? title;
|
||||
|
||||
// AudioHitResult(super.src, {this.title});
|
||||
// }
|
||||
|
||||
// /// If the HTML element was of type 'HTMLImageElement' and contained a URI.
|
||||
// class ImageSrcHitResult extends HitResult {
|
||||
// final String uri;
|
||||
|
||||
// ImageSrcHitResult(super.src, this.uri);
|
||||
// }
|
||||
|
||||
// /// The type used if the URI is prepended with 'tel:'.
|
||||
// class PhoneHitResult extends HitResult {
|
||||
// PhoneHitResult(super.src);
|
||||
// }
|
||||
|
||||
// /// The type used if the URI is prepended with 'mailto:'.
|
||||
// class EmailHitResult extends HitResult {
|
||||
// EmailHitResult(super.src);
|
||||
// }
|
||||
|
||||
// /// The type used if the URI is prepended with 'geo:'.
|
||||
// class GeoHitResult extends HitResult {
|
||||
// GeoHitResult(super.src);
|
||||
// }
|
||||
|
||||
@ConfigurePigeon(
|
||||
PigeonOptions(
|
||||
dartOut: 'lib/src/pigeons/gecko.g.dart',
|
||||
dartOptions: DartOptions(),
|
||||
kotlinOut:
|
||||
'android/src/main/kotlin/eu/lensai/flutter_mozilla_components/pigeons/Gecko.g.kt',
|
||||
kotlinOptions:
|
||||
KotlinOptions(package: 'eu.lensai.flutter_mozilla_components.pigeons'),
|
||||
dartPackageName: 'flutter_mozilla_components',
|
||||
),
|
||||
)
|
||||
@HostApi()
|
||||
abstract class GeckoBrowserApi {
|
||||
void showNativeFragment();
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
abstract class GeckoEngineSettingsApi {
|
||||
void javaScriptEnabled(bool state);
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
abstract class GeckoSessionApi {
|
||||
void loadUrl({
|
||||
@@ -629,6 +705,13 @@ abstract class GeckoTabsApi {
|
||||
});
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
abstract class GeckoFindApi {
|
||||
void findAll(String? tabId, String text);
|
||||
void findNext(String? tabId, bool forward);
|
||||
void clearMatches(String? tabId);
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
abstract class GeckoIconsApi {
|
||||
@async
|
||||
@@ -693,4 +776,48 @@ abstract class GeckoStateEvents {
|
||||
void onSecurityInfoStateChange(String id, SecurityInfoState state);
|
||||
void onIconChange(String id, Uint8List? bytes);
|
||||
void onThumbnailChange(String id, Uint8List? bytes);
|
||||
|
||||
void onFindResults(String id, List<FindResultState> results);
|
||||
}
|
||||
|
||||
@HostApi()
|
||||
abstract class ReaderViewEvents {
|
||||
void onToggleReaderView(bool enable);
|
||||
void onAppearanceButtonTap();
|
||||
}
|
||||
|
||||
@FlutterApi()
|
||||
abstract class ReaderViewController {
|
||||
void appearanceButtonVisibility(bool visible);
|
||||
void readerViewButtonVisibility(bool visible);
|
||||
}
|
||||
|
||||
@FlutterApi()
|
||||
abstract class SelectionAction {
|
||||
/// Gets Strings representing all possible selection actions.
|
||||
///
|
||||
/// @returns String IDs for each action that could possibly be shown in the context menu. This
|
||||
/// array must include all actions, available or not, and must not change over the class lifetime.
|
||||
List<String> getAllActions();
|
||||
|
||||
/// Checks if an action can be shown on a new selection context menu.
|
||||
///
|
||||
/// @returns whether or not the the custom action with the id of [id] is currently available
|
||||
/// which may be informed by [selectedText].
|
||||
bool isActionAvailable(String id, String selectedText);
|
||||
|
||||
/// Gets a title to be shown in the selection context menu.
|
||||
///
|
||||
/// @returns the text that should be shown on the action.
|
||||
String? getActionTitle(String id);
|
||||
|
||||
/// Should perform the action with the id of [id].
|
||||
///
|
||||
/// @returns [true] if the action was consumed.
|
||||
bool performAction(String id, String selectedText);
|
||||
|
||||
/// Takes in a list of actions and sorts them.
|
||||
///
|
||||
/// @returns the sorted list.
|
||||
List<String> sortedActions(List<String> actions);
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ environment:
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
plugin_platform_interface: ^2.0.2
|
||||
plugin_platform_interface: ^2.1.8
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^4.0.0
|
||||
pigeon: ^22.3.0
|
||||
lint: ^2.3.0
|
||||
pigeon: ^22.4.2
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
Reference in New Issue
Block a user