[ios] Fixed migration dialog appear logic.

This commit is contained in:
Ilya Grechuhin 2016-03-15 11:31:43 +03:00 committed by Sergey Yershov
parent 4433958db0
commit 5fbe60570b
5 changed files with 58 additions and 35 deletions

View file

@ -25,6 +25,8 @@
#include "Framework.h"
#include "platform/local_country_file_utils.hpp"
#include "storage/storage_helpers.hpp"
namespace
@ -242,7 +244,15 @@ extern NSString * const kAlohalyticsTapEventKey;
- (void)actionDownloadMaps
{
[self.ownerController openMapsDownloader];
if (platform::migrate::NeedMigrate())
{
[Statistics logEvent:kStatDownloaderMigrationDialogue withParameters:@{kStatFrom : kStatDownloader}];
[self.ownerController openMigration];
}
else
{
[self.ownerController openMapsDownloader];
}
}
#pragma mark - MWMBottomMenuControllerProtocol

View file

@ -30,6 +30,7 @@ namespace search { struct AddressInfo; }
- (void)performAction:(NSString *)action;
- (void)openMigration;
- (void)openBookmarks;
- (void)openMapsDownloader;
- (void)openEditor;

View file

@ -528,6 +528,11 @@ NSString * const kReportSegue = @"Map2ReportSegue";
#pragma mark - Open controllers
- (void)openMigration
{
[self performSegueWithIdentifier:kMigrationSegue sender:self];
}
- (void)openBookmarks
{
BOOL const oneCategory = (GetFramework().GetBmCategoriesCount() == 1);
@ -537,16 +542,8 @@ NSString * const kReportSegue = @"Map2ReportSegue";
- (void)openMapsDownloader
{
if (platform::migrate::NeedMigrate())
{
[Statistics logEvent:kStatDownloaderMigrationDialogue withParameters:@{kStatFrom : kStatDownloader}];
[self performSegueWithIdentifier:kMigrationSegue sender:self];
}
else
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"downloader"];
[self performSegueWithIdentifier:kDownloaderSegue sender:self];
}
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"downloader"];
[self performSegueWithIdentifier:kDownloaderSegue sender:self];
}
- (void)openEditor
@ -620,7 +617,15 @@ NSString * const kReportSegue = @"Map2ReportSegue";
auto & s = GetFramework().Storage();
for (auto const & countryId : absentCountries)
s.DownloadNode(countryId);
[self openMapsDownloader];
if (platform::migrate::NeedMigrate())
{
[Statistics logEvent:kStatDownloaderMigrationDialogue withParameters:@{kStatFrom : kStatMap}];
[self openMigration];
}
else
{
[self openMapsDownloader];
}
}];
break;
}
@ -637,17 +642,8 @@ NSString * const kReportSegue = @"Map2ReportSegue";
- (void)processViewportCountryEvent:(TCountryId const &)countryId
{
if (![self.navigationController.topViewController isEqual:self])
return;
if (countryId != kInvalidCountryId && platform::migrate::NeedMigrate())
{
[Statistics logEvent:kStatDownloaderMigrationDialogue withParameters:@{kStatFrom : kStatMap}];
[self performSegueWithIdentifier:kMigrationSegue sender:self];
}
else
{
if ([self.navigationController.topViewController isEqual:self])
[self.downloadDialog processViewportCountryEvent:countryId];
}
}
#pragma mark - MWMFrameworkStorageObserver

View file

@ -2,9 +2,11 @@
#include "storage/index.hpp"
@class MapViewController;
@interface MWMMapDownloadDialog : UIView
+ (instancetype)dialogForController:(MWMViewController *)controller;
+ (instancetype)dialogForController:(MapViewController *)controller;
- (void)processViewportCountryEvent:(storage::TCountryId const &)countryId;

View file

@ -1,6 +1,7 @@
#import "Common.h"
#import "LocationManager.h"
#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "MWMAlertViewController.h"
#import "MWMCircularProgress.h"
#import "MWMFrameworkListener.h"
@ -12,6 +13,8 @@
#include "Framework.h"
#include "platform/local_country_file_utils.hpp"
namespace
{
CGSize constexpr kInitialDialogSize = {200, 200};
@ -24,7 +27,9 @@ BOOL canAutoDownload(TCountryId const & countryId)
if (GetPlatform().ConnectionStatus() != Platform::EConnectionType::CONNECTION_WIFI)
return NO;
auto const & countryInfoGetter = GetFramework().CountryInfoGetter();
return countryId == countryInfoGetter.GetRegionCountryId(locationManager.lastLocation.mercator);
if (countryId != countryInfoGetter.GetRegionCountryId(locationManager.lastLocation.mercator))
return NO;
return !platform::migrate::NeedMigrate();
}
} // namespace
@ -39,7 +44,7 @@ using namespace storage;
@property (weak, nonatomic) IBOutlet UIButton * downloadButton;
@property (weak, nonatomic) IBOutlet UIView * progressWrapper;
@property (weak, nonatomic) MWMViewController * controller;
@property (weak, nonatomic) MapViewController * controller;
@property (nonatomic) MWMCircularProgress * progress;
@ -55,7 +60,7 @@ using namespace storage;
TCountryId m_autoDownloadCountryId;
}
+ (instancetype)dialogForController:(MWMViewController *)controller
+ (instancetype)dialogForController:(MapViewController *)controller
{
MWMMapDownloadDialog * dialog = [[NSBundle mainBundle] loadNibNamed:[self className] owner:nil options:nil].firstObject;
dialog.autoresizingMask = UIViewAutoresizingFlexibleHeight;
@ -101,6 +106,7 @@ using namespace storage;
if (!hideParent)
self.parentNode.text = @(nodeAttrs.m_parentInfo[0].m_localName.c_str());
self.node.text = @(nodeAttrs.m_nodeLocalName.c_str());
self.nodeSize.hidden = platform::migrate::NeedMigrate();
self.nodeSize.textColor = [UIColor blackSecondaryText];
self.nodeSize.text = formattedSize(nodeAttrs.m_mwmSize);
@ -287,15 +293,23 @@ using namespace storage;
- (IBAction)downloadAction
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatDownload,
kStatIsAuto : kStatNo,
kStatFrom : kStatMap,
kStatScenario : kStatDownload
}];
[self showInQueue];
[MWMStorage downloadNode:m_countryId alertController:self.controller.alertController onSuccess:nil];
if (platform::migrate::NeedMigrate())
{
[Statistics logEvent:kStatDownloaderMigrationDialogue withParameters:@{kStatFrom : kStatMap}];
[self.controller openMigration];
}
else
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatDownload,
kStatIsAuto : kStatNo,
kStatFrom : kStatMap,
kStatScenario : kStatDownload
}];
[self showInQueue];
[MWMStorage downloadNode:m_countryId alertController:self.controller.alertController onSuccess:nil];
}
}
#pragma mark - Properties