Преглед изворни кода

1.修改Select Mode界面,增加Company标识和Upload Setting按钮。
2.构建Upload Setting界面及业务功能。

Pen Li пре 9 година
родитељ
комит
a47f9c0eb1

+ 2 - 0
RA Image/BasicViewController.m

@@ -93,6 +93,8 @@ NSString *const LogoutNotification = @"LogouNotification";
         [self.currentFirstResponder resignFirstResponder];
         self.currentFirstResponder = nil;
         self.translateY = 0;
+    } else {
+        [self.view endEditing:YES];
     }
 }
 

+ 6 - 0
RA Image/RA Image.xcodeproj/project.pbxproj

@@ -24,6 +24,7 @@
 		42BC2D051EBAC4C00016B30D /* PhotoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BC2D041EBAC4C00016B30D /* PhotoCell.m */; };
 		42BC2D091EBAC75F0016B30D /* TouchImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BC2D081EBAC75F0016B30D /* TouchImageView.m */; };
 		42BC2D0C1EBB00FD0016B30D /* PhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BC2D0B1EBB00FD0016B30D /* PhotoPreviewController.m */; };
+		42BC6FFA1EC1ACF9004A5F30 /* UploadSettingController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BC6FF91EC1ACF9004A5F30 /* UploadSettingController.m */; };
 		42E1B0FD1EB1C8EE00EEF27C /* LoginSwitchCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E1B0FB1EB1C8EE00EEF27C /* LoginSwitchCell.m */; };
 		42E1B0FE1EB1C8EE00EEF27C /* LoginTextFiledCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E1B0FC1EB1C8EE00EEF27C /* LoginTextFiledCell.m */; };
 		42E1B1021EB1C92000EEF27C /* BasicViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E1B1011EB1C92000EEF27C /* BasicViewController.m */; };
@@ -95,6 +96,8 @@
 		42BC2D081EBAC75F0016B30D /* TouchImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TouchImageView.m; sourceTree = "<group>"; };
 		42BC2D0A1EBB00FD0016B30D /* PhotoPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoPreviewController.h; sourceTree = "<group>"; };
 		42BC2D0B1EBB00FD0016B30D /* PhotoPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoPreviewController.m; sourceTree = "<group>"; };
+		42BC6FF81EC1ACF9004A5F30 /* UploadSettingController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UploadSettingController.h; sourceTree = "<group>"; };
+		42BC6FF91EC1ACF9004A5F30 /* UploadSettingController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UploadSettingController.m; sourceTree = "<group>"; };
 		42E1B0F91EB1C8EE00EEF27C /* LoginSwitchCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginSwitchCell.h; sourceTree = "<group>"; };
 		42E1B0FA1EB1C8EE00EEF27C /* LoginTextFiledCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginTextFiledCell.h; sourceTree = "<group>"; };
 		42E1B0FB1EB1C8EE00EEF27C /* LoginSwitchCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginSwitchCell.m; sourceTree = "<group>"; };
@@ -241,6 +244,8 @@
 				42A829CA1EBC6CA200898B8A /* UploadViewController.h */,
 				42A829CB1EBC6CA200898B8A /* UploadViewController.m */,
 				42A829CD1EBC6CA900898B8A /* Upload.storyboard */,
+				42BC6FF81EC1ACF9004A5F30 /* UploadSettingController.h */,
+				42BC6FF91EC1ACF9004A5F30 /* UploadSettingController.m */,
 				42A829CF1EBC6D0F00898B8A /* view */,
 			);
 			name = Upload;
@@ -596,6 +601,7 @@
 				426E6B271EB85C4200942BE1 /* ModelModeViewController.m in Sources */,
 				42A829C71EBC0FAC00898B8A /* ManufacturerCell.m in Sources */,
 				71DCDC3F1EAF234E00BA045A /* RootViewController.m in Sources */,
+				42BC6FFA1EC1ACF9004A5F30 /* UploadSettingController.m in Sources */,
 				42A829C01EBC027100898B8A /* RootNavigationController.m in Sources */,
 				42E1B1081EB1D9B100EEF27C /* LoginSettingViewController.m in Sources */,
 				71114AC81EB1C73B00D2200C /* unzip.c in Sources */,

BIN
RA Image/RA Image.xcodeproj/project.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 28 - 0
RA Image/RA Image.xcodeproj/xcuserdata/macmini1.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -2,4 +2,32 @@
 <Bucket
    type = "1"
    version = "2.0">
+   <Breakpoints>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            scope = "0"
+            stopOnStyle = "0">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "../common/upload/RAUploadManager.m"
+            timestampString = "516013083.763092"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "227"
+            endingLineNumber = "227"
+            landmarkName = "-startTask:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+   </Breakpoints>
 </Bucket>

+ 30 - 7
RA Image/RA Image/AppDelegate.m

@@ -8,6 +8,8 @@
 
 #import "AppDelegate.h"
 #import "LoginViewController.h"
+#import "RootViewController.h"
+#import "UploadSettingController.h"
 
 @interface AppDelegate ()
 
@@ -48,15 +50,35 @@
     [self showLoginVC];
 }
 
-- (void)loadCompanyIcon:(NSString *)url {
-    if (!url.length) return;
+- (void)setCompanyIcon:(UIImage *)companyIcon {
+    _companyIcon = companyIcon;
     __weak typeof(self) weakself = self;
-    dispatch_async(dispatch_get_global_queue(0, 0), ^{
-        UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
-        if (weakself.bLogin) {
-            weakself.companyIcon = img;
-        }
+    dispatch_async(dispatch_get_main_queue(), ^{
+        UINavigationController *nav = (UINavigationController *)weakself.rootVC;
+        RootViewController *rvc = [nav.viewControllers firstObject];
+        [rvc setCompanyIcon:companyIcon];
     });
+
+}
+
+- (void)loadCompanyIcon:(NSString *)url {
+    if (!url.length) return;
+    NSString *name = [url lastPathComponent];
+    NSFileManager *manager = [NSFileManager defaultManager];
+    NSString *path = [[RAUtils appCacheDirectory] stringByAppendingPathComponent:name];
+    if ([manager fileExistsAtPath:path]) {
+        self.companyIcon = [UIImage imageWithContentsOfFile:path];
+    } else {
+        __weak typeof(self) weakself = self;
+        dispatch_async(dispatch_get_global_queue(0, 0), ^{
+            UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
+            if (weakself.bLogin) {
+                weakself.companyIcon = img;
+                [RAUtils saveData:UIImagePNGRepresentation(img) toPath:path];
+            }
+        });
+    }
+    
 }
 
 #pragma mark - Exception
@@ -142,6 +164,7 @@ void UncaughtExceptionHandler(NSException *exception) {
     
     self.uploadManager=[[RAUploadManager alloc] init];
     self.uploadManager.maxRetry = 2;
+    
     return YES;
 }
 

+ 85 - 4
RA Image/RA Image/Base.lproj/Main.storyboard

@@ -39,14 +39,14 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="40" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="qOW-M6-IJk">
-                                <rect key="frame" x="0.0" y="64" width="375" height="603"/>
+                                <rect key="frame" x="0.0" y="135" width="375" height="481"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                 <prototypes>
                                     <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="RootModeCell" rowHeight="40" id="a3Z-Pv-WAq" customClass="RootModeCell">
                                         <rect key="frame" x="0.0" y="28" width="375" height="40"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="a3Z-Pv-WAq" id="KU3-qN-JgJ">
-                                            <rect key="frame" x="0.0" y="0.0" width="375" height="40"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="375" height="39.5"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Mode" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wdD-Sc-rpM">
@@ -73,17 +73,98 @@
                                     <outlet property="delegate" destination="Dtz-oi-w09" id="qej-WZ-udw"/>
                                 </connections>
                             </tableView>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="76b-Zz-kRV">
+                                <rect key="frame" x="0.0" y="64" width="375" height="70"/>
+                                <subviews>
+                                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="jOJ-Py-4V7">
+                                        <rect key="frame" x="10" y="10" width="50" height="50"/>
+                                        <color key="backgroundColor" red="0.0" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="50" id="bmP-nQ-OPw"/>
+                                            <constraint firstAttribute="width" constant="50" id="lZh-XL-7AP"/>
+                                        </constraints>
+                                    </imageView>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Npd" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jih-EZ-3Hj">
+                                        <rect key="frame" x="70" y="25" width="295" height="20"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="20" id="qYa-PP-rUN"/>
+                                        </constraints>
+                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                        <nil key="textColor"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
+                                </subviews>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                <constraints>
+                                    <constraint firstItem="jih-EZ-3Hj" firstAttribute="leading" secondItem="jOJ-Py-4V7" secondAttribute="trailing" constant="10" id="BPG-R3-znz"/>
+                                    <constraint firstAttribute="height" constant="70" id="InE-Jf-NGV"/>
+                                    <constraint firstItem="jOJ-Py-4V7" firstAttribute="top" secondItem="76b-Zz-kRV" secondAttribute="top" constant="10" id="LrP-ye-G0Q"/>
+                                    <constraint firstAttribute="trailing" secondItem="jih-EZ-3Hj" secondAttribute="trailing" constant="10" id="QNz-Zn-cTs"/>
+                                    <constraint firstItem="jOJ-Py-4V7" firstAttribute="leading" secondItem="76b-Zz-kRV" secondAttribute="leading" constant="10" id="hKT-Gc-IXr"/>
+                                    <constraint firstItem="jih-EZ-3Hj" firstAttribute="centerY" secondItem="jOJ-Py-4V7" secondAttribute="centerY" id="wxs-cU-63N"/>
+                                </constraints>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="U7i-RF-fNv">
+                                <rect key="frame" x="0.0" y="132" width="375" height="1"/>
+                                <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="0.5" id="BoU-iz-Rb0"/>
+                                </constraints>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="I9R-Zj-mk5">
+                                <rect key="frame" x="0.0" y="616" width="375" height="1"/>
+                                <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="0.5" id="s2D-BK-xN7"/>
+                                </constraints>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TfJ-sO-Wub">
+                                <rect key="frame" x="0.0" y="617" width="375" height="50"/>
+                                <subviews>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="I2w-Kd-8pR">
+                                        <rect key="frame" x="10" y="8.5" width="110" height="33"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                        <state key="normal" title="upload setting">
+                                            <color key="titleColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                        </state>
+                                        <state key="highlighted" title="upload setting"/>
+                                        <connections>
+                                            <action selector="uploadSettingBtnClick:" destination="Dtz-oi-w09" eventType="touchUpInside" id="oev-bL-zCh"/>
+                                        </connections>
+                                    </button>
+                                </subviews>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="50" id="hxt-9M-1T4"/>
+                                    <constraint firstItem="I2w-Kd-8pR" firstAttribute="centerY" secondItem="TfJ-sO-Wub" secondAttribute="centerY" id="vmW-3d-58x"/>
+                                    <constraint firstItem="I2w-Kd-8pR" firstAttribute="leading" secondItem="TfJ-sO-Wub" secondAttribute="leading" constant="10" id="wso-GZ-lSI"/>
+                                </constraints>
+                            </view>
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                         <constraints>
-                            <constraint firstItem="X0p-Er-QSV" firstAttribute="top" secondItem="qOW-M6-IJk" secondAttribute="bottom" id="IQH-Kk-j6U"/>
+                            <constraint firstAttribute="bottom" secondItem="TfJ-sO-Wub" secondAttribute="bottom" id="17k-AL-bPf"/>
+                            <constraint firstItem="TfJ-sO-Wub" firstAttribute="leading" secondItem="0cG-hA-GsV" secondAttribute="leading" id="DHk-0v-LNU"/>
+                            <constraint firstItem="I9R-Zj-mk5" firstAttribute="width" secondItem="TfJ-sO-Wub" secondAttribute="width" id="G7R-Lf-7r1"/>
+                            <constraint firstItem="qOW-M6-IJk" firstAttribute="top" secondItem="76b-Zz-kRV" secondAttribute="bottom" constant="1" id="IKq-f3-3C9"/>
+                            <constraint firstAttribute="trailing" secondItem="76b-Zz-kRV" secondAttribute="trailing" id="QGk-4V-qOB"/>
+                            <constraint firstItem="U7i-RF-fNv" firstAttribute="leading" secondItem="76b-Zz-kRV" secondAttribute="leading" id="e40-iU-EoT"/>
+                            <constraint firstItem="76b-Zz-kRV" firstAttribute="leading" secondItem="0cG-hA-GsV" secondAttribute="leading" id="eXT-Ew-DCY"/>
+                            <constraint firstAttribute="trailing" secondItem="TfJ-sO-Wub" secondAttribute="trailing" id="iBQ-rl-Ihk"/>
                             <constraint firstAttribute="trailing" secondItem="qOW-M6-IJk" secondAttribute="trailing" id="jxV-4b-nO7"/>
-                            <constraint firstItem="qOW-M6-IJk" firstAttribute="top" secondItem="qba-7X-gfw" secondAttribute="bottom" id="pB3-QS-V6Y"/>
+                            <constraint firstItem="I9R-Zj-mk5" firstAttribute="top" secondItem="TfJ-sO-Wub" secondAttribute="top" constant="-1" id="khb-wd-8tZ"/>
+                            <constraint firstItem="U7i-RF-fNv" firstAttribute="bottom" secondItem="76b-Zz-kRV" secondAttribute="bottom" constant="-1" id="ocf-gQ-IUN"/>
+                            <constraint firstItem="76b-Zz-kRV" firstAttribute="top" secondItem="qba-7X-gfw" secondAttribute="bottom" id="qpe-mG-XQC"/>
+                            <constraint firstItem="I9R-Zj-mk5" firstAttribute="leading" secondItem="TfJ-sO-Wub" secondAttribute="leading" id="se4-kr-7RF"/>
+                            <constraint firstItem="TfJ-sO-Wub" firstAttribute="top" secondItem="qOW-M6-IJk" secondAttribute="bottom" constant="1" id="uaP-Zb-zmr"/>
                             <constraint firstItem="qOW-M6-IJk" firstAttribute="leading" secondItem="0cG-hA-GsV" secondAttribute="leading" id="vgN-vX-TtL"/>
+                            <constraint firstItem="U7i-RF-fNv" firstAttribute="width" secondItem="76b-Zz-kRV" secondAttribute="width" id="zm7-mY-DJF"/>
                         </constraints>
                     </view>
                     <navigationItem key="navigationItem" id="OjN-Xn-Hk9"/>
                     <connections>
+                        <outlet property="companyIconView" destination="jOJ-Py-4V7" id="1Lr-g6-MVb"/>
+                        <outlet property="companyNameLabel" destination="jih-EZ-3Hj" id="uH7-PA-U0N"/>
                         <outlet property="modeTable" destination="qOW-M6-IJk" id="ZxK-nd-nZ7"/>
                     </connections>
                 </viewController>

+ 73 - 2
RA Image/RA Image/ModelModeViewController.m

@@ -11,6 +11,7 @@
 #import <AVFoundation/AVFoundation.h>
 #import <AssetsLibrary/AssetsLibrary.h>
 #import "ManufacturerListController.h"
+#import "UploadViewController.h"
 
 @interface ModelModeViewController ()<UITextViewDelegate>
 
@@ -37,7 +38,6 @@
     self.noteTextView.layer.borderWidth = 1.0f;    
     [self registListenKeyboard];
     
-//    self.manufacturerList = @[@"New Pacific Direct,inc",@"HMLG",@"Red Ant",@"Facebook"]; // Test Value
 }
 
 
@@ -47,6 +47,14 @@
     // Dispose of any resources that can be recreated.
 }
 
+- (void)clear {
+    self.barcode = nil;
+    self.manufacturer = nil;
+    self.noteTextView.text = @"Note:";
+    [self.imgBtn setBackgroundImage:nil forState:UIControlStateNormal];
+    [self clearPhotos];
+}
+
 #pragma mark - Button Action
 
 - (IBAction)imgBtnClick:(UIButton *)sender {
@@ -75,7 +83,67 @@
 }
 
 - (IBAction)uploadBtnClick:(id)sender {
-    self.barcodeLabel.text = @"upl";
+    if(self.barcode.length ==0)
+    {
+        [RAUtils message_alert:@"Barcode cann't be blank" title:@"Warning" controller:self];
+        return;
+    }
+    if(self.photos.count ==0)
+    {
+        [RAUtils message_alert:@"You must take at least one photo." title:@"Warning" controller:self];
+        return;
+    }
+    AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
+    
+    
+    
+    //prepare upload
+    NSMutableArray* tasks = [NSMutableArray new];
+    
+    for(NSMutableDictionary* photo in self.photos)
+    {
+        
+        NSMutableDictionary* task=[[NSMutableDictionary alloc]init];
+        
+        
+        task[@"path"]=self.name;
+        task[@"file"]=photo[@"file"];
+        
+        task[@"url"]=Appdelegate.address;
+        NSString *md5 = [photo objectForKey:@"md5"];
+        NSString *manufacturer = self.manufacturer;
+        NSString *note = self.noteTextView.text;
+        if (!manufacturer.length) {
+            manufacturer = @"";
+        }
+        if (!note.length) {
+            note = @"";
+        }
+        
+        NSDictionary* params = @{
+                                 @"user" : Appdelegate.user,
+                                 @"password" : Appdelegate.password,
+                                 @"mode":self.name,
+                                 @"barcode":self.barcode,
+                                 @"manufacturer":manufacturer,
+                                 @"note":note,
+                                 @"_operate":@"upload",
+                                 @"platform":@"ios",
+                                 @"md5":md5
+                                 };
+        task[@"params"]=params;
+        [tasks addObject:task];
+        
+    }
+    
+    
+    //    // add upload tasks;
+    [Appdelegate.uploadManager addTasks:tasks];
+    
+    [self clear];
+    
+    UploadViewController *upVC = (UploadViewController *)[self viewControllerInStoryboard:@"Upload" withId:@"UploadViewController"];
+    [self.navigationController pushViewController:upVC animated:YES];
 }
 - (IBAction)typeBtnClick:(UIButton *)sender {
     [self showBarcodeInput];
@@ -102,6 +170,9 @@
 
 - (void)setBarcode:(NSString *)barcode {
     [super setBarcode:barcode];
+    if (!barcode) {
+        barcode = @"";
+    }
     self.barcodeLabel.text = [NSString stringWithFormat:@"%@:%@",self.barcodeTitle,barcode];
 }
 

+ 1 - 0
RA Image/RA Image/RootViewController.h

@@ -10,6 +10,7 @@
 
 @interface RootViewController : BasicViewController
 
+@property (nonatomic,strong) UIImage *companyIcon;
 
 @end
 

+ 44 - 24
RA Image/RA Image/RootViewController.m

@@ -11,11 +11,13 @@
 #import "RootModeCell.h"
 #import "PopModeViewController.h"
 #import "ModelModeViewController.h"
+#import "UploadSettingController.h"
 
 static NSString *kLastMode = @"lastChooseMode";
 
 @interface RootViewController ()<UITableViewDelegate,UITableViewDataSource>
-
+@property (strong, nonatomic) IBOutlet UILabel *companyNameLabel;
+@property (strong, nonatomic) IBOutlet UIImageView *companyIconView;
 @property (strong, nonatomic) IBOutlet UITableView *modeTable;
 @property (nonatomic,strong) NSArray *modeList;
 @property (nonatomic,assign) NSInteger lastChoosedIndex;
@@ -35,7 +37,7 @@ static NSString *kLastMode = @"lastChooseMode";
 
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStylePlain target:self action:@selector(logoutItemClick:)];
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-    self.title = appDelegate.companyName;
+    self.title = @"Select Mode";
     self.modeList = appDelegate.modeList;
     self.modeTable.tableFooterView = [UIView new];
     
@@ -46,6 +48,8 @@ static NSString *kLastMode = @"lastChooseMode";
     [super viewWillAppear:animated];
     
     [self.modeTable reloadData];
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    self.companyNameLabel.text = appDelegate.companyName;
 }
 
 - (void)viewDidAppear:(BOOL)animated {
@@ -66,6 +70,8 @@ static NSString *kLastMode = @"lastChooseMode";
             [self tableView:self.modeTable didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:self.lastChoosedIndex inSection:0]];
         }
     }
+    [self setUserDefaultsValue:nil forKey:kLastMode];
+    self.lastChoosedIndex = -1;
 }
 
 
@@ -74,28 +80,9 @@ static NSString *kLastMode = @"lastChooseMode";
     // Dispose of any resources that can be recreated.
 }
 
-- (void)logoutItemClick:(UIBarButtonItem *)sender {
-    UIAlertView *alert = [RAUtils waiting_alert:@"Please wait..." title:@"Logout"];
-    __weak typeof(self) weakself = self;
-    dispatch_async(dispatch_get_main_queue(), ^{
-        
-        NSDictionary *logoutDic = [RAINetwork logout];
-        int result = [[logoutDic objectForKey:@"result"] intValue];
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [alert dismissWithClickedButtonIndex:0 animated:YES];
-            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-            if (result == RESULT_TRUE) {
-                [appDelegate logout];
-            } else {
-               __strong typeof(weakself) strongself = weakself;
-                NSString *msg = [logoutDic objectForKey:@"err_msg"];
-                [RAUtils message_alert:msg title:@"Warning" controller:strongself];
-            }
-        });
-
-        
-    });
-
+- (void)setCompanyIcon:(UIImage *)companyIcon {
+    _companyIcon = companyIcon;
+    self.companyIconView.image = companyIcon;
 }
 
 #pragma mark - DataSource
@@ -176,5 +163,38 @@ static NSString *kLastMode = @"lastChooseMode";
     [super userLogout:notification];
 }
 
+#pragma mark - Action
+
+- (void)logoutItemClick:(UIBarButtonItem *)sender {
+    UIAlertView *alert = [RAUtils waiting_alert:@"Please wait..." title:@"Logout"];
+    __weak typeof(self) weakself = self;
+    dispatch_async(dispatch_get_main_queue(), ^{
+        
+        NSDictionary *logoutDic = [RAINetwork logout];
+        int result = [[logoutDic objectForKey:@"result"] intValue];
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [alert dismissWithClickedButtonIndex:0 animated:YES];
+            AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+            if (result == RESULT_TRUE) {
+                [appDelegate logout];
+            } else {
+                __strong typeof(weakself) strongself = weakself;
+                NSString *msg = [logoutDic objectForKey:@"err_msg"];
+                [RAUtils message_alert:msg title:@"Warning" controller:strongself];
+            }
+        });
+        
+        
+    });
+    
+}
+
+- (IBAction)uploadSettingBtnClick:(UIButton *)sender {
+    
+    UploadSettingController *ups = (UploadSettingController *)[self viewControllerInStoryboard:@"Upload" withId:@"UploadSettingController"];
+    [self.navigationController pushViewController:ups animated:YES];
+    
+}
+
 
 @end

+ 78 - 11
RA Image/RA Image/Upload.storyboard

@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
-    <device id="retina5_5" orientation="landscape">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
         <deployment identifier="iOS"/>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
+        <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -18,26 +19,26 @@
                         <viewControllerLayoutGuide type="bottom" id="Lf0-ZV-MXy"/>
                     </layoutGuides>
                     <view key="view" contentMode="scaleToFill" id="aIg-QL-Ze6">
-                        <rect key="frame" x="0.0" y="0.0" width="736" height="414"/>
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="g67-RH-bZN">
-                                <rect key="frame" x="0.0" y="20" width="736" height="394"/>
+                                <rect key="frame" x="0.0" y="20" width="375" height="647"/>
                                 <subviews>
                                     <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="80" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="u4f-TD-M09">
-                                        <rect key="frame" x="0.0" y="0.0" width="736" height="394"/>
+                                        <rect key="frame" x="0.0" y="0.0" width="375" height="647"/>
                                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                         <inset key="separatorInset" minX="10" minY="0.0" maxX="0.0" maxY="0.0"/>
                                         <prototypes>
                                             <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="UploadCell" rowHeight="80" id="p1C-Cy-yXq" customClass="UploadCell">
-                                                <rect key="frame" x="0.0" y="28" width="736" height="80"/>
+                                                <rect key="frame" x="0.0" y="28" width="375" height="80"/>
                                                 <autoresizingMask key="autoresizingMask"/>
                                                 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="p1C-Cy-yXq" id="tdd-mO-6vJ">
-                                                    <rect key="frame" x="0.0" y="0.0" width="736" height="80"/>
+                                                    <rect key="frame" x="0.0" y="0.0" width="375" height="80"/>
                                                     <autoresizingMask key="autoresizingMask"/>
                                                     <subviews>
                                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="QS8884456999666666" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0VW-ZZ-YcB">
-                                                            <rect key="frame" x="10" y="5" width="716" height="20"/>
+                                                            <rect key="frame" x="10" y="5" width="355" height="20"/>
                                                             <constraints>
                                                                 <constraint firstAttribute="height" constant="20" id="bKP-Fo-NMF"/>
                                                             </constraints>
@@ -46,13 +47,13 @@
                                                             <nil key="highlightedColor"/>
                                                         </label>
                                                         <progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="NYs-S2-H37">
-                                                            <rect key="frame" x="10" y="37.333333333333336" width="716" height="5"/>
+                                                            <rect key="frame" x="10" y="37.5" width="355" height="5"/>
                                                             <constraints>
                                                                 <constraint firstAttribute="height" constant="5" id="QYr-rE-zSp"/>
                                                             </constraints>
                                                         </progressView>
                                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="99.9%" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8Qr-iv-UsW">
-                                                            <rect key="frame" x="676" y="52.333333333333329" width="50" height="20.999999999999986"/>
+                                                            <rect key="frame" x="315" y="52.5" width="50" height="21"/>
                                                             <constraints>
                                                                 <constraint firstAttribute="height" constant="21" id="8Tc-O3-69h"/>
                                                                 <constraint firstAttribute="width" constant="50" id="ljZ-ci-ehG"/>
@@ -62,7 +63,7 @@
                                                             <nil key="highlightedColor"/>
                                                         </label>
                                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Waiting" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DED-nv-Rm5">
-                                                            <rect key="frame" x="10" y="52.333333333333329" width="656" height="20.999999999999986"/>
+                                                            <rect key="frame" x="10" y="52.5" width="295" height="21"/>
                                                             <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                                             <nil key="textColor"/>
                                                             <nil key="highlightedColor"/>
@@ -123,5 +124,71 @@
             </objects>
             <point key="canvasLocation" x="-585" y="-38"/>
         </scene>
+        <!--Upload Setting Controller-->
+        <scene sceneID="lRS-zE-FWM">
+            <objects>
+                <viewController storyboardIdentifier="UploadSettingController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="rW7-Ba-NwZ" customClass="UploadSettingController" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="8l0-nk-W7m"/>
+                        <viewControllerLayoutGuide type="bottom" id="mVA-99-yPO"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="Zq9-4p-vj6">
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PZj-IO-85H">
+                                <rect key="frame" x="284" y="52" width="51" height="31"/>
+                                <connections>
+                                    <action selector="autoSwitchValueChange:" destination="rW7-Ba-NwZ" eventType="valueChanged" id="TwI-KM-Q5h"/>
+                                </connections>
+                            </switch>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Auto Start Upload" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uVx-M4-Qy4">
+                                <rect key="frame" x="16" y="52" width="237" height="31"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="31" id="qFQ-tt-giY"/>
+                                </constraints>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Max Retry Count" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="I3J-dT-AiE">
+                                <rect key="frame" x="16" y="116" width="237" height="31"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="HEJ-Eh-vI4">
+                                <rect key="frame" x="284" y="116" width="49" height="31"/>
+                                <nil key="textColor"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <textInputTraits key="textInputTraits" keyboardType="numberPad"/>
+                            </textField>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                        <constraints>
+                            <constraint firstItem="PZj-IO-85H" firstAttribute="top" secondItem="uVx-M4-Qy4" secondAttribute="top" id="1CF-Sg-YfU"/>
+                            <constraint firstAttribute="trailingMargin" secondItem="PZj-IO-85H" secondAttribute="trailing" constant="26" id="7bo-vv-OW6"/>
+                            <constraint firstItem="I3J-dT-AiE" firstAttribute="top" secondItem="uVx-M4-Qy4" secondAttribute="bottom" constant="33" id="GLg-mZ-edl"/>
+                            <constraint firstAttribute="leadingMargin" secondItem="uVx-M4-Qy4" secondAttribute="leading" id="Ka9-Iq-uvp"/>
+                            <constraint firstItem="I3J-dT-AiE" firstAttribute="height" secondItem="uVx-M4-Qy4" secondAttribute="height" id="NI9-6j-y0f"/>
+                            <constraint firstItem="PZj-IO-85H" firstAttribute="leading" secondItem="uVx-M4-Qy4" secondAttribute="trailing" constant="31" id="Vzf-9z-cAO"/>
+                            <constraint firstItem="HEJ-Eh-vI4" firstAttribute="leading" secondItem="PZj-IO-85H" secondAttribute="leading" id="Zc0-sx-Stz"/>
+                            <constraint firstItem="uVx-M4-Qy4" firstAttribute="top" secondItem="8l0-nk-W7m" secondAttribute="bottom" constant="32" id="aVf-kB-5t2"/>
+                            <constraint firstItem="I3J-dT-AiE" firstAttribute="leading" secondItem="uVx-M4-Qy4" secondAttribute="leading" id="aVx-QK-TDV"/>
+                            <constraint firstItem="HEJ-Eh-vI4" firstAttribute="width" secondItem="PZj-IO-85H" secondAttribute="width" id="iC1-8X-ikq"/>
+                            <constraint firstItem="HEJ-Eh-vI4" firstAttribute="height" secondItem="I3J-dT-AiE" secondAttribute="height" id="ite-dz-SB3"/>
+                            <constraint firstItem="PZj-IO-85H" firstAttribute="height" secondItem="uVx-M4-Qy4" secondAttribute="height" id="pDj-6j-QwR"/>
+                            <constraint firstItem="HEJ-Eh-vI4" firstAttribute="top" secondItem="I3J-dT-AiE" secondAttribute="top" id="y2V-7s-eKO"/>
+                        </constraints>
+                    </view>
+                    <connections>
+                        <outlet property="autoSwitch" destination="PZj-IO-85H" id="Nyl-DU-coe"/>
+                        <outlet property="retryCountBox" destination="HEJ-Eh-vI4" id="O5k-Ja-8k2"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="mh9-70-UUG" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="312.80000000000001" y="-38.23088455772114"/>
+        </scene>
     </scenes>
 </document>

+ 15 - 0
RA Image/RA Image/UploadSettingController.h

@@ -0,0 +1,15 @@
+//
+//  UploadSettingController.h
+//  RA Image
+//
+//  Created by Jack on 2017/5/9.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "BasicViewController.h"
+
+extern NSString *const kUploadSetting;
+
+@interface UploadSettingController : BasicViewController
+
+@end

+ 74 - 0
RA Image/RA Image/UploadSettingController.m

@@ -0,0 +1,74 @@
+//
+//  UploadSettingController.m
+//  RA Image
+//
+//  Created by Jack on 2017/5/9.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "UploadSettingController.h"
+#import "RAUploadManager.h"
+
+NSString *const kUploadSetting = @"UploadSettingKey";
+
+@interface UploadSettingController ()
+
+@property (strong, nonatomic) IBOutlet UISwitch *autoSwitch;
+@property (strong, nonatomic) IBOutlet UITextField *retryCountBox;
+
+@end
+
+@implementation UploadSettingController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    
+    UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(saveItemClick:)];
+    self.navigationItem.rightBarButtonItem = saveItem;
+    
+    BOOL autoUpload = YES;
+    int retryCount = 2;
+    NSDictionary *param = [self userDefaultsValue:kUploadSetting];
+    if (param) {
+        autoUpload = [[param objectForKey:@"auto_upload"] boolValue];
+        retryCount = [[param objectForKey:@"retry_count"] intValue];
+        
+    } else {
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        autoUpload = appDelegate.uploadManager.autoStart;
+        retryCount = appDelegate.uploadManager.maxRetry;
+    }
+    self.autoSwitch.on = autoUpload;
+    self.retryCountBox.text = [NSString stringWithFormat:@"%d",retryCount];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+#pragma mark - Action
+
+- (IBAction)autoSwitchValueChange:(UISwitch *)sender {
+    
+}
+
+- (void)saveItemClick:(UIBarButtonItem *)sender {
+    BOOL autoUpload = self.autoSwitch.isOn;
+    int retryCount = [self.retryCountBox.text intValue];
+    
+    NSDictionary *param = @{
+                            @"auto_upload" : @(autoUpload),
+                            @"retry_count" : @(retryCount)
+                            };
+    [self setUserDefaultsValue:param forKey:kUploadSetting];
+    
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    appDelegate.uploadManager.maxRetry = retryCount;
+    appDelegate.uploadManager.autoStart = autoUpload;
+    
+    [self.navigationController popViewControllerAnimated:YES];
+}
+
+@end