Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/iphone
diff options
context:
space:
mode:
authorZoia Pribytkova <niakris90@gmail.com>2019-04-24 18:35:43 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2019-05-08 16:49:33 +0300
commit67203010843b842e2386efdf8e20c353cdf8541f (patch)
treed08a226fc3065a50fa65407beff2d563e2ff26be /iphone
parent972b159b3e062319f06d00e419eba3fe9126b95d (diff)
[iOS] new onCancel callback for MWMStorage download/update actions
Diffstat (limited to 'iphone')
-rw-r--r--iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h2
-rw-r--r--iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm4
-rw-r--r--iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h2
-rw-r--r--iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm4
-rw-r--r--iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h2
-rw-r--r--iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm3
-rw-r--r--iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm4
-rw-r--r--iphone/Maps/Core/Framework/MWMFrameworkHelper.h2
-rw-r--r--iphone/Maps/Core/Framework/MWMFrameworkHelper.mm6
-rw-r--r--iphone/Maps/Core/Routing/MWMRouter.mm3
-rw-r--r--iphone/Maps/Core/Storage/MWMStorage.h11
-rw-r--r--iphone/Maps/Core/Storage/MWMStorage.mm20
-rw-r--r--iphone/Maps/UI/Autoupdate/MWMAutoupdateController.mm13
-rw-r--r--iphone/Maps/UI/Downloader/MWMBaseMapDownloaderViewController.mm10
-rw-r--r--iphone/Maps/UI/Migration/MWMMigrationViewController.mm2
-rw-r--r--iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm4
16 files changed, 57 insertions, 35 deletions
diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h
index 6f0c094f08..87320bf5e1 100644
--- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h
+++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h
@@ -21,7 +21,7 @@
- (void)presentMigrationProhibitedAlert;
- (void)presentDeleteMapProhibitedAlert;
- (void)presentUnsavedEditsAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock;
-- (void)presentNoWiFiAlertWithOkBlock:(nullable MWMVoidBlock)okBlock;
+- (void)presentNoWiFiAlertWithOkBlock:(nullable MWMVoidBlock)okBlock andCancelBlock:(nullable MWMVoidBlock)cancelBlock;
- (void)presentIncorrectFeauturePositionAlert;
- (void)presentInternalErrorAlert;
- (void)presentNotEnoughSpaceAlert;
diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm
index e6b6dd24fa..517b11406a 100644
--- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm
+++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm
@@ -80,9 +80,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
[self displayAlert:[MWMAlert unsavedEditsAlertWithOkBlock:okBlock]];
}
-- (void)presentNoWiFiAlertWithOkBlock:(nullable MWMVoidBlock)okBlock
+- (void)presentNoWiFiAlertWithOkBlock:(nullable MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock
{
- [self displayAlert:[MWMAlert noWiFiAlertWithOkBlock:okBlock]];
+ [self displayAlert:[MWMAlert noWiFiAlertWithOkBlock:okBlock andCancelBlock:cancelBlock]];
}
- (void)presentIncorrectFeauturePositionAlert
diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h
index 893eefe181..04ea557185 100644
--- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h
+++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h
@@ -8,7 +8,7 @@
+ (MWMAlert *)locationAlert;
+ (MWMAlert *)routingDisclaimerAlertWithOkBlock:(MWMVoidBlock)block;
+ (MWMAlert *)disabledLocationAlert;
-+ (MWMAlert *)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock;
++ (MWMAlert *)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock;
+ (MWMAlert *)noConnectionAlert;
+ (MWMAlert *)migrationProhibitedAlert;
+ (MWMAlert *)deleteMapProhibitedAlert;
diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm
index f51632e6fc..2cc2faf131 100644
--- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm
+++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm
@@ -27,9 +27,9 @@
}
+ (MWMAlert *)disabledLocationAlert { return [MWMDefaultAlert disabledLocationAlert]; }
-+ (MWMAlert *)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock
++ (MWMAlert *)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock
{
- return [MWMDefaultAlert noWiFiAlertWithOkBlock:okBlock];
+ return [MWMDefaultAlert noWiFiAlertWithOkBlock:okBlock andCancelBlock:cancelBlock];
}
+ (MWMAlert *)noConnectionAlert { return [MWMDefaultAlert noConnectionAlert]; }
diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h
index c0381a3a78..763b419681 100644
--- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h
+++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h
@@ -17,7 +17,7 @@
+ (instancetype)noCurrentPositionAlert;
+ (instancetype)pointsInDifferentMWMAlert;
+ (instancetype)disabledLocationAlert;
-+ (instancetype)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock;
++ (instancetype)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock;
+ (instancetype)noConnectionAlert;
+ (instancetype)migrationProhibitedAlert;
+ (instancetype)deleteMapProhibitedAlert;
diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm
index 6441a2a269..675061d9de 100644
--- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm
+++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm
@@ -123,7 +123,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
statisticsEvent:@"Editor unsaved changes on delete"];
}
-+ (instancetype)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock
++ (instancetype)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"download_over_mobile_header")
message:L(@"download_over_mobile_message")
@@ -131,6 +131,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
statisticsEvent:@"No WiFi Alert"];
+ alert.leftButtonAction = cancelBlock;
[alert setNeedsCloseAlertAfterEnterBackground];
return alert;
}
diff --git a/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm b/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm
index 9dcfd9163d..589c9c30a6 100644
--- a/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm
+++ b/iphone/Maps/Classes/Widgets/MWMMapDownloadDialog.mm
@@ -154,7 +154,7 @@ using namespace storage;
[MWMStorage downloadNode:m_countryId
onSuccess:^{
[self showInQueue];
- }];
+ } onCancel:nil];
}
else
{
@@ -383,7 +383,7 @@ using namespace storage;
[MWMStorage downloadNode:m_countryId
onSuccess:^{
[self showInQueue];
- }];
+ } onCancel:nil];
}
}
diff --git a/iphone/Maps/Core/Framework/MWMFrameworkHelper.h b/iphone/Maps/Core/Framework/MWMFrameworkHelper.h
index 9b5e8ad8b0..bc685d6c89 100644
--- a/iphone/Maps/Core/Framework/MWMFrameworkHelper.h
+++ b/iphone/Maps/Core/Framework/MWMFrameworkHelper.h
@@ -8,7 +8,7 @@
+ (MWMDayTime)daytime;
-+ (void)checkConnectionAndPerformAction:(MWMVoidBlock)action;
++ (void)checkConnectionAndPerformAction:(MWMVoidBlock)action cancelAction:(MWMVoidBlock)cancel;
+ (void)createFramework;
diff --git a/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm b/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm
index 642cc2773e..e81afb75c2 100644
--- a/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm
+++ b/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm
@@ -67,12 +67,14 @@
}
}
-+ (void)checkConnectionAndPerformAction:(MWMVoidBlock)action
++ (void)checkConnectionAndPerformAction:(MWMVoidBlock)action cancelAction:(MWMVoidBlock)cancel
{
switch (Platform::ConnectionStatus())
{
case Platform::EConnectionType::CONNECTION_NONE:
[[MWMAlertViewController activeAlertController] presentNoConnectionAlert];
+ if (cancel)
+ cancel();
break;
case Platform::EConnectionType::CONNECTION_WIFI:
action();
@@ -84,7 +86,7 @@
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:[action] {
GetFramework().GetDownloadingPolicy().EnableCellularDownload(true);
action();
- }];
+ } andCancelBlock:cancel];
}
else
{
diff --git a/iphone/Maps/Core/Routing/MWMRouter.mm b/iphone/Maps/Core/Routing/MWMRouter.mm
index c23cdf6bc8..1604c4ee30 100644
--- a/iphone/Maps/Core/Routing/MWMRouter.mm
+++ b/iphone/Maps/Core/Routing/MWMRouter.mm
@@ -725,7 +725,8 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType)
}
downloadBlock:^(storage::CountriesVec const & downloadCountries, MWMVoidBlock onSuccess) {
[MWMStorage downloadNodes:downloadCountries
- onSuccess:onSuccess];
+ onSuccess:onSuccess
+ onCancel:nil];
}
downloadCompleteBlock:^{
[MWMRouter rebuildWithBestRouter:NO];
diff --git a/iphone/Maps/Core/Storage/MWMStorage.h b/iphone/Maps/Core/Storage/MWMStorage.h
index 57b4917be4..fffc2f908d 100644
--- a/iphone/Maps/Core/Storage/MWMStorage.h
+++ b/iphone/Maps/Core/Storage/MWMStorage.h
@@ -2,13 +2,18 @@
@interface MWMStorage : NSObject
-+ (void)downloadNode:(storage::CountryId const &)countryId onSuccess:(MWMVoidBlock)onSuccess;
++ (void)downloadNode:(storage::CountryId const &)countryId
+ onSuccess:(MWMVoidBlock)onSuccess
+ onCancel:(MWMVoidBlock)onCancel;
+ (void)retryDownloadNode:(storage::CountryId const &)countryId;
-+ (void)updateNode:(storage::CountryId const &)countryId;
++ (void)updateNode:(storage::CountryId const &)countryId
+ onCancel:(MWMVoidBlock)onCancel;
+ (void)deleteNode:(storage::CountryId const &)countryId;
+ (void)cancelDownloadNode:(storage::CountryId const &)countryId;
+ (void)showNode:(storage::CountryId const &)countryId;
-+ (void)downloadNodes:(storage::CountriesVec const &)countryIds onSuccess:(MWMVoidBlock)onSuccess;
++ (void)downloadNodes:(storage::CountriesVec const &)countryIds
+ onSuccess:(MWMVoidBlock)onSuccess
+ onCancel:(MWMVoidBlock)onCancel;
@end
diff --git a/iphone/Maps/Core/Storage/MWMStorage.mm b/iphone/Maps/Core/Storage/MWMStorage.mm
index 50bfa38ee0..e88f2109d2 100644
--- a/iphone/Maps/Core/Storage/MWMStorage.mm
+++ b/iphone/Maps/Core/Storage/MWMStorage.mm
@@ -13,7 +13,7 @@ using namespace storage;
@implementation MWMStorage
-+ (void)downloadNode:(CountryId const &)countryId onSuccess:(MWMVoidBlock)onSuccess
++ (void)downloadNode:(CountryId const &)countryId onSuccess:(MWMVoidBlock)onSuccess onCancel:(MWMVoidBlock)onCancel
{
if (IsEnoughSpaceForDownload(countryId, GetFramework().GetStorage()))
{
@@ -21,11 +21,13 @@ using namespace storage;
GetFramework().GetStorage().DownloadNode(countryId);
if (onSuccess)
onSuccess();
- }];
+ } cancelAction:onCancel];
}
else
{
[[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert];
+ if (onCancel)
+ onCancel();
}
}
@@ -33,20 +35,22 @@ using namespace storage;
{
[MWMFrameworkHelper checkConnectionAndPerformAction:[countryId] {
GetFramework().GetStorage().RetryDownloadNode(countryId);
- }];
+ } cancelAction:nil];
}
-+ (void)updateNode:(CountryId const &)countryId
++ (void)updateNode:(CountryId const &)countryId onCancel:(MWMVoidBlock)onCancel
{
if (IsEnoughSpaceForUpdate(countryId, GetFramework().GetStorage()))
{
[MWMFrameworkHelper checkConnectionAndPerformAction:[countryId] {
GetFramework().GetStorage().UpdateNode(countryId);
- }];
+ } cancelAction:onCancel];
}
else
{
[[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert];
+ if (onCancel)
+ onCancel();
}
}
@@ -78,7 +82,7 @@ using namespace storage;
}
+ (void)showNode:(CountryId const &)countryId { GetFramework().ShowNode(countryId); }
-+ (void)downloadNodes:(CountriesVec const &)countryIds onSuccess:(MWMVoidBlock)onSuccess
++ (void)downloadNodes:(CountriesVec const &)countryIds onSuccess:(MWMVoidBlock)onSuccess onCancel:(MWMVoidBlock)onCancel
{
auto & s = GetFramework().GetStorage();
MwmSize requiredSize =
@@ -95,11 +99,13 @@ using namespace storage;
s.DownloadNode(countryId);
if (onSuccess)
onSuccess();
- }];
+ } cancelAction: onCancel];
}
else
{
[[MWMAlertViewController activeAlertController] presentNotEnoughSpaceAlert];
+ if (onCancel)
+ onCancel();
}
}
diff --git a/iphone/Maps/UI/Autoupdate/MWMAutoupdateController.mm b/iphone/Maps/UI/Autoupdate/MWMAutoupdateController.mm
index efdcc6ae89..9a1684be86 100644
--- a/iphone/Maps/UI/Autoupdate/MWMAutoupdateController.mm
+++ b/iphone/Maps/UI/Autoupdate/MWMAutoupdateController.mm
@@ -172,11 +172,13 @@ enum class State
self.progressFinished = NO;
[Statistics logEvent:kStatDownloaderOnStartScreenShow
withParameters:@{kStatMapDataSize : @(self.sizeInMB)}];
- auto view = static_cast<MWMAutoupdateView *>(self.view);
+ MWMAutoupdateView *view = (MWMAutoupdateView *)self.view;
if (self.todo == Framework::DoAfterUpdate::AutoupdateMaps)
{
[view stateDownloading];
- [MWMStorage updateNode:RootId()];
+ [MWMStorage updateNode:RootId() onCancel:^{
+ [view stateWaiting];
+ }];
[Statistics logEvent:kStatDownloaderOnStartScreenAutoDownload
withParameters:@{kStatMapDataSize : @(self.sizeInMB)}];
}
@@ -196,8 +198,11 @@ enum class State
- (IBAction)updateTap
{
- [static_cast<MWMAutoupdateView *>(self.view) stateDownloading];
- [MWMStorage updateNode:RootId()];
+ MWMAutoupdateView *view = (MWMAutoupdateView *)self.view;
+ [view stateDownloading];
+ [MWMStorage updateNode:RootId() onCancel:^{
+ [view stateWaiting];
+ }];
[Statistics logEvent:kStatDownloaderOnStartScreenManualDownload
withParameters:@{kStatMapDataSize : @(self.sizeInMB)}];
}
diff --git a/iphone/Maps/UI/Downloader/MWMBaseMapDownloaderViewController.mm b/iphone/Maps/UI/Downloader/MWMBaseMapDownloaderViewController.mm
index c04ba38aa9..d864e75a43 100644
--- a/iphone/Maps/UI/Downloader/MWMBaseMapDownloaderViewController.mm
+++ b/iphone/Maps/UI/Downloader/MWMBaseMapDownloaderViewController.mm
@@ -350,7 +350,8 @@ using namespace storage;
kStatFrom: kStatDownloader,
kStatScenario: kStatUpdateAll
}];
- [MWMStorage updateNode:parentCountryId];
+ [MWMStorage updateNode:parentCountryId
+ onCancel:nil];
}
else
{
@@ -362,7 +363,8 @@ using namespace storage;
kStatScenario : kStatDownloadGroup
}];
[MWMStorage downloadNode:parentCountryId
- onSuccess:nil];
+ onSuccess:nil
+ onCancel:nil];
}
self.skipCountryEventProcessing = NO;
[self processCountryEvent:parentCountryId];
@@ -636,7 +638,7 @@ using namespace storage;
kStatScenario: kStatDownload
}];
self.skipCountryEventProcessing = YES;
- [MWMStorage downloadNode:countryId onSuccess:nil];
+ [MWMStorage downloadNode:countryId onSuccess:nil onCancel:nil];
self.skipCountryEventProcessing = NO;
[self processCountryEvent:countryId];
}
@@ -666,7 +668,7 @@ using namespace storage;
kStatScenario: kStatUpdate
}];
self.skipCountryEventProcessing = YES;
- [MWMStorage updateNode:countryId];
+ [MWMStorage updateNode:countryId onCancel:nil];
self.skipCountryEventProcessing = NO;
[self processCountryEvent:countryId];
}
diff --git a/iphone/Maps/UI/Migration/MWMMigrationViewController.mm b/iphone/Maps/UI/Migration/MWMMigrationViewController.mm
index da7e1a0523..62c07af347 100644
--- a/iphone/Maps/UI/Migration/MWMMigrationViewController.mm
+++ b/iphone/Maps/UI/Migration/MWMMigrationViewController.mm
@@ -96,7 +96,7 @@ using namespace storage;
[self setState:MWMMigrationViewState::Processing];
else
migrate();
- }];
+ } cancelAction:nil];
}
- (void)showError:(NodeErrorCode)errorCode countryId:(CountryId const &)countryId
diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm
index 118103077c..cc80da7a82 100644
--- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm
+++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm
@@ -167,10 +167,10 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page:
switch (nodeAttrs.m_status)
{
case NodeStatus::NotDownloaded:
- case NodeStatus::Partly: [MWMStorage downloadNode:countryId onSuccess:nil]; break;
+ case NodeStatus::Partly: [MWMStorage downloadNode:countryId onSuccess:nil onCancel:nil]; break;
case NodeStatus::Undefined:
case NodeStatus::Error: [MWMStorage retryDownloadNode:countryId]; break;
- case NodeStatus::OnDiskOutOfDate: [MWMStorage updateNode:countryId]; break;
+ case NodeStatus::OnDiskOutOfDate: [MWMStorage updateNode:countryId onCancel:nil]; break;
case NodeStatus::Downloading:
case NodeStatus::Applying:
case NodeStatus::InQueue: [MWMStorage cancelDownloadNode:countryId]; break;