forked from organicmaps/organicmaps-tmp
Merge pull request #2653 from igrechuhin/ig-master
[ios] Updated no wifi alert display logic.
This commit is contained in:
commit
3cc940a149
12 changed files with 106 additions and 52 deletions
|
@ -23,7 +23,7 @@
|
|||
- (void)presentNoConnectionAlert;
|
||||
- (void)presentMigrationProhibitedAlert;
|
||||
- (void)presentUnsavedEditsAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock;
|
||||
- (void)presentNoWiFiAlertWithName:(nonnull NSString *)name okBlock:(nullable TMWMVoidBlock)okBlock;
|
||||
- (void)presentNoWiFiAlertWithOkBlock:(nullable TMWMVoidBlock)okBlock;
|
||||
- (void)presentPedestrianToastAlert:(BOOL)isFirstLaunch;
|
||||
- (void)presentIncorrectFeauturePositionAlert;
|
||||
- (void)presentInternalErrorAlert;
|
||||
|
@ -35,7 +35,7 @@
|
|||
- (void)presentDownloaderNeedUpdateAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock;
|
||||
- (void)presentEditorViralAlert;
|
||||
- (void)presentOsmAuthAlert;
|
||||
- (void)closeAlertWithCompletion:(nullable TMWMVoidBlock)completion;
|
||||
- (void)closeAlert;
|
||||
|
||||
- (nonnull instancetype)init __attribute__((unavailable("call -initWithViewController: instead!")));
|
||||
+ (nonnull instancetype)new __attribute__((unavailable("call -initWithViewController: instead!")));
|
||||
|
|
|
@ -69,9 +69,9 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert unsavedEditsAlertWithOkBlock:okBlock]];
|
||||
}
|
||||
|
||||
- (void)presentNoWiFiAlertWithName:(nonnull NSString *)name okBlock:(nullable TMWMVoidBlock)okBlock
|
||||
- (void)presentNoWiFiAlertWithOkBlock:(nullable TMWMVoidBlock)okBlock
|
||||
{
|
||||
[self displayAlert:[MWMAlert noWiFiAlertWithName:name okBlock:okBlock]];
|
||||
[self displayAlert:[MWMAlert noWiFiAlertWithOkBlock:okBlock]];
|
||||
}
|
||||
|
||||
- (void)presentPedestrianToastAlert:(BOOL)isFirstLaunch
|
||||
|
@ -177,20 +177,25 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert osmAuthAlert]];
|
||||
}
|
||||
|
||||
- (void)closeAlertWithCompletion:(nullable TMWMVoidBlock)completion
|
||||
- (void)closeAlert
|
||||
{
|
||||
MWMAlert * alert = self.view.subviews.firstObject;
|
||||
NSArray * subviews = self.view.subviews;
|
||||
MWMAlert * alert = subviews.firstObject;
|
||||
BOOL const isLastAlert = (subviews.count == 1);
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
alert.alpha = 0.;
|
||||
self.view.alpha = 0.;
|
||||
if (isLastAlert)
|
||||
self.view.alpha = 0.;
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
if (completion)
|
||||
completion();
|
||||
[self.view removeFromSuperview];
|
||||
[self removeFromParentViewController];
|
||||
[alert removeFromSuperview];
|
||||
if (isLastAlert)
|
||||
{
|
||||
[self.view removeFromSuperview];
|
||||
[self removeFromParentViewController];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
+ (MWMAlert *)locationAlert;
|
||||
+ (MWMAlert *)routingDisclaimerAlertWithInitialOrientation:(UIInterfaceOrientation)orientation;
|
||||
+ (MWMAlert *)disabledLocationAlert;
|
||||
+ (MWMAlert *)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock;
|
||||
+ (MWMAlert *)noWiFiAlertWithOkBlock:(TMWMVoidBlock)okBlock;
|
||||
+ (MWMAlert *)noConnectionAlert;
|
||||
+ (MWMAlert *)migrationProhibitedAlert;
|
||||
+ (MWMAlert *)unsavedEditsAlertWithOkBlock:(TMWMVoidBlock)okBlock;
|
||||
|
|
|
@ -43,9 +43,9 @@
|
|||
return [MWMDefaultAlert disabledLocationAlert];
|
||||
}
|
||||
|
||||
+ (MWMAlert *)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock
|
||||
+ (MWMAlert *)noWiFiAlertWithOkBlock:(TMWMVoidBlock)okBlock
|
||||
{
|
||||
return [MWMDefaultAlert noWiFiAlertWithName:name okBlock:okBlock];
|
||||
return [MWMDefaultAlert noWiFiAlertWithOkBlock:okBlock];
|
||||
}
|
||||
|
||||
+ (MWMAlert *)noConnectionAlert
|
||||
|
@ -169,10 +169,7 @@
|
|||
|
||||
- (void)close
|
||||
{
|
||||
[self.alertController closeAlertWithCompletion:^
|
||||
{
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
[self.alertController closeAlert];
|
||||
}
|
||||
|
||||
- (void)setNeedsCloseAlertAfterEnterBackground
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
+ (instancetype)noCurrentPositionAlert;
|
||||
+ (instancetype)pointsInDifferentMWMAlert;
|
||||
+ (instancetype)disabledLocationAlert;
|
||||
+ (instancetype)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock;
|
||||
+ (instancetype)noWiFiAlertWithOkBlock:(TMWMVoidBlock)okBlock;
|
||||
+ (instancetype)noConnectionAlert;
|
||||
+ (instancetype)migrationProhibitedAlert;
|
||||
+ (instancetype)unsavedEditsAlertWithOkBlock:(TMWMVoidBlock)okBlock;
|
||||
|
|
|
@ -97,12 +97,11 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
|
|||
rightButtonAction:okBlock];
|
||||
}
|
||||
|
||||
+ (instancetype)noWiFiAlertWithName:(NSString *)name okBlock:(TMWMVoidBlock)okBlock
|
||||
+ (instancetype)noWiFiAlertWithOkBlock:(TMWMVoidBlock)okBlock
|
||||
{
|
||||
kStatisticsEvent = @"No WiFi Alert";
|
||||
NSString * title = [NSString stringWithFormat:L(@"common_no_wifi_dialog"), name];
|
||||
MWMDefaultAlert * alert = [self defaultAlertWithTitle:title
|
||||
message:nil
|
||||
MWMDefaultAlert * alert = [self defaultAlertWithTitle:@"download_over_mobile_header"
|
||||
message:@"download_over_mobile_message"
|
||||
rightButtonTitle:@"use_cellular_data"
|
||||
leftButtonTitle:@"cancel"
|
||||
rightButtonAction:okBlock];
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#import "MWMPageController.h"
|
||||
#import "MWMPlacePageEntity.h"
|
||||
#import "MWMReportBaseController.h"
|
||||
#import "MWMStorage.h"
|
||||
#import "MWMTableViewController.h"
|
||||
#import "MWMTextToSpeech.h"
|
||||
#import "MWMWhatsNewDownloaderEditorController.h"
|
||||
|
@ -641,10 +642,9 @@ NSString * const kReportSegue = @"Map2ReportSegue";
|
|||
{
|
||||
[self presentDownloaderAlert:code countries:absentCountries okBlock:[self, absentCountries]
|
||||
{
|
||||
auto & s = GetFramework().Storage();
|
||||
for (auto const & countryId : absentCountries)
|
||||
s.DownloadNode(countryId);
|
||||
[self openMapsDownloader];
|
||||
[MWMStorage downloadNodes:absentCountries
|
||||
alertController:self.alertController
|
||||
onSuccess:^{ [self openMapsDownloader]; }];
|
||||
}];
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#import "MWMController.h"
|
||||
#import "MWMFrameworkListener.h"
|
||||
#import "MWMFrameworkObservers.h"
|
||||
#import "MWMStorage.h"
|
||||
#import "MWMTextToSpeech.h"
|
||||
#import "Preferences.h"
|
||||
#import "RouteState.h"
|
||||
|
@ -404,6 +405,7 @@ using namespace osm_auth_ios;
|
|||
if (launchOptions[UIApplicationLaunchOptionsLocalNotificationKey])
|
||||
[notificationManager processNotification:launchOptions[UIApplicationLaunchOptionsLocalNotificationKey] onLaunch:YES];
|
||||
|
||||
[MWMStorage startSession];
|
||||
if ([Alohalytics isFirstSession])
|
||||
[self firstLaunchSetup];
|
||||
else
|
||||
|
|
|
@ -20,6 +20,12 @@ NSString * const kDownloaderSegue = @"Migration2MapDownloaderSegue";
|
|||
|
||||
using namespace storage;
|
||||
|
||||
@interface MWMStorage ()
|
||||
|
||||
+ (void)performAction:(TMWMVoidBlock)action alertController:(MWMAlertViewController *)alertController;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMMigrationViewController () <MWMCircularProgressProtocol>
|
||||
|
||||
@end
|
||||
|
@ -97,11 +103,15 @@ using namespace storage;
|
|||
[view setProgress:static_cast<CGFloat>(progress.first) / progress.second];
|
||||
};
|
||||
|
||||
m_countryId = f.PreMigrate(position, onStatusChanged, onProgressChanged);
|
||||
if (m_countryId != kInvalidCountryId)
|
||||
[self setState:MWMMigrationViewState::Processing];
|
||||
else
|
||||
migrate();
|
||||
[MWMStorage performAction:^
|
||||
{
|
||||
self->m_countryId = f.PreMigrate(position, onStatusChanged, onProgressChanged);
|
||||
if (self->m_countryId != kInvalidCountryId)
|
||||
[self setState:MWMMigrationViewState::Processing];
|
||||
else
|
||||
migrate();
|
||||
}
|
||||
alertController:self.alertController];
|
||||
}
|
||||
|
||||
- (void)showError:(NodeErrorCode)errorCode countryId:(TCountryId const &)countryId
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
@interface MWMStorage : NSObject
|
||||
|
||||
+ (void)startSession;
|
||||
+ (void)downloadNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess;
|
||||
+ (void)retryDownloadNode:(storage::TCountryId const &)countryId;
|
||||
+ (void)updateNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController;
|
||||
|
@ -11,4 +12,6 @@
|
|||
+ (void)cancelDownloadNode:(storage::TCountryId const &)countryId;
|
||||
+ (void)showNode:(storage::TCountryId const &)countryId;
|
||||
|
||||
+ (void)downloadNodes:(storage::TCountriesVec const &)countryIds alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess;
|
||||
|
||||
@end
|
||||
|
|
|
@ -5,32 +5,48 @@
|
|||
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
NSString * const kStorageCanShowNoWifiAlert = @"StorageCanShowNoWifiAlert";
|
||||
} // namespace
|
||||
|
||||
using namespace storage;
|
||||
|
||||
@implementation MWMStorage
|
||||
|
||||
+ (void)downloadNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess
|
||||
+ (void)startSession
|
||||
{
|
||||
[self countryId:countryId alertController:alertController performAction:^
|
||||
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
|
||||
[ud setBool:YES forKey:kStorageCanShowNoWifiAlert];
|
||||
[ud synchronize];
|
||||
}
|
||||
|
||||
+ (void)downloadNode:(TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess
|
||||
{
|
||||
[self performAction:^
|
||||
{
|
||||
GetFramework().Storage().DownloadNode(countryId);
|
||||
if (onSuccess)
|
||||
onSuccess();
|
||||
}];
|
||||
}
|
||||
alertController:alertController];
|
||||
}
|
||||
|
||||
+ (void)retryDownloadNode:(storage::TCountryId const &)countryId
|
||||
+ (void)retryDownloadNode:(TCountryId const &)countryId
|
||||
{
|
||||
GetFramework().Storage().RetryDownloadNode(countryId);
|
||||
}
|
||||
|
||||
+ (void)updateNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController
|
||||
+ (void)updateNode:(TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController
|
||||
{
|
||||
[self countryId:countryId alertController:alertController performAction:^
|
||||
[self performAction:^
|
||||
{
|
||||
GetFramework().Storage().UpdateNode(countryId);
|
||||
}];
|
||||
}
|
||||
alertController:alertController];
|
||||
}
|
||||
|
||||
+ (void)deleteNode:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController
|
||||
+ (void)deleteNode:(TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController
|
||||
{
|
||||
if (GetFramework().HasUnsavedEdits(countryId))
|
||||
{
|
||||
|
@ -45,17 +61,30 @@
|
|||
}
|
||||
}
|
||||
|
||||
+ (void)cancelDownloadNode:(storage::TCountryId const &)countryId
|
||||
+ (void)cancelDownloadNode:(TCountryId const &)countryId
|
||||
{
|
||||
GetFramework().Storage().CancelDownloadNode(countryId);
|
||||
}
|
||||
|
||||
+ (void)showNode:(storage::TCountryId const &)countryId
|
||||
+ (void)showNode:(TCountryId const &)countryId
|
||||
{
|
||||
GetFramework().ShowNode(countryId);
|
||||
}
|
||||
|
||||
+ (void)countryId:(storage::TCountryId const &)countryId alertController:(MWMAlertViewController *)alertController performAction:(TMWMVoidBlock)action
|
||||
+ (void)downloadNodes:(storage::TCountriesVec const &)countryIds alertController:(MWMAlertViewController *)alertController onSuccess:(TMWMVoidBlock)onSuccess
|
||||
{
|
||||
[self performAction:[countryIds, onSuccess]
|
||||
{
|
||||
auto & s = GetFramework().Storage();
|
||||
for (auto const & countryId : countryIds)
|
||||
s.DownloadNode(countryId);
|
||||
if (onSuccess)
|
||||
onSuccess();
|
||||
}
|
||||
alertController:alertController];
|
||||
}
|
||||
|
||||
+ (void)performAction:(TMWMVoidBlock)action alertController:(MWMAlertViewController *)alertController
|
||||
{
|
||||
switch (Platform::ConnectionStatus())
|
||||
{
|
||||
|
@ -67,13 +96,20 @@
|
|||
break;
|
||||
case Platform::EConnectionType::CONNECTION_WWAN:
|
||||
{
|
||||
storage::NodeAttrs attrs;
|
||||
GetFramework().Storage().GetNodeAttrs(countryId, attrs);
|
||||
size_t const warningSizeForWWAN = 50 * MB;
|
||||
if (attrs.m_mwmSize > warningSizeForWWAN)
|
||||
[alertController presentNoWiFiAlertWithName:@(attrs.m_nodeLocalName.c_str()) okBlock:action];
|
||||
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
|
||||
if ([ud boolForKey:kStorageCanShowNoWifiAlert])
|
||||
{
|
||||
[alertController presentNoWiFiAlertWithOkBlock:^
|
||||
{
|
||||
[ud setBool:NO forKey:kStorageCanShowNoWifiAlert];
|
||||
[ud synchronize];
|
||||
action();
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
action();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,9 +127,10 @@ using namespace storage;
|
|||
kStatFrom : kStatMap,
|
||||
kStatScenario : kStatDownload
|
||||
}];
|
||||
[self showInQueue];
|
||||
m_autoDownloadCountryId = m_countryId;
|
||||
s.DownloadNode(m_countryId);
|
||||
[MWMStorage downloadNode:m_countryId
|
||||
alertController:self.controller.alertController
|
||||
onSuccess:^{ [self showInQueue]; }];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -313,8 +314,9 @@ using namespace storage;
|
|||
kStatFrom : kStatMap,
|
||||
kStatScenario : kStatDownload
|
||||
}];
|
||||
[self showInQueue];
|
||||
[MWMStorage downloadNode:m_countryId alertController:self.controller.alertController onSuccess:nil];
|
||||
[MWMStorage downloadNode:m_countryId
|
||||
alertController:self.controller.alertController
|
||||
onSuccess:^{ [self showInQueue]; }];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue