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
This commit is contained in:
David Vacca
2019-12-20 12:01:59 -08:00
committed by Facebook Github Bot
parent 58f3673099
commit f2d58483c2
@@ -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 abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
&& 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.