[ios] Only post layout change notifications when focused
Constantly posting accessibility layout change notifications on every location change made it very difficult to stay focused on an accessibility element, be it the user dot or some other element. Now we only post the notification when the user dot is focused, user tracking mode is off (so the user dot actually has a chance to move around), and the application is active (not in the middle of application switching).
This commit is contained in:
committed by
Minh Nguyễn
parent
193a843013
commit
8d5a6b515f
@@ -3738,6 +3738,13 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
duration = MAX([newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp], MGLUserLocationAnimationDuration);
|
||||
}
|
||||
[self updateUserLocationAnnotationViewAnimatedWithDuration:duration];
|
||||
|
||||
if (self.userTrackingMode == MGLUserTrackingModeNone &&
|
||||
self.userLocationAnnotationView.accessibilityElementIsFocused &&
|
||||
[UIApplication sharedApplication].applicationState == UIApplicationStateActive)
|
||||
{
|
||||
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.userLocationAnnotationView);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didUpdateLocationWithUserTrackingAnimated:(BOOL)animated
|
||||
@@ -4109,7 +4116,10 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
|
||||
if ( ! [self isSuppressingChangeDelimiters] && [self.delegate respondsToSelector:@selector(mapView:regionDidChangeAnimated:)])
|
||||
{
|
||||
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
|
||||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
|
||||
{
|
||||
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
|
||||
}
|
||||
BOOL animated = change == mbgl::MapChangeRegionDidChangeAnimated;
|
||||
[self.delegate mapView:self regionDidChangeAnimated:animated];
|
||||
}
|
||||
@@ -4257,8 +4267,6 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
|
||||
[self deselectAnnotation:self.selectedAnnotation animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
|
||||
}
|
||||
|
||||
/// Intended center point of the user location annotation view with respect to
|
||||
|
||||
@@ -57,7 +57,7 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck
|
||||
self.annotation = [[MGLUserLocation alloc] initWithMapView:mapView];
|
||||
_mapView = mapView;
|
||||
[self setupLayers];
|
||||
self.accessibilityTraits = UIAccessibilityTraitButton | UIAccessibilityTraitAdjustable;
|
||||
self.accessibilityTraits = UIAccessibilityTraitButton | UIAccessibilityTraitAdjustable | UIAccessibilityTraitUpdatesFrequently;
|
||||
|
||||
_accessibilityCoordinateFormatter = [[MGLCoordinateFormatter alloc] init];
|
||||
_accessibilityCoordinateFormatter.unitStyle = NSFormattingUnitStyleLong;
|
||||
@@ -117,6 +117,16 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck
|
||||
[self.mapView accessibilityDecrement];
|
||||
}
|
||||
|
||||
- (void)setHidden:(BOOL)hidden
|
||||
{
|
||||
BOOL oldValue = super.hidden;
|
||||
[super setHidden:hidden];
|
||||
if (oldValue != hidden)
|
||||
{
|
||||
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setTintColor:(UIColor *)tintColor
|
||||
{
|
||||
if (_puckModeActivated)
|
||||
|
||||
Reference in New Issue
Block a user