Skip to content
Draft
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
46 changes: 22 additions & 24 deletions OsmAnd.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
7 changes: 7 additions & 0 deletions Resources/Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -4435,3 +4435,10 @@
"routing_attr_maxaxleload_name" = "Max axle load";
"shared_string_release" = "Released";
"reconnect" = "Reconnect";

"shared_string_online_only" = "Online Only";
"shared_string_offline_only" = "Offline Only";
"show_image_previews"= "Show image previews";
"popular_places"= "Popular places";
"shared_string_wikipedia"= "Wikipedia";
"poi_source" = "POI Source";
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// DataSourceType.swift
// OsmAnd
//
// Created by Oleksandr Panchenko on 16.12.2025.
// Copyright © 2025 OsmAnd. All rights reserved.
//

@objc enum DataSourceType: Int, CaseIterable {
case offline
case online

var title: String {
switch self {
case .offline: localizedString("shared_string_offline_only")
case .online: localizedString("shared_string_online_only")
}
}

var icon: UIImage? {
switch self {
case .offline: .icCustomOffline
case .online: .icCustomOnline
}
}
}

@objcMembers
final class DataSourceTypeWrapper: NSObject {

static func titleFor(type: DataSourceType) -> String {
type.title
}

static func iconFor(type: DataSourceType) -> UIImage? {
type.icon?.withRenderingMode(.alwaysTemplate)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ - (void)setupView
if (!hasWiki || !_iapHelper.wiki.disabled)
{
[showSectionData addObject:@{
@"name": OALocalizedString(@"download_wikipedia_maps"),
@"image": hasWiki ? @"ic_custom_wikipedia" : @"ic_custom_wikipedia_download_colored",
@"name": [(OAWikipediaPlugin *)[OAPluginsHelper getPlugin:OAWikipediaPlugin.class] popularPlacesTitle],
@"image": @"ic_custom_popular_places",
hasWiki ? @"has_options" : @"desc": hasWiki ? @YES : OALocalizedString(@"explore_wikipedia_offline"),
@"type": hasWiki ? OASwitchTableViewCell.reuseIdentifier : OAButtonTableViewCell.reuseIdentifier,
@"key": @"wikipedia_layer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef NS_ENUM(NSInteger, EOAMapSettingsWikipediaSection)
{
EOAMapSettingsWikipediaSectionVisibility = 0,
EOAMapSettingsWikipediaSectionLanguages,
EOAMapSettingsWikipediaSectionOnlinePreview,
EOAMapSettingsWikipediaSectionAvailable
};

Expand All @@ -54,6 +55,7 @@ @implementation OAMapSettingsWikipediaScreen
NSObject *_dataLock;
BOOL _wikipediaEnabled;
NSArray<NSArray <NSDictionary *> *> *_data;
OAAppSettings *_settings;
}

@synthesize settingsScreen, tableData, vwController, tblView, title, isOnlineMapSource;
Expand All @@ -72,6 +74,10 @@ - (id)initWithTable:(UITableView *)tableView viewController:(OAMapSettingsViewCo
_dataLock = [[NSObject alloc] init];
_wikipediaEnabled = _app.data.wikipedia;
_mapViewController = [OARootViewController instance].mapPanel.mapViewController;
_settings = OAAppSettings.sharedManager;

[self.tblView registerNib:[UINib nibWithNibName:OAButtonTableViewCell.reuseIdentifier bundle:nil] forCellReuseIdentifier:OAButtonTableViewCell.reuseIdentifier];
[self.tblView registerNib:[UINib nibWithNibName:OASwitchTableViewCell.reuseIdentifier bundle:nil] forCellReuseIdentifier:OASwitchTableViewCell.reuseIdentifier];

[self setupDownloadingCellHelper];
[self updateResources];
Expand Down Expand Up @@ -105,15 +111,42 @@ - (void) updateResources
- (void)initData
{
NSMutableArray *dataArr = [NSMutableArray new];
[dataArr addObject:@[@{@"type": [OASwitchTableViewCell getCellIdentifier]}]];
[dataArr addObject:@[
@{
@"type": [OASwitchTableViewCell reuseIdentifier],
@"key": @"wikipediaSwitch",
@"title": _wikipediaEnabled ? OALocalizedString(@"shared_string_enabled")
: OALocalizedString(@"rendering_value_disabled_name"),
@"img": _wikipediaEnabled ? @"ic_custom_show" : @"ic_custom_hide",
@"isSelected": @(_wikipediaEnabled)
}
]];

if (_wikipediaEnabled)
{
[dataArr addObject:@[@{
@"type": [OAValueTableViewCell getCellIdentifier],
@"img": @"ic_custom_map_languge",
@"title": OALocalizedString(@"shared_string_language")
}]];
@"type": [OAValueTableViewCell reuseIdentifier],
@"img": @"ic_custom_map_languge",
@"title": OALocalizedString(@"shared_string_language")
}]];
BOOL isOffline = [_settings.wikiDataSourceType get] == EOAWikiDataSourceTypeOffline;
DataSourceType dataSourceType = isOffline ? DataSourceTypeOffline : DataSourceTypeOnline;
BOOL wikiShowImagePreviews = [_settings.wikiShowImagePreviews get];
[dataArr addObject:@[
@{
@"type": [OAButtonTableViewCell reuseIdentifier],
@"icon": [DataSourceTypeWrapper iconForType:dataSourceType],
@"title": OALocalizedString(@"poi_source"),
@"tintColor": isOffline ? [UIColor colorNamed:ACColorNameIconColorDisabled] : [UIColor colorNamed:ACColorNameIconColorSelected]
},
@{
@"type": [OASwitchTableViewCell reuseIdentifier],
@"key": @"wikiShowImagePreviews",
@"img": wikiShowImagePreviews ? @"ic_custom_photo" : @"ic_custom_photo_disable",
@"title": OALocalizedString(@"show_image_previews"),
@"isSelected": @(wikiShowImagePreviews)
}
]];
}

if (_mapItems.count > 0)
Expand All @@ -132,17 +165,17 @@ - (void)initData
[dataArr addObject:availableMapsArr];
}

_data = dataArr;
_data = [dataArr copy];
}

- (void)setupView
{
title = OALocalizedString(@"download_wikipedia_maps");
title = [(OAWikipediaPlugin *)[OAPluginsHelper getPlugin:OAWikipediaPlugin.class] popularPlacesTitle];

self.tblView.separatorInset = UIEdgeInsetsMake(0., [OAUtilities getLeftMargin] + 16., 0., 0.);
[self.tblView.tableFooterView removeFromSuperview];
self.tblView.tableFooterView = nil;
[self.tblView registerClass:OATableViewCustomFooterView.class forHeaderFooterViewReuseIdentifier:[OATableViewCustomFooterView getCellIdentifier]];
[self.tblView registerClass:OATableViewCustomFooterView.class forHeaderFooterViewReuseIdentifier:[OATableViewCustomFooterView reuseIdentifier]];
self.tblView.estimatedRowHeight = kEstimatedRowHeight;

[self updateResources];
Expand All @@ -158,9 +191,19 @@ - (void)applyParameter:(id)sender
{
if ([sender isKindOfClass:[UISwitch class]])
{
UISwitch *sw = (UISwitch *) sender;
[(OAWikipediaPlugin *) [OAPluginsHelper getPlugin:OAWikipediaPlugin.class] wikipediaChanged:sw.isOn];
_wikipediaEnabled = _app.data.wikipedia;
UISwitch *sw = (UISwitch *)sender;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sw.tag & 0x3FF inSection:sw.tag >> 10];
NSDictionary *item = [self getItem:indexPath];

NSString *key = item[@"key"];

if ([key isEqualToString: @"wikipediaSwitch"]) {
[(OAWikipediaPlugin *)[OAPluginsHelper getPlugin:OAWikipediaPlugin.class] wikipediaChanged:sw.isOn];
_wikipediaEnabled = _app.data.wikipedia;
} else if ([key isEqualToString: @"wikiShowImagePreviews"]) {
[_settings.wikiShowImagePreviews set:sw.isOn];
[self refreshPOI];
}
[self updateResources];
}
}
Expand Down Expand Up @@ -216,36 +259,29 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *item = [self getItem:indexPath];
if ([item[@"type"] isEqualToString:[OASwitchTableViewCell getCellIdentifier]])
if ([item[@"type"] isEqualToString:[OASwitchTableViewCell reuseIdentifier]])
{
OASwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[OASwitchTableViewCell getCellIdentifier]];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:[OASwitchTableViewCell getCellIdentifier] owner:self options:nil];
cell = (OASwitchTableViewCell *) nib[0];
[cell descriptionVisibility:NO];
}
if (cell)
{
cell.titleLabel.text = _wikipediaEnabled ? OALocalizedString(@"shared_string_enabled") : OALocalizedString(@"rendering_value_disabled_name");

NSString *imgName = _wikipediaEnabled ? @"ic_custom_show.png" : @"ic_custom_hide.png";
cell.leftIconView.image = [UIImage templateImageNamed:imgName];
cell.leftIconView.tintColor = _wikipediaEnabled ? [UIColor colorNamed:ACColorNameIconColorSelected] : [UIColor colorNamed:ACColorNameIconColorDisabled];

[cell.switchView setOn:_wikipediaEnabled];
cell.switchView.tag = indexPath.section << 10 | indexPath.row;
[cell.switchView removeTarget:nil action:NULL forControlEvents:UIControlEventValueChanged];
[cell.switchView addTarget:self action:@selector(applyParameter:) forControlEvents:UIControlEventValueChanged];
}
OASwitchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[OASwitchTableViewCell reuseIdentifier]];
[cell descriptionVisibility:NO];
cell.titleLabel.text = item[@"title"];

BOOL isSelected = ((NSNumber *)item[@"isSelected"]).boolValue;

cell.leftIconView.image = [UIImage templateImageNamed:item[@"img"]];
cell.leftIconView.tintColor = isSelected ? [UIColor colorNamed:ACColorNameIconColorSelected] : [UIColor colorNamed:ACColorNameIconColorDisabled];

[cell.switchView setOn:isSelected];
cell.switchView.tag = indexPath.section << 10 | indexPath.row;
[cell.switchView removeTarget:nil action:NULL forControlEvents:UIControlEventValueChanged];
[cell.switchView addTarget:self action:@selector(applyParameter:) forControlEvents:UIControlEventValueChanged];
return cell;
}
else if ([item[@"type"] isEqualToString:[OAValueTableViewCell getCellIdentifier]])
else if ([item[@"type"] isEqualToString:[OAValueTableViewCell reuseIdentifier]])
{
OAValueTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[OAValueTableViewCell getCellIdentifier]];
OAValueTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[OAValueTableViewCell reuseIdentifier]];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:[OAValueTableViewCell getCellIdentifier] owner:self options:nil];
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:[OAValueTableViewCell reuseIdentifier] owner:self options:nil];
cell = (OAValueTableViewCell *) nib[0];
[cell descriptionVisibility:NO];
}
Expand All @@ -264,10 +300,78 @@ - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS
OAResourceSwiftItem *mapItem = [[OAResourceSwiftItem alloc] initWithItem:item[@"item"]];
return [_downloadingCellResourceHelper getOrCreateCell:mapItem.resourceId swiftResourceItem:mapItem];
}
else if ([item[@"type"] isEqualToString:[OAButtonTableViewCell reuseIdentifier]])
{
OAButtonTableViewCell *cell =
(OAButtonTableViewCell *)[tableView dequeueReusableCellWithIdentifier:OAButtonTableViewCell.reuseIdentifier];

if (cell.contentHeightConstraint == nil)
{
NSLayoutConstraint *constraint =
[cell.contentView.heightAnchor constraintGreaterThanOrEqualToConstant:48.0];
constraint.active = YES;
cell.contentHeightConstraint = constraint;
}

cell.selectionStyle = UITableViewCellSelectionStyleNone;

[cell descriptionVisibility:NO];

cell.titleLabel.text = item[@"title"];
cell.leftIconView.image = item[@"icon"];
cell.leftIconView.tintColor = item[@"tintColor"];

UIButtonConfiguration *config = [UIButtonConfiguration plainButtonConfiguration];
config.contentInsets = NSDirectionalEdgeInsetsZero;
cell.button.configuration = config;

cell.button.menu = [self createMenuForCellButton:cell];

cell.button.showsMenuAsPrimaryAction = YES;
cell.button.changesSelectionAsPrimaryAction = YES;

[cell.button setContentHuggingPriority:UILayoutPriorityRequired
forAxis:UILayoutConstraintAxisHorizontal];
[cell.button setContentCompressionResistancePriority:UILayoutPriorityRequired
forAxis:UILayoutConstraintAxisHorizontal];

return cell;
}
return nil;
}

- (UIMenu *)createMenuForCellButton:(OAButtonTableViewCell *)cell
{
BOOL isOffline = [_settings.wikiDataSourceType get] == EOAWikiDataSourceTypeOffline;

__weak __typeof(cell) weakCell = cell;
__weak __typeof(self) weakSelf = self;
UIAction *onlineAction = [UIAction actionWithTitle:[DataSourceTypeWrapper titleForType:DataSourceTypeOnline] image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) {
[_settings.wikiDataSourceType set:EOAWikiDataSourceTypeOnline];
weakCell.leftIconView.image = [DataSourceTypeWrapper iconForType:DataSourceTypeOnline];
weakCell.leftIconView.tintColor = [UIColor colorNamed:ACColorNameIconColorSelected];
[weakSelf refreshPOI];
}];

UIAction *offlineAction = [UIAction actionWithTitle:[DataSourceTypeWrapper titleForType:DataSourceTypeOffline] image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) {
[_settings.wikiDataSourceType set:EOAWikiDataSourceTypeOffline];
weakCell.leftIconView.image = [DataSourceTypeWrapper iconForType:DataSourceTypeOffline];
weakCell.leftIconView.tintColor = [UIColor colorNamed:ACColorNameIconColorDisabled];
[weakSelf refreshPOI];
}];

onlineAction.state = isOffline ? UIMenuElementStateOff : UIMenuElementStateOn;
offlineAction.state = isOffline ? UIMenuElementStateOn : UIMenuElementStateOff;

return [UIMenu composedMenuFrom:@[@[onlineAction, offlineAction]]];
}

- (void)refreshPOI
{
[[OARootViewController instance].mapPanel refreshMap];
[_mapViewController updatePoiLayer];
}

#pragma mark - UITableViewDelegate

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
Expand Down Expand Up @@ -337,7 +441,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger
if (!_wikipediaEnabled)
return nil;

OATableViewCustomFooterView *vw = [tableView dequeueReusableHeaderFooterViewWithIdentifier:[OATableViewCustomFooterView getCellIdentifier]];
OATableViewCustomFooterView *vw = [tableView dequeueReusableHeaderFooterViewWithIdentifier:[OATableViewCustomFooterView reuseIdentifier]];
NSString *text = [self getTextForFooter:section];
vw.label.text = text;
return vw;
Expand All @@ -348,7 +452,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger
- (void)onItemClicked:(NSIndexPath *)indexPath
{
NSDictionary *item = [self getItem:indexPath];
if (indexPath.section == EOAMapSettingsWikipediaSectionLanguages && [item[@"type"] isEqualToString:[OAValueTableViewCell getCellIdentifier]])
if (indexPath.section == EOAMapSettingsWikipediaSectionLanguages && [item[@"type"] isEqualToString:[OAValueTableViewCell reuseIdentifier]])
{
OAWikipediaLanguagesViewController *controller = [[OAWikipediaLanguagesViewController alloc] initWithAppMode:[[OAAppSettings sharedManager].applicationMode get]];
controller.wikipediaDelegate = self;
Expand Down
Loading