Commit 99c7d060 authored by Alex Moore's avatar Alex Moore
Browse files

finished up some quick UI changes, fixed login page bugs, handled timeout...

finished up some quick UI changes, fixed login page bugs, handled timeout while app is inactive, or while on settings page.
parent 4b18b9f3
......@@ -10,7 +10,6 @@
@interface CaptuvoOptionsController : CaptuvoViewController
@property (weak, nonatomic) IBOutlet UIStepper *sledSoundStepper;
@property (weak, nonatomic) IBOutlet UILabel *sledSoundLabel;
@property (weak, nonatomic) IBOutlet UIImageView *batteryView;
@property (strong, nonatomic) IBOutlet UISlider *volumeSlider;
......
......@@ -14,8 +14,6 @@
@implementation CaptuvoOptionsController
int sled_volume;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
......@@ -33,79 +31,87 @@ int sled_volume;
*/
- (void)decoderGoodReadBeeperVolumeStatus:(BeeperVolume)volume
{
float sled_volume;
switch (volume) {
case BeeperVolumeHigh:
sled_volume = 3;
self.sledSoundLabel.text = @"High";
sled_volume = 3.0;
self.sledSoundLabel.text = @"Sled Volume: High";
break;
case BeeperVolumeMedium:
sled_volume = 2;
self.sledSoundLabel.text = @"Medium";
sled_volume = 2.0;
self.sledSoundLabel.text = @"Sled Volume: Medium";
break;
case BeeperVolumeLow:
sled_volume = 1;
self.sledSoundLabel.text = @"Low";
sled_volume = 1.0;
self.sledSoundLabel.text = @"Sled Volume: Low";
break;
case BeeperVolumeOff:
sled_volume = 0;
self.sledSoundLabel.text = @"Silent";
sled_volume = 0.0;
self.sledSoundLabel.text = @"Sled Volume: Silent";
break;
default:
sled_volume = 0.0;
self.sledSoundLabel.text = @"Sled Volume: Unknown";
break;
}
self.sledSoundStepper.value = (double)sled_volume;
//self.sledSoundStepper.value = (double)sled_volume;
self.volumeSlider.value = sled_volume;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
#pragma mark - UI Buttons
/**
@brief This method changes the sled volume between high, medium, low, and silent.
@param (id)sender - tied to button
@return IBAction - tied to button
*/
- (IBAction)changeSledVolume:(id)sender {
sled_volume = (int)self.sledSoundStepper.value;
switch (sled_volume) {
- (IBAction)changeSledVolumeSlider:(id)sender {
float sled_volume = lroundf(self.volumeSlider.value);
[self.volumeSlider setValue:sled_volume animated:NO];
switch ((int)sled_volume) {
case 0:
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadBeeperVolume:BeeperVolumeOff persistSetting:YES];
self.sledSoundLabel.text = @"Silent";
self.sledSoundLabel.text = @"Sled Volume: Silent";
break;
case 1:
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadBeeperVolume:BeeperVolumeLow persistSetting:YES];
self.sledSoundLabel.text = @"Low";
self.sledSoundLabel.text = @"Sled Volume: Low";
break;
case 2:
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadBeeperVolume:BeeperVolumeMedium persistSetting:YES];
self.sledSoundLabel.text = @"Medium";
self.sledSoundLabel.text = @"Sled Volume: Medium";
break;
case 3:
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadBeeperVolume:BeeperVolumeHigh persistSetting:YES];
self.sledSoundLabel.text = @"High";
self.sledSoundLabel.text = @"Sled Volume: High";
break;
default:
break;
}
}
- (IBAction)changeSledVolumeSlider:(id)sender {
sled_volume = (int)lroundf(self.volumeSlider.value);
[self.volumeSlider setValue:sled_volume animated:YES];
switch (sled_volume) {
- (IBAction)changeSledVolume:(id)sender {
float sled_volume = lroundf(self.volumeSlider.value);
switch ((int)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;
......@@ -113,14 +119,5 @@ int sled_volume;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
......@@ -10,9 +10,10 @@
#import "WebViewController.h"
@interface LogInViewController : WebViewController
@property (weak, nonatomic, readonly) UIButton *btnLogIn;
@property (weak, nonatomic, readwrite) UITextField *txtUsername;
@property (weak, nonatomic, readwrite) UITextField *txtPassword;
@property (strong, nonatomic) IBOutlet UIButton *btnLogIn;
@property (strong, nonatomic) IBOutlet UITextField *txtUsername;
@property (strong, nonatomic) IBOutlet UITextField *txtPassword;
@property (weak, nonatomic) IBOutlet UISwitch *rememberUsernameSwitch;
@property (weak, nonatomic) IBOutlet UISwitch *rememberPasswordSwitch;
......
......@@ -26,12 +26,21 @@
// Dispose of any resources that can be recreated.
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self checkAndSatisfyUserLoginPreferences];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
//Disable login button
[self.btnLogIn setEnabled:NO];
[self resetRTI];
[self checkAndSatisfyUserLoginPreferences];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[self evaluateNextRTIAction:webView];
}
......@@ -63,10 +72,15 @@
if ([prefs boolForKey:@"rememberUsername"]) {
[self.rememberUsernameSwitch setOn:YES];
self.txtUsername.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"usernameString"];
//Password only remembered if remembering username
if ([prefs boolForKey:@"rememberPassword"]) {
[self.rememberPasswordSwitch setOn:YES];
self.txtPassword.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"passwordString"];
}
}
if ([prefs boolForKey:@"rememberPassword"]) {
[self.rememberPasswordSwitch setOn:YES];
self.txtPassword.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"passwordString"];
else {
[self.rememberUsernameSwitch setOn:NO];
[self.rememberPasswordSwitch setOn:NO];
}
}
......@@ -122,6 +136,8 @@
}
else if ([url isEqualToString:[base_dest_url stringByAppendingString:@"/rti/RTILogin.aspx"]]) {
NSLog(@"1: %@", url);
//Enable login button
[self.btnLogIn setEnabled:YES];
}
else if ([url isEqualToString:[base_dest_url stringByAppendingString:@"/rti/RTISetup.aspx?location=1"]]) {
NSLog(@"2: %@", url);
......@@ -130,17 +146,17 @@
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if ([prefs boolForKey:@"rememberUsername"]) {
[prefs setValue:self.txtUsername.text forKey:@"usernameString"];
//Only remember password if remembering username
if ([prefs boolForKey:@"rememberPassword"]) {
[prefs setValue:self.txtPassword.text forKey:@"passwordString"];
}
else {
[prefs setValue:@"" forKey:@"passwordString"];
}
}
else {
[prefs setValue:@"" forKey:@"usernameString"];
}
[prefs synchronize];
if ([prefs boolForKey:@"rememberPassword"]) {
[prefs setValue:self.txtPassword.text forKey:@"passwordString"];
}
else {
[prefs setValue:@"" forKey:@"passwordString"];
[prefs setValue:nil forKey:@"usernameString"];
[prefs setValue:nil forKey:@"passwordString"];
}
[prefs synchronize];
......@@ -154,7 +170,7 @@
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];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"FATAL PAGE ERROR" message:@"Page not recognized, cannot proceed. Please try again in a moment; if problem persists, app may be broken." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
......@@ -193,11 +209,20 @@
- (IBAction)rememberUsernameBtnChanged:(id)sender {
[[NSUserDefaults standardUserDefaults] setBool:self.rememberUsernameSwitch.isOn forKey:@"rememberUsername"];
if (!self.rememberUsernameSwitch.isOn) {
[self.rememberPasswordSwitch setOn:NO animated:YES];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"rememberPassword"];
}
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (IBAction)rememberPasswordBtnChanged:(id)sender {
[[NSUserDefaults standardUserDefaults] setBool:self.rememberPasswordSwitch.isOn forKey:@"rememberPassword"];
[[NSUserDefaults standardUserDefaults] synchronize];
if (self.rememberUsernameSwitch.isOn) {
[[NSUserDefaults standardUserDefaults] setBool:self.rememberPasswordSwitch.isOn forKey:@"rememberPassword"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
else {
[self.rememberPasswordSwitch setOn:NO animated:YES];
}
}
@end
......@@ -34,11 +34,6 @@
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="u4E-6x-G9M">
<rect key="frame" x="110" y="212" width="474" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" secureTextEntry="YES"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rr9-HZ-Pee">
<rect key="frame" x="541" y="250" width="43" height="30"/>
<state key="normal" title="Log In">
......@@ -78,6 +73,11 @@
<action selector="rememberUsernameBtnChanged:" destination="BYZ-38-t0r" eventType="valueChanged" id="zWq-ZI-h8E"/>
</connections>
</switch>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="u4E-6x-G9M">
<rect key="frame" x="110" y="212" width="474" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" secureTextEntry="YES"/>
</textField>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
......@@ -108,10 +108,11 @@
</view>
<navigationItem key="navigationItem" title="PLUC Inventory Log-In" id="MTF-s9-qJz"/>
<connections>
<outlet property="btnLogIn" destination="rr9-HZ-Pee" id="XcP-d1-QuV"/>
<outlet property="rememberPasswordSwitch" destination="IYZ-Af-OWK" id="GBs-XC-YPI"/>
<outlet property="rememberUsernameSwitch" destination="jIg-lr-y4q" id="QpB-mO-Ut7"/>
<outlet property="txtPassword" destination="u4E-6x-G9M" id="sbx-w0-Hox"/>
<outlet property="txtUsername" destination="rFc-Xp-Oik" id="Q9Z-xl-cFg"/>
<outlet property="txtPassword" destination="u4E-6x-G9M" id="YvX-QY-C8K"/>
<outlet property="txtUsername" destination="rFc-Xp-Oik" id="c0A-p5-UcP"/>
<segue destination="Feu-98-wZh" kind="show" identifier="segueLoginToSection" id="mO8-qi-2TI"/>
</connections>
</viewController>
......@@ -206,22 +207,6 @@
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="2" maximumValue="4" translatesAutoresizingMaskIntoConstraints="NO" id="Unv-hz-Ovj">
<rect key="frame" x="253" y="290" width="94" height="29"/>
<connections>
<action selector="changeSledVolume:" destination="SAZ-ry-SGT" eventType="valueChanged" id="rBB-T2-ktI"/>
</connections>
</stepper>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sled Volume:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="K8q-Hx-Op6">
<rect key="frame" x="248" y="209" width="104" height="29"/>
<constraints>
<constraint firstAttribute="width" constant="104" id="1Fc-25-pGZ"/>
<constraint firstAttribute="height" constant="29" id="n8h-M2-Qhp"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<navigationBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UYK-DH-1XM">
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<items>
......@@ -243,67 +228,63 @@
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="6U7-zs-UVI">
<rect key="frame" x="250" y="411" width="100" height="100"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="T7b-O1-nHT"/>
<constraint firstAttribute="width" constant="100" id="Fv8-Wh-2zF"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sled Battery Level:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oGF-ud-951">
<rect key="frame" x="228" y="374" width="145" height="29"/>
<constraints>
<constraint firstAttribute="height" constant="29" id="fZg-Yx-fsJ"/>
<constraint firstAttribute="height" constant="29" id="Uka-kA-2UE"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Volume Level" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QRZ-Sy-r8t">
<rect key="frame" x="360" y="206" width="105" height="36"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sled Volume: Unknown" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="K8q-Hx-Op6">
<rect key="frame" x="210" y="232" width="181" height="29"/>
<constraints>
<constraint firstAttribute="width" constant="105" id="Hwg-Vb-I4V"/>
<constraint firstAttribute="height" constant="36" id="lZ0-Hs-HRh"/>
<constraint firstAttribute="width" constant="181" id="Cb4-EW-Wvh"/>
<constraint firstAttribute="height" constant="29" id="SAY-Jw-iMU"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1.5" minValue="0.0" maxValue="3" translatesAutoresizingMaskIntoConstraints="NO" id="SFu-zW-Gfv">
<rect key="frame" x="241" y="327" width="118" height="31"/>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="0.0" maxValue="3" translatesAutoresizingMaskIntoConstraints="NO" id="SFu-zW-Gfv">
<rect key="frame" x="168" y="269" width="265" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="114" id="3gL-A0-R7z"/>
<constraint firstAttribute="width" constant="261" id="FLb-IP-0SV"/>
</constraints>
<connections>
<action selector="changeSledVolumeSlider:" destination="SAZ-ry-SGT" eventType="touchUpInside" id="k1T-Gx-zrc"/>
<action selector="changeSledVolume:" destination="SAZ-ry-SGT" eventType="touchUpInside" id="5PG-sV-ozd"/>
<action selector="changeSledVolumeSlider:" destination="SAZ-ry-SGT" eventType="valueChanged" id="prZ-UA-uiC"/>
</connections>
</slider>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="UYK-DH-1XM" secondAttribute="trailing" id="0GR-iz-ezH"/>
<constraint firstItem="NbJ-uH-v6R" firstAttribute="top" secondItem="UYK-DH-1XM" secondAttribute="bottom" constant="58" id="0S8-oT-d7W"/>
<constraint firstItem="oGF-ud-951" firstAttribute="top" secondItem="SFu-zW-Gfv" secondAttribute="bottom" constant="17" id="6t7-1v-fkL"/>
<constraint firstItem="6gf-v9-uSr" firstAttribute="top" secondItem="NbJ-uH-v6R" secondAttribute="bottom" constant="8" symbolic="YES" id="AfP-qn-l0G"/>
<constraint firstItem="QRZ-Sy-r8t" firstAttribute="leading" secondItem="K8q-Hx-Op6" secondAttribute="trailing" constant="8" symbolic="YES" id="BlY-Fz-AXF"/>
<constraint firstItem="oGF-ud-951" firstAttribute="centerX" secondItem="6U7-zs-UVI" secondAttribute="centerX" id="EgQ-vG-afY"/>
<constraint firstItem="SFu-zW-Gfv" firstAttribute="centerX" secondItem="Unv-hz-Ovj" secondAttribute="centerX" id="Oi6-6P-IUt"/>
<constraint firstItem="SFu-zW-Gfv" firstAttribute="top" secondItem="Unv-hz-Ovj" secondAttribute="bottom" constant="8" symbolic="YES" id="RSg-l4-EY4"/>
<constraint firstItem="NbJ-uH-v6R" firstAttribute="centerX" secondItem="UYK-DH-1XM" secondAttribute="centerX" id="VTh-j5-L8H"/>
<constraint firstItem="Unv-hz-Ovj" firstAttribute="top" secondItem="K8q-Hx-Op6" secondAttribute="bottom" constant="52" id="YmZ-qf-jlU"/>
<constraint firstItem="NbJ-uH-v6R" firstAttribute="centerX" secondItem="6gf-v9-uSr" secondAttribute="centerX" id="cNb-cC-78G"/>
<constraint firstItem="6gf-v9-uSr" firstAttribute="centerX" secondItem="K8q-Hx-Op6" secondAttribute="centerX" id="cgs-UA-UuY"/>
<constraint firstItem="UYK-DH-1XM" firstAttribute="leading" secondItem="eDN-A7-E2u" secondAttribute="leading" id="hlH-7x-nrQ"/>
<constraint firstItem="UYK-DH-1XM" firstAttribute="top" secondItem="eDN-A7-E2u" secondAttribute="top" id="hzb-6i-Oes"/>
<constraint firstItem="oGF-ud-951" firstAttribute="centerX" secondItem="SFu-zW-Gfv" secondAttribute="centerX" id="jGM-zs-Kgo"/>
<constraint firstItem="6U7-zs-UVI" firstAttribute="top" secondItem="oGF-ud-951" secondAttribute="bottom" constant="8" symbolic="YES" id="nad-ec-ngh"/>
<constraint firstItem="K8q-Hx-Op6" firstAttribute="centerX" secondItem="Unv-hz-Ovj" secondAttribute="centerX" id="pEf-WW-Gcz"/>
<constraint firstItem="QRZ-Sy-r8t" firstAttribute="top" secondItem="NbJ-uH-v6R" secondAttribute="bottom" constant="83" id="ptu-HK-7xN"/>
<constraint firstItem="Obq-NZ-uqV" firstAttribute="top" secondItem="6U7-zs-UVI" secondAttribute="bottom" constant="89" id="rWt-IO-5qa"/>
<constraint firstItem="K8q-Hx-Op6" firstAttribute="top" secondItem="6gf-v9-uSr" secondAttribute="bottom" constant="47" id="tTm-Z8-yuZ"/>
<constraint firstItem="NbJ-uH-v6R" firstAttribute="centerX" secondItem="UYK-DH-1XM" secondAttribute="centerX" id="01s-cy-Pv8"/>
<constraint firstItem="SFu-zW-Gfv" firstAttribute="top" secondItem="K8q-Hx-Op6" secondAttribute="bottom" constant="8" symbolic="YES" id="0he-xh-RAB"/>
<constraint firstItem="oGF-ud-951" firstAttribute="centerX" secondItem="SFu-zW-Gfv" secondAttribute="centerX" id="7ga-bV-UGy"/>
<constraint firstItem="6U7-zs-UVI" firstAttribute="top" secondItem="oGF-ud-951" secondAttribute="bottom" constant="8" symbolic="YES" id="AQR-jm-n8Y"/>
<constraint firstItem="K8q-Hx-Op6" firstAttribute="top" secondItem="6gf-v9-uSr" secondAttribute="bottom" constant="70" id="GhO-II-ZnL"/>
<constraint firstItem="K8q-Hx-Op6" firstAttribute="centerX" secondItem="6gf-v9-uSr" secondAttribute="centerX" id="KoH-yZ-7Sz"/>
<constraint firstItem="oGF-ud-951" firstAttribute="top" secondItem="SFu-zW-Gfv" secondAttribute="bottom" constant="75" id="M7i-WI-3et"/>
<constraint firstItem="6U7-zs-UVI" firstAttribute="centerX" secondItem="oGF-ud-951" secondAttribute="centerX" id="PYa-tE-Exu"/>
<constraint firstItem="UYK-DH-1XM" firstAttribute="leading" secondItem="eDN-A7-E2u" secondAttribute="leading" id="PZi-Vs-zxa"/>
<constraint firstItem="6gf-v9-uSr" firstAttribute="top" secondItem="NbJ-uH-v6R" secondAttribute="bottom" constant="8" symbolic="YES" id="R6z-rv-ikI"/>
<constraint firstItem="NbJ-uH-v6R" firstAttribute="centerX" secondItem="6gf-v9-uSr" secondAttribute="centerX" id="SiB-nV-ceR"/>
<constraint firstItem="Obq-NZ-uqV" firstAttribute="top" secondItem="6U7-zs-UVI" secondAttribute="bottom" constant="89" id="bR9-Ir-44H"/>
<constraint firstItem="UYK-DH-1XM" firstAttribute="top" secondItem="eDN-A7-E2u" secondAttribute="top" id="dzp-ez-Yeh"/>
<constraint firstAttribute="trailing" secondItem="UYK-DH-1XM" secondAttribute="trailing" id="jBz-Ah-kYH"/>
<constraint firstItem="K8q-Hx-Op6" firstAttribute="centerX" secondItem="SFu-zW-Gfv" secondAttribute="centerX" id="kc3-hZ-mI9"/>
<constraint firstItem="NbJ-uH-v6R" firstAttribute="top" secondItem="UYK-DH-1XM" secondAttribute="bottom" constant="58" id="zmD-gQ-XyV"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="Settings" id="fve-mW-VnO"/>
<connections>
<outlet property="batteryView" destination="6U7-zs-UVI" id="azj-7s-oGQ"/>
<outlet property="sledSoundLabel" destination="QRZ-Sy-r8t" id="tp0-l2-mEe"/>
<outlet property="sledSoundStepper" destination="Unv-hz-Ovj" id="Zip-QH-U3h"/>
<outlet property="sledSoundLabel" destination="K8q-Hx-Op6" id="dIy-Qo-gPe"/>
<outlet property="switchContScan" destination="6gf-v9-uSr" id="rXm-pX-KXM"/>
<outlet property="volumeSlider" destination="SFu-zW-Gfv" id="hBv-nh-aH7"/>
<segue destination="Wc8-sq-8Gc" kind="unwind" identifier="segueSettingsToScan" unwindAction="prepareForUnwindFromSettings:" id="sQW-SB-ZnG"/>
......
......@@ -21,7 +21,6 @@
@property (weak, nonatomic) IBOutlet UILabel *lblSection;
@property NSArray *scannedBookList;
@property NSString *lastErrorReceived;
- (IBAction)txtChange:(id)sender;
@end
......@@ -24,7 +24,6 @@ static int BOOK_ID_LENGTH = 14;
@synthesize session;
@synthesize lblSection;
@synthesize scannedBookList;
@synthesize lastErrorReceived;
- (void)viewDidLoad {
[super viewDidLoad];
......@@ -34,7 +33,6 @@ static int BOOK_ID_LENGTH = 14;
//self.navigationItem.hidesBackButton = YES;
[self initializeScanPage];
}
- (void)didReceiveMemoryWarning {
......@@ -42,19 +40,30 @@ static int BOOK_ID_LENGTH = 14;
// Dispose of any resources that can be recreated.
}
-(void)viewDidAppear:(BOOL)animated {
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSString *url = [[self.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/Default.aspx"]]) {
NSLog(@"Timed out!");
[self performSegueWithIdentifier:@"segueScanToLogin" sender:nil];
}
[self checkContScanning];
}
-(void)viewWillDisappear:(BOOL)animated {
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"switchOnOff"]) {
[[Captuvo sharedCaptuvoDevice] stopDecoderScanning];
}
}
-(void) webViewDidFinishLoad:(UIWebView *)webView {
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[self evaluateNextRTIAction:webView];
}
......@@ -72,7 +81,6 @@ static int BOOK_ID_LENGTH = 14;
return [self.scannedBookList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ListPrototypeCell" forIndexPath:indexPath];
......@@ -93,16 +101,12 @@ static int BOOK_ID_LENGTH = 14;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Book *book = self.scannedBookList[indexPath.row];
NSString *bookID = book.barcode;
NSString *callNum = [book.callnum stringByReplacingOccurrencesOfString:@"&nbsp;" withString:@" "];
NSString *title = book.title;
NSString *errorMsg = book.error;
NSString *message;
if (errorMsg != nil) {
message = [NSString stringWithFormat:@"Book ID: %@\nCall Number: %@\nTitle: %@\nError: %@", bookID, callNum, title, errorMsg];
if (book.error != nil) {
message = [NSString stringWithFormat:@"Book ID:\n%@\n\nCall Number:\n%@\n\nTitle:\n%@\n\nError:\n%@", book.barcode, book.callnum, book.title, book.error];
}
else {
message = [NSString stringWithFormat:@"Book ID: %@\nCall Number: %@\nTitle: %@\n", bookID, callNum, title];
message = [NSString stringWithFormat:@"Book ID:\n%@\n\nCall Number:\n%@\n\nTitle:\n%@", book.barcode, book.callnum, book.title];
}
/*
UIAlertView *messageAlert = [[UIAlertView alloc]
......@@ -130,7 +134,7 @@ static int BOOK_ID_LENGTH = 14;
}
-(IBAction)prepareForUnwindFromSettings:(UIStoryboardSegue *)sender {
- (IBAction)prepareForUnwindFromSettings:(UIStoryboardSegue *)sender {
}
......@@ -148,8 +152,8 @@ static int BOOK_ID_LENGTH = 14;
- (void)initializeScanPage {
lblSection.text = session.section;
self.lastErrorReceived = nil;
//Check if continuous scanning enabled when returning from deactive (home)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(checkContScanning)
name:UIApplicationDidBecomeActiveNotification object:nil];
......@@ -164,8 +168,8 @@ static int BOOK_ID_LENGTH = 14;
- (void)checkContScanning {
BOOL enableContScanning = [[NSUserDefaults standardUserDefaults] boolForKey:@"switchOnOff"];
if (enableContScanning) {
[[Captuvo sharedCaptuvoDevice] startDecoderScanning];
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadDelayInMilliSeconds:1500 persistSetting:NO];
[[Captuvo sharedCaptuvoDevice] startDecoderScanning];
}
else {
[[Captuvo sharedCaptuvoDevice] setDecoderGoodReadDelayInMilliSeconds:500 persistSetting:NO];
......@@ -188,7 +192,7 @@ static int BOOK_ID_LENGTH = 14;
}
else if ([url isEqualToString:[base_dest_url stringByAppendingString:@"/rti/RTIScan.aspx?location=1"]]) {
NSLog(@"1: %@", url);
[self updateScanHistory:YES];
[self updateScanHistory];
}
else if ([url isEqualToString:[base_dest_url stringByAppendingString:@"/rti/RTIAction.aspx?location=1"]]) {
NSLog(@"2: %@", url);
......@@ -204,7 +208,7 @@ static int BOOK_ID_LENGTH = 14;
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];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"FATAL PAGE ERROR" message:@"Page not recognized, cannot proceed. Please try again in a moment; if problem persists, app may be broken." preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
......@@ -222,19 +226,6 @@ static int BOOK_ID_LENGTH = 14;
error:nil];
NSString *error = [webView stringByEvaluatingJavaScriptFromString:getError];
NSLog(@"%@", error);
//Isolate error message
//NSRegularExpression *errorRegex = [[NSRegularExpression alloc] initWithPattern:@"(.*),(.*),(.*)" options:0 error:nil];
//NSTextCheckingResult *match = [errorRegex firstMatchInString:error options:0 range:NSMakeRange(0, [error length])];
//NSString *bookID = [error substringWithRange:[match rangeAtIndex:1]];
//NSString *title = [error substringWithRange:[match rangeAtIndex:2]];
//NSString *errorMsg = [error substringWithRange:[match rangeAtIndex:3]];
//error = [NSString stringWithFormat:@"Book ID: %@\nTitle: %@\nError: %@", bookID, title, errorMsg];
//self.lastErrorReceived = errorMsg;
self.lastErrorReceived = error;
// Continue from error page
NSString *goToScanPath =
......@@ -253,9 +244,24 @@ static int BOOK_ID_LENGTH = 14;
[errorAlert show];
*/
//Parse error
NSArray *components = [error componentsSeparatedByString:@","];
NSString *callnum = components[0];
NSString *barcode = components[1];
NSString *errorMsg = components[2];
//If error has commas internally, parse here
if ([components count] > 3) {
for (NSString *component in [components subarrayWithRange:NSMakeRange(3, [components count]-3)]) {
errorMsg = [errorMsg stringByAppendingString:component];
}