Commit 51bfee04 authored by Alex Moore's avatar Alex Moore

cleaned up error messages, began adding battery monitor for sled, modified...

cleaned up error messages, began adding battery monitor for sled, modified error handling during scanning so that erroneous books highlight in red for easy access.
parent 0da8d5b7
This diff is collapsed.
......@@ -12,5 +12,5 @@
@property (strong, nonatomic) NSString *barcode;
@property (strong, nonatomic) NSString *callnum;
@property (strong, nonatomic) NSString *title;
@property (strong, nonatomic) NSString *error;
@property (strong, nonatomic) NSString *errorMsg;
@end
......@@ -19,7 +19,7 @@
[copy setBarcode:[self.barcode copyWithZone:zone]];
[copy setCallnum:[self.callnum copyWithZone:zone]];
[copy setTitle:[self.title copyWithZone:zone]];
[copy setError:[self.error copyWithZone:zone]];
[copy setErrorMsg:[self.errorMsg copyWithZone:zone]];
}
return copy;
......
......@@ -12,5 +12,6 @@
@property (weak, nonatomic) IBOutlet UIStepper *sledSoundStepper;
@property (weak, nonatomic) IBOutlet UILabel *sledSoundLabel;
@property (weak, nonatomic) IBOutlet UIImageView *batteryView;
@end
......@@ -67,6 +67,15 @@
return NO; // Unknown value
}
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
-(IBAction)unwind:(UIStoryboardSegue *)sender {
//reset UIWebView here
......
This diff is collapsed.
......@@ -21,14 +21,10 @@ static int BOOK_ID_LENGTH = 14;
@property (weak, nonatomic) IBOutlet UIImageView *imgX;
@property (weak, nonatomic) IBOutlet UILabel *lblSection;
@property NSArray *scannedBookList;
@property NSMutableArray *idList;
@property NSMutableArray *callNumList;
@property NSMutableArray *titleList;
@property NSMutableArray *scannedBookList;
@property NSString *lastErrorReceived;
- (IBAction)txtChange:(id)sender;
@end
@implementation ScanBookViewController
......@@ -40,24 +36,18 @@ static int BOOK_ID_LENGTH = 14;
@synthesize imgX;
@synthesize scannedBookList;
@synthesize idList;
@synthesize callNumList;
@synthesize titleList;
@synthesize lastErrorReceived;
- (void)viewDidLoad {
NSLog(@"ScanBook did load");
[super viewDidLoad];
// Do any additional setup after loading the view.
lblSection.text = session.section;
[self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(endEditing:)]];
// SEND SESSION TO RTI
//self.navigationItem.hidesBackButton = YES;
// self.scannedBookList = [[NSMutableArray alloc] init];
// self.idList = [[NSMutableArray alloc] init];
// self.callNumList = [[NSMutableArray alloc] init];
// self.titleList = [[NSMutableArray alloc] init];
self.lastErrorReceived = nil;
self.scannedBookList = [[NSMutableArray alloc] init];
self.scannedBookTableView.delegate = self;
self.scannedBookTableView.dataSource = self;
......@@ -65,24 +55,15 @@ static int BOOK_ID_LENGTH = 14;
}
-(void)viewDidAppear:(BOOL)animated {
NSLog(@"ScanBook did appear");
self.webview = [GlobalWebController getInstance].web;
[self.webview setDelegate:self];
[self.view addSubview:self.webview];
[super viewDidAppear:animated];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"switchOnOff"]) {
[[Captuvo sharedCaptuvoDevice] requestDecoderSerialTriggerTimeoutInMilliSecondsStatus];
[[Captuvo sharedCaptuvoDevice] startDecoderScanning];
}
}
-(void)decoderSerialTriggerTimeoutInMilliSecondsStatus:(int)milliseconds {
//NSString *msg = [[NSString alloc] initWithFormat:@"%ul", milliseconds];
//UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Timeout" message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
//[alert show];
}
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"switchOnOff"]) {
......@@ -114,17 +95,7 @@ static int BOOK_ID_LENGTH = 14;
NSString *error = [webView stringByEvaluatingJavaScriptFromString:getError];
self.view.backgroundColor = [UIColor redColor];
[UIView animateWithDuration:1.0 animations:^{
self.view.backgroundColor = [UIColor whiteColor];
}];
//Remove last scanned item IF list isn't empty
if ([self.scannedBookList count] != 0) {
NSMutableArray *temp = [NSMutableArray arrayWithArray:self.scannedBookList];
[temp removeObjectAtIndex:(NSUInteger)0];
self.scannedBookList = [temp copy];
}
self.lastErrorReceived = error;
// Continue from error page
NSString *goToScanPath =
......@@ -141,7 +112,7 @@ static int BOOK_ID_LENGTH = 14;
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[errorAlert show];
}
//Handle deeper errors
else {
......@@ -195,7 +166,16 @@ static int BOOK_ID_LENGTH = 14;
//TODO + IMPORTANT - will this capture invalid books?
else {
NSLog(@"SUCCESS");
self.scannedBookList = books;
Book *book = [books objectAtIndex:0];
[self.scannedBookList insertObject:book atIndex:0];
//Check if last book had error
if (lastErrorReceived != nil) {
Book *book = [self.scannedBookList objectAtIndex:0];
book.errorMsg = lastErrorReceived;
lastErrorReceived = nil;
}
[self.scannedBookTableView reloadData];
}
}
......@@ -222,6 +202,14 @@ static int BOOK_ID_LENGTH = 14;
return NO; // Unknown value
}
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
......@@ -241,17 +229,33 @@ static int BOOK_ID_LENGTH = 14;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ListPrototypeCell" forIndexPath:indexPath];
// Configure the cell...
Book *book = self.scannedBookList[indexPath.row];
Book *book = [self.scannedBookList objectAtIndex:indexPath.row];
cell.textLabel.text = book.barcode;
if (book.errorMsg != nil) {
cell.contentView.backgroundColor = [UIColor redColor];
cell.textLabel.backgroundColor = [UIColor redColor];
}
else {
cell.contentView.backgroundColor = [UIColor whiteColor];
cell.textLabel.backgroundColor = [UIColor whiteColor];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Book *book = self.scannedBookList[indexPath.row];
NSString *bookID = book.barcode;
NSString *callNum = book.callnum;
NSString *title = book.title;
NSString *message = [NSString stringWithFormat:@"Book ID: %@\nCall Number: %@\nTitle: %@\n", bookID, callNum, title];
NSString *callNum = [book.callnum stringByReplacingOccurrencesOfString:@" " withString:@" "];
NSString *title = [book.title stringByReplacingOccurrencesOfString:@" " withString:@" "];
NSString *errorMsg = book.errorMsg;
NSString *message;
if (errorMsg != nil) {
message = [NSString stringWithFormat:@"Book ID: %@\nCall Number: %@\nTitle: %@\nError: %@", bookID, callNum, title, errorMsg];
}
else {
message = [NSString stringWithFormat:@"Book ID: %@\nCall Number: %@\nTitle: %@\n", bookID, callNum, title];
}
UIAlertView *messageAlert = [[UIAlertView alloc]
initWithTitle:@"Book details" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
......
......@@ -102,8 +102,8 @@
[NSString stringWithContentsOfFile:selectedPath
encoding:NSUTF8StringEncoding
error:nil];
NSString *selected =
[self.webview stringByEvaluatingJavaScriptFromString:selectedFunc];
[self.webview stringByEvaluatingJavaScriptFromString:selectedFunc];
//UIAlertView *selectedAlert =
//[[UIAlertView alloc] initWithTitle:@"Collections Selected"
......@@ -174,6 +174,14 @@
return NO; // Unknown value
}
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
#pragma mark - Table view data source
......
......@@ -28,6 +28,9 @@
NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
[self.switchContScan setOn:[preferences boolForKey:@"switchOnOff"]];
BatteryStatus battery_status = [[Captuvo sharedCaptuvoDevice] getBatteryStatus];
[self displayBatteryStatusIcon:battery_status];
}
- (void)didReceiveMemoryWarning {
......@@ -48,6 +51,48 @@
return NO; // Unknown value
}
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
-(void) displayBatteryStatusIcon:(BatteryStatus)battery_status {
switch (battery_status) {
case BatteryStatus0Of4Bars: {
self.batteryView.image = [UIImage imageNamed:@"battery_discharging_000.png"];
break;
}
case BatteryStatus1Of4Bars: {
self.batteryView.image = [UIImage imageNamed:@"battery_discharging_020.png"];
break;
}
case BatteryStatus2Of4Bars: {
self.batteryView.image = [UIImage imageNamed:@"battery_discharging_060.png"];
break;
}
case BatteryStatus3Of4Bars: {
self.batteryView.image = [UIImage imageNamed:@"battery_discharging_080.png"];
break;
}
case BatteryStatus4Of4Bars: {
self.batteryView.image = [UIImage imageNamed:@"battery_discharging_100.png"];
break;
}
case BatteryStatusPowerSourceConnected: {
self.batteryView.image = [UIImage imageNamed:@"battery_charging_100.png"];
break;
}
case BatteryStatusUndefined: {
self.batteryView.image = [UIImage imageNamed:@"laptop_nobattery_klaptopdaemon.png"];
break;
}
}
}
#pragma mark - Navigation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment