[IOS] Handling kmz/kml files openning.

Review Fix

code review fix
This commit is contained in:
Kirill Zhdanovich 2013-01-11 13:20:19 +03:00 committed by Alex Zolotarev
parent fa67eda1d5
commit 17106a22a4
4 changed files with 125 additions and 4 deletions

View file

@ -25,6 +25,10 @@
target:self
action:@selector(onCloseButton:)] autorelease];
self.tableView.allowsSelectionDuringEditing = YES;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(newCategoryAdded)
name:@"KML file added"
object:nil];
}
return self;
}
@ -289,4 +293,15 @@
return NO;
}
-(void)newCategoryAdded
{
[self.tableView reloadData];
}
-(void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
@end

View file

@ -4,13 +4,14 @@
@class SettingsManager;
@class LocationManager;
@interface MapsAppDelegate : NSObject <UIApplicationDelegate>
@interface MapsAppDelegate : NSObject <UIApplicationDelegate, UIAlertViewDelegate>
{
SettingsManager * m_settingsManager;
NSInteger m_standbyCounter;
NSInteger m_activeDownloadsCounter;
UINavigationController * m_navController;
UIWindow * m_window;
UIAlertView * m_loadingAlertView;
}
@property (nonatomic, retain) IBOutlet MapViewController * m_mapViewController;

View file

@ -137,17 +137,50 @@ void InitLocalizedStrings()
annotation:(id)annotation
{
NSString * scheme = url.scheme;
NSLog(@"Launched with URL Scheme %@ from the app %@", url.scheme, sourceApplication);
// geo scheme support, see http://tools.ietf.org/html/rfc5870
if ([scheme isEqualToString:@"geo"])
{
GetFramework().SetViewportByURL([[url.absoluteString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] UTF8String]);
return YES;
}
if ([scheme isEqualToString:@"file"])
{
if (!GetFramework().AddBookmarksFile([[url relativePath] UTF8String]))
{
[self showLoadFileAlertIsSuccessful:NO];
return NO;
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"KML file added" object:nil];
[self showLoadFileAlertIsSuccessful:YES];
return YES;
}
NSLog(@"Scheme %@ is not supported", scheme);
return NO;
}
-(void)showLoadFileAlertIsSuccessful:(BOOL) successful
{
m_loadingAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"load_kml_title", nil)
message:
(successful ? NSLocalizedString(@"load_kml_successful", nil) : NSLocalizedString(@"load_kml_failed", nil))
delegate:nil
cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles:nil];
m_loadingAlertView.delegate = self;
[m_loadingAlertView show];
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(dismissAlert) userInfo:nil repeats:NO];
[m_loadingAlertView release];
}
-(void)dismissAlert
{
if (m_loadingAlertView)
{
[m_loadingAlertView dismissWithClickedButtonIndex:0 animated:YES];
}
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
m_loadingAlertView = nil;
}
@end

View file

@ -6,6 +6,29 @@
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>Google Earth KML Document</string>
<key>LSItemContentTypes</key>
<array>
<string>com.google.earth.kml</string>
</array>
</dict>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>Google Earth KMZ Document</string>
<key>LSItemContentTypes</key>
<array>
<string>com.google.earth.kmz</string>
</array>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFiles</key>
@ -65,5 +88,54 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.xml</string>
</array>
<key>UTTypeDescription</key>
<string>Google Earth KML Document</string>
<key>UTTypeIdentifier</key>
<string>com.google.earth.kml</string>
<key>UTTypeReferenceURL</key>
<string>http://earth.google.com/kml/</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>com.apple.ostype</key>
<string>GKml</string>
<key>public.filename-extension</key>
<array>
<string>kml</string>
</array>
<key>public.mime-type</key>
<string>application/vnd.google-earth.kml+xml</string>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>com.pkware.zip-archive</string>
</array>
<key>UTTypeDescription</key>
<string>Google Earth KMZ Document</string>
<key>UTTypeIdentifier</key>
<string>com.google.earth.kmz</string>
<key>UTTypeReferenceURL</key>
<string>http://earth.google.com/kmz/</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>com.apple.ostype</key>
<string>GKmz</string>
<key>public.filename-extension</key>
<array>
<string>kmz</string>
</array>
<key>public.mime-type</key>
<string>application/vnd.google-earth.kmz+xml</string>
</dict>
</dict>
</array>
</dict>
</plist>