Flutter Engine
The Flutter Engine
AccessibilityEventsDelegate.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter.plugin.platform;
6
7import android.view.MotionEvent;
8import android.view.View;
9import android.view.accessibility.AccessibilityEvent;
10import androidx.annotation.NonNull;
11import androidx.annotation.Nullable;
12import io.flutter.view.AccessibilityBridge;
13
14/**
15 * Delegates accessibility events to the currently attached accessibility bridge if one is attached.
16 */
18 private AccessibilityBridge accessibilityBridge;
19
20 /**
21 * Delegates handling of {@link android.view.ViewParent#requestSendAccessibilityEvent} to the
22 * accessibility bridge.
23 *
24 * <p>This is a no-op if there is no accessibility delegate set.
25 *
26 * <p>This is used by embedded platform views to propagate accessibility events from their view
27 * hierarchy to the accessibility bridge.
28 *
29 * <p>As the embedded view doesn't have to be the only View in the embedded hierarchy (it can have
30 * child views) and the event might have been originated from any view in this hierarchy, this
31 * method gets both a reference to the embedded platform view, and a reference to the view from
32 * its hierarchy that sent the event.
33 *
34 * @param embeddedView the embedded platform view for which the event is delegated
35 * @param eventOrigin the view in the embedded view's hierarchy that sent the event.
36 * @return True if the event was sent.
37 */
39 @NonNull View embeddedView, @NonNull View eventOrigin, @NonNull AccessibilityEvent event) {
40 if (accessibilityBridge == null) {
41 return false;
42 }
43 return accessibilityBridge.externalViewRequestSendAccessibilityEvent(
44 embeddedView, eventOrigin, event);
45 }
46
47 public boolean onAccessibilityHoverEvent(MotionEvent event, boolean ignorePlatformViews) {
48 if (accessibilityBridge == null) {
49 return false;
50 }
51 return accessibilityBridge.onAccessibilityHoverEvent(event, ignorePlatformViews);
52 }
53
54 /*
55 * This setter should only be used directly in PlatformViewsController when attached/detached to an accessibility
56 * bridge.
57 */
58 void setAccessibilityBridge(@Nullable AccessibilityBridge accessibilityBridge) {
59 this.accessibilityBridge = accessibilityBridge;
60 }
61}
boolean onAccessibilityHoverEvent(MotionEvent event, boolean ignorePlatformViews)
void setAccessibilityBridge(@Nullable AccessibilityBridge accessibilityBridge)
boolean requestSendAccessibilityEvent( @NonNull View embeddedView, @NonNull View eventOrigin, @NonNull AccessibilityEvent event)
FlKeyEvent * event