Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d43ce79f authored by Daniel Akinola's avatar Daniel Akinola
Browse files

Fix a11y for new refactored app handle

With the new WindowDecortation refactor, app handle bound are now
reported to status bar, and status bar has a region excluded for touch
recognition. This allows the app handle to be detected by a11y servcices
without the need of the input layer workaround. The final needed change
is to allow the app handle to handle its own a11y hover events, so that
it can gain focus via touch again.

Bug: 404766889
Test: manually testing
Flag: com.android.window.flags.enable_remove_status_bar_input_layer
Change-Id: I3db6350ed0c169f29f1309bf4df21bc21d03edd5
parent d85d573d
Loading
Loading
Loading
Loading
+21 −14
Original line number Diff line number Diff line
@@ -98,20 +98,27 @@ class AppHandleViewHolder(
        captionView.setOnTouchListener(onCaptionTouchListener)
        captionHandle.setOnTouchListener(onCaptionTouchListener)
        captionHandle.setOnClickListener(onCaptionButtonClickListener)
        if (DesktopExperienceFlags.ENABLE_REMOVE_STATUS_BAR_INPUT_LAYER.isTrue) {
            ViewCompat.replaceAccessibilityAction(
                captionHandle,
                AccessibilityActionCompat.ACTION_CLICK,
                context.getString(R.string.app_handle_chip_accessibility_announce),
                null,
            )
        } else {
            captionHandle.accessibilityDelegate =
                object : View.AccessibilityDelegate() {
                    override fun sendAccessibilityEvent(host: View, eventType: Int) {
                        when (eventType) {
                            AccessibilityEvent.TYPE_VIEW_HOVER_ENTER,
                            AccessibilityEvent.TYPE_VIEW_HOVER_EXIT -> {
                            // Caption Handle itself can't get a11y focus because it's under the
                            // status
                            // bar, so pass through TYPE_VIEW_HOVER a11y events to the status bar
                            // input layer, so that it can get a11y focus on the caption handle's
                            // behalf
                                // Caption Handle itself can't get a11y focus because it's under
                                // the status bar, so pass through TYPE_VIEW_HOVER a11y events to
                                // the status bar input layer, so that it can get a11y focus on
                                // the caption handle's behalf
                                statusBarInputLayer?.view?.sendAccessibilityEvent(eventType)
                            }
                        else -> super.sendAccessibilityEvent(host, eventType)
                        }
                    }
                }
        }