diff options
author | v.mikhaylenko <v.mikhaylenko@corp.mail.ru> | 2015-07-15 18:39:31 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:55:57 +0300 |
commit | b5a05b66f9d562dd6a5fcbab98bd40013293aa09 (patch) | |
tree | 918bf691fca5a14e9c13bcdbe22229e36b6e8d0c /iphone/Maps/Classes/CustomAlert | |
parent | caf44785aa7f6aa4475922c340c4d577260f3684 (diff) |
[ios] Replace location dialog with default dialog.
Diffstat (limited to 'iphone/Maps/Classes/CustomAlert')
-rw-r--r-- | iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm index 9869bb603e..640fef12a4 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm @@ -9,10 +9,11 @@ #import "Common.h" #import "MWMAlertViewController.h" #import "MWMDownloadTransitMapAlert.h" +#import "UIKitCategories.h" static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController"; -@interface MWMAlertViewController () <UIGestureRecognizerDelegate> +@interface MWMAlertViewController () <UIGestureRecognizerDelegate, UIAlertViewDelegate> @property (weak, nonatomic, readwrite) UIViewController * ownerViewController; @@ -44,12 +45,30 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController - (void)presentLocationAlert { - dispatch_async(dispatch_get_main_queue(), ^ + NSString * title = L(@"location_is_disabled_long_text"); + NSString * cancel = L(@"cancel"); + NSString * openSettings = L(@"settings"); + if (isIOSVersionLessThan(8)) { - // @TODO Remove dispatch on LocationManager -> MWMLocationManager - // Test case when location is denied by user on app launch/relaunch - [self displayAlert:MWMAlert.locationAlert]; - }); + UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:title message:nil delegate:self cancelButtonTitle:cancel otherButtonTitles:openSettings, nil]; + [alertView show]; + return; + } + UIAlertController * alertController = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:cancel style:UIAlertActionStyleCancel handler:nil]; + UIAlertAction * openSettingsAction = [UIAlertAction actionWithTitle:openSettings style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) + { + [self openSettings]; + }]; + [alertController addAction:cancelAction]; + [alertController addAction:openSettingsAction]; + [self.ownerViewController presentViewController:alertController animated:YES completion:nil]; +// dispatch_async(dispatch_get_main_queue(), ^ +// { +// // @TODO Remove dispatch on LocationManager -> MWMLocationManager +// // Test case when location is denied by user on app launch/relaunch +// [self displayAlert:MWMAlert.locationAlert]; +// }); } - (void)presentFacebookAlert @@ -123,4 +142,21 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController [self removeFromParentViewController]; } +- (void)openSettings +{ + NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; + UIApplication * a = [UIApplication sharedApplication]; + if ([a canOpenURL:url]) + [a openURL:url]; +} + +#pragma mark - UIAlertViewDelegate + +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +{ + if (buttonIndex == 1) + [self openSettings]; +} + + @end |