Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Announce zoom level, visible annotations after zooming
Browse files Browse the repository at this point in the history
Announce the zoom level and number of visible annotations after zooming using VoiceOver’s swipe up or swipe down gesture.

Works toward #4821.
  • Loading branch information
1ec5 committed Apr 26, 2016
1 parent d5970f2 commit 51cd978
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
14 changes: 14 additions & 0 deletions platform/ios/ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@
DABFB8711CBE9A0F00D62B32 /* MGLMapView+MGLCustomStyleLayerAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8848381CBAFB8500AB86E3 /* MGLMapView+MGLCustomStyleLayerAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
DABFB8721CBE9A0F00D62B32 /* MGLUserLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = DA8848391CBAFB8500AB86E3 /* MGLUserLocation.h */; settings = {ATTRIBUTES = (Public, ); }; };
DABFB8731CBE9A9900D62B32 /* Mapbox.h in Headers */ = {isa = PBXBuildFile; fileRef = DA88485E1CBAFC2E00AB86E3 /* Mapbox.h */; settings = {ATTRIBUTES = (Public, ); }; };
DAC49C5C1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = DAC49C5F1CD02BC9009E1AA3 /* Localizable.stringsdict */; };
DAC49C5D1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = DAC49C5F1CD02BC9009E1AA3 /* Localizable.stringsdict */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -459,6 +461,7 @@
DABCABBF1CB80717000A7C39 /* locations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = locations.cpp; sourceTree = "<group>"; };
DABCABC01CB80717000A7C39 /* locations.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = locations.hpp; sourceTree = "<group>"; };
DAC07C961CBB2CD6000CB309 /* mbgl.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = mbgl.xcconfig; path = ../../build/ios/mbgl.xcconfig; sourceTree = "<group>"; };
DAC49C5E1CD02BC9009E1AA3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = Base; path = Base.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -720,6 +723,7 @@
isa = PBXGroup;
children = (
DA89339F1CCC951200E68420 /* Localizable.strings */,
DAC49C5F1CD02BC9009E1AA3 /* Localizable.stringsdict */,
DA8848771CBAFD5C00AB86E3 /* api_mapbox_com-digicert.der */,
DA8848781CBAFD5C00AB86E3 /* api_mapbox_com-geotrust.der */,
DA8848791CBAFD5C00AB86E3 /* star_tilestream_net.der */,
Expand Down Expand Up @@ -1160,6 +1164,7 @@
DA8933F01CCD387900E68420 /* strip-frameworks.sh in Resources */,
DA8848751CBAFCC100AB86E3 /* mapbox@3x.png in Resources */,
DA88487B1CBAFD5C00AB86E3 /* api_mapbox_com-geotrust.der in Resources */,
DAC49C5C1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */,
DA8933BF1CCD2CAD00E68420 /* Foundation.stringsdict in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -1181,6 +1186,7 @@
DA8933DB1CCD31D400E68420 /* Foundation.strings in Resources */,
DA8933DC1CCD31D400E68420 /* Foundation.stringsdict in Resources */,
DA8933DD1CCD31D400E68420 /* api_mapbox_com-digicert.der in Resources */,
DAC49C5D1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */,
DA8933DE1CCD31D400E68420 /* api_mapbox_com-geotrust.der in Resources */,
DA8933DF1CCD31D400E68420 /* star_tilestream_net.der in Resources */,
);
Expand Down Expand Up @@ -1390,6 +1396,14 @@
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
DAC49C5F1CD02BC9009E1AA3 /* Localizable.stringsdict */ = {
isa = PBXVariantGroup;
children = (
DAC49C5E1CD02BC9009E1AA3 /* Base */,
);
name = Localizable.stringsdict;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down
3 changes: 3 additions & 0 deletions platform/ios/resources/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
/* Accessibility label */
"MAP_A11Y_LABEL" = "Map";

/* Map accessibility value */
"MAP_A11Y_VALUE" = "Zoom %1$dx\n%2$ld annotation(s) visible";

/* Action in attribution sheet */
"MAP_FEEDBACK" = "Improve This Map";

Expand Down
27 changes: 27 additions & 0 deletions platform/ios/resources/Base.lproj/Localizable.stringsdict
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MAP_A11Y_VALUE</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@count@</string>
<key>count</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>ld</string>
<key>zero</key>
<string>Zoom %dx
no annotations visible</string>
<key>one</key>
<string>Zoom %dx
%d annotation visible</string>
<key>other</key>
<string>Zoom %dx
%d annotations visible</string>
</dict>
</dict>
</dict>
</plist>
17 changes: 15 additions & 2 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,12 @@ - (void)emptyMemoryCache

#pragma mark - Accessibility -

- (NSString *)accessibilityValue
{
double zoomLevel = round(self.zoomLevel - 1);
return [NSString stringWithFormat:NSLocalizedStringWithDefaultValue(@"MAP_A11Y_VALUE", nil, nil, @"Zoom %dx\n%ld annotation(s) visible", @"Map accessibility value"), (int)zoomLevel, (long)self.accessibilityAnnotationCount];
}

- (CGRect)accessibilityFrame
{
CGRect frame = [super accessibilityFrame];
Expand Down Expand Up @@ -1881,15 +1887,20 @@ - (NSInteger)accessibilityElementCount
{
return 2 /* selectedAnnotationCalloutView, mapViewProxyAccessibilityElement */;
}
std::vector<MGLAnnotationTag> visibleAnnotations = [self annotationTagsInRect:self.bounds];
NSInteger count = visibleAnnotations.size() + 2 /* compass, userLocationAnnotationView, attributionButton */;
NSInteger count = self.accessibilityAnnotationCount + 2 /* compass, attributionButton */;
if (self.userLocationAnnotationView)
{
count++;
}
return count;
}

- (NSInteger)accessibilityAnnotationCount
{
std::vector<MGLAnnotationTag> visibleAnnotations = [self annotationTagsInRect:self.bounds];
return visibleAnnotations.size();
}

- (id)accessibilityElementAtIndex:(NSInteger)index
{
if (self.calloutViewForSelectedAnnotation)
Expand Down Expand Up @@ -2045,6 +2056,8 @@ - (void)accessibilityScaleBy:(double)scaleFactor
}
_mbglMap->scaleBy(scaleFactor, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y });
[self unrotateIfNeededForGesture];

UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, self.accessibilityValue);
}

#pragma mark - Geography -
Expand Down

0 comments on commit 51cd978

Please sign in to comment.