forked from organicmaps/organicmaps
[old-map-downloader][ios] Added mwm migration alert.
This commit is contained in:
parent
6986a4cb88
commit
35011f1880
11 changed files with 101 additions and 40 deletions
|
@ -12,10 +12,12 @@
|
|||
- (void)presentAlert:(routing::IRouter::ResultCode)type;
|
||||
- (void)presentDownloaderAlertWithCountries:(vector<storage::TIndex> const &)countries
|
||||
routes:(vector<storage::TIndex> const &)routes
|
||||
code:(routing::IRouter::ResultCode)code;
|
||||
code:(routing::IRouter::ResultCode)code
|
||||
block:(nonnull TMWMVoidBlock)block;
|
||||
- (void)presentRateAlert;
|
||||
- (void)presentFacebookAlert;
|
||||
- (void)presentPoint2PointAlertWithOkBlock:(nonnull TMWMVoidBlock)block needToRebuild:(BOOL)needToRebuild;
|
||||
- (void)presentNeedMigrationAlertWithOkBlock:(nonnull TMWMVoidBlock)block;
|
||||
- (void)presentRoutingDisclaimerAlert;
|
||||
- (void)presentDisabledLocationAlert;
|
||||
- (void)presentLocationAlert;
|
||||
|
|
|
@ -66,6 +66,11 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert point2PointAlertWithOkBlock:block needToRebuild:needToRebuild]];
|
||||
}
|
||||
|
||||
- (void)presentNeedMigrationAlertWithOkBlock:(nonnull CloseAlertCompletion)block
|
||||
{
|
||||
[self displayAlert:[MWMAlert needMigrationAlertWithOkBlock:block]];
|
||||
}
|
||||
|
||||
- (void)presentFacebookAlert
|
||||
{
|
||||
[self displayAlert:MWMAlert.facebookAlert];
|
||||
|
@ -94,8 +99,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
- (void)presentDownloaderAlertWithCountries:(vector<storage::TIndex> const &)countries
|
||||
routes:(vector<storage::TIndex> const &)routes
|
||||
code:(routing::IRouter::ResultCode)code
|
||||
block:(TMWMVoidBlock)block
|
||||
{
|
||||
[self displayAlert:[MWMAlert downloaderAlertWithAbsentCountries:countries routes:routes code:code]];
|
||||
[self displayAlert:[MWMAlert downloaderAlertWithAbsentCountries:countries routes:routes code:code block:block]];
|
||||
}
|
||||
|
||||
- (void)presentRoutingDisclaimerAlert
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
+ (MWMAlert *)alert:(routing::IRouter::ResultCode)type;
|
||||
+ (MWMAlert *)downloaderAlertWithAbsentCountries:(vector<storage::TIndex> const &)countries
|
||||
routes:(vector<storage::TIndex> const &)routes
|
||||
code:(routing::IRouter::ResultCode)code;
|
||||
code:(routing::IRouter::ResultCode)code
|
||||
block:(TMWMVoidBlock)block;
|
||||
+ (MWMAlert *)rateAlert;
|
||||
+ (MWMAlert *)facebookAlert;
|
||||
+ (MWMAlert *)locationAlert;
|
||||
|
@ -20,6 +21,7 @@
|
|||
+ (MWMAlert *)locationServiceNotSupportedAlert;
|
||||
+ (MWMAlert *)pedestrianToastShareAlert:(BOOL)isFirstLaunch;
|
||||
+ (MWMAlert *)point2PointAlertWithOkBlock:(TMWMVoidBlock)block needToRebuild:(BOOL)needToRebuild;
|
||||
+ (MWMAlert *)needMigrationAlertWithOkBlock:(TMWMVoidBlock)block;
|
||||
- (void)close;
|
||||
|
||||
- (void)setNeedsCloseAlertAfterEnterBackground;
|
||||
|
|
|
@ -31,6 +31,11 @@
|
|||
return [MWMDefaultAlert point2PointAlertWithOkBlock:block needToRebuild:needToRebuild];
|
||||
}
|
||||
|
||||
+ (MWMAlert *)needMigrationAlertWithOkBlock:(TMWMVoidBlock)block
|
||||
{
|
||||
return [MWMDefaultAlert needMigrationAlertWithOkBlock:block];
|
||||
}
|
||||
|
||||
+ (MWMAlert *)routingDisclaimerAlertWithInitialOrientation:(UIInterfaceOrientation)orientation
|
||||
{
|
||||
return [MWMRoutingDisclaimerAlert alertWithInitialOrientation:orientation];
|
||||
|
@ -59,8 +64,9 @@
|
|||
+ (MWMAlert *)downloaderAlertWithAbsentCountries:(vector<storage::TIndex> const &)countries
|
||||
routes:(vector<storage::TIndex> const &)routes
|
||||
code:(routing::IRouter::ResultCode)code
|
||||
block:(TMWMVoidBlock)block
|
||||
{
|
||||
return [MWMDownloadTransitMapAlert downloaderAlertWithMaps:countries routes:routes code:code];
|
||||
return [MWMDownloadTransitMapAlert downloaderAlertWithMaps:countries routes:routes code:code block:block];
|
||||
}
|
||||
|
||||
+ (MWMAlert *)alert:(routing::IRouter::ResultCode)type
|
||||
|
|
|
@ -14,5 +14,6 @@
|
|||
+ (instancetype)noConnectionAlert;
|
||||
+ (instancetype)locationServiceNotSupportedAlert;
|
||||
+ (instancetype)point2PointAlertWithOkBlock:(TMWMVoidBlock)block needToRebuild:(BOOL)needToRebuild;
|
||||
+ (instancetype)needMigrationAlertWithOkBlock:(TMWMVoidBlock)block;
|
||||
|
||||
@end
|
||||
|
|
|
@ -124,6 +124,15 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
|
|||
}
|
||||
}
|
||||
|
||||
+ (instancetype)needMigrationAlertWithOkBlock:(TMWMVoidBlock)block
|
||||
{
|
||||
return [self defaultAlertWithTitle:@"need_migrate_title"
|
||||
message:@"need_migrate_message"
|
||||
rightButtonTitle:@"migrate"
|
||||
leftButtonTitle:@"not_now"
|
||||
rightButtonAction:block];
|
||||
}
|
||||
|
||||
+ (instancetype)defaultAlertWithTitle:(nonnull NSString *)title message:(nullable NSString *)message rightButtonTitle:(nonnull NSString *)rightButtonTitle leftButtonTitle:(nullable NSString *)leftButtonTitle rightButtonAction:(nullable TMWMVoidBlock)action
|
||||
{
|
||||
[[Statistics instance] logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatOpen}];
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
|
||||
+ (instancetype)downloaderAlertWithMaps:(vector<storage::TIndex> const &)maps
|
||||
routes:(vector<storage::TIndex> const &)routes
|
||||
code:(routing::IRouter::ResultCode)code;
|
||||
code:(routing::IRouter::ResultCode)code
|
||||
block:(TMWMVoidBlock)block;
|
||||
- (void)showDownloadDetail:(UIButton *)sender;
|
||||
|
||||
@end
|
||||
|
|
|
@ -86,6 +86,7 @@ static NSString * const kStatisticsEvent = @"Map download Alert";
|
|||
+ (instancetype)downloaderAlertWithMaps:(vector<storage::TIndex> const &)maps
|
||||
routes:(vector<storage::TIndex> const &)routes
|
||||
code:(routing::IRouter::ResultCode)code
|
||||
block:(TMWMVoidBlock)block
|
||||
{
|
||||
[[Statistics instance] logEvent:kStatisticsEvent withParameters:@{kStatAction : kStatOpen}];
|
||||
MWMDownloadTransitMapAlert * alert = [self alertWithMaps:maps routes:routes];
|
||||
|
@ -109,6 +110,7 @@ static NSString * const kStatisticsEvent = @"Map download Alert";
|
|||
NSAssert(false, @"Incorrect code!");
|
||||
break;
|
||||
}
|
||||
alert.downloaderBlock = block;
|
||||
return alert;
|
||||
}
|
||||
|
||||
|
@ -129,16 +131,6 @@ static NSString * const kStatisticsEvent = @"Map download Alert";
|
|||
alert.missedFiles = missedFiles;
|
||||
alert->maps = maps;
|
||||
alert->routes = routes;
|
||||
__weak MWMDownloadTransitMapAlert * wAlert = alert;
|
||||
alert.downloaderBlock = ^()
|
||||
{
|
||||
__strong MWMDownloadTransitMapAlert * alert = wAlert;
|
||||
auto & a = GetFramework().GetCountryTree().GetActiveMapLayout();
|
||||
for (auto const & index : alert->maps)
|
||||
a.DownloadMap(index, MapOptions::MapWithCarRouting);
|
||||
for (auto const & index : alert->routes)
|
||||
a.DownloadMap(index, MapOptions::CarRouting);
|
||||
};
|
||||
[alert configure];
|
||||
return alert;
|
||||
}
|
||||
|
|
|
@ -207,9 +207,7 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
|
||||
- (void)actionDownloadMaps
|
||||
{
|
||||
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"downloader"];
|
||||
CountryTreeVC * vc = [[CountryTreeVC alloc] initWithNodePosition:-1];
|
||||
[self.ownerController.navigationController pushViewController:vc animated:YES];
|
||||
[self.ownerController downloadMaps];
|
||||
}
|
||||
|
||||
#pragma mark - MWMBottomMenuControllerProtocol
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace search { struct AddressInfo; }
|
|||
- (void)performAction:(NSString *)action;
|
||||
|
||||
- (void)openBookmarks;
|
||||
- (void)downloadMaps;
|
||||
|
||||
- (void)refreshAd;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#import "BookmarksRootVC.h"
|
||||
#import "BookmarksVC.h"
|
||||
#import "Common.h"
|
||||
#import "CountryTreeVC.h"
|
||||
#import "EAGLView.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
|
@ -32,6 +33,7 @@
|
|||
#include "drape_frontend/user_event_stream.hpp"
|
||||
|
||||
#include "platform/file_logging.hpp"
|
||||
#include "platform/local_country_file_utils.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "platform/settings.hpp"
|
||||
|
||||
|
@ -554,32 +556,35 @@ NSString * const kAuthorizationSegue = @"Map2AuthorizationSegue";
|
|||
}
|
||||
else
|
||||
{
|
||||
LocalAndRemoteSizeT sizes = layout.GetRemoteCountrySizes(idx);
|
||||
uint64_t sizeToDownload = sizes.first;
|
||||
MapOptions options = static_cast<MapOptions>(opt);
|
||||
if(HasOptions(options, MapOptions::CarRouting))
|
||||
sizeToDownload += sizes.second;
|
||||
|
||||
NSString * name = @(layout.GetCountryName(idx).c_str());
|
||||
Platform::EConnectionType const connection = Platform::ConnectionStatus();
|
||||
if (connection != Platform::EConnectionType::CONNECTION_NONE)
|
||||
[self checkMigrationAndCallBlock:^
|
||||
{
|
||||
if (connection == Platform::EConnectionType::CONNECTION_WWAN && sizeToDownload > 50 * MB)
|
||||
LocalAndRemoteSizeT sizes = layout.GetRemoteCountrySizes(idx);
|
||||
uint64_t sizeToDownload = sizes.first;
|
||||
MapOptions options = static_cast<MapOptions>(opt);
|
||||
if(HasOptions(options, MapOptions::CarRouting))
|
||||
sizeToDownload += sizes.second;
|
||||
|
||||
NSString * name = @(layout.GetCountryName(idx).c_str());
|
||||
Platform::EConnectionType const connection = Platform::ConnectionStatus();
|
||||
if (connection != Platform::EConnectionType::CONNECTION_NONE)
|
||||
{
|
||||
[self.alertController presentnoWiFiAlertWithName:name downloadBlock:^
|
||||
if (connection == Platform::EConnectionType::CONNECTION_WWAN && sizeToDownload > 50 * MB)
|
||||
{
|
||||
layout.DownloadMap(idx, static_cast<MapOptions>(opt));
|
||||
}];
|
||||
[self.alertController presentnoWiFiAlertWithName:name downloadBlock:^
|
||||
{
|
||||
layout.DownloadMap(idx, static_cast<MapOptions>(opt));
|
||||
}];
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[self.alertController presentNoConnectionAlert];
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[self.alertController presentNoConnectionAlert];
|
||||
return;
|
||||
}
|
||||
|
||||
layout.DownloadMap(idx, static_cast<MapOptions>(opt));
|
||||
layout.DownloadMap(idx, static_cast<MapOptions>(opt));
|
||||
}];
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -600,6 +605,31 @@ NSString * const kAuthorizationSegue = @"Map2AuthorizationSegue";
|
|||
});
|
||||
}
|
||||
|
||||
- (void)checkMigrationAndCallBlock:(TMWMVoidBlock)block
|
||||
{
|
||||
if (platform::migrate::NeedMigrate())
|
||||
{
|
||||
[self.alertController presentNeedMigrationAlertWithOkBlock:^
|
||||
{
|
||||
GetFramework().Migrate();
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
block();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)downloadMaps
|
||||
{
|
||||
[self checkMigrationAndCallBlock:^
|
||||
{
|
||||
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"downloader"];
|
||||
CountryTreeVC * vc = [[CountryTreeVC alloc] initWithNodePosition:-1];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)processRoutingBuildingEvent:(routing::IRouter::ResultCode)code
|
||||
countries:(vector<storage::TIndex> const &)absentCountries
|
||||
routes:(vector<storage::TIndex> const &)absentRoutes
|
||||
|
@ -633,10 +663,22 @@ NSString * const kAuthorizationSegue = @"Map2AuthorizationSegue";
|
|||
case routing::IRouter::NeedMoreMaps:
|
||||
case routing::IRouter::FileTooOld:
|
||||
case routing::IRouter::RouteNotFound:
|
||||
{
|
||||
[self.controlsManager handleRoutingError];
|
||||
[self presentDownloaderAlert:code countries:absentCountries routes:absentRoutes];
|
||||
[self presentDownloaderAlert:code countries:absentCountries routes:absentRoutes block:^
|
||||
{
|
||||
[self checkMigrationAndCallBlock:^
|
||||
{
|
||||
auto & a = GetFramework().GetCountryTree().GetActiveMapLayout();
|
||||
for (auto const & index : absentCountries)
|
||||
a.DownloadMap(index, MapOptions::MapWithCarRouting);
|
||||
for (auto const & index : absentRoutes)
|
||||
a.DownloadMap(index, MapOptions::CarRouting);
|
||||
}];
|
||||
}];
|
||||
self.forceRoutingStateChange = ForceRoutingStateChangeNone;
|
||||
break;
|
||||
}
|
||||
case routing::IRouter::Cancelled:
|
||||
self.forceRoutingStateChange = ForceRoutingStateChangeNone;
|
||||
break;
|
||||
|
@ -748,9 +790,10 @@ NSString * const kAuthorizationSegue = @"Map2AuthorizationSegue";
|
|||
- (void)presentDownloaderAlert:(routing::IRouter::ResultCode)code
|
||||
countries:(vector<storage::TIndex> const &)countries
|
||||
routes:(vector<storage::TIndex> const &)routes
|
||||
block:(TMWMVoidBlock)block
|
||||
{
|
||||
if (countries.size() || routes.size())
|
||||
[self.alertController presentDownloaderAlertWithCountries:countries routes:routes code:code];
|
||||
[self.alertController presentDownloaderAlertWithCountries:countries routes:routes code:code block:block];
|
||||
else
|
||||
[self presentDefaultAlert:code];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue