فهرست منبع

1.修改RA Image增加网络状态监测。

Pen Li 8 سال پیش
والد
کامیت
d0a81d55d7

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

@@ -16,6 +16,7 @@
 		428566D51EF1220F0041208A /* NewPhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 428566D41EF1220F0041208A /* NewPhotoPreviewController.m */; };
 		428566D81EF122360041208A /* PhotoPreviewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 428566D71EF122360041208A /* PhotoPreviewCell.m */; };
 		429F25221EC9AA4200C22ABB /* TakePhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 429F25211EC9AA4200C22ABB /* TakePhotoPreviewController.m */; };
+		42A0E02A1F1D98970020BFC6 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42A0E0291F1D98970020BFC6 /* SystemConfiguration.framework */; };
 		42A829C01EBC027100898B8A /* RootNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42A829BF1EBC027100898B8A /* RootNavigationController.m */; };
 		42A829C31EBC0F8300898B8A /* ManufacturerListController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42A829C21EBC0F8300898B8A /* ManufacturerListController.m */; };
 		42A829C71EBC0FAC00898B8A /* ManufacturerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42A829C61EBC0FAC00898B8A /* ManufacturerCell.m */; };
@@ -88,6 +89,8 @@
 		428566D71EF122360041208A /* PhotoPreviewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoPreviewCell.m; sourceTree = "<group>"; };
 		429F25201EC9AA4200C22ABB /* TakePhotoPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TakePhotoPreviewController.h; sourceTree = "<group>"; };
 		429F25211EC9AA4200C22ABB /* TakePhotoPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TakePhotoPreviewController.m; sourceTree = "<group>"; };
+		42A0E0291F1D98970020BFC6 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
+		42A0E02B1F1D98D20020BFC6 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
 		42A829BE1EBC027100898B8A /* RootNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootNavigationController.h; sourceTree = "<group>"; };
 		42A829BF1EBC027100898B8A /* RootNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootNavigationController.m; sourceTree = "<group>"; };
 		42A829C11EBC0F8300898B8A /* ManufacturerListController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ManufacturerListController.h; sourceTree = "<group>"; };
@@ -193,6 +196,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				42A0E02A1F1D98970020BFC6 /* SystemConfiguration.framework in Frameworks */,
 				71114ACC1EB1C76E00D2200C /* libz.tbd in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -446,6 +450,8 @@
 		71114ACA1EB1C76E00D2200C /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				42A0E02B1F1D98D20020BFC6 /* CoreGraphics.framework */,
+				42A0E0291F1D98970020BFC6 /* SystemConfiguration.framework */,
 				71114ACB1EB1C76E00D2200C /* libz.tbd */,
 			);
 			name = Frameworks;

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


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

@@ -2,22 +2,4 @@
 <Bucket
    type = "1"
    version = "2.0">
-   <Breakpoints>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            shouldBeEnabled = "No"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "../common/upload/RANetworkTaskDelegate.m"
-            timestampString = "517385396.33492"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "83"
-            endingLineNumber = "83"
-            landmarkName = "-URLSession:task:didCompleteWithError:"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-   </Breakpoints>
 </Bucket>

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

@@ -24,6 +24,7 @@
 - (void)clearPhotos;
 - (void)showTopImage;
 - (void)moveTmpImageToCache:(NSString *)img;
+- (BOOL)shouldUploadWithCurrentNerworkStatus;
 #pragma mark - 需要子类重写
 - (void)receiveImage:(UIImage *)img;
 

+ 8 - 0
RA Image/RA Image/BasicModeViewController.m

@@ -388,6 +388,14 @@
     }
 }
 
+- (BOOL)shouldUploadWithCurrentNerworkStatus {
+    AppDelegate* appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
+    if (appdelegate.uploadManager.onlyWiFi && appdelegate.uploadManager.reach.currentReachabilityStatus != ReachableViaWiFi) {
+        return NO;
+    }
+    return YES;
+}
+
 #pragma mark - Image Picker Button Action
 
 - (void)cancelCameraClick:(UIButton *)sender {

+ 6 - 0
RA Image/RA Image/ModelModeViewController.m

@@ -87,6 +87,12 @@
 }
 
 - (IBAction)uploadBtnClick:(id)sender {
+    
+    if (![self shouldUploadWithCurrentNerworkStatus]) {
+        [self.view makeToast:@"Current network is not WiFi" duration:3.0 position:CSToastPositionCenter];
+        return;
+    }
+    
     if(self.barcode.length ==0)
     {
         [RAUtils message_alert:[NSString stringWithFormat:@"%@ cann't be blank",self.barcodeTitle] title:@"Warning" controller:self];

+ 5 - 0
RA Image/RA Image/PopModeViewController.m

@@ -63,6 +63,11 @@
 
 - (IBAction)uploadBtnClick:(UIButton *)sender {
     
+    if (![self shouldUploadWithCurrentNerworkStatus]) {
+        [self.view makeToast:@"Current network is not WiFi" duration:3.0 position:CSToastPositionCenter];
+        return;
+    }
+    
     // check piid, photo...
     if(self.barcode.length ==0)
     {

+ 50 - 27
RA Image/RA Image/Upload.storyboard

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <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">
+    <device id="retina5_5" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
@@ -19,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="375" height="667"/>
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
                         <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="375" height="647"/>
+                                <rect key="frame" x="0.0" y="20" width="414" height="716"/>
                                 <subviews>
                                     <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="100" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="u4f-TD-M09">
-                                        <rect key="frame" x="0.0" y="0.0" width="375" height="647"/>
+                                        <rect key="frame" x="0.0" y="0.0" width="414" height="716"/>
                                         <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="100" id="p1C-Cy-yXq" customClass="UploadCell">
-                                                <rect key="frame" x="0.0" y="28" width="375" height="100"/>
+                                                <rect key="frame" x="0.0" y="28" width="414" height="100"/>
                                                 <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="375" height="100"/>
+                                                    <rect key="frame" x="0.0" y="0.0" width="414" height="100"/>
                                                     <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="355" height="20"/>
+                                                            <rect key="frame" x="10" y="5" width="394" height="20"/>
                                                             <constraints>
                                                                 <constraint firstAttribute="height" constant="20" id="bKP-Fo-NMF"/>
                                                             </constraints>
@@ -47,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="35" width="355" height="5"/>
+                                                            <rect key="frame" x="10" y="35" width="394" 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="315" y="45" width="50" height="21"/>
+                                                            <rect key="frame" x="354" y="45" width="50" height="21"/>
                                                             <constraints>
                                                                 <constraint firstAttribute="height" constant="21" id="8Tc-O3-69h"/>
                                                                 <constraint firstAttribute="width" constant="50" id="ljZ-ci-ehG"/>
@@ -63,13 +63,13 @@
                                                             <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="45" width="295" height="21"/>
+                                                            <rect key="frame" x="10" y="45" width="334" height="21"/>
                                                             <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                                             <nil key="textColor"/>
                                                             <nil key="highlightedColor"/>
                                                         </label>
                                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Error:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AOp-qH-n4C">
-                                                            <rect key="frame" x="10" y="71" width="355" height="17"/>
+                                                            <rect key="frame" x="10" y="71" width="394" height="17"/>
                                                             <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                                             <nil key="textColor"/>
                                                             <nil key="highlightedColor"/>
@@ -143,17 +143,17 @@
                         <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"/>
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
                         <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"/>
+                                <rect key="frame" x="319" 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"/>
+                                <rect key="frame" x="20" y="52" width="268" height="31"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="31" id="qFQ-tt-giY"/>
                                 </constraints>
@@ -162,37 +162,37 @@
                                 <nil key="highlightedColor"/>
                             </label>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Max Retry Count" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="I3J-dT-AiE">
-                                <rect key="frame" x="16" y="215.5" width="237" height="31"/>
+                                <rect key="frame" x="20" y="261.66666666666669" width="268" height="31"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
                             <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FYV-4e-6Ap">
-                                <rect key="frame" x="284" y="93" width="51" height="31"/>
+                                <rect key="frame" x="319" y="93" width="51" height="31"/>
                                 <connections>
                                     <action selector="autoRmFinishClick:" destination="rW7-Ba-NwZ" eventType="valueChanged" id="8Bw-uk-9Do"/>
                                 </connections>
                             </switch>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Auto Remove Finish" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Zr-Ac-9Ae">
-                                <rect key="frame" x="16" y="93" width="237" height="31"/>
+                                <rect key="frame" x="20" y="93" width="268" height="31"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
                             <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gOA-fB-4s1">
-                                <rect key="frame" x="284" y="134" width="51" height="31"/>
+                                <rect key="frame" x="319" y="134" width="51" height="31"/>
                                 <connections>
                                     <action selector="autoRmErrClick:" destination="rW7-Ba-NwZ" eventType="valueChanged" id="KtW-o9-qW6"/>
                                 </connections>
                             </switch>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Auto Remove Error" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lG4-HU-q7O">
-                                <rect key="frame" x="16" y="134" width="237" height="31"/>
+                                <rect key="frame" x="20" y="134" width="268" 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="215.5" width="49" height="31"/>
+                                <rect key="frame" x="319" y="261.66666666666669" width="49" height="31"/>
                                 <nil key="textColor"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                 <textInputTraits key="textInputTraits" keyboardType="numberPad"/>
@@ -201,47 +201,69 @@
                                 </connections>
                             </textField>
                             <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZKg-aU-mIC">
-                                <rect key="frame" x="284" y="175" width="51" height="31"/>
+                                <rect key="frame" x="319" y="175" width="51" height="31"/>
                                 <connections>
                                     <action selector="autoRmErrClick:" destination="rW7-Ba-NwZ" eventType="valueChanged" id="j2v-FC-9dI"/>
                                     <action selector="compressSwitchClick:" destination="rW7-Ba-NwZ" eventType="valueChanged" id="7It-Um-Jee"/>
                                 </connections>
                             </switch>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Compress Image" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="13k-tQ-BSv">
-                                <rect key="frame" x="16" y="180" width="129.5" height="20.5"/>
+                                <rect key="frame" x="20" y="180" width="129.66666666666666" height="20.666666666666657"/>
                                 <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" text="Only Use The WiFi" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9mp-ot-ria">
+                                <rect key="frame" x="20" y="215.66666666666666" width="268" height="31"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pSj-dG-qXr">
+                                <rect key="frame" x="319" y="215.66666666666666" width="51" height="31"/>
+                                <connections>
+                                    <action selector="autoRmErrClick:" destination="rW7-Ba-NwZ" eventType="valueChanged" id="djr-GE-iLI"/>
+                                    <action selector="compressSwitchClick:" destination="rW7-Ba-NwZ" eventType="valueChanged" id="Zg7-r2-eDx"/>
+                                </connections>
+                            </switch>
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                         <constraints>
+                            <constraint firstItem="pSj-dG-qXr" firstAttribute="width" secondItem="ZKg-aU-mIC" secondAttribute="width" id="0eG-Fh-0QA"/>
                             <constraint firstItem="5Zr-Ac-9Ae" firstAttribute="top" secondItem="uVx-M4-Qy4" secondAttribute="bottom" constant="10" id="2oq-dc-wzL"/>
                             <constraint firstItem="13k-tQ-BSv" firstAttribute="top" secondItem="lG4-HU-q7O" secondAttribute="bottom" constant="15" id="3l1-3S-bZz"/>
                             <constraint firstItem="gOA-fB-4s1" firstAttribute="leading" secondItem="FYV-4e-6Ap" secondAttribute="leading" id="5jc-nd-fCa"/>
+                            <constraint firstItem="pSj-dG-qXr" firstAttribute="top" secondItem="9mp-ot-ria" secondAttribute="top" id="6dw-j4-tn9"/>
                             <constraint firstItem="FYV-4e-6Ap" firstAttribute="leading" secondItem="PZj-IO-85H" secondAttribute="leading" id="7Vf-0z-Ijh"/>
                             <constraint firstAttribute="trailingMargin" secondItem="PZj-IO-85H" secondAttribute="trailing" constant="26" id="7bo-vv-OW6"/>
-                            <constraint firstItem="I3J-dT-AiE" firstAttribute="leading" secondItem="lG4-HU-q7O" secondAttribute="leading" id="7vL-et-gIa"/>
+                            <constraint firstItem="9mp-ot-ria" firstAttribute="height" secondItem="lG4-HU-q7O" secondAttribute="height" id="A7P-Ky-Xf3"/>
                             <constraint firstItem="lG4-HU-q7O" firstAttribute="height" secondItem="5Zr-Ac-9Ae" secondAttribute="height" id="CWZ-uW-HAw"/>
                             <constraint firstItem="5Zr-Ac-9Ae" firstAttribute="height" secondItem="uVx-M4-Qy4" secondAttribute="height" id="CvC-FX-OHH"/>
-                            <constraint firstItem="I3J-dT-AiE" firstAttribute="top" secondItem="13k-tQ-BSv" secondAttribute="bottom" constant="15" id="E4d-jg-ezx"/>
+                            <constraint firstItem="pSj-dG-qXr" firstAttribute="height" secondItem="ZKg-aU-mIC" secondAttribute="height" id="ERz-NS-CbM"/>
+                            <constraint firstItem="pSj-dG-qXr" firstAttribute="leading" secondItem="ZKg-aU-mIC" secondAttribute="leading" id="Ecj-cf-DyC"/>
                             <constraint firstItem="ZKg-aU-mIC" firstAttribute="centerY" secondItem="13k-tQ-BSv" secondAttribute="centerY" id="G5E-v9-6Fa"/>
                             <constraint firstItem="13k-tQ-BSv" firstAttribute="leading" secondItem="lG4-HU-q7O" secondAttribute="leading" id="Gje-d8-QLD"/>
                             <constraint firstItem="FYV-4e-6Ap" firstAttribute="height" secondItem="PZj-IO-85H" secondAttribute="height" id="HBu-2m-WlK"/>
+                            <constraint firstItem="9mp-ot-ria" firstAttribute="leading" secondItem="13k-tQ-BSv" secondAttribute="leading" id="IiS-ub-QCx"/>
                             <constraint firstItem="lG4-HU-q7O" firstAttribute="leading" secondItem="5Zr-Ac-9Ae" secondAttribute="leading" id="ItV-fy-FwH"/>
                             <constraint firstAttribute="leadingMargin" secondItem="uVx-M4-Qy4" secondAttribute="leading" id="Ka9-Iq-uvp"/>
                             <constraint firstItem="HEJ-Eh-vI4" firstAttribute="height" secondItem="gOA-fB-4s1" secondAttribute="height" id="NM8-u8-jta"/>
+                            <constraint firstItem="9mp-ot-ria" firstAttribute="width" secondItem="lG4-HU-q7O" secondAttribute="width" id="Qi4-64-gDh"/>
+                            <constraint firstItem="9mp-ot-ria" firstAttribute="top" secondItem="13k-tQ-BSv" secondAttribute="bottom" constant="15" id="RXW-aO-3lO"/>
                             <constraint firstItem="FYV-4e-6Ap" firstAttribute="width" secondItem="PZj-IO-85H" secondAttribute="width" id="Uoh-7Q-2ek"/>
                             <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="top" secondItem="I3J-dT-AiE" secondAttribute="top" id="aD3-c9-GaE"/>
                             <constraint firstItem="uVx-M4-Qy4" firstAttribute="top" secondItem="8l0-nk-W7m" secondAttribute="bottom" constant="32" id="aVf-kB-5t2"/>
                             <constraint firstItem="5Zr-Ac-9Ae" firstAttribute="width" secondItem="uVx-M4-Qy4" secondAttribute="width" id="bal-FY-Ct5"/>
-                            <constraint firstItem="HEJ-Eh-vI4" firstAttribute="centerY" secondItem="I3J-dT-AiE" secondAttribute="centerY" id="cRH-a8-dSK"/>
-                            <constraint firstItem="I3J-dT-AiE" firstAttribute="width" secondItem="lG4-HU-q7O" secondAttribute="width" id="dyG-F0-Vmd"/>
+                            <constraint firstItem="I3J-dT-AiE" firstAttribute="top" secondItem="9mp-ot-ria" secondAttribute="bottom" constant="15" id="csP-fg-iDf"/>
+                            <constraint firstItem="I3J-dT-AiE" firstAttribute="width" secondItem="9mp-ot-ria" secondAttribute="width" id="dMq-mX-UG5"/>
                             <constraint firstItem="HEJ-Eh-vI4" firstAttribute="leading" secondItem="gOA-fB-4s1" secondAttribute="leading" id="e3N-xS-gDH"/>
                             <constraint firstItem="HEJ-Eh-vI4" firstAttribute="width" secondItem="gOA-fB-4s1" secondAttribute="width" id="f20-8E-4h4"/>
-                            <constraint firstItem="I3J-dT-AiE" firstAttribute="height" secondItem="lG4-HU-q7O" secondAttribute="height" id="he9-5F-FKV"/>
+                            <constraint firstItem="HEJ-Eh-vI4" firstAttribute="leading" secondItem="pSj-dG-qXr" secondAttribute="leading" id="jS2-Bl-NWa"/>
+                            <constraint firstItem="I3J-dT-AiE" firstAttribute="height" secondItem="9mp-ot-ria" secondAttribute="height" id="oAY-mc-aaO"/>
                             <constraint firstItem="PZj-IO-85H" firstAttribute="height" secondItem="uVx-M4-Qy4" secondAttribute="height" id="pDj-6j-QwR"/>
                             <constraint firstItem="ZKg-aU-mIC" firstAttribute="leading" secondItem="gOA-fB-4s1" secondAttribute="leading" id="pjc-md-epB"/>
+                            <constraint firstItem="I3J-dT-AiE" firstAttribute="leading" secondItem="9mp-ot-ria" secondAttribute="leading" id="qpf-ne-VUI"/>
                             <constraint firstItem="PZj-IO-85H" firstAttribute="centerY" secondItem="uVx-M4-Qy4" secondAttribute="centerY" id="sNt-TE-Wt7"/>
                             <constraint firstItem="lG4-HU-q7O" firstAttribute="top" secondItem="5Zr-Ac-9Ae" secondAttribute="bottom" constant="10" id="tha-TB-ufH"/>
                             <constraint firstItem="gOA-fB-4s1" firstAttribute="centerY" secondItem="lG4-HU-q7O" secondAttribute="centerY" id="w7n-jz-bfA"/>
@@ -257,6 +279,7 @@
                         <outlet property="autoRmFinishSwitch" destination="FYV-4e-6Ap" id="eTP-xV-a6u"/>
                         <outlet property="autoSwitch" destination="PZj-IO-85H" id="Nyl-DU-coe"/>
                         <outlet property="compressSwitch" destination="ZKg-aU-mIC" id="f1D-bt-5Oc"/>
+                        <outlet property="onlyWiFiSwitch" destination="pSj-dG-qXr" id="ahs-FF-JEa"/>
                         <outlet property="retryCountBox" destination="HEJ-Eh-vI4" id="O5k-Ja-8k2"/>
                     </connections>
                 </viewController>

+ 9 - 4
RA Image/RA Image/UploadSettingController.m

@@ -18,6 +18,7 @@ NSString *const kUploadSetting = @"UploadSettingKey";
 @property (strong, nonatomic) IBOutlet UISwitch *autoRmFinishSwitch;
 @property (strong, nonatomic) IBOutlet UISwitch *autoRmErrorSwith;
 @property (strong, nonatomic) IBOutlet UISwitch *compressSwitch;
+@property (strong, nonatomic) IBOutlet UISwitch *onlyWiFiSwitch;
 
 @end
 
@@ -34,6 +35,7 @@ NSString *const kUploadSetting = @"UploadSettingKey";
     BOOL autoRmFinish = YES;
     BOOL autoRmErr = NO;
     BOOL compress = YES;
+    BOOL onlyWiFi = YES;
     int retryCount = 2;
     NSDictionary *param = [self userDefaultsValue:kUploadSetting];
     if (param) {
@@ -42,6 +44,7 @@ NSString *const kUploadSetting = @"UploadSettingKey";
         autoRmFinish = [[param objectForKey:@"auto_rm_finish"] boolValue];
         autoRmErr = [[param objectForKey:@"auto_rm_error"] boolValue];
         compress = [[param objectForKey:@"compress_img"] boolValue];
+        onlyWiFi = [[param objectForKey:@"only_wifi"] boolValue];
     } else {
         
         autoUpload = appDelegate.uploadManager.autoStart;
@@ -49,14 +52,14 @@ NSString *const kUploadSetting = @"UploadSettingKey";
         autoRmFinish = appDelegate.uploadManager.removeFinish;
         autoRmErr = appDelegate.uploadManager.removeError;
         compress = appDelegate.compressFile;
-
+        onlyWiFi = appDelegate.uploadManager.onlyWiFi;
     }
     self.autoSwitch.on = autoUpload;
     self.autoRmFinishSwitch.on = autoRmFinish;
     self.autoRmErrorSwith.on = autoRmErr;
     self.retryCountBox.text = [NSString stringWithFormat:@"%d",retryCount];
     self.compressSwitch.on = compress;
-    
+    self.onlyWiFiSwitch.on = onlyWiFi;
     [self registListenKeyboard];
 }
 
@@ -87,13 +90,14 @@ NSString *const kUploadSetting = @"UploadSettingKey";
     BOOL autoRmErr = self.autoRmErrorSwith.isOn;
     BOOL compress = self.compressSwitch.isOn;
     int retryCount = [self.retryCountBox.text intValue];
-    
+    BOOL onlyWiFi = self.onlyWiFiSwitch.isOn;
     NSDictionary *param = @{
                             @"auto_upload" : @(autoUpload),
                             @"auto_rm_finish"   : @(autoRmFinish),
                             @"auto_rm_error"    : @(autoRmErr),
                             @"compress_img"     : @(compress),
-                            @"retry_count" : @(retryCount)
+                            @"retry_count" : @(retryCount),
+                            @"only_wifi" : @(onlyWiFi)
                             };
     [self setUserDefaultsValue:param forKey:kUploadSetting];
     
@@ -103,6 +107,7 @@ NSString *const kUploadSetting = @"UploadSettingKey";
     appDelegate.uploadManager.removeFinish = autoRmFinish;
     appDelegate.uploadManager.removeError = autoRmErr;
     appDelegate.compressFile = compress;
+    appDelegate.uploadManager.onlyWiFi = onlyWiFi;
     
     [self.navigationController popViewControllerAnimated:YES];
 }

+ 14 - 5
RA Image/RA Image/UploadViewController.m

@@ -8,6 +8,7 @@
 
 #import "UploadViewController.h"
 #import "UploadCell.h"
+#import "UIView+Toast.h"
 
 @interface UploadViewController ()<UITableViewDelegate,UITableViewDataSource>
 
@@ -125,7 +126,6 @@
         UploadCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
         
         
-        
         NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
 //        
 //        if (cell.operation) {
@@ -173,7 +173,6 @@
 //        __block NSIndexPath* block_index = indexPath;
 //        long idx = indexPath.row;
 //        __weak typeof(self) weakself = self;
-
         
         op.updateUI=^(){
             
@@ -225,9 +224,14 @@
                NSMutableDictionary * task = Appdelegate.uploadManager.arr_queue[indexPath.row];
     
     
-    
+    __weak typeof(self) weakself = self;
     UITableViewRowAction *startAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Restart"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
         
+        if (Appdelegate.uploadManager.onlyWiFi && Appdelegate.uploadManager.reach.currentReachabilityStatus != ReachableViaWiFi) {
+            [weakself.view makeToast:@"Current Network is not WiFi" duration:3.0 position:CSToastPositionCenter];
+            [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
+            return ;
+        }
         DebugLog(@"Start click");
         task[@"retry"]=[NSNumber numberWithInt:0];
         [Appdelegate.uploadManager startTask:task];
@@ -320,8 +324,8 @@
 //    UploadCell *upCell = (UploadCell *)cell;
 //    
 //}
-//
 
+// reloadRow 该IndexPath Cell会改变
 - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
     UploadCell *upCell = (UploadCell *)cell;
 //    if (upCell.operation) {
@@ -333,7 +337,12 @@
     if (count > row) {
         NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
         RAUploadOperation* operation = item_json[@"operation"];
-        operation.updateUI = nil;
+        UploadCell *newCell = (UploadCell *)[tableView cellForRowAtIndexPath:indexPath];
+        if (newCell != upCell) {
+            // reload row
+        } else {
+            operation.updateUI = nil; // restart 会调用就会导致cell不会刷新
+        }
     }
     upCell.name = nil;
     upCell.progress = 0;