forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delegate a11y events and action to/from embedded Android platform vie…
…ws. (flutter#8250) Delegate a11y events and action to/from embedded Android platfrom views. This handles delegation of: * AccessibilityNodeProvider#performAction * ViewGroup#requestSendAccessibilityEvent * View#onHoverEvent Additionally updates the currently input accessibility focused node state that is tracked by the a11y bridge when an embedded view's node is focused.
- Loading branch information
Showing
8 changed files
with
376 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
shell/platform/android/io/flutter/plugin/platform/AccessibilityEventsDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugin.platform; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.view.View; | ||
import android.view.accessibility.AccessibilityEvent; | ||
import io.flutter.view.AccessibilityBridge; | ||
|
||
/** | ||
* Delegates accessibility events to the currently attached accessibility bridge if one is attached. | ||
*/ | ||
class AccessibilityEventsDelegate { | ||
private AccessibilityBridge accessibilityBridge; | ||
|
||
/** | ||
* Delegates handling of {@link android.view.ViewParent#requestSendAccessibilityEvent} to the accessibility bridge. | ||
* | ||
* This is a no-op if there is no accessibility delegate set. | ||
* | ||
* This is used by embedded platform views to propagate accessibility events from their view hierarchy to the | ||
* accessibility bridge. | ||
* | ||
* As the embedded view doesn't have to be the only View in the embedded hierarchy (it can have child views) and the | ||
* event might have been originated from any view in this hierarchy, this method gets both a reference to the | ||
* embedded platform view, and a reference to the view from its hierarchy that sent the event. | ||
* | ||
* @param embeddedView the embedded platform view for which the event is delegated | ||
* @param eventOrigin the view in the embedded view's hierarchy that sent the event. | ||
* @return True if the event was sent. | ||
*/ | ||
public boolean requestSendAccessibilityEvent(@NonNull View embeddedView, @NonNull View eventOrigin, @NonNull AccessibilityEvent event) { | ||
if (accessibilityBridge == null) { | ||
return false; | ||
} | ||
return accessibilityBridge.externalViewRequestSendAccessibilityEvent(embeddedView, eventOrigin, event); | ||
} | ||
|
||
/* | ||
* This setter should only be used directly in PlatformViewsController when attached/detached to an accessibility | ||
* bridge. | ||
*/ | ||
void setAccessibilityBridge(@Nullable AccessibilityBridge accessibilityBridge) { | ||
this.accessibilityBridge = accessibilityBridge; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.