Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | List of all members
io.flutter.embedding.engine.systemchannels.ProcessTextChannel Class Reference

Classes

interface  ProcessTextMethodHandler
 

Public Member Functions

 ProcessTextChannel ( @NonNull DartExecutor dartExecutor, @NonNull PackageManager packageManager)
 
void setMethodHandler (@Nullable ProcessTextMethodHandler processTextMethodHandler)
 

Public Attributes

final MethodChannel channel
 
final PackageManager packageManager
 
final MethodChannel.MethodCallHandler parsingMethodHandler
 

Detailed Description

ProcessTextChannel is a platform channel that is used by the framework to initiate text processing feature in the embedding and for the embedding to send back the results.

When the framework needs to query the list of text processing actions (for instance to expose them in the selected text context menu), it will send to the embedding the message
ProcessText.queryTextActions
. In response, the io.flutter.plugin.text.ProcessTextPlugin will return a map of all activities that can process text. The map keys are generated IDs and the values are the activities labels. On the first request, the io.flutter.plugin.text.ProcessTextPlugin will make a call to Android's package manager to query all activities that can be performed for the Intent.ACTION_PROCESS_TEXT intent.

When a text processing action has to be executed, the framework will send to the embedding the message ProcessText.processTextAction with the int id of the choosen text action and the String of text to process as arguments. In response, the io.flutter.plugin.text.ProcessTextPlugin will make a call to the Android application activity to start the activity exposing the text action. The io.flutter.plugin.text.ProcessTextPlugin will return the processed text if there is one, or null if the activity did not return a transformed text.

io.flutter.plugin.text.ProcessTextPlugin implements ProcessTextMethodHandler that parses incoming messages from Flutter.

Definition at line 40 of file ProcessTextChannel.java.

Constructor & Destructor Documentation

◆ ProcessTextChannel()

io.flutter.embedding.engine.systemchannels.ProcessTextChannel.ProcessTextChannel ( @NonNull DartExecutor  dartExecutor,
@NonNull PackageManager  packageManager 
)
inline

Definition at line 87 of file ProcessTextChannel.java.

88 {
89 this.packageManager = packageManager;
90 channel = new MethodChannel(dartExecutor, CHANNEL_NAME, StandardMethodCodec.INSTANCE);
91 channel.setMethodCallHandler(parsingMethodHandler);
92 }

Member Function Documentation

◆ setMethodHandler()

void io.flutter.embedding.engine.systemchannels.ProcessTextChannel.setMethodHandler ( @Nullable ProcessTextMethodHandler  processTextMethodHandler)
inline

Sets the ProcessTextMethodHandler which receives all requests to the text processing feature sent through this channel.

Definition at line 98 of file ProcessTextChannel.java.

98 {
99 this.processTextMethodHandler = processTextMethodHandler;
100 }

Member Data Documentation

◆ channel

final MethodChannel io.flutter.embedding.engine.systemchannels.ProcessTextChannel.channel

Definition at line 46 of file ProcessTextChannel.java.

◆ packageManager

final PackageManager io.flutter.embedding.engine.systemchannels.ProcessTextChannel.packageManager

Definition at line 47 of file ProcessTextChannel.java.

◆ parsingMethodHandler

final MethodChannel.MethodCallHandler io.flutter.embedding.engine.systemchannels.ProcessTextChannel.parsingMethodHandler

Definition at line 51 of file ProcessTextChannel.java.

52 {
53 @Override
54 public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
55 if (processTextMethodHandler == null) {
56 return;
57 }
58 String method = call.method;
59 Object args = call.arguments;
60 switch (method) {
61 case METHOD_QUERY_TEXT_ACTIONS:
62 try {
63 Map<String, String> actions = processTextMethodHandler.queryTextActions();
64 result.success(actions);
65 } catch (IllegalStateException exception) {
66 result.error("error", exception.getMessage(), null);
67 }
68 break;
69 case METHOD_PROCESS_TEXT_ACTION:
70 try {
71 final ArrayList<Object> argumentList = (ArrayList<Object>) args;
72 String id = (String) (argumentList.get(0));
73 String text = (String) (argumentList.get(1));
74 boolean readOnly = (boolean) (argumentList.get(2));
75 processTextMethodHandler.processTextAction(id, text, readOnly, result);
76 } catch (IllegalStateException exception) {
77 result.error("error", exception.getMessage(), null);
78 }
79 break;
80 default:
81 result.notImplemented();
82 break;
83 }
84 }
85 };
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static ::testing::Matcher< GBytes * > MethodCall(const std::string &name, ::testing::Matcher< FlValue * > args)
GAsyncResult * result
void processTextAction( @NonNull String id, @NonNull String input, @NonNull boolean readOnly, @NonNull MethodChannel.Result result)
std::u16string text
call(args)
Definition dom.py:159

The documentation for this class was generated from the following file: