forked from organicmaps/organicmaps
[iPhone] Added About button in downloader
@TODO fix data/about.html text
This commit is contained in:
parent
ccac55a7b4
commit
48fbec050d
9 changed files with 132 additions and 22 deletions
|
@ -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 = "<group>"; };
|
||||
FAFCB63513366E78001A5C59 /* WebViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebViewController.mm; path = Settings/WebViewController.mm; sourceTree = "<group>"; };
|
||||
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 = "<group>";
|
||||
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#import "SettingsManager.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
#import "WebViewController.h"
|
||||
|
||||
#include "IPhonePlatform.hpp"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
12
iphone/Maps/Settings/WebViewController.h
Normal file
12
iphone/Maps/Settings/WebViewController.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface WebViewController : UIViewController
|
||||
{
|
||||
NSURL * m_url;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) NSURL * m_url;
|
||||
|
||||
- (id) initWithUrl: (NSURL *)url andTitleOrNil:(NSString *)title;
|
||||
|
||||
@end
|
70
iphone/Maps/Settings/WebViewController.mm
Normal file
70
iphone/Maps/Settings/WebViewController.mm
Normal file
|
@ -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
|
|
@ -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]);
|
||||
|
|
|
@ -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<int>(root.SiblingsCount()))
|
||||
if (index.m_group == TIndex::INVALID || index.m_group >= static_cast<int>(root.SiblingsCount()))
|
||||
return root;
|
||||
else
|
||||
{
|
||||
if (index.m_country == -1 || index.m_country >= static_cast<int>(root[index.m_group].SiblingsCount()))
|
||||
if (index.m_country == TIndex::INVALID || index.m_country >= static_cast<int>(root[index.m_group].SiblingsCount()))
|
||||
return root[index.m_group];
|
||||
if (index.m_region == -1 || index.m_region >= static_cast<int>(root[index.m_group][index.m_country].SiblingsCount()))
|
||||
if (index.m_region == TIndex::INVALID || index.m_region >= static_cast<int>(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];
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue