[ios] Restored user dot accessibility
Put the user dot back into rotation as an accessible element.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user