mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Guard initialization of touch exploration listener (#8103)
This commit is contained in:
parent
9e8f8d0889
commit
4e54bc93ca
@ -266,25 +266,7 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
|
||||
// This is guarded at instantiation time.
|
||||
@TargetApi(19)
|
||||
@RequiresApi(19)
|
||||
private final AccessibilityManager.TouchExplorationStateChangeListener touchExplorationStateChangeListener = new AccessibilityManager.TouchExplorationStateChangeListener() {
|
||||
@Override
|
||||
public void onTouchExplorationStateChanged(boolean isTouchExplorationEnabled) {
|
||||
if (isTouchExplorationEnabled) {
|
||||
accessibilityFeatureFlags |= AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
|
||||
} else {
|
||||
onTouchExplorationExit();
|
||||
accessibilityFeatureFlags &= ~AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
|
||||
}
|
||||
sendLatestAccessibilityFlagsToFlutter();
|
||||
|
||||
if (onAccessibilityChangeListener != null) {
|
||||
onAccessibilityChangeListener.onAccessibilityChanged(
|
||||
accessibilityManager.isEnabled(),
|
||||
isTouchExplorationEnabled
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
private final AccessibilityManager.TouchExplorationStateChangeListener touchExplorationStateChangeListener;
|
||||
|
||||
// Listener that is notified when the global TRANSITION_ANIMATION_SCALE. When this scale goes
|
||||
// to zero, we instruct Flutter to disable animations.
|
||||
@ -336,8 +318,29 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
|
||||
// Tell Flutter whether touch exploration is initially active or not. Then register a listener
|
||||
// to be notified of changes in the future.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
touchExplorationStateChangeListener = new AccessibilityManager.TouchExplorationStateChangeListener() {
|
||||
@Override
|
||||
public void onTouchExplorationStateChanged(boolean isTouchExplorationEnabled) {
|
||||
if (isTouchExplorationEnabled) {
|
||||
accessibilityFeatureFlags |= AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
|
||||
} else {
|
||||
onTouchExplorationExit();
|
||||
accessibilityFeatureFlags &= ~AccessibilityFeature.ACCESSIBLE_NAVIGATION.value;
|
||||
}
|
||||
sendLatestAccessibilityFlagsToFlutter();
|
||||
|
||||
if (onAccessibilityChangeListener != null) {
|
||||
onAccessibilityChangeListener.onAccessibilityChanged(
|
||||
accessibilityManager.isEnabled(),
|
||||
isTouchExplorationEnabled
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
touchExplorationStateChangeListener.onTouchExplorationStateChanged(accessibilityManager.isTouchExplorationEnabled());
|
||||
this.accessibilityManager.addTouchExplorationStateChangeListener(touchExplorationStateChangeListener);
|
||||
} else {
|
||||
touchExplorationStateChangeListener = null;
|
||||
}
|
||||
|
||||
// Tell Flutter whether animations should initially be enabled or disabled. Then register a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user