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
diff options
context:
space:
mode:
authorIlya Grechuhin <i.grechuhin@gmail.com>2016-03-18 13:00:51 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:56:54 +0300
commitcbd362c67af9ac46ce0b45711471b239dddb96bd (patch)
tree36cdabbe97da07ab66b5f4f3474f1a18f7ede75c
parent74eaf00cde32902a82c9aa15b5b45dff9bb48341 (diff)
[ios] Added cancel all button.
-rw-r--r--iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm94
-rw-r--r--iphone/Maps/Classes/MapDownloader/MWMMapDownloaderViewController.mm2
-rw-r--r--iphone/Maps/Mapsme.storyboard2
3 files changed, 71 insertions, 27 deletions
diff --git a/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm b/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm
index ba0da9dc8e..a934740e06 100644
--- a/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm
+++ b/iphone/Maps/Classes/MapDownloader/MWMBaseMapDownloaderViewController.mm
@@ -24,11 +24,16 @@ extern NSString * const kLargeCountryCellIdentifier = @"MWMMapDownloaderLargeCou
namespace
{
-NSString * const kDownloadActionTitle = L(@"downloader_download_map");
-NSString * const kUpdateActionTitle = L(@"downloader_status_outdated");
+NSString * const kAllMapsLabelFormat = @"%@: %@ (%@)";
+NSString * const kCancelActionTitle = L(@"cancel");
+NSString * const kCancelAllTitle = L(@"downloader_cancel_all");
NSString * const kDeleteActionTitle = L(@"downloader_delete_map");
+NSString * const kDownloaAllTitle = L(@"downloader_download_all_button");
+NSString * const kDownloadActionTitle = L(@"downloader_download_map");
+NSString * const kDownloadingTitle = L(@"downloader_downloading");
+NSString * const kMapsTitle = L(@"maps");
NSString * const kShowActionTitle = L(@"zoom_to_country");
-NSString * const kCancelActionTitle = L(@"cancel");
+NSString * const kUpdateActionTitle = L(@"downloader_status_outdated");
} // namespace
@interface MWMBaseMapDownloaderViewController () <UIActionSheetDelegate, MWMFrameworkStorageObserver>
@@ -37,6 +42,7 @@ NSString * const kCancelActionTitle = L(@"cancel");
@property (weak, nonatomic) IBOutlet UIView * allMapsView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * allMapsViewBottomOffset;
+@property (weak, nonatomic) IBOutlet UIButton * allMapsButton;
@property (nonatomic) UIImage * navBarBackground;
@property (nonatomic) UIImage * navBarShadow;
@@ -307,23 +313,48 @@ using namespace storage;
- (void)configAllMapsView
{
- if (self.dataSource.isParentRoot)
- return;
+ self.showAllMapsView = YES;
auto const & s = GetFramework().Storage();
- NodeAttrs nodeAttrs;
- s.GetNodeAttrs(self.parentCountryId, nodeAttrs);
- uint32_t remoteMWMCounter = nodeAttrs.m_mwmCounter - nodeAttrs.m_localMwmCounter;
- if (remoteMWMCounter != 0)
+ TCountriesVec downloadedChildren;
+ TCountriesVec availableChildren;
+ s.GetChildrenInGroups(self.parentCountryId, downloadedChildren, availableChildren);
+
+ if (availableChildren.empty())
{
- self.showAllMapsView = YES;
- self.allMapsLabel.text =
- [NSString stringWithFormat:@"%@: %@ (%@)", L(@"maps"), @(remoteMWMCounter),
- formattedSize(nodeAttrs.m_mwmSize - nodeAttrs.m_localMwmSize)];
+ TCountriesVec queuedChildren;
+ s.GetQueuedChildren(self.parentCountryId, queuedChildren);
+ if (!queuedChildren.empty())
+ {
+ size_t queuedSize = 0;
+ for (TCountryId const & countryId : queuedChildren)
+ {
+ NodeAttrs nodeAttrs;
+ s.GetNodeAttrs(countryId, nodeAttrs);
+ queuedSize += nodeAttrs.m_mwmSize;
+ }
+ self.allMapsLabel.text =
+ [NSString stringWithFormat:kAllMapsLabelFormat, kDownloadingTitle,
+ @(queuedChildren.size()), formattedSize(queuedSize)];
+ [self.allMapsButton setTitle:kCancelAllTitle forState:UIControlStateNormal];
+ return;
+ }
}
else
{
- self.showAllMapsView = NO;
+ NodeAttrs nodeAttrs;
+ s.GetNodeAttrs(self.parentCountryId, nodeAttrs);
+ uint32_t remoteMWMCounter = nodeAttrs.m_mwmCounter - nodeAttrs.m_localMwmCounter;
+ if (remoteMWMCounter != 0)
+ {
+ self.allMapsLabel.text =
+ [NSString stringWithFormat:kAllMapsLabelFormat, kMapsTitle, @(remoteMWMCounter),
+ formattedSize(nodeAttrs.m_mwmSize - nodeAttrs.m_localMwmSize)];
+ [self.allMapsButton setTitle:kDownloaAllTitle forState:UIControlStateNormal];
+ return;
+ }
}
+
+ self.showAllMapsView = NO;
}
- (void)refreshAllMapsView
@@ -371,16 +402,31 @@ using namespace storage;
}
else
{
- [Statistics logEvent:kStatDownloaderMapAction
- withParameters:@{
- kStatAction : kStatDownload,
- kStatIsAuto : kStatNo,
- kStatFrom : kStatDownloader,
- kStatScenario : kStatDownloadGroup
- }];
- [MWMStorage downloadNode:self.parentCountryId
- alertController:self.alertController
- onSuccess:nil];
+ NSString * allMapsButtonTitle = [self.allMapsButton titleForState:UIControlStateNormal];
+ if ([allMapsButtonTitle isEqualToString:kDownloaAllTitle])
+ {
+ [Statistics logEvent:kStatDownloaderMapAction
+ withParameters:@{
+ kStatAction : kStatDownload,
+ kStatIsAuto : kStatNo,
+ kStatFrom : kStatDownloader,
+ kStatScenario : kStatDownloadGroup
+ }];
+ [MWMStorage downloadNode:self.parentCountryId
+ alertController:self.alertController
+ onSuccess:nil];
+ }
+ else if ([allMapsButtonTitle isEqualToString:kCancelAllTitle])
+ {
+ [Statistics logEvent:kStatDownloaderMapAction
+ withParameters:@{
+ kStatAction : kStatCancel,
+ kStatIsAuto : kStatNo,
+ kStatFrom : kStatDownloader,
+ kStatScenario : kStatDownloadGroup
+ }];
+ [MWMStorage cancelDownloadNode:self.parentCountryId];
+ }
}
self.skipCountryEventProcessing = NO;
[self processCountryEvent:self.parentCountryId];
diff --git a/iphone/Maps/Classes/MapDownloader/MWMMapDownloaderViewController.mm b/iphone/Maps/Classes/MapDownloader/MWMMapDownloaderViewController.mm
index 2dac207b3c..dea63d4b43 100644
--- a/iphone/Maps/Classes/MapDownloader/MWMMapDownloaderViewController.mm
+++ b/iphone/Maps/Classes/MapDownloader/MWMMapDownloaderViewController.mm
@@ -60,8 +60,6 @@ using namespace storage;
- (void)configAllMapsView
{
- [super configAllMapsView];
-
self.showAllMapsView = NO;
auto const & s = GetFramework().Storage();
Storage::UpdateInfo updateInfo{};
diff --git a/iphone/Maps/Mapsme.storyboard b/iphone/Maps/Mapsme.storyboard
index 5354229d1b..9941dfd9ee 100644
--- a/iphone/Maps/Mapsme.storyboard
+++ b/iphone/Maps/Mapsme.storyboard
@@ -240,7 +240,6 @@
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="linkBlue"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="medium17"/>
- <userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="downloader_download_all_button"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="allMapsAction" destination="cIk-gU-IeI" eventType="touchUpInside" id="BFl-NK-h9n"/>
@@ -314,6 +313,7 @@
</variation>
</view>
<connections>
+ <outlet property="allMapsButton" destination="X7X-s8-4rf" id="wUG-P2-9cX"/>
<outlet property="allMapsLabel" destination="etq-PP-stT" id="eP2-FS-hQq"/>
<outlet property="allMapsView" destination="Lqq-c4-P1I" id="bG7-3N-pyH"/>
<outlet property="allMapsViewBottomOffset" destination="8rS-RJ-MXs" id="PCw-X2-Tea"/>