[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:
Minh Nguyễn
2016-04-26 12:21:32 -07:00
committed by Minh Nguyễn
parent 193a843013
commit 8d5a6b515f
2 changed files with 22 additions and 4 deletions

View File

@@ -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

View File

@@ -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)