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

Commit f049b97c authored by Daniel Akinola's avatar Daniel Akinola Committed by Android (Google) Code Review
Browse files

Merge "Fix a11y for new refactored app handle" into main

parents 40ae3f5a d43ce79f
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)
                        }
                    }
                }
        }