From b5376d0fd0f75e6f7c7ca76dfc14b64808e4f469 Mon Sep 17 00:00:00 2001 From: thiago.filipe Date: Thu, 30 Mar 2017 23:28:34 -0300 Subject: [PATCH] Fix Share --- Assets/Plugins/IOS/iOSNativeShare.m | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------- Assets/Resources/ANIMS/Ç.anim | 2 +- Assets/Scenes/Main.unity | 92 ++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- Assets/Scripts/Export Video/MediaShareIOS.cs | 16 ++++++---------- 4 files changed, 111 insertions(+), 101 deletions(-) diff --git a/Assets/Plugins/IOS/iOSNativeShare.m b/Assets/Plugins/IOS/iOSNativeShare.m index e95723f..fbdf917 100755 --- a/Assets/Plugins/IOS/iOSNativeShare.m +++ b/Assets/Plugins/IOS/iOSNativeShare.m @@ -14,106 +14,120 @@ extern UIViewController* UnityGetGLViewController(); #endif +(id) withTitle:(char*)title withMessage:(char*)message{ - + return [[iOSNativeShare alloc] initWithTitle:title withMessage:message]; } -(id) initWithTitle:(char*)title withMessage:(char*)message{ - + self = [super init]; - + if( !self ) return self; - + ShowAlertMessage([[NSString alloc] initWithUTF8String:title], [[NSString alloc] initWithUTF8String:message]); - + return self; - + } +(id) withTitle:(char*)path{ - + return [[iOSNativeShare alloc] initWithTitle:path]; } -(id) initWithTitle:(char*)path { - + self = [super init]; - + if( !self ) return self; - + SendToGallery([[NSString alloc] initWithUTF8String:path]); - + return self; - + } void SendToGallery(NSString *path){ if(UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(path)){ - UISaveVideoAtPathToSavedPhotosAlbum (path,nil, nil, nil); + //UISaveVideoAtPathToSavedPhotosAlbum (path,self, nil, nil); + UISaveVideoAtPathToSavedPhotosAlbum (path,self, @selector(video:didFinishSavingWithError:contextInfo:), nil); + //ShowAlertMessage(@"Vlibras Vídeo",@"Video salvo na galeria."); + } +} + +- (void)video:(NSString*)videoPath didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo +{ + if (error) + { + ShowAlertMessage(@"Vlibras Vídeo",@"Error ao salvar vídeo."); + } + else + { + ShowAlertMessage(@"Vlibras Vídeo",@"Video salvo na galeria."); } } void ShowAlertMessage (NSString *title, NSString *message){ - + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title - + message:message - + delegate:nil - + cancelButtonTitle:@"OK" - + otherButtonTitles: nil]; - + [alert show]; - + } +(id) withText:(char*)text withURL:(char*)url withImage:(char*)image withSubject:(char*)subject{ - + return [[iOSNativeShare alloc] initWithText:text withURL:url withImage:image withSubject:subject]; } -(id) initWithText:(char*)text withURL:(char*)url withImage:(char*)image withSubject:(char*)subject{ - + self = [super init]; - + if( !self ) return self; - - - + + + NSString *mText = text ? [[NSString alloc] initWithUTF8String:text] : nil; - + NSString *mUrl = url ? [[NSString alloc] initWithUTF8String:url] : nil; - + NSString *mImage = image ? [[NSString alloc] initWithUTF8String:image] : nil; - + NSString *mSubject = subject ? [[NSString alloc] initWithUTF8String:subject] : nil; - - + + //NSMutableArray *items = [NSMutableArray new]; NSArray *postItems = [NSArray new]; - + if(mImage != NULL && mImage.length > 0){ - + NSFileManager *fileMgr = [NSFileManager defaultManager]; if([fileMgr fileExistsAtPath:mImage]){ - + //NSData *dataImage = [NSData dataWithContentsOfFile:mImage]; - + // UIImage *imageFromUrl = [UIImage imageWithData:dataImage]; NSData *data = [[NSData alloc] initWithContentsOfFile:mImage]; NSURL *videoURL = [NSURL fileURLWithPath:mImage]; - + // [items addObject:videoURL]; postItems = @[videoURL]; //NSArray *postItems = @[videoURL]; }else{ ShowAlertMessage(@"Error", @"Cannot find image"); } - + } - + // UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:Nil]; // // if(mSubject != NULL) { @@ -133,7 +147,7 @@ void ShowAlertMessage (NSString *title, NSString *message){ // UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activity]; // [popup presentPopoverFromRect:CGRectMake(rootViewController.view.frame.size.width/2, rootViewController.view.frame.size.height/4, 0, 0)inView:rootViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; // } - + UIActivityViewController *activityVc = [[UIActivityViewController alloc]initWithActivityItems:postItems applicationActivities:nil]; if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && [activityVc respondsToSelector:@selector(popoverPresentationController)] ) { UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activityVc]; @@ -142,15 +156,15 @@ void ShowAlertMessage (NSString *title, NSString *message){ } else [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:activityVc animated:YES completion:nil]; - - + + return self; } -(BOOL) isStringValideBase64:(NSString*)string{ - - NSString *regExPattern = @"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"; - + + NSString regExPattern = @"^(?:[A-Za-z0-9+/]{4})(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"; + NSRegularExpression *regEx = [[NSRegularExpression alloc] initWithPattern:regExPattern options:NSRegularExpressionCaseInsensitive error:nil]; NSUInteger regExMatches = [regEx numberOfMatchesInString:string options:0 range:NSMakeRange(0, [string length])]; return regExMatches != 0; diff --git a/Assets/Resources/ANIMS/Ç.anim b/Assets/Resources/ANIMS/Ç.anim index 80f699d..d16eeac 100644 --- a/Assets/Resources/ANIMS/Ç.anim +++ b/Assets/Resources/ANIMS/Ç.anim @@ -5,7 +5,7 @@ AnimationClip: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_Name: "C\u0327" + m_Name: "\xC7" serializedVersion: 6 m_Legacy: 1 m_Compressed: 0 diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 6766003..58017da 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -3592,53 +3592,53 @@ Animation: m_GameObject: {fileID: 535548070} m_Enabled: 1 serializedVersion: 3 - m_Animation: {fileID: 7400000, guid: e0b82ea10d92c45a49236639d7e127a7, type: 2} + m_Animation: {fileID: 7400000, guid: 365e5f41595503c48915848d883fabfe, type: 2} m_Animations: - - {fileID: 7400000, guid: 094c9782dfd1a4419b4300050525a196, type: 2} - - {fileID: 7400000, guid: 0a25b7eb696464a9ba3fedba28052f44, type: 2} - - {fileID: 7400000, guid: 212a470f4d8764d3aab828715dcceadd, type: 2} - - {fileID: 7400000, guid: 24ccfe8cc110546aab2e9ea1edab0997, type: 2} - - {fileID: 7400000, guid: 255d4ddbbcdac46d9917908e6dc83fbf, type: 2} - - {fileID: 7400000, guid: 2fdb4638c75f24f0aabd6cc76fb610c4, type: 2} - - {fileID: 7400000, guid: 353f223b7116a4871a1ed9cb10953fec, type: 2} - - {fileID: 7400000, guid: 38aa20a48a06548d9946da7f3491fd79, type: 2} - - {fileID: 7400000, guid: 3953996c14ada434e8bece627ea272fb, type: 2} - - {fileID: 7400000, guid: 3b02e44ef03c5471c873718351272938, type: 2} - - {fileID: 7400000, guid: 3ff67392ee17d46e8b75e23614754596, type: 2} - - {fileID: 7400000, guid: 46db7a3a687d6491c87b272ba4a3af9b, type: 2} - - {fileID: 7400000, guid: 48640d5b0a6804e8a892d7e3f9878338, type: 2} - - {fileID: 7400000, guid: 6867e7a4c4a93433b85dd978831a5789, type: 2} - - {fileID: 7400000, guid: 723477075e06c43dca279006c68f629a, type: 2} - - {fileID: 7400000, guid: 75289ce9809d340a39e5d2d9896ef14e, type: 2} - - {fileID: 7400000, guid: 773b86077b0a9459eb0d40f9c6147238, type: 2} - - {fileID: 7400000, guid: 7ccd4c6ab0ec54ceaa2946562f1a9498, type: 2} - - {fileID: 7400000, guid: 7f65fa3885c054b49ae6e5271be81d3f, type: 2} - - {fileID: 7400000, guid: 8043026f4179c4e36bf9c52857439067, type: 2} - - {fileID: 7400000, guid: 829700cfb4bf84f01a308423418d482d, type: 2} - - {fileID: 7400000, guid: 87310cd5c3519409081aad5bc7d001f4, type: 2} - - {fileID: 7400000, guid: 8b46d8bdc57654882b802d8a424bbc64, type: 2} - - {fileID: 7400000, guid: 8c3b08031b41a4af6a38cddd30b6b711, type: 2} - - {fileID: 7400000, guid: 922333c7fb2f24607a2b6bc7eddc0c92, type: 2} - - {fileID: 7400000, guid: 93c97cf7199d14c8a85c6a47dfe96fdd, type: 2} - - {fileID: 7400000, guid: 99e6d1fa06bef4cffb3985c33858ab7f, type: 2} - - {fileID: 7400000, guid: 9a03fa44cc4e74406a490fa7a601eb2d, type: 2} - - {fileID: 7400000, guid: 9d20ba4e0319344f29101e050835449a, type: 2} - - {fileID: 7400000, guid: 9f404de03117c44fcbf5c4bebbdebc39, type: 2} - - {fileID: 7400000, guid: 9fac8b289e9c34268bade7f7dc070255, type: 2} - - {fileID: 7400000, guid: a2f710de3a93149d981cfd3643c29f5d, type: 2} - - {fileID: 7400000, guid: a55f62e68785e4f16b38373c27770c2c, type: 2} - - {fileID: 7400000, guid: ad8d4c5f8f40746fb809287d36da0da4, type: 2} - - {fileID: 7400000, guid: b0298c4a0832c4567a80f0293805f766, type: 2} - - {fileID: 7400000, guid: b90260b13c6b043008a3231f0e325d8b, type: 2} - - {fileID: 7400000, guid: bd4784c7f8ccc4dd6b9c0d3bca313258, type: 2} - - {fileID: 7400000, guid: d3a14cd4d3aef472f81d58456286f1da, type: 2} - - {fileID: 7400000, guid: d902aa4db6b5e44fe9153e04e901b357, type: 2} - - {fileID: 7400000, guid: d9a3268b5233b489489a6b406f5b560d, type: 2} - - {fileID: 7400000, guid: daceeb12c57434b03ab14733724787b0, type: 2} - - {fileID: 7400000, guid: e0b82ea10d92c45a49236639d7e127a7, type: 2} - - {fileID: 7400000, guid: e0e4fafd1c404477a9330c24fad5c5d5, type: 2} - - {fileID: 7400000, guid: e5df376619b5547418da0a4bb053a736, type: 2} - - {fileID: 7400000, guid: edc0fe305be934cfdaf262b2372efc9f, type: 2} + - {fileID: 7400000, guid: f1f36f20657e5244e9c1e21117d9a452, type: 2} + - {fileID: 7400000, guid: 55bec2c04d14e74488ef127ee380a080, type: 2} + - {fileID: 7400000, guid: b368bfe0efa37c04bb9c661058ccedb9, type: 2} + - {fileID: 7400000, guid: 365e5f41595503c48915848d883fabfe, type: 2} + - {fileID: 7400000, guid: fa9ef8a15fe08a143bc89dc00289fc17, type: 2} + - {fileID: 7400000, guid: 939bebf16bb2dba44894c5745c5dc1f8, type: 2} + - {fileID: 7400000, guid: aecdf652be04b444f84644ba7c403960, type: 2} + - {fileID: 7400000, guid: 53ed20623f5573345a4fb057db454b05, type: 2} + - {fileID: 7400000, guid: b0bafda258c57414ebfbc4cf89719795, type: 2} + - {fileID: 7400000, guid: 67caa6e2d05387848a9448b57fffcb0f, type: 2} + - {fileID: 7400000, guid: a79227e28dd60fa4c9812a51ab9d455e, type: 2} + - {fileID: 7400000, guid: 8b1d930398178064795f5d23af67dce4, type: 2} + - {fileID: 7400000, guid: af8192a32a30ab746be40ff1dcb8bc0a, type: 2} + - {fileID: 7400000, guid: e282c734045b47241988e2b9fdf0dc7e, type: 2} + - {fileID: 7400000, guid: 698d03f46785361449a10cc0003862eb, type: 2} + - {fileID: 7400000, guid: e193836512c744c4299651990fc3ca10, type: 2} + - {fileID: 7400000, guid: c4d452a56e2f4ee4a83e5679f969a354, type: 2} + - {fileID: 7400000, guid: 220a675640cc72d4f9c8d364c9a377b4, type: 2} + - {fileID: 7400000, guid: 9a1e34a6954967f4fb3982394bf61eef, type: 2} + - {fileID: 7400000, guid: 039911b68664f7b40b97e2665893a1e5, type: 2} + - {fileID: 7400000, guid: b4a4a507b5b85404f9ca30cf2855b359, type: 2} + - {fileID: 7400000, guid: 3b67cb87e08f4e34badc00f7b49d2591, type: 2} + - {fileID: 7400000, guid: dc854de773a9e3f488c7a1b42d6a460b, type: 2} + - {fileID: 7400000, guid: 21b376087ddd4ec46a1da0c3ba1181d9, type: 2} + - {fileID: 7400000, guid: db84b318b67dbc54fa1fab6d31dfeb6e, type: 2} + - {fileID: 7400000, guid: 47e5da18eda740844ba111cfab49d0eb, type: 2} + - {fileID: 7400000, guid: ba9dc32834cf193429f27449b1d9d701, type: 2} + - {fileID: 7400000, guid: 22f7b3c892f0e5e41b120798d7953026, type: 2} + - {fileID: 7400000, guid: 9396f2d833a082446b36b0cda61ba87c, type: 2} + - {fileID: 7400000, guid: 289449396bffd4045b8657269df378f2, type: 2} + - {fileID: 7400000, guid: 99bb7e6adbe6d5f4984c51d5d5e92045, type: 2} + - {fileID: 7400000, guid: b6faf58a03a0dc24cb9777c70fda828b, type: 2} + - {fileID: 7400000, guid: b2b18bfa970783a4ab32945b1c4bc54b, type: 2} + - {fileID: 7400000, guid: a8b0488b23a43b3499d2b1d8b81f0707, type: 2} + - {fileID: 7400000, guid: ccdf6bab5e56c0447abfc0a8f745b62c, type: 2} + - {fileID: 7400000, guid: 8d2c7cdb67fea144e9660db7edd82239, type: 2} + - {fileID: 7400000, guid: 6191f3fb2e8027b48ac60aa48c11065d, type: 2} + - {fileID: 7400000, guid: dbf77a3c567182846bad50598584109d, type: 2} + - {fileID: 7400000, guid: d2f41e4d1ce31a4458ccdab2cd91faae, type: 2} + - {fileID: 7400000, guid: fc72e7fd88de0b94fb9b050fc1368547, type: 2} + - {fileID: 7400000, guid: 5b7bf0ae891107f4aaa366ba42eac9ee, type: 2} + - {fileID: 7400000, guid: d9c72b1fb167df045ae7ac711d1dee6c, type: 2} + - {fileID: 7400000, guid: d927185f3fb021844834f7086d346e3a, type: 2} + - {fileID: 7400000, guid: e62d77cfc7d0d104b84d8beb5ef72c33, type: 2} + - {fileID: 7400000, guid: 1dd400df2179f94469eb2480a313a8cf, type: 2} m_WrapMode: 0 m_PlayAutomatically: 1 m_AnimatePhysics: 0 diff --git a/Assets/Scripts/Export Video/MediaShareIOS.cs b/Assets/Scripts/Export Video/MediaShareIOS.cs index 9ef0083..1d59d84 100644 --- a/Assets/Scripts/Export Video/MediaShareIOS.cs +++ b/Assets/Scripts/Export Video/MediaShareIOS.cs @@ -46,17 +46,18 @@ public class MediaShareIOS : MonoBehaviour { dir.Create(); } - try - { + FileStream SourceStream = new FileStream(Path.Combine(path, FilePath), FileMode.OpenOrCreate); if (SourceStream.CanWrite) { SourceStream.Write(videoContent, 0, bytes); SourceStream.Close(); ShareIOS.CallSendToGallery(Path.Combine(path,FilePath)); + yield return new WaitForSeconds(0.5f); + finishWriting(); - yield break; + } else @@ -67,13 +68,8 @@ public class MediaShareIOS : MonoBehaviour { } - } - catch (Exception e) - { - PlayerLogger.Log("MediaShareIOS", "WriteOnIOS", "Message: " + e.Message); - PlayerLogger.Log("MediaShareIOS", "WriteOnIOS", "Message: " + e.StackTrace); - errorWriting(); - } + + yield break; -- libgit2 0.21.2