You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ji...@apache.org on 2017/01/24 08:19:02 UTC

[47/50] [abbrv] incubator-weex git commit: * [ios] remove ZXing

* [ios] remove ZXing


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/82a79d1a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/82a79d1a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/82a79d1a

Branch: refs/heads/master
Commit: 82a79d1ab6d0ec5ed330aa55eaac6c1011149fed
Parents: 6bd1255
Author: acton393 <zh...@gmail.com>
Authored: Mon Jun 13 13:53:31 2016 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Mon Jun 13 13:53:31 2016 +0800

----------------------------------------------------------------------
 ios/playground/Podfile                        |  3 +-
 ios/playground/WeexDemo/Scanner/WXScannerVC.h |  4 +-
 ios/playground/WeexDemo/Scanner/WXScannerVC.m | 67 ++++++++++------------
 3 files changed, 33 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/82a79d1a/ios/playground/Podfile
----------------------------------------------------------------------
diff --git a/ios/playground/Podfile b/ios/playground/Podfile
index ed6e27f..f46aeeb 100644
--- a/ios/playground/Podfile
+++ b/ios/playground/Podfile
@@ -1,4 +1,4 @@
-source 'git@github.com:CocoaPods/Specs.git'
+source 'https://github.com/CocoaPods/Specs.git'
 platform :ios, '7.0'
 #inhibit_all_warnings!
 
@@ -6,7 +6,6 @@ target 'WeexDemo' do
   pod 'WeexSDK', :path=>'../sdk/'
   pod 'SDWebImage', '3.7.5'
   pod 'SocketRocket', '0.4.2'
-  pod 'ZXingObjC', '~> 3.0'
   pod 'ATSDK-Weex', '0.0.1'
 end
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/82a79d1a/ios/playground/WeexDemo/Scanner/WXScannerVC.h
----------------------------------------------------------------------
diff --git a/ios/playground/WeexDemo/Scanner/WXScannerVC.h b/ios/playground/WeexDemo/Scanner/WXScannerVC.h
index fa0f56a..3618d35 100644
--- a/ios/playground/WeexDemo/Scanner/WXScannerVC.h
+++ b/ios/playground/WeexDemo/Scanner/WXScannerVC.h
@@ -7,8 +7,8 @@
  */
 
 #import <UIKit/UIKit.h>
-#import <ZXingObjC/ZXingObjC.h>
+#import <AVFoundation/AVFoundation.h>
 
-@interface WXScannerVC : UIViewController <ZXCaptureDelegate>
+@interface WXScannerVC : UIViewController <AVCaptureMetadataOutputObjectsDelegate>
 
 @end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/82a79d1a/ios/playground/WeexDemo/Scanner/WXScannerVC.m
----------------------------------------------------------------------
diff --git a/ios/playground/WeexDemo/Scanner/WXScannerVC.m b/ios/playground/WeexDemo/Scanner/WXScannerVC.m
index 24e6291..fcf5e60 100644
--- a/ios/playground/WeexDemo/Scanner/WXScannerVC.m
+++ b/ios/playground/WeexDemo/Scanner/WXScannerVC.m
@@ -16,7 +16,9 @@
 
 @interface WXScannerVC ()
 
-@property (nonatomic, strong) ZXCapture *capture;
+@property (nonatomic, strong) AVCaptureSession * session;
+@property (nonatomic, strong) AVCaptureVideoPreviewLayer *captureLayer;
+@property (nonatomic, strong) UIView *sanFrameView;
 
 @property (nonatomic) BOOL opened;
 
@@ -27,69 +29,60 @@
 #pragma mark - lifeCircle
 
 - (void)dealloc {
-    [self.capture.layer removeFromSuperlayer];
+    [_captureLayer removeFromSuperlayer];
 }
 
 - (void)viewDidLoad {
     [super viewDidLoad];
-    
     self.edgesForExtendedLayout = UIRectEdgeNone;
-    
     [self setupNaviBar];
     
-    self.capture = [[ZXCapture alloc] init];
-    self.capture.camera = self.capture.back;
-    self.capture.focusMode = AVCaptureFocusModeContinuousAutoFocus;
-    self.capture.rotation = 90.0f;
+    self.session = [[AVCaptureSession alloc]init];
+    [_session setSessionPreset:AVCaptureSessionPresetHigh];
+    AVCaptureDevice * device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
+    AVCaptureDeviceInput * input = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil];
+    AVCaptureMetadataOutput * output = [[AVCaptureMetadataOutput alloc]init];
+    [output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
+    [_session addInput:input];
+    [_session addOutput:output];
     
-    self.capture.layer.frame = self.view.bounds;
-    [self.view.layer addSublayer:self.capture.layer];
-
+    output.metadataObjectTypes=@[AVMetadataObjectTypeQRCode,AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeCode128Code];
+    
+    _captureLayer = [AVCaptureVideoPreviewLayer layerWithSession:_session];
+    _captureLayer.videoGravity=AVLayerVideoGravityResizeAspectFill;
+    _captureLayer.frame=self.view.layer.bounds;
 }
 
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     
-    [self.view.layer addSublayer:self.capture.layer];
-    [self.capture start];
-    
-    self.capture.delegate = self;
-    self.capture.layer.frame = self.view.bounds;
-    
-    CGAffineTransform captureSizeTransform = CGAffineTransformMakeScale(320 / self.view.frame.size.width, 480 / self.view.frame.size.height);
-    self.capture.scanRect = CGRectApplyAffineTransform(self.view.frame, captureSizeTransform);
+    [self.view.layer addSublayer:_captureLayer];
+    [_session startRunning];
 }
 
 - (void) viewDidDisappear:(BOOL)animated
 {
     [super viewDidDisappear:animated];
     
-    [self.capture.layer removeFromSuperlayer];
-    [self.capture stop];
+    [_captureLayer removeFromSuperlayer];
+    [_session stopRunning];
 }
 
-#pragma mark - ZXCaptureDelegate
-
-- (void)captureResult:(ZXCapture *)capture result:(ZXResult *)result {
-    if (!result) return;
-
-    [self.capture.layer removeFromSuperlayer];
-    [self.capture stop];
-    
+- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection
+{
+    [_captureLayer removeFromSuperlayer];
+    [_session stopRunning];
     if (!_opened) {
-        //Vibrate
         AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
         _opened = YES;
-        __weak __typeof__(self) weakSelf = self;
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-            weakSelf.opened = NO;
-        });
-        
-        [self openURL:result.text];
+        if (metadataObjects.count > 0) {
+            AVMetadataMachineReadableCodeObject * metadataObject = [metadataObjects objectAtIndex : 0 ];
+            [self openURL:metadataObject.stringValue];
+        }
     }
 }
 
-- (void) openURL:(NSString*)URL
+- (void)openURL:(NSString*)URL
 {
     NSURL *url = [NSURL URLWithString:URL];
     [self remoteDebug:url];