Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1368)

Unified Diff: components/autofill/android/java/src/org/chromium/components/autofill/AutofillPopup.java

Issue 2811803002: Fixes accessibility navigation out of autofill popup. (Closed)
Patch Set: Renames OnAutofillPopupAccessibilityFocusCleared to GetIdForElementAfterElementHostingAutofillPopup. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/android/java/src/org/chromium/components/autofill/AutofillPopup.java
diff --git a/components/autofill/android/java/src/org/chromium/components/autofill/AutofillPopup.java b/components/autofill/android/java/src/org/chromium/components/autofill/AutofillPopup.java
index 47f13dddf8f6785586aa71273c859938e1961e0b..7906d2580b3b284ebaa7d09dc8c2ba64a40c404d 100644
--- a/components/autofill/android/java/src/org/chromium/components/autofill/AutofillPopup.java
+++ b/components/autofill/android/java/src/org/chromium/components/autofill/AutofillPopup.java
@@ -8,6 +8,9 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
+import android.view.View.AccessibilityDelegate;
+import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
import android.widget.AdapterView;
import android.widget.PopupWindow;
@@ -34,10 +37,26 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On
*/
private static final int ITEM_ID_SEPARATOR_ENTRY = -3;
+ /**
+ * We post a delayed runnable to clear accessibility focus from the autofill popup's list view
+ * when we receive a {@code TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED} event because we receive a
+ * {@code TYPE_VIEW_ACCESSIBILITY_FOCUSED} for the same list view if user navigates to a
+ * different suggestion. On the other hand, if user navigates out of the popup we do not receive
+ * a {@code TYPE_VIEW_ACCESSIBILITY_FOCUSED} in immediate succession.
+ */
+ private static final long CLEAR_ACCESSIBILITY_FOCUS_DELAY_MS = 100;
+
private final Context mContext;
private final AutofillDelegate mAutofillDelegate;
private List<AutofillSuggestion> mSuggestions;
+ private final Runnable mClearAccessibilityFocusRunnable = new Runnable() {
+ @Override
+ public void run() {
+ mAutofillDelegate.accessibilityFocusCleared();
+ }
+ };
+
/**
* Creates an AutofillWindow with specified parameters.
* @param context Application context.
@@ -94,6 +113,19 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On
setRtl(isRtl);
show();
getListView().setOnItemLongClickListener(this);
+ getListView().setAccessibilityDelegate(new AccessibilityDelegate() {
+ @Override
+ public boolean onRequestSendAccessibilityEvent(
+ ViewGroup host, View child, AccessibilityEvent event) {
+ getListView().removeCallbacks(mClearAccessibilityFocusRunnable);
+ if (event.getEventType()
+ == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED) {
+ getListView().postDelayed(
+ mClearAccessibilityFocusRunnable, CLEAR_ACCESSIBILITY_FOCUS_DELAY_MS);
+ }
+ return super.onRequestSendAccessibilityEvent(host, child, event);
+ }
+ });
}
@Override

Powered by Google App Engine
This is Rietveld 408576698