From f2d58483c2aec689d7065eb68766a5aec7c96e97 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 20 Dec 2019 12:01:59 -0800 Subject: [PATCH] Disable accessibility state changes of the focused view for Android API < 21 Summary: This diff disables accessibility state changes of the focused view for Android API < 21. This is necessary because the method view.isAccessibilityFocused was introduced in Android API 21 Users in Android API < 21 will not be able to hear accessibility state changes of the focused view (feature introduced by D17903205) Changelog: disables accessibility state changes of the focused view for Android API < 21, see PR: 26624 Reviewed By: fkgozali Differential Revision: D19199096 fbshipit-source-id: 12b349f0ac94b77e9e7328ae40e1ae1a278e8b24 --- .../java/com/facebook/react/uimanager/BaseViewManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java index 4897ba25b4631e..ef39975d4936ba 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java @@ -8,6 +8,7 @@ package com.facebook.react.uimanager; import android.graphics.Color; +import android.os.Build; import android.text.TextUtils; import android.view.View; import android.view.ViewParent; @@ -173,7 +174,8 @@ public void setViewState(@NonNull T view, @Nullable ReadableMap accessibilitySta && accessibilityState.getType(STATE_CHECKED) == ReadableType.String)) { updateViewContentDescription(view); break; - } else if (view.isAccessibilityFocused()) { + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP + && view.isAccessibilityFocused()) { // Internally Talkback ONLY uses TYPE_VIEW_CLICKED for "checked" and // "selected" announcements. Send a click event to make sure Talkback // get notified for the state changes that don't happen upon users' click.