diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-04-26 12:21:32 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-04-26 14:19:10 -0700 |
commit | 8d5a6b515f030ed832f3fdf1b0b3e24a4050dc3f (patch) | |
tree | 10eb092a7c4c7a5ec216542bac1cc14c6e9338f9 /platform | |
parent | 193a843013c9dee5634c5e7f1a757507686cb12a (diff) | |
download | qtlocation-mapboxgl-8d5a6b515f030ed832f3fdf1b0b3e24a4050dc3f.tar.gz |
[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).
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 14 | ||||
-rw-r--r-- | platform/ios/src/MGLUserLocationAnnotationView.m | 12 |
2 files changed, 22 insertions, 4 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index aa9af82fdf..a88cb9acdb 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -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 diff --git a/platform/ios/src/MGLUserLocationAnnotationView.m b/platform/ios/src/MGLUserLocationAnnotationView.m index 72045f05e6..c514026e42 100644 --- a/platform/ios/src/MGLUserLocationAnnotationView.m +++ b/platform/ios/src/MGLUserLocationAnnotationView.m @@ -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) |