From fc98524cf166df90f8a99af417b6d5e9345c5f1b Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 10 Mar 2020 10:54:55 +0300 Subject: [PATCH] [iOS] Added update size to context menu in Downloader https://jira.mail.ru/browse/MAPSME-12871 --- iphone/CoreApi/CoreApi/Storage/MWMMapNodeAttributes.h | 1 + iphone/CoreApi/CoreApi/Storage/MWMMapNodeAttributes.mm | 8 ++++++++ .../Maps/UI/Downloader/DownloadMapsViewController.swift | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/iphone/CoreApi/CoreApi/Storage/MWMMapNodeAttributes.h b/iphone/CoreApi/CoreApi/Storage/MWMMapNodeAttributes.h index 71edb0bf80..72fb64d8fc 100644 --- a/iphone/CoreApi/CoreApi/Storage/MWMMapNodeAttributes.h +++ b/iphone/CoreApi/CoreApi/Storage/MWMMapNodeAttributes.h @@ -34,6 +34,7 @@ NS_SWIFT_NAME(MapNodeAttributes) @property(nonatomic, readonly) uint64_t totalSize; @property(nonatomic, readonly) uint64_t downloadedSize; @property(nonatomic, readonly) uint64_t downloadingSize; +@property(nonatomic, readonly) uint64_t totalUpdateSizeBytes; @property(nonatomic, readonly) NSString *nodeName; @property(nonatomic, readonly) NSString *nodeDescription; @property(nonatomic, readonly) MWMMapNodeStatus nodeStatus; diff --git a/iphone/CoreApi/CoreApi/Storage/MWMMapNodeAttributes.mm b/iphone/CoreApi/CoreApi/Storage/MWMMapNodeAttributes.mm index 3fd83c7fd0..e332820748 100644 --- a/iphone/CoreApi/CoreApi/Storage/MWMMapNodeAttributes.mm +++ b/iphone/CoreApi/CoreApi/Storage/MWMMapNodeAttributes.mm @@ -1,4 +1,5 @@ #import "MWMMapNodeAttributes+Core.h" +#include static MWMMapNodeStatus convertStatus(storage::NodeStatus status) { switch (status) { @@ -77,6 +78,13 @@ static MWMMapNodeStatus convertStatus(storage::NodeStatus status) { _hasChildren = hasChildren; _hasParent = hasParent; + storage::Storage::UpdateInfo updateInfo; + if (GetFramework().GetStorage().GetUpdateInfo([countryId UTF8String], updateInfo)) { + _totalUpdateSizeBytes = updateInfo.m_totalUpdateSizeInBytes; + } else { + _totalUpdateSizeBytes = 0; + } + NSMutableArray *parentInfoArray = [NSMutableArray arrayWithCapacity:attributes.m_parentInfo.size()]; for (auto const &pi : attributes.m_parentInfo) { MWMCountryIdAndName *cn = [[MWMCountryIdAndName alloc] initWithCountryAndName:pi]; diff --git a/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift b/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift index d9ca37eb7b..1e5bdcf2de 100644 --- a/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift +++ b/iphone/Maps/UI/Downloader/DownloadMapsViewController.swift @@ -127,7 +127,8 @@ class DownloadMapsViewController: MWMViewController { Storage.downloadNode(nodeAttrs.countryId) }) case .update: - let title = "\(L("downloader_status_outdated")) (TODO: updated size)" + let size = formattedSize(nodeAttrs.totalUpdateSizeBytes) + let title = "\(L("downloader_status_outdated")) \(size)" action = UIAlertAction(title: title, style: .default, handler: { _ in Storage.updateNode(nodeAttrs.countryId) })