new search action and sorting of actions
This commit is contained in:
@@ -2,6 +2,8 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||||
import 'package:lensai/core/logger.dart';
|
import 'package:lensai/core/logger.dart';
|
||||||
|
import 'package:lensai/core/providers/router.dart';
|
||||||
|
import 'package:lensai/core/routing/routes.dart';
|
||||||
import 'package:lensai/features/bangs/domain/providers/bangs.dart';
|
import 'package:lensai/features/bangs/domain/providers/bangs.dart';
|
||||||
import 'package:lensai/features/geckoview/domain/providers/tab_state.dart';
|
import 'package:lensai/features/geckoview/domain/providers/tab_state.dart';
|
||||||
import 'package:lensai/features/geckoview/domain/repositories/tab.dart';
|
import 'package:lensai/features/geckoview/domain/repositories/tab.dart';
|
||||||
@@ -19,6 +21,17 @@ GeckoSelectionActionService selectionActionService(Ref ref) {
|
|||||||
unawaited(
|
unawaited(
|
||||||
service.setActions([
|
service.setActions([
|
||||||
SearchAction((text) async {
|
SearchAction((text) async {
|
||||||
|
final router = ref.read(routerProvider);
|
||||||
|
final isCurrentPrivate =
|
||||||
|
ref.read(selectedTabStateProvider)?.isPrivate ?? false;
|
||||||
|
final route = SearchRoute(
|
||||||
|
tabType: isCurrentPrivate ? TabType.private : TabType.regular,
|
||||||
|
searchText: text,
|
||||||
|
);
|
||||||
|
|
||||||
|
await router.push(route.location);
|
||||||
|
}),
|
||||||
|
DefaultSearchAction((text) async {
|
||||||
final defaultSearchBang = await ref.read(
|
final defaultSearchBang = await ref.read(
|
||||||
defaultSearchBangDataProvider.future,
|
defaultSearchBangDataProvider.future,
|
||||||
);
|
);
|
||||||
@@ -37,19 +50,6 @@ GeckoSelectionActionService selectionActionService(Ref ref) {
|
|||||||
logger.e('No default search bang found');
|
logger.e('No default search bang found');
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
// PrivateSearchAction((text) async {
|
|
||||||
// final defaultSearchBang = await ref.read(
|
|
||||||
// defaultSearchBangDataProvider.future,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if (defaultSearchBang != null) {
|
|
||||||
// await ref
|
|
||||||
// .read(tabRepositoryProvider.notifier)
|
|
||||||
// .addTab(url: defaultSearchBang.getUrl(text), private: true);
|
|
||||||
// } else {
|
|
||||||
// logger.e('No default search bang found');
|
|
||||||
// }
|
|
||||||
// }),
|
|
||||||
ShareAction((text) async {
|
ShareAction((text) async {
|
||||||
await SharePlus.instance.share(ShareParams(text: text));
|
await SharePlus.instance.share(ShareParams(text: text));
|
||||||
}),
|
}),
|
||||||
|
|||||||
+7
-1
@@ -109,7 +109,13 @@ class GeckoBrowserApiImpl : GeckoBrowserApi {
|
|||||||
private fun setupGeckoEngine() {
|
private fun setupGeckoEngine() {
|
||||||
val selectionActionEvents = GeckoSelectionActionEvents(_flutterPluginBinding.binaryMessenger)
|
val selectionActionEvents = GeckoSelectionActionEvents(_flutterPluginBinding.binaryMessenger)
|
||||||
|
|
||||||
val selectionActionDelegate = DefaultSelectionActionDelegate(selectionActionEvents)
|
val selectionActionDelegate = DefaultSelectionActionDelegate(selectionActionEvents) { actions ->
|
||||||
|
val processTextAction = "android.intent.action.PROCESS_TEXT"
|
||||||
|
val withoutProcessText = actions.filter { it != processTextAction }.toTypedArray()
|
||||||
|
val processTextActions = actions.filter { it == processTextAction }.toTypedArray()
|
||||||
|
|
||||||
|
withoutProcessText + processTextActions
|
||||||
|
}
|
||||||
|
|
||||||
val readerViewController =
|
val readerViewController =
|
||||||
ReaderViewController(_flutterPluginBinding.binaryMessenger)
|
ReaderViewController(_flutterPluginBinding.binaryMessenger)
|
||||||
|
|||||||
+9
@@ -33,6 +33,15 @@ class EmailAction extends BaseSelectionAction {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DefaultSearchAction extends BaseSelectionAction {
|
||||||
|
DefaultSearchAction(PerformAction action)
|
||||||
|
: super(
|
||||||
|
id: 'CUSTOM_CONTEXT_MENU_SEARCH_DEFAULT',
|
||||||
|
title: 'Web Search',
|
||||||
|
performAction: action,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
class SearchAction extends BaseSelectionAction {
|
class SearchAction extends BaseSelectionAction {
|
||||||
SearchAction(PerformAction action)
|
SearchAction(PerformAction action)
|
||||||
: super(
|
: super(
|
||||||
|
|||||||
Reference in New Issue
Block a user