diff --git a/Classes_cocos/JcWallet.mm b/Classes_cocos/JcWallet.mm index 938c6c4..766b9b4 100644 --- a/Classes_cocos/JcWallet.mm +++ b/Classes_cocos/JcWallet.mm @@ -293,8 +293,8 @@ bool jsb_scanQRCode(se::State& s) { NSString *nfunid = [NSString stringWithCString:funid.c_str() encoding:NSUTF8StringEncoding]; dispatch_async(dispatch_get_main_queue(), ^{ UIWindow* window = [[[UIApplication sharedApplication] delegate] window]; -// [window.rootViewController scanQRCode:nfunid title:ntitle]; - [window.rootViewController loadRestoreKey:nfunid oid: ntitle]; + [window.rootViewController scanQRCode:nfunid title:ntitle]; +// [window.rootViewController loadRestoreKey:nfunid oid: ntitle]; }); return true; } diff --git a/Classes_cocos/QRCodeReaderViewController/QRCodeReaderViewController.m b/Classes_cocos/QRCodeReaderViewController/QRCodeReaderViewController.m index eef6beb..3b302b0 100644 --- a/Classes_cocos/QRCodeReaderViewController/QRCodeReaderViewController.m +++ b/Classes_cocos/QRCodeReaderViewController/QRCodeReaderViewController.m @@ -342,6 +342,7 @@ if (_delegate && [_delegate respondsToSelector:@selector(readerDidCancel:)]) { [_delegate readerDidCancel:self]; } + [self dismissViewControllerAnimated:YES completion:nil]; } - (void)switchCameraAction:(UIButton *)button @@ -415,6 +416,9 @@ if (self.completion) { self.completion(scanResult.strScanned, nil); } + if (self.delegate && [self.delegate respondsToSelector:@selector(reader:didScanResult:)]) { + [self.delegate reader:self didScanResult:scanResult.strScanned]; + } [self dismissViewControllerAnimated:YES completion:nil]; } diff --git a/Classes_cocos/UIViewController+QR.mm b/Classes_cocos/UIViewController+QR.mm index 49efd0c..21ecc21 100644 --- a/Classes_cocos/UIViewController+QR.mm +++ b/Classes_cocos/UIViewController+QR.mm @@ -11,14 +11,12 @@ #import "QRCodeReaderDelegate.h" #import "LBXPermission.h" #import "LBXPermissionSetting.h" -#include "LBXScanNative.h" -#include "LBXScanTypes.h" #include "QrCodeViewController.h" #include #import "NSString+Customer.h" #include "JcWallet.h" -@interface UIViewController (QR) +@interface UIViewController (QR) @end static QRCodeReaderViewController *qrcodeReaderVC = nil; @@ -47,31 +45,23 @@ static QRCodeReaderViewController *qrcodeReaderVC = nil; -(void)loadRestoreKey:(NSString *)funid oid:(NSString *) oid{ NSLog(@"loadRestoreKey::funid: %@, oid:%@", funid, oid); dispatch_async(dispatch_get_main_queue(), ^{ -// UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Tips" -// message:@"In order to restore recovery key, please Scan QRCode or Pick from Photo Library." -// preferredStyle:UIAlertControllerStyleActionSheet]; -// UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel" -// style:UIAlertActionStyleCancel -// handler: ^(UIAlertAction *action){ -// [self nativeCb:funid hasErr:YES dataStr: @"user cancel"]; -// }]; -// -// UIAlertAction *scanAction = [UIAlertAction actionWithTitle:@"Scan" -// style:UIAlertActionStyleDefault -// handler: ^(UIAlertAction *action){ -// [self scanQRCode:funid title: @"" restore:YES ]; -// }]; -// -// UIAlertAction *photoAction = [UIAlertAction actionWithTitle:@"Photo" -// style:UIAlertActionStyleDefault -// handler: ^(UIAlertAction *action){ -// [self openLocalPhotoAlbum: funid]; -// }]; -// [alertController addAction:actionCancel]; -// [alertController addAction:scanAction]; -// [alertController addAction:photoAction]; -// [self presentViewController:alertController animated:YES completion:nil]; - [self scanQRCode:funid title: @"" restore:YES ]; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Tips" + message:@"In order to restore recovery key, please Scan QRCode or Pick from Photo Library." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"Cancel" + style:UIAlertActionStyleCancel + handler: ^(UIAlertAction *action){ + [self nativeCb:funid hasErr:YES dataStr: @"user cancel"]; + }]; + + UIAlertAction *scanAction = [UIAlertAction actionWithTitle:@"Scan" + style:UIAlertActionStyleDefault + handler: ^(UIAlertAction *action){ + [self scanQRCode:funid title: @"" restore:YES ]; + }]; + [alertController addAction:actionCancel]; + [alertController addAction:scanAction]; + [self presentViewController:alertController animated:YES completion:nil]; }); } @@ -125,77 +115,6 @@ static QRCodeReaderViewController *qrcodeReaderVC = nil; }]; } - -#pragma mark- - PhotoAlbum -- (void)openLocalPhotoAlbum:(NSString *)funid { - __weak __typeof(self) weakSelf = self; - [LBXPermission authorizeWithType:LBXPermissionType_Photos completion:^(BOOL granted, BOOL firstTime) { - if (granted) { - [weakSelf openLocalPhoto:funid]; - } else if (!firstTime ) { - [LBXPermissionSetting showAlertToDislayPrivacySettingWithTitle:@"Error" msg:@"The Photo Library is need to restore recovery key." cancel:@"Cancel" setting:@"Setting" completion:^{ - [weakSelf loadRestoreKey:funid oid:@""]; - }]; - } - }]; -} - -/*! - * open local Photo Library - */ -- (void)openLocalPhoto:(NSString *)funid { - UIImagePickerController *picker = [[UIImagePickerController alloc] init]; - picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; - picker.delegate = self; - // crash on some mobile - picker.allowsEditing = NO; - picker.title = funid; - [self presentViewController:picker animated:YES completion:nil]; -} -#pragma mark- - UIImagePickerControllerDelegate --(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ - [picker dismissViewControllerAnimated:YES completion:^{ - NSString *funid = picker.title; - [self handPhotoDidFinishPickingMediaWithInfo:funid info:info]; - }]; -} - --(void)imagePickerControllerDidCancel:(UIImagePickerController*)picker { - [picker dismissViewControllerAnimated:YES completion:^{ - NSLog(@"imagePickerControllerDidCancel %@", picker.title); - [self loadRestoreKey: picker.title oid: @"" ]; - }]; -} - -- (void)handPhotoDidFinishPickingMediaWithInfo:(NSString *)funid info:(NSDictionary *)info { - __block UIImage* image = [info objectForKey:UIImagePickerControllerEditedImage]; - - if (!image){ - image = [info objectForKey:UIImagePickerControllerOriginalImage]; - } - if (@available(iOS 8.0, *)) { - __weak __typeof(self) weakSelf = self; - [LBXScanNative recognizeImage:image success:^(NSArray *array) { - [weakSelf scanResultWithArray:funid array:array]; - }]; - }else{ - [self nativeCb:funid hasErr:YES dataStr: @"os version is lower then IOS8.0"]; - } -} - -- (void)scanResultWithArray:(NSString *)funid array:(NSArray*)array { - if (!array || array.count < 1) { - [self nativeCb:funid hasErr:YES dataStr: @"error scan photo"]; - return; - } - if (!array[0].strScanned || [array[0].strScanned isEqualToString:@""] ) { - [self nativeCb:funid hasErr:YES dataStr: @"failed decoding QR code"]; - return; - } - LBXScanResult *scanResult = array[0]; - [self nativeCb:funid hasErr:NO dataStr: scanResult.strScanned]; -} - -(void)nativeCb:(NSString *)funid hasErr: (BOOL) hasErr dataStr:(NSString *) dataStr { if ([NSString isStringEmpty:funid]) { NSLog(@"nativeCallBack with empty funid: %@", funid); diff --git a/Unity-iPhone.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate b/Unity-iPhone.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate index 33d9e8c..ff5fe7a 100644 Binary files a/Unity-iPhone.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate and b/Unity-iPhone.xcworkspace/xcuserdata/zhl.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Unity-iPhone.xcworkspace/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Unity-iPhone.xcworkspace/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index c7c3352..843b7d8 100644 --- a/Unity-iPhone.xcworkspace/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Unity-iPhone.xcworkspace/xcuserdata/zhl.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -196,22 +196,6 @@ landmarkType = "7"> - - - -