Parsing of NavData implemented, lookup of Waypoints implemented as testbed
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
//
|
||||
|
||||
#import "DropboxV2ObjC.h"
|
||||
#import "NavDataParser.h"
|
||||
#import "ViewController.h"
|
||||
#import "ViewControllerServiceMenu.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@@ -14,9 +16,9 @@
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
#pragma mark - Shared Dropbox client
|
||||
/// Shared Dropbox client
|
||||
@property (strong, nonatomic) DropboxV2ObjC *dbClient;
|
||||
#pragma mark - Refrence to other views in app
|
||||
|
||||
@property (strong, nonatomic) ViewController *main;
|
||||
|
||||
#pragma mark - Refrence to authentication web view in order to dismiss it
|
||||
|
||||
|
||||
+11
-20
@@ -15,18 +15,8 @@
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
// Override point for customization after application launch.
|
||||
_dbClient = [[DropboxV2ObjC alloc] init];
|
||||
NSDictionary *credentials =
|
||||
[[NSURLCredentialStorage sharedCredentialStorage]
|
||||
credentialsForProtectionSpace:_dbClient.kDropboxProtectionSpace];
|
||||
NSURLCredential *credential = [credentials.objectEnumerator nextObject];
|
||||
_dbClient.token = credential.password;
|
||||
// Reset if user changed it
|
||||
[_dbClient setupDropboxWithHandler:^{
|
||||
}
|
||||
presenter:nil];
|
||||
[self setup];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -74,15 +64,16 @@
|
||||
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
|
||||
{
|
||||
// Display text
|
||||
[_dbClient authorizeUserWithToke:url
|
||||
completion:^(void) {
|
||||
[_smWebView.navigationController
|
||||
popViewControllerAnimated:YES];
|
||||
[_dbClient setupDropboxWithHandler:^{
|
||||
}
|
||||
presenter:_smMenu];
|
||||
}
|
||||
presenter:_smMenu];
|
||||
[_main.dbClient authorizeUserWithToke:url
|
||||
completion:^(void) {
|
||||
[_smWebView.navigationController
|
||||
popViewControllerAnimated:YES];
|
||||
[_main.dbClient
|
||||
setupDropboxWithHandler:^{
|
||||
}
|
||||
presenter:_smMenu];
|
||||
}
|
||||
presenter:_smMenu];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
@@ -116,7 +115,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MYC-QY-v42">
|
||||
<rect key="frame" x="73" y="72" width="176" height="30"/>
|
||||
<rect key="frame" x="72" y="72" width="176" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="30" id="2iN-qg-kf5"/>
|
||||
<constraint firstAttribute="width" constant="176" id="30a-wW-H5A"/>
|
||||
@@ -127,9 +126,9 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fft-ba-oCA">
|
||||
<rect key="frame" x="112" y="224" width="97" height="30"/>
|
||||
<rect key="frame" x="107" y="224" width="107" height="30"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="97" id="1fV-Ks-aH1"/>
|
||||
<constraint firstAttribute="width" constant="107" id="1fV-Ks-aH1"/>
|
||||
<constraint firstAttribute="height" constant="30" id="WLI-4o-ris"/>
|
||||
</constraints>
|
||||
<state key="normal" title="Load NavData"/>
|
||||
@@ -143,11 +142,11 @@
|
||||
<constraint firstItem="n9p-C2-IND" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="91" id="3OR-Oa-8cl"/>
|
||||
<constraint firstAttribute="trailing" secondItem="n9p-C2-IND" secondAttribute="trailing" constant="91" id="6nb-b2-JUb"/>
|
||||
<constraint firstItem="MYC-QY-v42" firstAttribute="top" secondItem="ggM-lD-yT2" secondAttribute="bottom" constant="8" id="7Aw-oA-8DT"/>
|
||||
<constraint firstAttribute="trailing" secondItem="fft-ba-oCA" secondAttribute="trailing" constant="111" id="8mU-OF-jU7"/>
|
||||
<constraint firstAttribute="trailing" secondItem="MYC-QY-v42" secondAttribute="trailing" constant="71" id="9o7-P0-T70"/>
|
||||
<constraint firstItem="MYC-QY-v42" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="73" id="Clk-jD-xRP"/>
|
||||
<constraint firstAttribute="trailing" secondItem="fft-ba-oCA" secondAttribute="trailing" constant="106" id="8mU-OF-jU7"/>
|
||||
<constraint firstAttribute="trailing" secondItem="MYC-QY-v42" secondAttribute="trailing" constant="72" id="9o7-P0-T70"/>
|
||||
<constraint firstItem="MYC-QY-v42" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="72" id="Clk-jD-xRP"/>
|
||||
<constraint firstItem="V5o-Hb-Mk0" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="73" id="ISQ-lm-JNH"/>
|
||||
<constraint firstItem="fft-ba-oCA" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="112" id="LEy-ig-Kbg"/>
|
||||
<constraint firstItem="fft-ba-oCA" firstAttribute="leading" secondItem="Q1M-LV-Smi" secondAttribute="leading" constant="107" id="LEy-ig-Kbg"/>
|
||||
<constraint firstItem="xba-tH-5D0" firstAttribute="top" secondItem="V5o-Hb-Mk0" secondAttribute="bottom" constant="8" id="UcB-x5-idK"/>
|
||||
<constraint firstItem="fft-ba-oCA" firstAttribute="top" secondItem="xba-tH-5D0" secondAttribute="bottom" constant="8" id="cfI-Sc-hrE"/>
|
||||
<constraint firstItem="n9p-C2-IND" firstAttribute="top" secondItem="MYC-QY-v42" secondAttribute="bottom" constant="8" id="fvc-m1-XMt"/>
|
||||
@@ -842,7 +841,6 @@
|
||||
<constraint firstAttribute="trailing" secondItem="sro-Ep-8wL" secondAttribute="trailing" constant="10" id="1Th-Lj-0rz"/>
|
||||
<constraint firstAttribute="trailing" secondItem="mXy-bk-ceo" secondAttribute="trailing" constant="10" id="1Vv-tc-eER"/>
|
||||
<constraint firstItem="do1-lk-i4d" firstAttribute="height" secondItem="Loy-Fk-sOd" secondAttribute="height" id="1rI-kB-WIo"/>
|
||||
<constraint firstItem="Loy-Fk-sOd" firstAttribute="top" secondItem="2YN-Dg-9F2" secondAttribute="topMargin" constant="1" id="2AI-CS-ecI"/>
|
||||
<constraint firstItem="DKU-Ht-Zkn" firstAttribute="height" secondItem="Loy-Fk-sOd" secondAttribute="height" id="2E0-GI-3WL"/>
|
||||
<constraint firstItem="k64-uO-je8" firstAttribute="leading" secondItem="2YN-Dg-9F2" secondAttribute="leading" constant="10" id="2JU-4a-rdl"/>
|
||||
<constraint firstItem="BXf-ft-vHl" firstAttribute="height" secondItem="Loy-Fk-sOd" secondAttribute="height" id="2Yp-AR-BNB"/>
|
||||
@@ -864,6 +862,7 @@
|
||||
<constraint firstItem="8LD-xq-b8N" firstAttribute="leading" secondItem="f2v-9B-nOm" secondAttribute="trailing" id="7ie-Gv-rWl"/>
|
||||
<constraint firstItem="LPI-AA-rrg" firstAttribute="height" secondItem="Loy-Fk-sOd" secondAttribute="height" id="7nh-EX-nEn"/>
|
||||
<constraint firstItem="5g4-VN-3D0" firstAttribute="leading" secondItem="2YN-Dg-9F2" secondAttribute="leading" constant="10" id="81d-Gh-AB9"/>
|
||||
<constraint firstItem="Loy-Fk-sOd" firstAttribute="top" secondItem="bgX-Bo-CkS" secondAttribute="bottom" constant="1" id="8Bq-II-XC6"/>
|
||||
<constraint firstItem="Sdv-Fw-LQq" firstAttribute="leading" secondItem="Z4K-ej-cbf" secondAttribute="trailing" id="8aa-6a-4Qb"/>
|
||||
<constraint firstItem="DKU-Ht-Zkn" firstAttribute="leading" secondItem="2YN-Dg-9F2" secondAttribute="leading" constant="1" id="8rF-0n-Wz1"/>
|
||||
<constraint firstItem="fxC-LW-Dp9" firstAttribute="height" secondItem="Loy-Fk-sOd" secondAttribute="height" id="93b-ex-ETS"/>
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
@property (strong, nonatomic) NSString *rootDirectory;
|
||||
@property (strong, nonatomic) NSData *kJSONNullObject;
|
||||
@property (strong, nonatomic) NSURLProtectionSpace *kDropboxProtectionSpace;
|
||||
@property (strong, nonatomic) NSError *dbError;
|
||||
|
||||
#pragma mark - Authorization methods
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// NavDataParser.h
|
||||
// FMC Planner 2
|
||||
//
|
||||
// Created by Kilian Hofmann on 13.04.16.
|
||||
// Copyright © 2016 Kilian Hofmann. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SharedDeclerations.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@interface NavDataParser : NSObject
|
||||
|
||||
@property (strong, nonatomic) NSMutableDictionary *intersections;
|
||||
@property (strong, nonatomic) NSMutableDictionary *navaids;
|
||||
@property (strong, nonatomic) NSMutableDictionary *airways;
|
||||
@property (nonatomic) BOOL parserReady;
|
||||
|
||||
#pragma mark - Search for elements in normal route entry
|
||||
|
||||
- (NSArray *)findWaypoint:(NSString *)waypoint;
|
||||
- (NSArray *)findAirway:(NSString *)airway;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,168 @@
|
||||
//
|
||||
// NavDataParser.m
|
||||
// FMC Planner 2
|
||||
//
|
||||
// Created by Kilian Hofmann on 13.04.16.
|
||||
// Copyright © 2016 Kilian Hofmann. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NavDataParser.h"
|
||||
|
||||
@implementation NavDataParser
|
||||
|
||||
NSString *const Airways = @"NAVDATA/awys.txt";
|
||||
NSString *const Intersections = @"NAVDATA/ints.txt";
|
||||
NSString *const Navaids = @"NAVDATA/navs.txt";
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self.parserReady = false;
|
||||
// Load Navaids
|
||||
NSArray *temp = [[NSString
|
||||
stringWithContentsOfFile:[SharedDeclerations savePathForFile:Navaids]
|
||||
encoding:NSASCIIStringEncoding
|
||||
error:nil] componentsSeparatedByString:@"\r\n"];
|
||||
self.navaids = [[NSMutableDictionary alloc] init];
|
||||
for (NSString *str in temp) {
|
||||
if (str.length > 0 &&
|
||||
![[str substringToIndex:1] isEqualToString:@";"]) {
|
||||
if ([self.navaids objectForKey:[str substringToIndex:5]] != nil) {
|
||||
// Item exists, make array and set that.
|
||||
NSMutableArray *temp2 = [[NSMutableArray alloc] init];
|
||||
[temp2 addObject:[str substringFromIndex:10]];
|
||||
if ([[self.navaids objectForKey:[str substringToIndex:5]]
|
||||
isKindOfClass:[NSArray class]]) {
|
||||
[temp2 addObjectsFromArray:
|
||||
[self.navaids
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
else {
|
||||
[temp2
|
||||
addObject:[self.navaids
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
[self.navaids setValue:temp2 forKey:[str substringToIndex:5]];
|
||||
}
|
||||
else {
|
||||
[self.navaids setValue:[str substringFromIndex:10]
|
||||
forKey:[str substringToIndex:5]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load Intersections
|
||||
temp = [[NSString
|
||||
stringWithContentsOfFile:[SharedDeclerations
|
||||
savePathForFile:Intersections]
|
||||
encoding:NSASCIIStringEncoding
|
||||
error:nil] componentsSeparatedByString:@"\r\n"];
|
||||
self.intersections = [[NSMutableDictionary alloc] init];
|
||||
for (NSString *str in temp) {
|
||||
if (str.length > 0 &&
|
||||
![[str substringToIndex:1] isEqualToString:@";"]) {
|
||||
if ([self.intersections objectForKey:[str substringToIndex:5]] !=
|
||||
nil) {
|
||||
// Item exists, make array and set that.
|
||||
NSMutableArray *temp2 = [[NSMutableArray alloc] init];
|
||||
[temp2 addObject:[str substringFromIndex:10]];
|
||||
if ([[self.intersections objectForKey:[str substringToIndex:5]]
|
||||
isKindOfClass:[NSArray class]]) {
|
||||
[temp2 addObjectsFromArray:
|
||||
[self.intersections
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
else {
|
||||
[temp2
|
||||
addObject:[self.intersections
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
[self.intersections setValue:temp2
|
||||
forKey:[str substringToIndex:5]];
|
||||
}
|
||||
else {
|
||||
[self.intersections setValue:[str substringFromIndex:10]
|
||||
forKey:[str substringToIndex:5]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load Airways
|
||||
temp = [[NSString
|
||||
stringWithContentsOfFile:[SharedDeclerations savePathForFile:Airways]
|
||||
encoding:NSASCIIStringEncoding
|
||||
error:nil] componentsSeparatedByString:@"\r\n"];
|
||||
self.airways = [[NSMutableDictionary alloc] init];
|
||||
for (NSString *str in temp) {
|
||||
if (str.length > 0 &&
|
||||
![[str substringToIndex:1] isEqualToString:@";"]) {
|
||||
if ([self.airways objectForKey:[str substringToIndex:5]] != nil) {
|
||||
// Item exists, make array and set that.
|
||||
NSMutableArray *temp2 = [[NSMutableArray alloc] init];
|
||||
[temp2 addObject:[str substringFromIndex:10]];
|
||||
if ([[self.airways objectForKey:[str substringToIndex:5]]
|
||||
isKindOfClass:[NSArray class]]) {
|
||||
[temp2 addObjectsFromArray:
|
||||
[self.airways
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
else {
|
||||
[temp2
|
||||
addObject:[self.airways
|
||||
objectForKey:[str substringToIndex:5]]];
|
||||
}
|
||||
[self.airways setValue:temp2 forKey:[str substringToIndex:5]];
|
||||
}
|
||||
else {
|
||||
[self.airways setValue:[str substringFromIndex:10]
|
||||
forKey:[str substringToIndex:5]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.parserReady = true;
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Search for elements in normal route entry
|
||||
|
||||
- (NSArray *)findAirway:(NSString *)airway
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the given waypoint in both files, returns Array so user can select
|
||||
* @param waypoint
|
||||
*/
|
||||
- (NSArray *)findWaypoint:(NSString *)waypoint
|
||||
{
|
||||
NSMutableArray *array = [[NSMutableArray alloc] init];
|
||||
for (int i = (int)waypoint.length; i < 5; i++) {
|
||||
waypoint = [waypoint stringByAppendingString:@" "];
|
||||
}
|
||||
|
||||
id navaids = [_navaids objectForKey:waypoint];
|
||||
id intersections = [_intersections objectForKey:waypoint];
|
||||
|
||||
if (navaids != nil) {
|
||||
if ([navaids isKindOfClass:[NSArray class]]) {
|
||||
[array addObjectsFromArray:navaids];
|
||||
}
|
||||
else {
|
||||
[array addObject:navaids];
|
||||
}
|
||||
}
|
||||
|
||||
if (intersections != nil) {
|
||||
if ([intersections isKindOfClass:[NSArray class]]) {
|
||||
[array addObjectsFromArray:intersections];
|
||||
}
|
||||
else {
|
||||
[array addObject:intersections];
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -14,6 +14,14 @@
|
||||
|
||||
extern NSString *const FMCNEXTRTEPAGE;
|
||||
extern NSString *const FMCFIRSTRTEPAGE;
|
||||
|
||||
#pragma mark - FMC Error messages
|
||||
|
||||
extern NSString *const INVALID;
|
||||
extern NSString *const NOTREADY;
|
||||
|
||||
#pragma mark - Dropbox constants
|
||||
|
||||
extern NSString *const DropboxErrorDomain;
|
||||
extern NSString *const DropboxErrorUserInfo;
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
|
||||
NSString *const FMCNEXTRTEPAGE = @"NEXTRTEPAGE";
|
||||
NSString *const FMCFIRSTRTEPAGE = @"FIRSTRTEPAGE";
|
||||
|
||||
NSString *const INVALID = @"INVALID ENTRY";
|
||||
NSString *const NOTREADY = @"NAV DATA NOT READY";
|
||||
|
||||
NSString *const DropboxErrorDomain = @"com.weebly.alikja.FMC";
|
||||
NSString *const DropboxErrorUserInfo = @"error_summary";
|
||||
|
||||
@@ -75,27 +79,29 @@ NSString *const DropboxErrorUserInfo = @"error_summary";
|
||||
+ (void)presentErrorAlert:(NSError *)error
|
||||
presenter:(UIViewController *)presenter
|
||||
{
|
||||
if ([UIAlertController class]) {
|
||||
UIAlertController *alert = [UIAlertController
|
||||
alertControllerWithTitle:@"Error"
|
||||
message:error.localizedDescription
|
||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
UIAlertAction *defaultAction =
|
||||
[UIAlertAction actionWithTitle:@"OK"
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:nil];
|
||||
[alert addAction:defaultAction];
|
||||
if (presenter != nil) {
|
||||
if ([UIAlertController class]) {
|
||||
UIAlertController *alert = [UIAlertController
|
||||
alertControllerWithTitle:@"Error"
|
||||
message:error.localizedDescription
|
||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
UIAlertAction *defaultAction =
|
||||
[UIAlertAction actionWithTitle:@"OK"
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:nil];
|
||||
[alert addAction:defaultAction];
|
||||
|
||||
[presenter presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
else {
|
||||
UIAlertView *alert =
|
||||
[[UIAlertView alloc] initWithTitle:@"Error"
|
||||
message:error.localizedDescription
|
||||
delegate:nil
|
||||
cancelButtonTitle:@"Cancel"
|
||||
otherButtonTitles:nil];
|
||||
[alert show];
|
||||
[presenter presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
else {
|
||||
UIAlertView *alert =
|
||||
[[UIAlertView alloc] initWithTitle:@"Error"
|
||||
message:error.localizedDescription
|
||||
delegate:nil
|
||||
cancelButtonTitle:@"Cancel"
|
||||
otherButtonTitles:nil];
|
||||
[alert show];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class ViewControllerServiceMenu;
|
||||
@interface TableViewController : UITableViewController <SWTableViewCellDelegate>
|
||||
@interface TableViewController
|
||||
: UITableViewController <SWTableViewCellDelegate> {
|
||||
DropboxV2ObjC *dbClient;
|
||||
}
|
||||
|
||||
#pragma mark - Refrence to other views in app
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
@implementation TableViewController
|
||||
|
||||
DropboxV2ObjC *dbClient = nil;
|
||||
|
||||
#pragma mark - View management and navigation
|
||||
|
||||
- (void)viewDidLoad
|
||||
@@ -26,8 +24,7 @@ DropboxV2ObjC *dbClient = nil;
|
||||
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
||||
self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
||||
_markList = [[NSMutableArray alloc] init];
|
||||
dbClient =
|
||||
((AppDelegate *)[UIApplication sharedApplication].delegate).dbClient;
|
||||
dbClient = _main.dbClient;
|
||||
|
||||
if ([self.title isEqualToString:@"Manage"] ||
|
||||
[self.title isEqualToString:@"Upload"]) {
|
||||
@@ -46,19 +43,20 @@ DropboxV2ObjC *dbClient = nil;
|
||||
contentsOfPath:@"SAVES"
|
||||
completion:^(NSArray *data) {
|
||||
NSMutableArray *temp = [[NSMutableArray alloc] init];
|
||||
if (data != nil) {
|
||||
for (NSDictionary *dict in data) {
|
||||
[temp addObject:[dict valueForKey:@"name"]];
|
||||
}
|
||||
|
||||
for (NSDictionary *dict in data) {
|
||||
[temp addObject:[dict valueForKey:@"name"]];
|
||||
_dataSource = [[temp
|
||||
filteredArrayUsingPredicate:
|
||||
[NSPredicate predicateWithFormat:
|
||||
@"NOT (SELF BEGINSWITH %@)",
|
||||
@"."]] mutableCopy];
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
[self.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
_dataSource = [[temp
|
||||
filteredArrayUsingPredicate:
|
||||
[NSPredicate
|
||||
predicateWithFormat:@"NOT (SELF BEGINSWITH %@)",
|
||||
@"."]] mutableCopy];
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
[self.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
presenter:self];
|
||||
}
|
||||
@@ -112,13 +110,17 @@ DropboxV2ObjC *dbClient = nil;
|
||||
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if ([self.title isEqualToString:@"Manage"]) {
|
||||
[self dismissViewControllerAnimated:YES
|
||||
completion:^(void) {
|
||||
[_main loadSave:[tableView
|
||||
cellForRowAtIndexPath:
|
||||
indexPath]
|
||||
.textLabel.text];
|
||||
}];
|
||||
[self
|
||||
dismissViewControllerAnimated:YES
|
||||
completion:^(void) {
|
||||
[_main loadSave:
|
||||
[@"SAVES/"
|
||||
stringByAppendingString:
|
||||
[tableView
|
||||
cellForRowAtIndexPath:
|
||||
indexPath]
|
||||
.textLabel.text]];
|
||||
}];
|
||||
}
|
||||
else {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
@@ -262,7 +264,10 @@ DropboxV2ObjC *dbClient = nil;
|
||||
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
|
||||
[[NSFileManager defaultManager]
|
||||
removeItemAtPath:[SharedDeclerations
|
||||
savePathForFile:_dataSource[indexPath.row]]
|
||||
savePathForFile:[@"SAVES/"
|
||||
stringByAppendingString:
|
||||
_dataSource[indexPath
|
||||
.row]]]
|
||||
error:nil];
|
||||
[_dataSource removeObjectAtIndex:indexPath.row];
|
||||
[self.tableView deleteRowsAtIndexPaths:@[ indexPath ]
|
||||
|
||||
@@ -14,6 +14,14 @@
|
||||
|
||||
@interface ViewController : UIViewController <UIAlertViewDelegate>
|
||||
|
||||
#pragma mark - Shared nav data parser
|
||||
|
||||
@property (strong, nonatomic) NavDataParser *navDataParser;
|
||||
|
||||
#pragma mark - Shared Dropbox client
|
||||
/// Shared Dropbox client
|
||||
@property (strong, nonatomic) DropboxV2ObjC *dbClient;
|
||||
|
||||
#pragma mark - Refrence to other views in app
|
||||
|
||||
@property (strong, nonatomic) ViewControllerScreen *screen;
|
||||
|
||||
@@ -25,6 +25,23 @@
|
||||
_save = [[NSMutableDictionary alloc] init];
|
||||
_firstLoad = true;
|
||||
self.title = @"FMC";
|
||||
|
||||
// Override point for customization after application launch._dbClient =
|
||||
// [[DropboxV2ObjC alloc] init];
|
||||
NSDictionary *credentials =
|
||||
[[NSURLCredentialStorage sharedCredentialStorage]
|
||||
credentialsForProtectionSpace:_dbClient.kDropboxProtectionSpace];
|
||||
NSURLCredential *credential = [credentials.objectEnumerator nextObject];
|
||||
_dbClient.token = credential.password;
|
||||
// Reset if user changed it
|
||||
[_dbClient setupDropboxWithHandler:^{
|
||||
}
|
||||
presenter:self];
|
||||
|
||||
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
|
||||
[queue addOperationWithBlock:^{
|
||||
_navDataParser = [[NavDataParser alloc] init];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
|
||||
@@ -44,8 +61,12 @@
|
||||
|
||||
- (void)saveToFile:(NSDictionary *)save
|
||||
{
|
||||
NSString *file =
|
||||
[SharedDeclerations savePathForFile:[_save valueForKey:@"MENU@LSKR1"]];
|
||||
NSString *file = [[NSString alloc] init];
|
||||
if ([_save valueForKey:@"MENU@LSKR1"] != nil) {
|
||||
file = [SharedDeclerations
|
||||
savePathForFile:[@"SAVES/" stringByAppendingString:
|
||||
[_save valueForKey:@"MENU@LSKR1"]]];
|
||||
}
|
||||
if (_firstLoad) {
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:file]) {
|
||||
[self alertViewiOS7:file];
|
||||
@@ -79,7 +100,8 @@
|
||||
clickedButtonAtIndex:(NSInteger)buttonIndex
|
||||
{
|
||||
if (buttonIndex == 1) {
|
||||
[self loadSave:[_save valueForKey:@"MENU@LSKR1"]];
|
||||
[self loadSave:[@"SAVES/" stringByAppendingString:
|
||||
[_save valueForKey:@"MENU@LSKR1"]]];
|
||||
}
|
||||
else if (buttonIndex == 2) {
|
||||
[_save
|
||||
|
||||
@@ -110,7 +110,9 @@
|
||||
[_main.screen.Scratchpad.text stringByAppendingString:@" "];
|
||||
}
|
||||
else if ([sender.restorationIdentifier isEqualToString:@"Clear"]) {
|
||||
if ([_main.screen.Scratchpad.text isEqualToString:@"DELETE"]) {
|
||||
if ([_main.screen.Scratchpad.text isEqualToString:@"DELETE"] ||
|
||||
[_main.screen.Scratchpad.text isEqualToString:INVALID] ||
|
||||
[_main.screen.Scratchpad.text isEqualToString:NOTREADY]) {
|
||||
_main.screen.Scratchpad.text = @"";
|
||||
}
|
||||
else if (_main.screen.Scratchpad.text.length > 0) {
|
||||
@@ -139,7 +141,8 @@
|
||||
}
|
||||
else {
|
||||
_main.screen.Scratchpad.text = [_main.screen.Scratchpad.text
|
||||
stringByAppendingString:sender.titleLabel.text];
|
||||
stringByAppendingString:[sender
|
||||
titleForState:UIControlStateNormal]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// Copyright © 2016 Kilian Hofmann. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NavDataParser.h"
|
||||
#import "SharedDeclerations.h"
|
||||
#import "ViewController.h"
|
||||
#import "ViewControllerServiceMenu.h"
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
@implementation ViewControllerScreen
|
||||
|
||||
NavDataParser *parser = nil;
|
||||
|
||||
#pragma mark - View management and navigation
|
||||
|
||||
- (void)viewDidLoad
|
||||
@@ -37,6 +39,8 @@
|
||||
reg.numberOfTouchesRequired = 1;
|
||||
[label addGestureRecognizer:reg];
|
||||
}
|
||||
|
||||
parser = _main.navDataParser;
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
@@ -71,8 +75,13 @@
|
||||
|
||||
- (void)enterLSK:(UITapGestureRecognizer *)tapReg
|
||||
{
|
||||
if ([_Scratchpad.text isEqualToString:@"DELETE"]) {
|
||||
if ([_Scratchpad.text isEqualToString:INVALID] ||
|
||||
[_Scratchpad.text isEqualToString:NOTREADY]) {
|
||||
// DO NOTHING AS OF YET
|
||||
}
|
||||
else if ([_Scratchpad.text isEqualToString:@"DELETE"]) {
|
||||
((UILabel *)tapReg.view).text = @"";
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
else if ([_Header.text isEqualToString:@"MENU"]) {
|
||||
if ([((UILabel *)tapReg.view)
|
||||
@@ -86,6 +95,7 @@
|
||||
}
|
||||
_main.backupCoRte = ((UILabel *)tapReg.view).text;
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
else if ([((UILabel *)tapReg.view)
|
||||
.restorationIdentifier isEqualToString:@"LSKR4"]) {
|
||||
@@ -122,33 +132,52 @@
|
||||
}
|
||||
else {
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
}
|
||||
else if ([[_Header.text substringToIndex:3] isEqualToString:@"ROU"]) {
|
||||
|
||||
#warning TEST BED for NOW
|
||||
if (parser.parserReady) {
|
||||
NSArray *finds = [parser findWaypoint:_Scratchpad.text];
|
||||
|
||||
if (finds.count != 0) {
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
else {
|
||||
_Scratchpad.text = INVALID;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_Scratchpad.text = NOTREADY;
|
||||
}
|
||||
if ([((UILabel *)tapReg.view)
|
||||
.restorationIdentifier isEqualToString:@"LSKR6"] &&
|
||||
_numRoutePage == _maxNumRoutePages) {
|
||||
_maxNumRoutePages += 1;
|
||||
NSRange indexSlash = [_Header.text rangeOfString:@"/"];
|
||||
_Header.text = [_Header.text
|
||||
stringByReplacingCharactersInRange:NSMakeRange(
|
||||
indexSlash.location,
|
||||
_Header.text.length -
|
||||
indexSlash.location)
|
||||
withString:
|
||||
[NSString
|
||||
stringWithFormat:
|
||||
@"/%lu",
|
||||
(unsigned long)
|
||||
_maxNumRoutePages]];
|
||||
}
|
||||
}
|
||||
else {
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
}
|
||||
if ([((UILabel *)tapReg.view)
|
||||
.restorationIdentifier isEqualToString:@"LSKR6"] &&
|
||||
_numRoutePage == _maxNumRoutePages &&
|
||||
[[_Header.text substringToIndex:3] isEqualToString:@"ROU"]) {
|
||||
_maxNumRoutePages += 1;
|
||||
NSRange indexSlash = [_Header.text rangeOfString:@"/"];
|
||||
_Header.text = [_Header.text
|
||||
stringByReplacingCharactersInRange:NSMakeRange(
|
||||
indexSlash.location,
|
||||
_Header.text.length -
|
||||
indexSlash.location)
|
||||
withString:[NSString
|
||||
stringWithFormat:
|
||||
@"/%lu",
|
||||
(unsigned long)
|
||||
_maxNumRoutePages]];
|
||||
_Scratchpad.text = @"";
|
||||
}
|
||||
(_main.save)[[NSString
|
||||
stringWithFormat:@"%@@%@", _Header.text,
|
||||
((UILabel *)tapReg.view).restorationIdentifier]] =
|
||||
((UILabel *)tapReg.view).text;
|
||||
_Scratchpad.text = @"";
|
||||
[_main saveToFile:_main.save];
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
#import "ViewController.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface ViewControllerServiceMenu : UIViewController <UIAlertViewDelegate>
|
||||
@interface ViewControllerServiceMenu : UIViewController <UIAlertViewDelegate> {
|
||||
DropboxV2ObjC *dbClient;
|
||||
}
|
||||
|
||||
#pragma mark - Refrence to other views in app
|
||||
|
||||
|
||||
@@ -20,13 +20,12 @@
|
||||
style:UIBarButtonItemStyleDone
|
||||
target:self
|
||||
action:@selector(back)];
|
||||
dbClient = _main.dbClient;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
DropboxV2ObjC *dbClient =
|
||||
((AppDelegate *)[UIApplication sharedApplication].delegate).dbClient;
|
||||
if (dbClient.token != nil) {
|
||||
[_dbConnectButton setTitle:@"Disconnect from Dropbox"
|
||||
forState:UIControlStateNormal];
|
||||
@@ -97,8 +96,6 @@
|
||||
// Dynamically set and unset
|
||||
- (IBAction)dbDisconnect:(UIButton *)sender
|
||||
{
|
||||
DropboxV2ObjC *dbClient =
|
||||
((AppDelegate *)[UIApplication sharedApplication].delegate).dbClient;
|
||||
[dbClient deauthorizeUserWithPresenter:self];
|
||||
[_dbConnectButton setTitle:@"Connect to Dropbox"
|
||||
forState:UIControlStateNormal];
|
||||
@@ -122,9 +119,6 @@
|
||||
_dbNavData.alpha = 0.5;
|
||||
_main.navDataActive = true;
|
||||
[queue addOperationWithBlock:^{
|
||||
DropboxV2ObjC *dbClient =
|
||||
((AppDelegate *)[UIApplication sharedApplication].delegate)
|
||||
.dbClient;
|
||||
[dbClient
|
||||
contentsOfPath:@"NAVDATA"
|
||||
completion:^(NSArray *files) {
|
||||
|
||||
Reference in New Issue
Block a user