diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 05f97d7e25..7931a3aaf6 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -85,6 +85,8 @@ FAF37EFF126DCE6F005EA154 /* IPhoneDownload.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAF37EFA126DCE6F005EA154 /* IPhoneDownload.mm */; }; FAF37F00126DCE6F005EA154 /* IPhoneDownloadManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAF37EFB126DCE6F005EA154 /* IPhoneDownloadManager.mm */; }; FAF37F01126DCE6F005EA154 /* IPhonePlatform.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAF37EFD126DCE6F005EA154 /* IPhonePlatform.mm */; }; + FAFCB63613366E78001A5C59 /* WebViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAFCB63513366E78001A5C59 /* WebViewController.mm */; }; + FAFCB63813367AD1001A5C59 /* about.html in Resources */ = {isa = PBXBuildFile; fileRef = FAFCB63713367AD1001A5C59 /* about.html */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -182,6 +184,9 @@ FAF37EFD126DCE6F005EA154 /* IPhonePlatform.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = IPhonePlatform.mm; path = Platform/IPhonePlatform.mm; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; FAF37EFE126DCE6F005EA154 /* IPhonePlatform.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = IPhonePlatform.hpp; path = Platform/IPhonePlatform.hpp; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; FAF37F03126DCF11005EA154 /* IPhoneDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = IPhoneDownload.h; path = Platform/IPhoneDownload.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + FAFCB63413366E78001A5C59 /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebViewController.h; path = Settings/WebViewController.h; sourceTree = ""; }; + FAFCB63513366E78001A5C59 /* WebViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebViewController.mm; path = Settings/WebViewController.mm; sourceTree = ""; }; + FAFCB63713367AD1001A5C59 /* about.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = about.html; path = ../../data/about.html; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -309,6 +314,7 @@ FA065FC61286143F00FEA989 /* External Resources */ = { isa = PBXGroup; children = ( + FAFCB63713367AD1001A5C59 /* about.html */, EEFE7C3112F8CC2D006AF8C3 /* 01_dejavusans.ttf */, EEFE7C3212F8CC2D006AF8C3 /* 02_wqy-microhei.ttf */, EEFE7C3312F8CC2D006AF8C3 /* 03_jomolhari-id-a3d.ttf */, @@ -378,6 +384,8 @@ FA4135E2120A263C0062D5B4 /* CountriesViewController.mm */, FA4135E6120A263C0062D5B4 /* SettingsManager.h */, FA4135E7120A263C0062D5B4 /* SettingsManager.mm */, + FAFCB63413366E78001A5C59 /* WebViewController.h */, + FAFCB63513366E78001A5C59 /* WebViewController.mm */, ); name = Settings; sourceTree = ""; @@ -492,6 +500,7 @@ 49DD2B52132FA8880031D82E /* GuideViewController.xib in Resources */, 4945D21C1334187D0082387C /* settings.png in Resources */, 4945D21D1334187D0082387C /* settings@2x.png in Resources */, + FAFCB63813367AD1001A5C59 /* about.html in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -516,6 +525,7 @@ FAF37F00126DCE6F005EA154 /* IPhoneDownloadManager.mm in Sources */, FAF37F01126DCE6F005EA154 /* IPhonePlatform.mm in Sources */, 49DD2B51132FA8880031D82E /* GuideViewController.mm in Sources */, + FAFCB63613366E78001A5C59 /* WebViewController.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iphone/Maps/Settings/CountriesViewController.mm b/iphone/Maps/Settings/CountriesViewController.mm index 617ea6e5e2..00a5cb5f50 100644 --- a/iphone/Maps/Settings/CountriesViewController.mm +++ b/iphone/Maps/Settings/CountriesViewController.mm @@ -2,6 +2,9 @@ #import "SettingsManager.h" #import "MapsAppDelegate.h" #import "MapViewController.h" +#import "WebViewController.h" + +#include "IPhonePlatform.hpp" #include #include @@ -57,16 +60,40 @@ static bool IsOurIndex(TIndex const & theirs, TIndex const & ours) [[[MapsAppDelegate theApp] settingsManager] Hide]; } +- (void) OnAboutButton:(id)sender +{ + // display WebView with About text + + NSString * filePath = [NSString stringWithUTF8String:GetPlatform().ReadPathForFile("about.html").c_str()]; + NSURL * url = [NSURL fileURLWithPath:filePath]; + + WebViewController * aboutViewController = + [[WebViewController alloc] initWithUrl:url andTitleOrNil:@"About"]; + [self.navigationController pushViewController:aboutViewController animated:YES]; + [aboutViewController release]; +} + - (id) initWithStorage: (Storage &)storage andIndex: (TIndex const &) index andHeader: (NSString *)header { m_storage = &storage; m_index = index; if ((self = [super initWithNibName:nil bundle:nil])) { - UIBarButtonItem * button = [[UIBarButtonItem alloc] initWithTitle:@"Close" style: UIBarButtonItemStyleDone - target:self action:@selector(OnCloseButton:)]; - self.navigationItem.rightBarButtonItem = button; + UIBarButtonItem * closeButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style: UIBarButtonItemStyleDone + target:self action:@selector(OnCloseButton:)]; + self.navigationItem.rightBarButtonItem = closeButton; + [closeButton release]; + self.navigationItem.title = header; + + // About button is displayed only on first view in hierarchy + if (index.m_group == TIndex::INVALID) + { + UIBarButtonItem * aboutButton = [[UIBarButtonItem alloc] initWithTitle:@"About" style: UIBarButtonItemStylePlain + target:self action:@selector(OnAboutButton:)]; + self.navigationItem.leftBarButtonItem = aboutButton; + [aboutButton release]; + } } return self; } diff --git a/iphone/Maps/Settings/SettingsManager.h b/iphone/Maps/Settings/SettingsManager.h index 5d4f66828a..e2668fa9e2 100644 --- a/iphone/Maps/Settings/SettingsManager.h +++ b/iphone/Maps/Settings/SettingsManager.h @@ -3,12 +3,9 @@ namespace storage { class Storage; } -@class CountriesViewController; - /// Responsible for all settings dialogs @interface SettingsManager : NSObject { - CountriesViewController * m_countriesController; UINavigationController * m_navController; UIViewController * m_prevController; storage::Storage * m_storage; diff --git a/iphone/Maps/Settings/SettingsManager.mm b/iphone/Maps/Settings/SettingsManager.mm index 1018149893..198965b2b8 100644 --- a/iphone/Maps/Settings/SettingsManager.mm +++ b/iphone/Maps/Settings/SettingsManager.mm @@ -15,8 +15,6 @@ using namespace storage; { [m_prevController release]; m_prevController = nil; - [m_countriesController release]; - m_countriesController = nil; [m_navController release]; m_navController = nil; [super dealloc]; @@ -44,16 +42,13 @@ using namespace storage; m_storage = storage; m_prevController = [prevController retain]; - if (!m_countriesController) - { - m_countriesController = [[CountriesViewController alloc] - initWithStorage:*m_storage andIndex:TIndex() andHeader:@"Download"]; - } - if (!m_navController) { + CountriesViewController * countriesController = [[CountriesViewController alloc] + initWithStorage:*m_storage andIndex:TIndex() andHeader:@"Download"]; m_navController = [[UINavigationController alloc] - initWithRootViewController:m_countriesController]; + initWithRootViewController:countriesController]; + [countriesController release]; } // Subscribe to storage callbacks. @@ -108,8 +103,6 @@ using namespace storage; m_storage = nil; [m_prevController release]; m_prevController = nil; - [m_countriesController release]; - m_countriesController = nil; [m_navController release]; m_navController = nil; diff --git a/iphone/Maps/Settings/WebViewController.h b/iphone/Maps/Settings/WebViewController.h new file mode 100644 index 0000000000..bdf988d015 --- /dev/null +++ b/iphone/Maps/Settings/WebViewController.h @@ -0,0 +1,12 @@ +#import + +@interface WebViewController : UIViewController +{ + NSURL * m_url; +} + +@property (nonatomic, retain) NSURL * m_url; + +- (id) initWithUrl: (NSURL *)url andTitleOrNil:(NSString *)title; + +@end diff --git a/iphone/Maps/Settings/WebViewController.mm b/iphone/Maps/Settings/WebViewController.mm new file mode 100644 index 0000000000..9b4442cf4d --- /dev/null +++ b/iphone/Maps/Settings/WebViewController.mm @@ -0,0 +1,70 @@ +#import "WebViewController.h" + +@implementation WebViewController + +@synthesize m_url; + +- (id) initWithUrl: (NSURL *)url andTitleOrNil:(NSString *)title +{ + self = [super initWithNibName:nil bundle:nil]; + if (self) + { + self.m_url = url; + if (title) + self.navigationItem.title = title; + } + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +- (void)didReceiveMemoryWarning +{ + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +#pragma mark - View lifecycle + +// Implement loadView to create a view hierarchy programmatically, without using a nib. +- (void)loadView +{ + CGRect frame = [[UIScreen mainScreen] applicationFrame]; + UIWebView * webView = [[UIWebView alloc] initWithFrame:frame]; +// webView.scalesPageToFit = YES; + webView.autoresizesSubviews = YES; + webView.autoresizingMask= (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth); + + [webView loadRequest:[NSURLRequest requestWithURL:m_url]]; + + self.view = webView; + [webView release]; +} + +/* + // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. + - (void)viewDidLoad + { + [super viewDidLoad]; + } + */ + +- (void)viewDidUnload +{ + [super viewDidUnload]; + // Release any retained subviews of the main view. + self.view = nil; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + // Return YES for supported orientations + return YES; +} + +@end diff --git a/qt/update_dialog.cpp b/qt/update_dialog.cpp index eb05c2ee25..2a4bbeb4bd 100644 --- a/qt/update_dialog.cpp +++ b/qt/update_dialog.cpp @@ -100,7 +100,7 @@ namespace qt parent = parent->parent(); } while (treeIndex.size() < 3) - treeIndex.append(-1); + treeIndex.append(TIndex::INVALID); } TIndex const countryIndex(treeIndex[0], treeIndex[1], treeIndex[2]); diff --git a/storage/storage.cpp b/storage/storage.cpp index 43dd06954d..d47acc91a8 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -74,13 +74,13 @@ namespace storage TCountriesContainer const & NodeFromIndex(TCountriesContainer const & root, TIndex const & index) { // complex logic to avoid [] out_of_bounds exceptions - if (index.m_group == -1 || index.m_group >= static_cast(root.SiblingsCount())) + if (index.m_group == TIndex::INVALID || index.m_group >= static_cast(root.SiblingsCount())) return root; else { - if (index.m_country == -1 || index.m_country >= static_cast(root[index.m_group].SiblingsCount())) + if (index.m_country == TIndex::INVALID || index.m_country >= static_cast(root[index.m_group].SiblingsCount())) return root[index.m_group]; - if (index.m_region == -1 || index.m_region >= static_cast(root[index.m_group][index.m_country].SiblingsCount())) + if (index.m_region == TIndex::INVALID || index.m_region >= static_cast(root[index.m_group][index.m_country].SiblingsCount())) return root[index.m_group][index.m_country]; return root[index.m_group][index.m_country][index.m_region]; } diff --git a/storage/storage.hpp b/storage/storage.hpp index b0e0784615..cb655a2898 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -40,10 +40,11 @@ namespace storage struct TIndex { + static int const INVALID = -1; int m_group; int m_country; int m_region; - TIndex(int group = -1, int country = -1, int region = -1) + TIndex(int group = INVALID, int country = INVALID, int region = INVALID) : m_group(group), m_country(country), m_region(region) {} bool operator==(TIndex const & other) const {