Commit ab795a3b authored by Alex Moore's avatar Alex Moore

big update, bug fixes and accessibility changes

parent 07600fc5
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
EF0F973F1ACA61C5008D8416 /* BookBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = EF0F973E1ACA61C5008D8416 /* BookBuilder.m */; }; EF0F973F1ACA61C5008D8416 /* BookBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = EF0F973E1ACA61C5008D8416 /* BookBuilder.m */; };
EF0F97411ACA7003008D8416 /* Book.m in Sources */ = {isa = PBXBuildFile; fileRef = EF0F97401ACA7003008D8416 /* Book.m */; }; EF0F97411ACA7003008D8416 /* Book.m in Sources */ = {isa = PBXBuildFile; fileRef = EF0F97401ACA7003008D8416 /* Book.m */; };
EF18373F1AD07C5000E427A7 /* Section.m in Sources */ = {isa = PBXBuildFile; fileRef = EF18373E1AD07C5000E427A7 /* Section.m */; };
EF1837421AD07C6100E427A7 /* SectionBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = EF1837411AD07C6100E427A7 /* SectionBuilder.m */; };
EFDA4ED31ABFC128002B9CEC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = EFDA4ED21ABFC128002B9CEC /* main.m */; }; EFDA4ED31ABFC128002B9CEC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = EFDA4ED21ABFC128002B9CEC /* main.m */; };
EFDA4EDE1ABFC128002B9CEC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EFDA4EDD1ABFC128002B9CEC /* Images.xcassets */; }; EFDA4EDE1ABFC128002B9CEC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EFDA4EDD1ABFC128002B9CEC /* Images.xcassets */; };
EFDA4EE11ABFC128002B9CEC /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = EFDA4EDF1ABFC128002B9CEC /* LaunchScreen.xib */; }; EFDA4EE11ABFC128002B9CEC /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = EFDA4EDF1ABFC128002B9CEC /* LaunchScreen.xib */; };
...@@ -70,6 +72,10 @@ ...@@ -70,6 +72,10 @@
EF0F973D1ACA61C5008D8416 /* BookBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BookBuilder.h; sourceTree = "<group>"; }; EF0F973D1ACA61C5008D8416 /* BookBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BookBuilder.h; sourceTree = "<group>"; };
EF0F973E1ACA61C5008D8416 /* BookBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BookBuilder.m; sourceTree = "<group>"; }; EF0F973E1ACA61C5008D8416 /* BookBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BookBuilder.m; sourceTree = "<group>"; };
EF0F97401ACA7003008D8416 /* Book.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Book.m; sourceTree = "<group>"; }; EF0F97401ACA7003008D8416 /* Book.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Book.m; sourceTree = "<group>"; };
EF18373D1AD07C4F00E427A7 /* Section.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Section.h; sourceTree = "<group>"; };
EF18373E1AD07C5000E427A7 /* Section.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Section.m; sourceTree = "<group>"; };
EF1837401AD07C6100E427A7 /* SectionBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SectionBuilder.h; sourceTree = "<group>"; };
EF1837411AD07C6100E427A7 /* SectionBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SectionBuilder.m; sourceTree = "<group>"; };
EFDA4ECD1ABFC128002B9CEC /* WAMI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WAMI.app; sourceTree = BUILT_PRODUCTS_DIR; }; EFDA4ECD1ABFC128002B9CEC /* WAMI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WAMI.app; sourceTree = BUILT_PRODUCTS_DIR; };
EFDA4ED11ABFC128002B9CEC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; EFDA4ED11ABFC128002B9CEC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EFDA4ED21ABFC128002B9CEC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; EFDA4ED21ABFC128002B9CEC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
...@@ -151,6 +157,87 @@ ...@@ -151,6 +157,87 @@
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
EF1837351AD061A300E427A7 /* View Controllers */ = {
isa = PBXGroup;
children = (
EF1837391AD062B600E427A7 /* Header Files */,
EFDA4F431ABFC211002B9CEC /* LogInViewController.m */,
EFDA4F451ABFC211002B9CEC /* SectionViewController.m */,
EFDA4F441ABFC211002B9CEC /* ScanBookViewController.m */,
EFDA4F471ABFC211002B9CEC /* SettingsViewController.m */,
);
name = "View Controllers";
sourceTree = "<group>";
};
EF1837361AD061B500E427A7 /* Captuvo Controllers */ = {
isa = PBXGroup;
children = (
EF18373A1AD062C200E427A7 /* Header Files */,
EFDA4F411ABFC211002B9CEC /* CaptuvoViewController.m */,
EFDA4F3F1ABFC211002B9CEC /* CaptuvoOptionsController.m */,
EFDA4F401ABFC211002B9CEC /* CaptuvoScannerController.m */,
);
name = "Captuvo Controllers";
sourceTree = "<group>";
};
EF1837381AD0623600E427A7 /* Miscellaneous */ = {
isa = PBXGroup;
children = (
EF18373B1AD062C900E427A7 /* Header Files */,
EF0F97401ACA7003008D8416 /* Book.m */,
EF0F973E1ACA61C5008D8416 /* BookBuilder.m */,
EFDA4F421ABFC211002B9CEC /* GlobalWebController.m */,
EF18373E1AD07C5000E427A7 /* Section.m */,
EF1837411AD07C6100E427A7 /* SectionBuilder.m */,
EFDA4F461ABFC211002B9CEC /* Session.m */,
);
name = Miscellaneous;
sourceTree = "<group>";
};
EF1837391AD062B600E427A7 /* Header Files */ = {
isa = PBXGroup;
children = (
EFDA4F381ABFC1ED002B9CEC /* LogInViewController.h */,
EFDA4F3A1ABFC1ED002B9CEC /* SectionViewController.h */,
EFDA4F391ABFC1ED002B9CEC /* ScanBookViewController.h */,
EFDA4F3C1ABFC1ED002B9CEC /* SettingsViewController.h */,
);
name = "Header Files";
sourceTree = "<group>";
};
EF18373A1AD062C200E427A7 /* Header Files */ = {
isa = PBXGroup;
children = (
EFDA4F331ABFC1ED002B9CEC /* Captuvo.h */,
EFDA4F361ABFC1ED002B9CEC /* CaptuvoViewController.h */,
EFDA4F341ABFC1ED002B9CEC /* CaptuvoOptionsController.h */,
EFDA4F351ABFC1ED002B9CEC /* CaptuvoScannerController.h */,
);
name = "Header Files";
sourceTree = "<group>";
};
EF18373B1AD062C900E427A7 /* Header Files */ = {
isa = PBXGroup;
children = (
EF0F973A1ACA604B008D8416 /* Book.h */,
EF0F973D1ACA61C5008D8416 /* BookBuilder.h */,
EFDA4F371ABFC1ED002B9CEC /* GlobalWebController.h */,
EF18373D1AD07C4F00E427A7 /* Section.h */,
EF1837401AD07C6100E427A7 /* SectionBuilder.h */,
EFDA4F3B1ABFC1ED002B9CEC /* Session.h */,
);
name = "Header Files";
sourceTree = "<group>";
};
EF18373C1AD062DE00E427A7 /* Header Files */ = {
isa = PBXGroup;
children = (
EFDA4F321ABFC1ED002B9CEC /* AppDelegate.h */,
EFDA4F3D1ABFC1ED002B9CEC /* WebViewController.h */,
);
name = "Header Files";
sourceTree = "<group>";
};
EFDA4EC41ABFC127002B9CEC = { EFDA4EC41ABFC127002B9CEC = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -173,7 +260,6 @@ ...@@ -173,7 +260,6 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
EFDA4F561ABFC232002B9CEC /* Main.storyboard */, EFDA4F561ABFC232002B9CEC /* Main.storyboard */,
EFDA4F131ABFC15B002B9CEC /* Include */,
EFDA4F141ABFC161002B9CEC /* Source */, EFDA4F141ABFC161002B9CEC /* Source */,
EFDA4F151ABFC166002B9CEC /* Libraries */, EFDA4F151ABFC166002B9CEC /* Libraries */,
EFDA4F121ABFC155002B9CEC /* JavaScript */, EFDA4F121ABFC155002B9CEC /* JavaScript */,
...@@ -232,43 +318,15 @@ ...@@ -232,43 +318,15 @@
name = JavaScript; name = JavaScript;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
EFDA4F131ABFC15B002B9CEC /* Include */ = {
isa = PBXGroup;
children = (
EFDA4F321ABFC1ED002B9CEC /* AppDelegate.h */,
EF0F973A1ACA604B008D8416 /* Book.h */,
EF0F973D1ACA61C5008D8416 /* BookBuilder.h */,
EFDA4F331ABFC1ED002B9CEC /* Captuvo.h */,
EFDA4F341ABFC1ED002B9CEC /* CaptuvoOptionsController.h */,
EFDA4F351ABFC1ED002B9CEC /* CaptuvoScannerController.h */,
EFDA4F361ABFC1ED002B9CEC /* CaptuvoViewController.h */,
EFDA4F371ABFC1ED002B9CEC /* GlobalWebController.h */,
EFDA4F381ABFC1ED002B9CEC /* LogInViewController.h */,
EFDA4F391ABFC1ED002B9CEC /* ScanBookViewController.h */,
EFDA4F3A1ABFC1ED002B9CEC /* SectionViewController.h */,
EFDA4F3B1ABFC1ED002B9CEC /* Session.h */,
EFDA4F3C1ABFC1ED002B9CEC /* SettingsViewController.h */,
EFDA4F3D1ABFC1ED002B9CEC /* WebViewController.h */,
);
name = Include;
sourceTree = "<group>";
};
EFDA4F141ABFC161002B9CEC /* Source */ = { EFDA4F141ABFC161002B9CEC /* Source */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
EF18373C1AD062DE00E427A7 /* Header Files */,
EFDA4F3E1ABFC211002B9CEC /* AppDelegate.m */, EFDA4F3E1ABFC211002B9CEC /* AppDelegate.m */,
EF0F97401ACA7003008D8416 /* Book.m */,
EF0F973E1ACA61C5008D8416 /* BookBuilder.m */,
EFDA4F3F1ABFC211002B9CEC /* CaptuvoOptionsController.m */,
EFDA4F401ABFC211002B9CEC /* CaptuvoScannerController.m */,
EFDA4F411ABFC211002B9CEC /* CaptuvoViewController.m */,
EFDA4F421ABFC211002B9CEC /* GlobalWebController.m */,
EFDA4F431ABFC211002B9CEC /* LogInViewController.m */,
EFDA4F441ABFC211002B9CEC /* ScanBookViewController.m */,
EFDA4F451ABFC211002B9CEC /* SectionViewController.m */,
EFDA4F461ABFC211002B9CEC /* Session.m */,
EFDA4F471ABFC211002B9CEC /* SettingsViewController.m */,
EFDA4F481ABFC211002B9CEC /* WebViewController.m */, EFDA4F481ABFC211002B9CEC /* WebViewController.m */,
EF1837351AD061A300E427A7 /* View Controllers */,
EF1837361AD061B500E427A7 /* Captuvo Controllers */,
EF1837381AD0623600E427A7 /* Miscellaneous */,
); );
name = Source; name = Source;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -436,10 +494,12 @@ ...@@ -436,10 +494,12 @@
EFDA4F4D1ABFC211002B9CEC /* GlobalWebController.m in Sources */, EFDA4F4D1ABFC211002B9CEC /* GlobalWebController.m in Sources */,
EFDA4F491ABFC211002B9CEC /* AppDelegate.m in Sources */, EFDA4F491ABFC211002B9CEC /* AppDelegate.m in Sources */,
EFDA4F511ABFC211002B9CEC /* Session.m in Sources */, EFDA4F511ABFC211002B9CEC /* Session.m in Sources */,
EF1837421AD07C6100E427A7 /* SectionBuilder.m in Sources */,
EF0F973F1ACA61C5008D8416 /* BookBuilder.m in Sources */, EF0F973F1ACA61C5008D8416 /* BookBuilder.m in Sources */,
EFDA4F531ABFC211002B9CEC /* WebViewController.m in Sources */, EFDA4F531ABFC211002B9CEC /* WebViewController.m in Sources */,
EFDA4F4B1ABFC211002B9CEC /* CaptuvoScannerController.m in Sources */, EFDA4F4B1ABFC211002B9CEC /* CaptuvoScannerController.m in Sources */,
EFDA4F521ABFC211002B9CEC /* SettingsViewController.m in Sources */, EFDA4F521ABFC211002B9CEC /* SettingsViewController.m in Sources */,
EF18373F1AD07C5000E427A7 /* Section.m in Sources */,
EFDA4F4A1ABFC211002B9CEC /* CaptuvoOptionsController.m in Sources */, EFDA4F4A1ABFC211002B9CEC /* CaptuvoOptionsController.m in Sources */,
EF0F97411ACA7003008D8416 /* Book.m in Sources */, EF0F97411ACA7003008D8416 /* Book.m in Sources */,
EFDA4ED31ABFC128002B9CEC /* main.m in Sources */, EFDA4ED31ABFC128002B9CEC /* main.m in Sources */,
...@@ -559,6 +619,7 @@ ...@@ -559,6 +619,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS[arch=*]" = TESTING;
INFOPLIST_FILE = WAMI/Info.plist; INFOPLIST_FILE = WAMI/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch. // Override point for customization after application launch.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; //NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
return YES; return YES;
} }
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
- (void)applicationWillResignActive:(UIApplication *)application { - (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
} }
- (void)applicationDidEnterBackground:(UIApplication *)application { - (void)applicationDidEnterBackground:(UIApplication *)application {
...@@ -38,11 +39,12 @@ ...@@ -38,11 +39,12 @@
- (void)applicationWillEnterForeground:(UIApplication *)application { - (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
[[Captuvo sharedCaptuvoDevice] startDecoderHardware] ; [[Captuvo sharedCaptuvoDevice] startDecoderHardware] ;
[[Captuvo sharedCaptuvoDevice] startPMHardware] ; [[Captuvo sharedCaptuvoDevice] startPMHardware];
} }
- (void)applicationDidBecomeActive:(UIApplication *)application { - (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
} }
- (void)applicationWillTerminate:(UIApplication *)application { - (void)applicationWillTerminate:(UIApplication *)application {
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
NSMutableArray *books = [[NSMutableArray alloc] init]; NSMutableArray *books = [[NSMutableArray alloc] init];
NSArray *results = [parsedObject valueForKey:@"books"]; NSArray *results = [parsedObject valueForKey:@"books"];
NSLog(@"Count %lu", (unsigned long)results.count);
for (NSDictionary *bookDic in results) { for (NSDictionary *bookDic in results) {
Book *book = [[Book alloc] init]; Book *book = [[Book alloc] init];
......
...@@ -13,5 +13,6 @@ ...@@ -13,5 +13,6 @@
@property (weak, nonatomic) IBOutlet UIStepper *sledSoundStepper; @property (weak, nonatomic) IBOutlet UIStepper *sledSoundStepper;
@property (weak, nonatomic) IBOutlet UILabel *sledSoundLabel; @property (weak, nonatomic) IBOutlet UILabel *sledSoundLabel;
@property (weak, nonatomic) IBOutlet UIImageView *batteryView; @property (weak, nonatomic) IBOutlet UIImageView *batteryView;
@property (strong, nonatomic) IBOutlet UISlider *volumeSlider;
@end @end
...@@ -54,6 +54,7 @@ int sled_volume; ...@@ -54,6 +54,7 @@ int sled_volume;
break; break;
} }
self.sledSoundStepper.value = (double)sled_volume; self.sledSoundStepper.value = (double)sled_volume;
self.volumeSlider.value = sled_volume;
} }
/** /**
...@@ -86,6 +87,32 @@ int sled_volume; ...@@ -86,6 +87,32 @@ int sled_volume;
} }
} }
- (IBAction)changeSledVolumeSlider:(id)sender {
sled_volume = (int)lroundf(self.volumeSlider.value);
[self.volumeSlider setValue:sled_volume animated:YES];
switch (sled_volume) {
case 0:
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadBeeperVolume:BeeperVolumeOff persistSetting:YES];
self.sledSoundLabel.text = @"Silent";
break;
case 1:
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadBeeperVolume:BeeperVolumeLow persistSetting:YES];
self.sledSoundLabel.text = @"Low";
break;
case 2:
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadBeeperVolume:BeeperVolumeMedium persistSetting:YES];
self.sledSoundLabel.text = @"Medium";
break;
case 3:
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadBeeperVolume:BeeperVolumeHigh persistSetting:YES];
self.sledSoundLabel.text = @"High";
break;
default:
break;
}
}
/* /*
#pragma mark - Navigation #pragma mark - Navigation
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. // Do any additional setup after loading the view, typically from a nib.
[self initDecoder];
} }
-(void) viewDidAppear:(BOOL)animated { -(void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated]; [super viewDidAppear:animated];
[self initDecoder];
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
...@@ -97,8 +97,6 @@ ...@@ -97,8 +97,6 @@
// codabarOptions.minMessageLength = 4; // codabarOptions.minMessageLength = 4;
// codabarOptions.maxMessageLength = 60; // codabarOptions.maxMessageLength = 60;
// [[Captuvo sharedCaptuvoDevice] setDecoderCodabarConfiguration:codabarOptions persistSetting:NO]; // [[Captuvo sharedCaptuvoDevice] setDecoderCodabarConfiguration:codabarOptions persistSetting:NO];
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadDelayInMilliSeconds:2000 persistSetting:YES];
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
@property(nonatomic, retain) UIWebView *web; @property(nonatomic, retain) UIWebView *web;
@property(nonatomic, assign) bool isInitialized; @property(nonatomic, assign) bool isInitialized;
+(GlobalWebController*) getInstance; + (GlobalWebController*)getInstance;
+(GlobalWebController*) resetInstance; + (GlobalWebController*)resetInstance;
@end @end
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
static GlobalWebController *instance = nil; static GlobalWebController *instance = nil;
+(GlobalWebController*) getInstance + (GlobalWebController*)getInstance
{ {
@synchronized(self) @synchronized(self)
{ {
...@@ -25,7 +25,7 @@ static GlobalWebController *instance = nil; ...@@ -25,7 +25,7 @@ static GlobalWebController *instance = nil;
} }
return instance; return instance;
} }
+(GlobalWebController*) resetInstance + (GlobalWebController*)resetInstance
{ {
@synchronized(self) @synchronized(self)
{ {
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
@property (weak, nonatomic, readonly) UIButton *btnLogIn; @property (weak, nonatomic, readonly) UIButton *btnLogIn;
@property (weak, nonatomic, readwrite) UITextField *txtUsername; @property (weak, nonatomic, readwrite) UITextField *txtUsername;
@property (weak, nonatomic, readwrite) UITextField *txtPassword; @property (weak, nonatomic, readwrite) UITextField *txtPassword;
@property (weak, nonatomic) IBOutlet UISwitch *rememberUsernameSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *rememberPasswordSwitch;
- (IBAction)btnLogInTouch:(id)sender; - (IBAction)btnLogInTouch:(id)sender;
@end @end
...@@ -21,94 +21,69 @@ ...@@ -21,94 +21,69 @@
self.navigationItem.hidesBackButton = YES; self.navigationItem.hidesBackButton = YES;
} }
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidAppear:(BOOL)animated { - (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated]; [super viewDidAppear:animated];
[self resetRTI]; [self resetRTI];
[self checkAndSatisfyUserLoginPreferences];
} }
- (void)webViewDidFinishLoad:(UIWebView *)webView { - (void)webViewDidFinishLoad:(UIWebView *)webView {
NSString *url = [[self.webview request] URL].absoluteString; [self evaluateNextRTIAction:webView];
NSString *base_dest_url;
#ifdef TESTING
base_dest_url = @"http://162.223.19.75";
#else
base_dest_url = @"http://192.168.1.131";
#endif
if ([url isEqualToString:[base_dest_url stringByAppendingString:@"/rti/"]]
|| [url isEqualToString:[base_dest_url stringByAppendingString:@"/rti/RTILogin.aspx"]]) {
NSLog(@"1: %@", url);
}
else if ([url isEqualToString:[base_dest_url stringByAppendingString:@"/rti/RTISetup.aspx?location=1"]]) {
NSLog(@"2: %@", url);
[self performSegueWithIdentifier:@"segueLogIn" sender:nil];
}
//Page handles username/password errors; now handle deeper errors
else {
NSLog(@"3: %@", url);
/*
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"FATAL PAGE ERROR" message:@"Page not recognized, cannot proceed. App will no longer work as expected." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
*/
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"FATAL PAGE ERROR" message:@"Page not recognized, cannot proceed. App will no longer work as expected." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction: ok];
[self presentViewController:alert animated:YES completion:nil];
}
} }
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Navigation
//allow app to flip to upside down // In a storyboard-based application, you will often want to do a little preparation before navigation
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait) // Get the new view controller using [segue destinationViewController].
return YES; // Pass the selected object to the new view controller.
if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
return YES;
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
return NO;
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
return NO;
return NO; // Unknown value
}
-(BOOL)shouldAutorotate {
return YES;
} }
-(NSUInteger)supportedInterfaceOrientations { - (IBAction)prepareForUnwindToLogin:(UIStoryboardSegue *)sender {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
} }
-(IBAction)unwindFromSection:(UIStoryboardSegue *)sender { #pragma mark - Helper Functions
} - (void)checkAndSatisfyUserLoginPreferences {
self.txtPassword.text = @"";
self.txtUsername.text = @"";
-(IBAction)unwindFromScan:(UIStoryboardSegue *)sender { //Set switches, username, password
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if ([prefs boolForKey:@"rememberUsername"]) {
[self.rememberUsernameSwitch setOn:YES];
self.txtUsername.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"usernameString"];
}
if ([prefs boolForKey:@"rememberPassword"]) {
[self.rememberPasswordSwitch setOn:YES];
self.txtPassword.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"passwordString"];
}
} }
- (void)resetRTI {
//Remove delegate from webview
[self.webview setDelegate:nil];
-(void) resetRTI {
//Reset global uiwebview //Reset global uiwebview
GlobalWebController *globalWeb = [GlobalWebController resetInstance]; GlobalWebController *globalWeb = [GlobalWebController resetInstance];
//Create new uiwebview //Create new uiwebview
self.webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; self.webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
//Set global uiwebview = new uiwebview, mark as initialized //Set global uiwebview = new uiwebview, mark as initialized
globalWeb.web = self.webview; globalWeb.web = self.webview;
globalWeb.isInitialized = true; globalWeb.isInitialized = true;
//Set current view as delegate of uiwebview //Set current view as delegate of uiwebview
[self.webview setDelegate:self]; [self.webview setDelegate:self];
//Create URL request for RTI webpage //Create URL request for RTI webpage
NSURLRequest *rti; NSURLRequest *rti;
#ifdef TESTING #ifdef TESTING
...@@ -133,17 +108,63 @@ ...@@ -133,17 +108,63 @@
[self.view addSubview:self.webview]; [self.view addSubview:self.webview];
} }
- (void)evaluateNextRTIAction:(UIWebView *)webView {
NSString *url = [[webView request] URL].absoluteString;
NSString *base_dest_url;
#ifdef TESTING
base_dest_url = @"http://162.223.19.75";
#else
base_dest_url = @"http://192.168.1.131";
#endif
/* if ([url isEqualToString:[base_dest_url stringByAppendingString:@"/rti/"]]) {
#pragma mark - Navigation NSLog(@"0: %@", url);
}
else if ([url isEqualToString:[base_dest_url stringByAppendingString:@"/rti/RTILogin.aspx"]]) {
NSLog(@"1: %@", url);
}
else if ([url isEqualToString:[base_dest_url stringByAppendingString:@"/rti/RTISetup.aspx?location=1"]]) {
NSLog(@"2: %@", url);
// In a storyboard-based application, you will often want to do a little preparation before navigation //Remember username/password if desired
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// Get the new view controller using [segue destinationViewController]. if ([prefs boolForKey:@"rememberUsername"]) {
// Pass the selected object to the new view controller. [prefs setValue:self.txtUsername.text forKey:@"usernameString"];
}
else {
[prefs setValue:@"" forKey:@"usernameString"];
}
[prefs synchronize];
if ([prefs boolForKey:@"rememberPassword"]) {
[prefs setValue:self.txtPassword.text forKey:@"passwordString"];
}
else {
[prefs setValue:@"" forKey:@"passwordString"];
}
[prefs synchronize];
//Segue to section page
[self performSegueWithIdentifier:@"segueLoginToSection" sender:nil];
}
//Page handles username/password errors; now handle deeper errors
else {
NSLog(@"3: %@", url);
/*
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"FATAL PAGE ERROR" message:@"Page not recognized, cannot proceed. App will no longer work as expected." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
*/
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"FATAL PAGE ERROR" message:@"Page not recognized, cannot proceed. App will no longer work as expected." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction: ok];
[self presentViewController:alert animated:YES completion:nil];
}
} }
*/
#pragma mark - UI Buttons
- (IBAction)btnLogInTouch:(id)sender { - (IBAction)btnLogInTouch:(id)sender {
...@@ -168,6 +189,15 @@ ...@@ -168,6 +189,15 @@
NSString *login = [login1 stringByAppendingString:[username stringByAppendingString:[password stringByAppendingString:login2]]]; NSString *login = [login1 stringByAppendingString:[username stringByAppendingString:[password stringByAppendingString:login2]]];
[self.webview stringByEvaluatingJavaScriptFromString:login]; [self.webview stringByEvaluatingJavaScriptFromString:login];
}
- (IBAction)rememberUsernameBtnChanged:(id)sender {
[[NSUserDefaults standardUserDefaults] setBool:self.rememberUsernameSwitch.isOn forKey:@"rememberUsername"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (IBAction)rememberPasswordBtnChanged:(id)sender {
[[NSUserDefaults standardUserDefaults] setBool:self.rememberPasswordSwitch.isOn forKey:@"rememberPassword"];
[[NSUserDefaults standardUserDefaults] synchronize];
} }
@end @end
This diff is collapsed.
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
@interface ScanBookViewController : CaptuvoScannerController<UITableViewDataSource, UITableViewDelegate> @interface ScanBookViewController : CaptuvoScannerController<UITableViewDataSource, UITableViewDelegate>
@property Session *session;