Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/Controllers/Map/OAMapHudViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1253,8 +1253,8 @@ - (void) onDownloadTaskProgressChanged:(id<OAObservableProtocol>)observer withKe
[self.view insertSubview:self.downloadView aboveSubview:self.searchButton];
}

if (![_downloadView.titleView.text isEqualToString:task.name])
[_downloadView setTitle: task.name];
if (![_downloadView.titleView.text isEqualToString:task.title])
[_downloadView setTitle: task.title];

[self.downloadView setProgress:[value floatValue]];

Expand Down
1 change: 1 addition & 0 deletions Sources/DownloadsManager/OADownloadTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef NS_ENUM(NSInteger, OADownloadTaskState) {
@property(readonly) NSString* targetPath;
@property(readonly) NSString* key;
@property(readonly) NSString* name;
@property(nonatomic) NSString* title;
@property(readonly) BOOL hidden;
@property(readonly) NSTimeInterval downloadTime;
@property(readonly) CGFloat fileSize; // in MB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
andHidden:(BOOL)hidden;

@property(readonly) NSURLSessionDownloadTask* task;
@property(nonatomic) NSString *title;
@property(nonatomic) id resourceItem;
@property(nonatomic) NSDate *creationTime;

Expand Down
15 changes: 15 additions & 0 deletions Sources/DownloadsManager/OADownloadTask_AFURLSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,21 @@ - (NSURLResponse*)response
@synthesize name = _name;
@synthesize hidden = _hidden;

//- (NSString *) name
//{
// return _name;
//}
//
//- (void) setName:(NSString *)name
//{
// _name = name;
//}

- (NSString *) title
{
return _title ? _title : _name;
}

- (OADownloadTaskState)state
{
switch (_task.state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class DownloadingListHelper: NSObject, DownloadingCellResourceHelperDelega
var title = localizedString("downloading") + ": "
let tasks = getDownloadingTasks()
if let downloadingTask = tasks.first(where: { $0.state == .running }) {
title += downloadingTask.name
title += downloadingTask.title
}
cell.textView.text = title

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class DownloadingListViewController: OABaseNavbarViewController, Downloadi
if let resourceItem = OAResourcesUISwiftHelper.getResourceFrom(task) {
let row = section.createNewRow()
row.cellType = DownloadingCell.reuseIdentifier
row.title = task.name
row.title = task.title
let resourceId = task.key.replacingOccurrences(of: "resource:", with: "")
row.setObj(resourceId, forKey: "resourceId")
row.setObj(resourceItem, forKey: "item")
Expand Down
1 change: 1 addition & 0 deletions Sources/Helpers/OAResourcesInstaller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ - (void) processResource:(id<OADownloadTask>)task
{
// Handle custom resources
BOOL failed = [self.class installCustomResource:localPath resourceId:nsResourceId fileName:task.name hidden:task.hidden];

if (failed)
{
task.installResourceRetry++;
Expand Down
21 changes: 11 additions & 10 deletions Sources/Helpers/OAResourcesUIHelper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1311,22 +1311,22 @@ + (void) startDownloadOfCustomItem:(OACustomResourceItem *)item
{
if (item.downloadUrl)
{
NSString *name = [item getVisibleName];
if (!name)
{
name = item.title;
if (item.subfolder && item.subfolder.length > 0)
name = [item.subfolder stringByAppendingPathComponent:name];
}

NSString *fileName = item.title;
if (item.subfolder && item.subfolder.length > 0)
fileName = [item.subfolder stringByAppendingPathComponent:fileName];

NSString *taskTitle = [item getVisibleName];
if (!taskTitle)
taskTitle = fileName;
if ([item.downloadUrl hasPrefix:@"@"])
{
NSString *relPath = [item.downloadUrl substringFromIndex:1];
NSString *pluginPath = [OAPluginsHelper getAbsoulutePluginPathByRegion:item.worldRegion];
if (pluginPath.length > 0 && relPath.length > 0)
{
NSString *srcFilePath = [pluginPath stringByAppendingPathComponent:relPath];
BOOL failed = [OAResourcesInstaller installCustomResource:srcFilePath resourceId:srcFilePath.lastPathComponent fileName:name hidden:item.hidden];
BOOL failed = [OAResourcesInstaller installCustomResource:srcFilePath resourceId:srcFilePath.lastPathComponent fileName:fileName hidden:item.hidden];
if (!failed)
[OsmAndApp.instance.localResourcesChangedObservable notifyEvent];
}
Expand All @@ -1342,9 +1342,10 @@ + (void) startDownloadOfCustomItem:(OACustomResourceItem *)item
OsmAndAppInstance app = [OsmAndApp instance];
id<OADownloadTask> task = [app.downloadsManager downloadTaskWithRequest:request
andKey:[@"resource:" stringByAppendingString:item.resourceId.toNSString()]
andName:name
andName:fileName
andHidden:item.hidden];

task.title = taskTitle;
task.resourceItem = item;
task.creationTime = [NSDate now];

Expand Down
12 changes: 10 additions & 2 deletions Sources/Helpers/OAResourcesUISwiftHelper.mm
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,16 @@ - (NSString *) iconName

- (BOOL) isInstalled
{
OAResourceItem *res = (OAResourceItem *)self.objcResourceItem;
return [OsmAndApp instance].resourcesManager->isResourceInstalled(res.resourceId);
if ([self.objcResourceItem isKindOfClass:OACustomResourceItem.class])
{
OACustomResourceItem *customResource = self.objcResourceItem;
return [customResource isInstalled];
}
else
{
OAResourceItem *res = (OAResourceItem *)self.objcResourceItem;
return [OsmAndApp instance].resourcesManager->isResourceInstalled(res.resourceId);
}
}

- (NSString *) resourceId
Expand Down