summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-05-13 11:47:06 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-04-25 00:18:06 -0700
commit9d3269eaa36d929de6191e60d7b332919ae02cab (patch)
treebdd070f69679db9e2612573171b4db21c77abfd9
parentbabc43ea6289a5ec6eee9dbf80057ab2de742dfd (diff)
downloadqtlocation-mapboxgl-9d3269eaa36d929de6191e60d7b332919ae02cab.tar.gz
[ios] Restored user dot accessibility
Put the user dot back into rotation as an accessible element.
-rw-r--r--platform/ios/src/MGLMapView.mm20
1 files changed, 15 insertions, 5 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 222bd8f22b..72f3bc915b 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1803,7 +1803,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
- (NSInteger)accessibilityElementCount
{
std::vector<MGLAnnotationTag> visibleAnnotations = [self annotationTagsInRect:self.bounds];
- return visibleAnnotations.size() + 2 /* compass, attributionButton */;
+ return visibleAnnotations.size() + 3 /* compass, userLocationAnnotationView, attributionButton */;
}
- (id)accessibilityElementAtIndex:(NSInteger)index
@@ -1815,7 +1815,11 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
{
return self.compassView;
}
- if (index > 0 && (NSUInteger)index == visibleAnnotations.size() + 1 /* compass */)
+ if (index == 1)
+ {
+ return self.userLocationAnnotationView;
+ }
+ if (index > 0 && (NSUInteger)index == visibleAnnotations.size() + 2 /* compass, userLocationAnnotationView */)
{
return self.attributionButton;
}
@@ -1838,9 +1842,9 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
});
NSUInteger annotationIndex = MGLAnnotationTagNotFound;
- if (index >= 0 && (NSUInteger)index < visibleAnnotations.size())
+ if (index >= 0 && (NSUInteger)(index - 2) < visibleAnnotations.size())
{
- annotationIndex = index - 1 /* compass */;
+ annotationIndex = index - 2 /* compass, userLocationAnnotationView */;
}
MGLAnnotationTag annotationTag = visibleAnnotations[annotationIndex];
NSAssert(annotationTag != MGLAnnotationTagNotFound, @"Can’t get accessibility element for nonexistent or invisible annotation at index %li.", index);
@@ -1881,6 +1885,10 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
{
return 0;
}
+ if (element == self.userLocationAnnotationView)
+ {
+ return 1;
+ }
if ( ! [element isKindOfClass:[MGLAnnotationAccessibilityElement class]] &&
element != self.attributionButton)
{
@@ -1896,7 +1904,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
auto foundElement = std::find(visibleAnnotations.begin(), visibleAnnotations.end(),
((MGLAnnotationAccessibilityElement *)element).tag);
if (foundElement == visibleAnnotations.end()) return NSNotFound;
- else return std::distance(visibleAnnotations.begin(), foundElement) + 1;
+ else return std::distance(visibleAnnotations.begin(), foundElement) + 2 /* compass, userLocationAnnotationView */;
}
#pragma mark - Geography -
@@ -4113,6 +4121,8 @@ 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