Loading from LSK, Alerts (pre ios7 and post ios7)

This commit is contained in:
Kilian Hofmann 2016-03-26 14:10:30 +01:00
parent a95ed4bd90
commit bddfd723b7
9 changed files with 203 additions and 16 deletions

View File

@ -19,6 +19,7 @@
E28E106D1C9FF93D006E2C6B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E28E106C1C9FF93D006E2C6B /* QuartzCore.framework */; }; E28E106D1C9FF93D006E2C6B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E28E106C1C9FF93D006E2C6B /* QuartzCore.framework */; };
E28E10711CA01EC9006E2C6B /* MENU.plist in Resources */ = {isa = PBXBuildFile; fileRef = E28E10701CA01EC9006E2C6B /* MENU.plist */; }; E28E10711CA01EC9006E2C6B /* MENU.plist in Resources */ = {isa = PBXBuildFile; fileRef = E28E10701CA01EC9006E2C6B /* MENU.plist */; };
E28E10731CA0375F006E2C6B /* ROUTE.plist in Resources */ = {isa = PBXBuildFile; fileRef = E28E10721CA0375F006E2C6B /* ROUTE.plist */; }; E28E10731CA0375F006E2C6B /* ROUTE.plist in Resources */ = {isa = PBXBuildFile; fileRef = E28E10721CA0375F006E2C6B /* ROUTE.plist */; };
E29391CE1CA444F4008EB590 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E29391CD1CA444F4008EB590 /* LaunchScreen.storyboard */; };
E2A927161CA30CEE00606E07 /* SharedDeclerations.m in Sources */ = {isa = PBXBuildFile; fileRef = E2A927151CA30CEE00606E07 /* SharedDeclerations.m */; }; E2A927161CA30CEE00606E07 /* SharedDeclerations.m in Sources */ = {isa = PBXBuildFile; fileRef = E2A927151CA30CEE00606E07 /* SharedDeclerations.m */; };
E2CC73E31CA2B7C7005B786E /* PERF INIT.plist in Resources */ = {isa = PBXBuildFile; fileRef = E2CC73E21CA2B7C7005B786E /* PERF INIT.plist */; }; E2CC73E31CA2B7C7005B786E /* PERF INIT.plist in Resources */ = {isa = PBXBuildFile; fileRef = E2CC73E21CA2B7C7005B786E /* PERF INIT.plist */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -63,6 +64,7 @@
E28E106C1C9FF93D006E2C6B /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; E28E106C1C9FF93D006E2C6B /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
E28E10701CA01EC9006E2C6B /* MENU.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = MENU.plist; sourceTree = "<group>"; }; E28E10701CA01EC9006E2C6B /* MENU.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = MENU.plist; sourceTree = "<group>"; };
E28E10721CA0375F006E2C6B /* ROUTE.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ROUTE.plist; sourceTree = "<group>"; }; E28E10721CA0375F006E2C6B /* ROUTE.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ROUTE.plist; sourceTree = "<group>"; };
E29391CD1CA444F4008EB590 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
E2A927141CA30CEE00606E07 /* SharedDeclerations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedDeclerations.h; sourceTree = "<group>"; }; E2A927141CA30CEE00606E07 /* SharedDeclerations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedDeclerations.h; sourceTree = "<group>"; };
E2A927151CA30CEE00606E07 /* SharedDeclerations.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SharedDeclerations.m; sourceTree = "<group>"; }; E2A927151CA30CEE00606E07 /* SharedDeclerations.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SharedDeclerations.m; sourceTree = "<group>"; };
E2CC73E21CA2B7C7005B786E /* PERF INIT.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "PERF INIT.plist"; sourceTree = "<group>"; }; E2CC73E21CA2B7C7005B786E /* PERF INIT.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "PERF INIT.plist"; sourceTree = "<group>"; };
@ -198,6 +200,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E22EE9D81C9DB7B3001F5BC0 /* Main.storyboard */, E22EE9D81C9DB7B3001F5BC0 /* Main.storyboard */,
E29391CD1CA444F4008EB590 /* LaunchScreen.storyboard */,
); );
name = Storyboards; name = Storyboards;
sourceTree = "<group>"; sourceTree = "<group>";
@ -330,6 +333,7 @@
E2CC73E31CA2B7C7005B786E /* PERF INIT.plist in Resources */, E2CC73E31CA2B7C7005B786E /* PERF INIT.plist in Resources */,
E28E10711CA01EC9006E2C6B /* MENU.plist in Resources */, E28E10711CA01EC9006E2C6B /* MENU.plist in Resources */,
E22EE9DC1C9DB7B3001F5BC0 /* Assets.xcassets in Resources */, E22EE9DC1C9DB7B3001F5BC0 /* Assets.xcassets in Resources */,
E29391CE1CA444F4008EB590 /* LaunchScreen.storyboard in Resources */,
E28E10731CA0375F006E2C6B /* ROUTE.plist in Resources */, E28E10731CA0375F006E2C6B /* ROUTE.plist in Resources */,
E22EE9DA1C9DB7B3001F5BC0 /* Main.storyboard in Resources */, E22EE9DA1C9DB7B3001F5BC0 /* Main.storyboard in Resources */,
); );

View File

@ -2,4 +2,86 @@
<Bucket <Bucket
type = "1" type = "1"
version = "2.0"> version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewController.m"
timestampString = "480527626.718105"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "38"
endingLineNumber = "38"
landmarkName = "-saveToFile:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewControllerScreen.m"
timestampString = "480525698.152591"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "71"
endingLineNumber = "71"
landmarkName = "-enterLSK:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewController.m"
timestampString = "480533104.077959"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "120"
endingLineNumber = "120"
landmarkName = "-alertView:clickedButtonAtIndex:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewController.m"
timestampString = "480532926.915992"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "108"
endingLineNumber = "108"
landmarkName = "-loadSave:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FMC Planner 2/ViewControllerScreen.m"
timestampString = "480532991.825411"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "142"
endingLineNumber = "142"
landmarkName = "-loadDataToScreen"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket> </Bucket>

View File

@ -888,6 +888,7 @@
<connections> <connections>
<outlet property="FrameHeight" destination="PAI-JI-9VG" id="Bwh-ww-HeF"/> <outlet property="FrameHeight" destination="PAI-JI-9VG" id="Bwh-ww-HeF"/>
<outlet property="Header" destination="Loy-Fk-sOd" id="KgH-s5-udY"/> <outlet property="Header" destination="Loy-Fk-sOd" id="KgH-s5-udY"/>
<outlet property="LSK_R1" destination="sro-Ep-8wL" id="eNa-h9-Esx"/>
<outlet property="Scratchpad" destination="DKU-Ht-Zkn" id="mcM-29-Lhx"/> <outlet property="Scratchpad" destination="DKU-Ht-Zkn" id="mcM-29-Lhx"/>
<outletCollection property="Desc" destination="em7-UJ-Joo" id="Y2K-hy-s4X"/> <outletCollection property="Desc" destination="em7-UJ-Joo" id="Y2K-hy-s4X"/>
<outletCollection property="Desc" destination="Z4K-ej-cbf" id="3ur-q6-AfV"/> <outletCollection property="Desc" destination="Z4K-ej-cbf" id="3ur-q6-AfV"/>

View File

@ -22,6 +22,8 @@
<string>1</string> <string>1</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>
<string>Main</string> <string>Main</string>
<key>UIRequiredDeviceCapabilities</key> <key>UIRequiredDeviceCapabilities</key>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
</dependencies>
<scenes/>
</document>

View File

@ -11,11 +11,13 @@
#import "ViewControllerScreen.h" #import "ViewControllerScreen.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface ViewController : UIViewController @interface ViewController : UIViewController <UIAlertViewDelegate>
@property(strong, nonatomic) ViewControllerScreen *screen; @property(strong, nonatomic) ViewControllerScreen *screen;
@property(strong, nonatomic) ViewControllerKeyboard *keys; @property(strong, nonatomic) ViewControllerKeyboard *keys;
@property(strong, nonatomic) NSMutableDictionary *save; @property(strong, nonatomic) NSMutableDictionary *save;
@property(nonatomic) BOOL firstLoad;
@property(strong, nonatomic) NSString *backupCoRte;
@property(strong, nonatomic) IBOutlet UIView *backdropKeys; @property(strong, nonatomic) IBOutlet UIView *backdropKeys;

View File

@ -20,6 +20,7 @@
_backdropScreen.layer.masksToBounds = YES; _backdropScreen.layer.masksToBounds = YES;
// Setup save system // Setup save system
_save = [[NSMutableDictionary alloc] init]; _save = [[NSMutableDictionary alloc] init];
_firstLoad = true;
} }
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
@ -34,18 +35,74 @@
} }
} }
#warning TODO: check if file already exists -- load or replace
#warning TODO: else -> jump to file browsing for load/delete
- (void)saveToFile:(NSDictionary *)save { - (void)saveToFile:(NSDictionary *)save {
if (!([_save valueForKey:@"MENU@LSKR1"] == nil || if (_firstLoad) {
[[_save valueForKey:@"MENU@LSKR1"] isEqualToString:@""])) { if ([[NSFileManager defaultManager]
fileExistsAtPath:
[SharedDeclerations
savePathForFile:[_save valueForKey:@"MENU@LSKR1"]]]) {
#warning TODO: check if file already exists -- load or replace
if ([UIAlertController class]) {
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"Load or replace?"
message:
@"The entered CO ROUTE alreay exists. "
@"Do you want to load or replace it?"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *defaultAction =
[UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:nil];
UIAlertAction *loadAction = [UIAlertAction
actionWithTitle:@"Load"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[self
loadSave:[_save valueForKey:@"MENU@LSKR1"]];
}];
UIAlertAction *replaceAction = [UIAlertAction
actionWithTitle:@"Replace"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[_save
writeToFile:
[SharedDeclerations
savePathForFile:
[_save
valueForKey:@"MENU@LSKR1"]]
atomically:YES];
}];
[alert addAction:defaultAction];
[alert addAction:loadAction];
[alert addAction:replaceAction];
[self presentViewController:alert animated:YES completion:nil];
} else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Load or replace?"
message:@"The entered CO ROUTE alreay exists. Do "
@"you want to load "
@"or replace it?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Load", @"Replace", nil];
[alert show];
}
} else {
[_save
writeToFile:[SharedDeclerations
savePathForFile:[_save
valueForKey:@"MENU@LSKR1"]]
atomically:YES];
}
} else if (!([_save valueForKey:@"MENU@LSKR1"] == nil ||
[[_save valueForKey:@"MENU@LSKR1"] isEqualToString:@""])) {
[_save writeToFile:[SharedDeclerations [_save writeToFile:[SharedDeclerations
savePathForFile: savePathForFile:
[SharedDeclerations
savePathForFile: [_save valueForKey:@"MENU@LSKR1"]]
[_save valueForKey:@"MENU@LSKR1"]]] atomically:NO];
atomically:YES];
} }
_firstLoad = false;
} }
- (void)loadSave:(NSString *)file { - (void)loadSave:(NSString *)file {
@ -53,6 +110,24 @@
fileExistsAtPath:[SharedDeclerations savePathForFile:file]]) { fileExistsAtPath:[SharedDeclerations savePathForFile:file]]) {
_save = [[NSMutableDictionary alloc] _save = [[NSMutableDictionary alloc]
initWithContentsOfFile:[SharedDeclerations savePathForFile:file]]; initWithContentsOfFile:[SharedDeclerations savePathForFile:file]];
[_screen clearScreen];
[_screen loadDataToScreen];
}
}
#pragma mark - Delegate vo UIAlertView
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
[self loadSave:[_save valueForKey:@"MENU@LSKR1"]];
} else if (buttonIndex == 2) {
[_save
writeToFile:[SharedDeclerations
savePathForFile:[_save valueForKey:@"MENU@LSKR1"]]
atomically:YES];
} else {
_screen.LSK_R1.text = _backupCoRte;
} }
} }

View File

@ -26,7 +26,10 @@
@property(strong, nonatomic) IBOutlet NSLayoutConstraint *FrameHeight; @property(strong, nonatomic) IBOutlet NSLayoutConstraint *FrameHeight;
@property(strong, nonatomic) IBOutlet UILabel *LSK_R1;
- (void)loadScreen:(NSString *)screenName withOptions:(NSArray *)options; - (void)loadScreen:(NSString *)screenName withOptions:(NSArray *)options;
- (void)loadDataToScreen; - (void)loadDataToScreen;
- (void)clearScreen;
@end @end

View File

@ -71,6 +71,16 @@
- (void)enterLSK:(UITapGestureRecognizer *)tapReg { - (void)enterLSK:(UITapGestureRecognizer *)tapReg {
if ([_Scratchpad.text isEqualToString:@"DELETE"]) { if ([_Scratchpad.text isEqualToString:@"DELETE"]) {
((UILabel *)tapReg.view).text = @""; ((UILabel *)tapReg.view).text = @"";
} else if ([((UILabel *)tapReg.view)
.restorationIdentifier isEqualToString:@"LSKR1"]) {
if ([((UILabel *)tapReg.view).text isEqualToString:@""]) {
_main.firstLoad = true;
} else if (!([((UILabel *)tapReg.view)
.text isEqualToString:_Scratchpad.text])) {
_main.firstLoad = true;
}
_main.backupCoRte = ((UILabel *)tapReg.view).text;
((UILabel *)tapReg.view).text = _Scratchpad.text;
} else { } else {
((UILabel *)tapReg.view).text = _Scratchpad.text; ((UILabel *)tapReg.view).text = _Scratchpad.text;
} }
@ -86,15 +96,16 @@
indexSlash.location) indexSlash.location)
withString:[NSString withString:[NSString
stringWithFormat: stringWithFormat:
@"/%u", @"/%lu",
_maxNumRoutePages]]; (unsigned long)
_maxNumRoutePages]];
} }
_Scratchpad.text = @"";
[_main.save [_main.save
setObject:((UILabel *)tapReg.view).text setObject:((UILabel *)tapReg.view).text
forKey:[NSString stringWithFormat:@"%@@%@", _Header.text, forKey:[NSString stringWithFormat:@"%@@%@", _Header.text,
((UILabel *)tapReg.view) ((UILabel *)tapReg.view)
.restorationIdentifier]]; .restorationIdentifier]];
_Scratchpad.text = @"";
[_main saveToFile:_main.save]; [_main saveToFile:_main.save];
} }
@ -120,10 +131,10 @@
_numRoutePage = 1; _numRoutePage = 1;
} }
_Header.text = [_Header.text _Header.text = [_Header.text
stringByAppendingString:[NSString stringByAppendingString:
stringWithFormat:@" %u/%u", [NSString stringWithFormat:@" %lu/%lu",
_numRoutePage, (unsigned long)_numRoutePage,
_maxNumRoutePages]]; (unsigned long)_maxNumRoutePages]];
} }
[self loadDataToScreen]; [self loadDataToScreen];
} }