Skip to content

Commit

Permalink
Set and unset accessibility flags even when re-entrant (flutter#6853)
Browse files Browse the repository at this point in the history
* Make sure to not unset a11y flags on reentrant calls to API
  • Loading branch information
dnfield authored Nov 14, 2018
1 parent 396402f commit 114d33d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions shell/platform/android/io/flutter/view/FlutterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,9 @@ protected void onAttachedToWindow() {
ensureAccessibilityEnabled();
}
if (mTouchExplorationEnabled) {
mAccessibilityFeatureFlags ^= AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
mAccessibilityFeatureFlags |= AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
} else {
mAccessibilityFeatureFlags &= ~AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
}
// Apply additional accessibility settings
updateAccessibilityFeatures();
Expand All @@ -896,7 +898,7 @@ private void updateAccessibilityFeatures() {
String transitionAnimationScale = Settings.Global.getString(getContext().getContentResolver(),
Settings.Global.TRANSITION_ANIMATION_SCALE);
if (transitionAnimationScale != null && transitionAnimationScale.equals("0")) {
mAccessibilityFeatureFlags ^= AccessibilityFeature.DISABLE_ANIMATIONS.value;
mAccessibilityFeatureFlags |= AccessibilityFeature.DISABLE_ANIMATIONS.value;
} else {
mAccessibilityFeatureFlags &= ~AccessibilityFeature.DISABLE_ANIMATIONS.value;
}
Expand Down Expand Up @@ -966,7 +968,7 @@ public void onChange(boolean selfChange, Uri uri) {
String value = Settings.Global.getString(getContext().getContentResolver(),
Settings.Global.TRANSITION_ANIMATION_SCALE);
if (value != null && value.equals("0")) {
mAccessibilityFeatureFlags ^= AccessibilityFeature.DISABLE_ANIMATIONS.value;
mAccessibilityFeatureFlags |= AccessibilityFeature.DISABLE_ANIMATIONS.value;
} else {
mAccessibilityFeatureFlags &= ~AccessibilityFeature.DISABLE_ANIMATIONS.value;
}
Expand All @@ -980,7 +982,7 @@ public void onTouchExplorationStateChanged(boolean enabled) {
if (enabled) {
mTouchExplorationEnabled = true;
ensureAccessibilityEnabled();
mAccessibilityFeatureFlags ^= AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
mAccessibilityFeatureFlags |= AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
nativeSetAccessibilityFeatures(mNativeView.get(), mAccessibilityFeatureFlags);
} else {
mTouchExplorationEnabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,11 +716,11 @@ - (void)onAccessibilityStatusChanged:(NSNotification*)notification {
auto platformView = [_engine.get() platformView];
int32_t flags = 0;
if (UIAccessibilityIsInvertColorsEnabled())
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kInvertColors);
flags |= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kInvertColors);
if (UIAccessibilityIsReduceMotionEnabled())
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kReduceMotion);
flags |= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kReduceMotion);
if (UIAccessibilityIsBoldTextEnabled())
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kBoldText);
flags |= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kBoldText);
#if TARGET_OS_SIMULATOR
// There doesn't appear to be any way to determine whether the accessibility
// inspector is enabled on the simulator. We conservatively always turn on the
Expand All @@ -729,8 +729,8 @@ - (void)onAccessibilityStatusChanged:(NSNotification*)notification {
platformView->SetAccessibilityFeatures(flags);
#else
bool enabled = UIAccessibilityIsVoiceOverRunning() || UIAccessibilityIsSwitchControlRunning();
if (UIAccessibilityIsVoiceOverRunning() || UIAccessibilityIsSwitchControlRunning())
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kAccessibleNavigation);
if (enabled)
flags |= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kAccessibleNavigation);
platformView->SetSemanticsEnabled(enabled || UIAccessibilityIsSpeakScreenEnabled());
platformView->SetAccessibilityFeatures(flags);
#endif
Expand Down

0 comments on commit 114d33d

Please sign in to comment.