Loading from LSK, Alerts (pre ios7 and post ios7)
This commit is contained in:
@@ -888,6 +888,7 @@
|
||||
<connections>
|
||||
<outlet property="FrameHeight" destination="PAI-JI-9VG" id="Bwh-ww-HeF"/>
|
||||
<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"/>
|
||||
<outletCollection property="Desc" destination="em7-UJ-Joo" id="Y2K-hy-s4X"/>
|
||||
<outletCollection property="Desc" destination="Z4K-ej-cbf" id="3ur-q6-AfV"/>
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
|
||||
@@ -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>
|
||||
@@ -11,11 +11,13 @@
|
||||
#import "ViewControllerScreen.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface ViewController : UIViewController
|
||||
@interface ViewController : UIViewController <UIAlertViewDelegate>
|
||||
|
||||
@property(strong, nonatomic) ViewControllerScreen *screen;
|
||||
@property(strong, nonatomic) ViewControllerKeyboard *keys;
|
||||
@property(strong, nonatomic) NSMutableDictionary *save;
|
||||
@property(nonatomic) BOOL firstLoad;
|
||||
@property(strong, nonatomic) NSString *backupCoRte;
|
||||
|
||||
@property(strong, nonatomic) IBOutlet UIView *backdropKeys;
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
_backdropScreen.layer.masksToBounds = YES;
|
||||
// Setup save system
|
||||
_save = [[NSMutableDictionary alloc] init];
|
||||
_firstLoad = true;
|
||||
}
|
||||
|
||||
- (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 {
|
||||
if (!([_save valueForKey:@"MENU@LSKR1"] == nil ||
|
||||
[[_save valueForKey:@"MENU@LSKR1"] isEqualToString:@""])) {
|
||||
if (_firstLoad) {
|
||||
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
|
||||
savePathForFile:
|
||||
[SharedDeclerations
|
||||
savePathForFile:
|
||||
[_save valueForKey:@"MENU@LSKR1"]]]
|
||||
atomically:YES];
|
||||
|
||||
[_save valueForKey:@"MENU@LSKR1"]]
|
||||
atomically:NO];
|
||||
}
|
||||
_firstLoad = false;
|
||||
}
|
||||
|
||||
- (void)loadSave:(NSString *)file {
|
||||
@@ -53,6 +110,24 @@
|
||||
fileExistsAtPath:[SharedDeclerations savePathForFile:file]]) {
|
||||
_save = [[NSMutableDictionary alloc]
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,10 @@
|
||||
|
||||
@property(strong, nonatomic) IBOutlet NSLayoutConstraint *FrameHeight;
|
||||
|
||||
@property(strong, nonatomic) IBOutlet UILabel *LSK_R1;
|
||||
|
||||
- (void)loadScreen:(NSString *)screenName withOptions:(NSArray *)options;
|
||||
- (void)loadDataToScreen;
|
||||
- (void)clearScreen;
|
||||
|
||||
@end
|
||||
|
||||
@@ -71,6 +71,16 @@
|
||||
- (void)enterLSK:(UITapGestureRecognizer *)tapReg {
|
||||
if ([_Scratchpad.text isEqualToString:@"DELETE"]) {
|
||||
((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 {
|
||||
((UILabel *)tapReg.view).text = _Scratchpad.text;
|
||||
}
|
||||
@@ -86,15 +96,16 @@
|
||||
indexSlash.location)
|
||||
withString:[NSString
|
||||
stringWithFormat:
|
||||
@"/%u",
|
||||
_maxNumRoutePages]];
|
||||
@"/%lu",
|
||||
(unsigned long)
|
||||
_maxNumRoutePages]];
|
||||
}
|
||||
_Scratchpad.text = @"";
|
||||
[_main.save
|
||||
setObject:((UILabel *)tapReg.view).text
|
||||
forKey:[NSString stringWithFormat:@"%@@%@", _Header.text,
|
||||
((UILabel *)tapReg.view)
|
||||
.restorationIdentifier]];
|
||||
_Scratchpad.text = @"";
|
||||
[_main saveToFile:_main.save];
|
||||
}
|
||||
|
||||
@@ -120,10 +131,10 @@
|
||||
_numRoutePage = 1;
|
||||
}
|
||||
_Header.text = [_Header.text
|
||||
stringByAppendingString:[NSString
|
||||
stringWithFormat:@" %u/%u",
|
||||
_numRoutePage,
|
||||
_maxNumRoutePages]];
|
||||
stringByAppendingString:
|
||||
[NSString stringWithFormat:@" %lu/%lu",
|
||||
(unsigned long)_numRoutePage,
|
||||
(unsigned long)_maxNumRoutePages]];
|
||||
}
|
||||
[self loadDataToScreen];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user