diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h index 760f076f6a..08f9626a41 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h @@ -17,7 +17,7 @@ typedef void (^CloseAlertCompletion)(); code:(routing::IRouter::ResultCode)code; - (void)presentRateAlert; - (void)presentFacebookAlert; -- (void)presentPoint2PointAlertWithOkBlock:(nonnull CloseAlertCompletion)block; +- (void)presentPoint2PointAlertWithOkBlock:(nonnull CloseAlertCompletion)block needToRebuild:(BOOL)needToRebuild; - (void)presentRoutingDisclaimerAlert; - (void)presentDisabledLocationAlert; - (void)presentLocationAlert; diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm index 455e6b6bf4..d8da930c7f 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm @@ -61,9 +61,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController // }); } -- (void)presentPoint2PointAlertWithOkBlock:(nonnull CloseAlertCompletion)block +- (void)presentPoint2PointAlertWithOkBlock:(nonnull CloseAlertCompletion)block needToRebuild:(BOOL)needToRebuild { - [self displayAlert:[MWMAlert point2PointAlertWithOkBlock:block]]; + [self displayAlert:[MWMAlert point2PointAlertWithOkBlock:block needToRebuild:needToRebuild]]; } - (void)presentFacebookAlert diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h index 1c1166f603..b8e85aaced 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h @@ -23,7 +23,7 @@ typedef void (^RightButtonAction)(); + (MWMAlert *)noConnectionAlert; + (MWMAlert *)locationServiceNotSupportedAlert; + (MWMAlert *)pedestrianToastShareAlert:(BOOL)isFirstLaunch; -+ (MWMAlert *)point2PointAlertWithOkBlock:(RightButtonAction)block; ++ (MWMAlert *)point2PointAlertWithOkBlock:(RightButtonAction)block needToRebuild:(BOOL)needToRebuild; - (void)close; - (void)setNeedsCloseAlertAfterEnterBackground; diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm index 65dac0dea0..10c0f3c0a7 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm @@ -26,9 +26,9 @@ return [MWMFacebookAlert alert]; } -+ (MWMAlert *)point2PointAlertWithOkBlock:(RightButtonAction)block ++ (MWMAlert *)point2PointAlertWithOkBlock:(RightButtonAction)block needToRebuild:(BOOL)needToRebuild { - return [MWMDefaultAlert point2PointAlertWithOkBlock:block]; + return [MWMDefaultAlert point2PointAlertWithOkBlock:block needToRebuild:needToRebuild]; } + (MWMAlert *)routingDisclaimerAlertWithInitialOrientation:(UIInterfaceOrientation)orientation diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h index 41e9fba419..fbe09232ad 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h @@ -13,6 +13,6 @@ + (instancetype)noWiFiAlertWithName:(NSString *)name downloadBlock:(RightButtonAction)block; + (instancetype)noConnectionAlert; + (instancetype)locationServiceNotSupportedAlert; -+ (instancetype)point2PointAlertWithOkBlock:(RightButtonAction)block; ++ (instancetype)point2PointAlertWithOkBlock:(RightButtonAction)block needToRebuild:(BOOL)needToRebuild; @end diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm index ae78381c01..ef4be4d83b 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm @@ -108,11 +108,19 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; return [self defaultAlertWithTitle:@"routing_failed_cross_mwm_building" message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; } -+ (instancetype)point2PointAlertWithOkBlock:(RightButtonAction)block ++ (instancetype)point2PointAlertWithOkBlock:(RightButtonAction)block needToRebuild:(BOOL)needToRebuild { - return [self defaultAlertWithTitle:@"Navigation is available only from your current location." + if (needToRebuild) + { + return [self defaultAlertWithTitle:@"Navigation is available only from your current location." message:@"Do you want us to recreate/rebuild/ plan the route?" rightButtonTitle:@"ok" leftButtonTitle:@"cancel" rightButtonAction:block]; + } + else + { + return [self defaultAlertWithTitle:@"dialog_routing_location_unknown" + message:nil rightButtonTitle:@"ok" leftButtonTitle:nil rightButtonAction:nil]; + } } + (instancetype)defaultAlertWithTitle:(nonnull NSString *)title message:(nullable NSString *)message rightButtonTitle:(nonnull NSString *)rightButtonTitle leftButtonTitle:(nullable NSString *)leftButtonTitle rightButtonAction:(nullable RightButtonAction)action diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 81d6f27527..2190066d64 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -382,12 +382,17 @@ extern NSString * const kAlohalyticsTapEventKey; if (!self.routeSource.IsMyPosition()) { MWMAlertViewController * controller = [[MWMAlertViewController alloc] initWithViewController:self.ownerController]; + LocationManager * manager = MapsAppDelegate.theApp.m_locationManager; + auto const m = GetFramework().GetLocationState()->GetMode(); + BOOL const needToRebuild = manager.lastLocationIsValid && + m != location::State::Mode::PendingPosition && + m != location::State::Mode::UnknownPosition; [controller presentPoint2PointAlertWithOkBlock:^ { - m2::PointD const locationPoint = ToMercator(MapsAppDelegate.theApp.m_locationManager.lastLocation.coordinate); + m2::PointD const locationPoint = ToMercator(manager.lastLocation.coordinate); self.routeSource = MWMRoutePoint(locationPoint); [self buildRoute]; - }]; + } needToRebuild:needToRebuild]; return NO; } self.hidden = NO;