Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c01431f

Browse files
committed
Update comments
1 parent 3eab698 commit c01431f

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

shell/platform/android/io/flutter/embedding/engine/systemchannels/ProcessTextChannel.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@
1818
* {@link ProcessTextChannel} is a platform channel that is used by the framework to initiate text
1919
* processing feature in the embedding and for the embedding to send back the results.
2020
*
21-
* <p>When there is new a text context menu to display, the framework will send to the embedding the
22-
* message {@code ProcessText.queryTextActions}. In response, the {@link
23-
* io.flutter.plugin.text.ProcessTextPlugin} will return a map of all activities that can be
24-
* performed to process text. The map keys are generated IDs and the values are the activities
25-
* labels. On the first request, the {@link io.flutter.plugin.text.ProcessTextPlugin} will make a
26-
* call to Android's package manager to query all activities that can be performed for the {@code
27-
* Intent.ACTION_PROCESS_TEXT} intent.
21+
* <p>When the framework needs to query the list of text processing actions (for instance to expose
22+
* them in the selected text context menu), it will send to the embedding the message {@code
23+
* ProcessText.queryTextActions}. In response, the {@link io.flutter.plugin.text.ProcessTextPlugin}
24+
* will return a map of all activities that can process text. The map keys are generated IDs and the
25+
* values are the activities labels. On the first request, the {@link
26+
* io.flutter.plugin.text.ProcessTextPlugin} will make a call to Android's package manager to query
27+
* all activities that can be performed for the {@code Intent.ACTION_PROCESS_TEXT} intent.
2828
*
29-
* <p>When an text processing action has to be executed, the framework will send to the embedding
30-
* the message {@code ProcessText.processTextAction} with the {@code int id} of the choosen text
31-
* action and the {@code String} of text to process as arguments. In response, the {@link
29+
* <p>When a text processing action has to be executed, the framework will send to the embedding the
30+
* message {@code ProcessText.processTextAction} with the {@code int id} of the choosen text action
31+
* and the {@code String} of text to process as arguments. In response, the {@link
3232
* io.flutter.plugin.text.ProcessTextPlugin} will make a call to the Android application activity to
33-
* start the activity exposing the text action and it will return the processed text, or null if the
34-
* activity did not return a value.
33+
* start the activity exposing the text action. The {@link io.flutter.plugin.text.ProcessTextPlugin}
34+
* will return the processed text if there is one, or null if the activity did not return a
35+
* transformed text.
3536
*
3637
* <p>{@link io.flutter.plugin.text.ProcessTextPlugin} implements {@link ProcessTextMethodHandler}
3738
* that parses incoming messages from Flutter.
@@ -99,15 +100,13 @@ public void setMethodHandler(@Nullable ProcessTextMethodHandler processTextMetho
99100
}
100101

101102
public interface ProcessTextMethodHandler {
102-
/**
103-
* Requests the list of text actions. Each text action has a unique id and a localized label.
104-
*/
103+
/** Requests the map of text actions. Each text action has a unique id and a localized label. */
105104
Map<Integer, String> queryTextActions();
106105

107106
/**
108107
* Requests to run a text action on a given input text.
109108
*
110-
* @param id The ID of the text action returned by queryTextActions.
109+
* @param id The ID of the text action returned by {@code ProcessText.queryTextActions}.
111110
* @param input The text to be processed.
112111
* @param readOnly Indicates to the activity if the processed text will be used as read-only.
113112
* see

shell/platform/android/io/flutter/plugin/text/ProcessTextPlugin.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public void processTextAction(
9797
intent.putExtra(Intent.EXTRA_PROCESS_TEXT, text);
9898
intent.putExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, readOnly);
9999

100-
// Start the text processing activity. onActivityResult callback is called
101-
// when the activity completes.
100+
// Start the text processing activity. When the activity complets, the onActivityResult callback
101+
// is called.
102102
activityBinding.getActivity().startActivityForResult(intent, requestCode);
103103
}
104104

@@ -128,7 +128,11 @@ private void cacheResolveInfos() {
128128
/**
129129
* Executed when a text processing activity terminates.
130130
*
131-
* <p>The result is null when an activity does not return an updated text.
131+
* <p>When an activity returns a value, the request is completed successfully and returns the
132+
* processed text.
133+
*
134+
* <p>When an activity does not return a valuen. the request is completed successfully and returns
135+
* null.
132136
*/
133137
@TargetApi(Build.VERSION_CODES.M)
134138
@RequiresApi(Build.VERSION_CODES.M)

shell/platform/android/test/io/flutter/plugin/text/ProcessTextPluginTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ public void performProcessTextActionWithNoReturnedValue() {
126126
final int action2Id = 1;
127127
assertEquals(textActions, Map.of(action1Id, "Action1", action2Id, "Action2"));
128128

129-
// Set up activity binding.
129+
// Set up the activity binding.
130130
ActivityPluginBinding mockActivityPluginBinding = mock(ActivityPluginBinding.class);
131131
Activity mockActivity = mock(Activity.class);
132132
when(mockActivityPluginBinding.getActivity()).thenReturn(mockActivity);
133133
processTextPlugin.onAttachedToActivity(mockActivityPluginBinding);
134134

135-
// Execute first action.
135+
// Execute th first action.
136136
String textToBeProcessed = "Flutter!";
137137
MethodChannel.Result result = mock(MethodChannel.Result.class);
138138
processTextPlugin.processTextAction(action1Id, textToBeProcessed, false, result);
@@ -143,7 +143,7 @@ public void performProcessTextActionWithNoReturnedValue() {
143143
Intent intent = intentCaptor.getValue();
144144
assertEquals(intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT), textToBeProcessed);
145145

146-
// Simulate an Android activity answer which does not return any value.
146+
// Simulate an Android activity answer which does not return a value.
147147
Intent resultIntent = new Intent();
148148
processTextPlugin.onActivityResult(result.hashCode(), Activity.RESULT_OK, resultIntent);
149149

@@ -175,13 +175,13 @@ public void performProcessTextActionWithReturnedValue() {
175175
final int action2Id = 1;
176176
assertEquals(textActions, Map.of(action1Id, "Action1", action2Id, "Action2"));
177177

178-
// Set up activity binding.
178+
// Set up the activity binding.
179179
ActivityPluginBinding mockActivityPluginBinding = mock(ActivityPluginBinding.class);
180180
Activity mockActivity = mock(Activity.class);
181181
when(mockActivityPluginBinding.getActivity()).thenReturn(mockActivity);
182182
processTextPlugin.onAttachedToActivity(mockActivityPluginBinding);
183183

184-
// Execute first action.
184+
// Execute the first action.
185185
String textToBeProcessed = "Flutter!";
186186
MethodChannel.Result result = mock(MethodChannel.Result.class);
187187
processTextPlugin.processTextAction(action1Id, textToBeProcessed, false, result);

0 commit comments

Comments
 (0)