summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2016-10-02 16:55:45 -0400
committerJason Wray <jason@mapbox.com>2016-10-02 16:55:45 -0400
commit1cf6ed070c5b32cd81e46956fd8f8a8069af165c (patch)
tree2c9916e8249b8c9fadf83e6298935f0213d1481f
parentee4715a821437e6ed374231fad2ca6193eeac499 (diff)
downloadqtlocation-mapboxgl-upstream/fb-attribution-version-longpress.tar.gz
Show release version on attribution button long pressupstream/fb-attribution-version-longpress
-rw-r--r--platform/ios/src/MGLMapView.mm26
1 files changed, 24 insertions, 2 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 4d660f8f35..461407ba8e 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -437,6 +437,9 @@ public:
_attributionButtonConstraints = [NSMutableArray array];
[_attributionButton addObserver:self forKeyPath:@"hidden" options:NSKeyValueObservingOptionNew context:NULL];
+ UILongPressGestureRecognizer *attributionLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showAttributionFromLongPress)];
+ [_attributionButton addGestureRecognizer:attributionLongPress];
+
// setup compass
//
_compassView = [[UIImageView alloc] initWithImage:self.compassImage];
@@ -1668,9 +1671,21 @@ public:
- (void)showAttribution
{
+ [self showAttributionWithVersion:NO];
+}
+
+- (void)showAttributionFromLongPress
+{
+ [self showAttributionWithVersion:YES];
+}
+
+- (void)showAttributionWithVersion:(BOOL)showVersion
+{
+ NSString *title = NSLocalizedStringWithDefaultValue(@"SDK_NAME", nil, nil, @"Mapbox iOS SDK", @"Action sheet title");
+
if ( ! self.attributionSheet)
{
- self.attributionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedStringWithDefaultValue(@"SDK_NAME", nil, nil, @"Mapbox iOS SDK", @"Action sheet title")
+ self.attributionSheet = [[UIActionSheet alloc] initWithTitle:title
delegate:self
cancelButtonTitle:NSLocalizedStringWithDefaultValue(@"CANCEL", nil, nil, @"Cancel", @"")
destructiveButtonTitle:nil
@@ -1680,9 +1695,16 @@ public:
NSLocalizedStringWithDefaultValue(@"MAP_FEEDBACK", nil, nil, @"Improve This Map", @"Action in attribution sheet"),
NSLocalizedStringWithDefaultValue(@"TELEMETRY_NAME", nil, nil, @"Mapbox Telemetry", @"Action in attribution sheet"),
nil];
+ }
+ if (showVersion && [self.attributionSheet.title isEqualToString:title])
+ {
+ NSString *semanticVersion = [NSBundle mgl_frameworkInfoDictionary][@"MGLSemanticVersionString"];
+ NSString *shortVersion = [NSBundle mgl_frameworkInfoDictionary][@"CFBundleShortVersionString"];
+ NSString *sdkVersion = semanticVersion ?: shortVersion;
+ self.attributionSheet.title = [self.attributionSheet.title stringByAppendingFormat:@" %@", sdkVersion];
}
-
+
[self.attributionSheet showFromRect:self.attributionButton.frame inView:self animated:YES];
}