Skip to content

Commit 718329c

Browse files
Android Embedding PR 17: Clarify AccessibilityBridge and move logic out of FlutterView. (flutter#8061)
1 parent edfc0cf commit 718329c

File tree

5 files changed

+1103
-634
lines changed

5 files changed

+1103
-634
lines changed

shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import io.flutter.embedding.engine.FlutterEngine.EngineLifecycleListener;
2121
import io.flutter.embedding.engine.renderer.FlutterRenderer;
2222
import io.flutter.embedding.engine.renderer.OnFirstFrameRenderedListener;
23+
import io.flutter.plugin.common.StandardMessageCodec;
24+
import io.flutter.view.AccessibilityBridge;
2325

2426
/**
2527
* Interface between Flutter embedding's Java code and Flutter engine's C/C++ code.
@@ -323,6 +325,22 @@ private native void nativeDispatchPointerDataPacket(long nativePlatformViewId,
323325
ByteBuffer buffer,
324326
int position);
325327

328+
public void dispatchSemanticsAction(int id, @NonNull AccessibilityBridge.Action action) {
329+
dispatchSemanticsAction(id, action, null);
330+
}
331+
332+
public void dispatchSemanticsAction(int id, @NonNull AccessibilityBridge.Action action, @Nullable Object args) {
333+
ensureAttachedToNative();
334+
335+
ByteBuffer encodedArgs = null;
336+
int position = 0;
337+
if (args != null) {
338+
encodedArgs = StandardMessageCodec.INSTANCE.encodeMessage(args);
339+
position = encodedArgs.position();
340+
}
341+
dispatchSemanticsAction(id, action.value, encodedArgs, position);
342+
}
343+
326344
@UiThread
327345
public void dispatchSemanticsAction(int id, int action, ByteBuffer args, int argsPosition) {
328346
ensureAttachedToNative();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ public interface AccessibilityMessageHandler {
103103
void announce(@NonNull String message);
104104

105105
/**
106-
* The user has tapped on the artifact with the given {@code nodeId}.
106+
* The user has tapped on the widget with the given {@code nodeId}.
107107
*/
108108
void onTap(int nodeId);
109109

110110
/**
111-
* The user has long pressed on the artifact with the given {@code nodeId}.
111+
* The user has long pressed on the widget with the given {@code nodeId}.
112112
*/
113113
void onLongPress(int nodeId);
114114

115115
/**
116-
* The user has opened a popup window, menu, dialog, etc.
116+
* The user has opened a tooltip.
117117
*/
118118
void onTooltip(@NonNull String message);
119119
}

0 commit comments

Comments
 (0)