|
45 | 45 | import androidx.annotation.NonNull; |
46 | 46 | import androidx.annotation.Nullable; |
47 | 47 | import androidx.core.view.ViewCompat; |
| 48 | +import androidx.core.view.accessibility.AccessibilityEventCompat; |
48 | 49 | import androidx.core.view.accessibility.AccessibilityManagerCompat.TouchExplorationStateChangeListener; |
49 | 50 | import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; |
50 | 51 | import com.google.android.material.animation.AnimationUtils; |
@@ -230,13 +231,21 @@ public void onInitializeAccessibilityNodeInfo( |
230 | 231 | } |
231 | 232 | } |
232 | 233 |
|
| 234 | + @SuppressLint("WrongConstant") |
233 | 235 | @Override |
234 | 236 | public void onPopulateAccessibilityEvent(View host, @NonNull AccessibilityEvent event) { |
| 237 | + if (!accessibilityManager.isEnabled() || isEditable(autoCompleteTextView)) { |
| 238 | + return; |
| 239 | + } |
| 240 | + // TODO(b/256138189): Find better workaround, back gesture should call |
| 241 | + // AutoCompleteTextView.OnDismissListener. |
| 242 | + boolean invalidState = |
| 243 | + event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED |
| 244 | + && isEndIconChecked |
| 245 | + && !autoCompleteTextView.isPopupShowing(); |
235 | 246 | // If dropdown is non editable, layout click is what triggers showing/hiding the popup |
236 | 247 | // list. Otherwise, arrow icon alone is what triggers it. |
237 | | - if (event.getEventType() == TYPE_VIEW_CLICKED |
238 | | - && accessibilityManager.isEnabled() |
239 | | - && !isEditable(autoCompleteTextView)) { |
| 248 | + if (event.getEventType() == TYPE_VIEW_CLICKED || invalidState) { |
240 | 249 | showHideDropdown(); |
241 | 250 | updateDropdownPopupDirty(); |
242 | 251 | } |
|
0 commit comments