Commit 4c01e0c9df00116f2aa1bf17e4e5c9abf501d04a
1 parent
d18e74a3
Exists in
IosBuild
Fix IOS Build
Showing
16 changed files
with
441 additions
and
104 deletions
Show diff stats
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
... | ... | @@ -0,0 +1,35 @@ |
1 | +#import "UnityAppController.h" | |
2 | + | |
3 | +@interface iOSNativeShare : UIViewController | |
4 | +{ | |
5 | + UINavigationController *navController; | |
6 | +} | |
7 | + | |
8 | + | |
9 | +struct ConfigStruct { | |
10 | + char* title; | |
11 | + char* message; | |
12 | +}; | |
13 | + | |
14 | +struct SocialSharingStruct { | |
15 | + char* text; | |
16 | + char* url; | |
17 | + char* image; | |
18 | + char* subject; | |
19 | +}; | |
20 | + | |
21 | + | |
22 | +#ifdef __cplusplus | |
23 | +extern "C" { | |
24 | +#endif | |
25 | + | |
26 | + void showAlertMessage(struct ConfigStruct *confStruct); | |
27 | + void showSocialSharing(struct SocialSharingStruct *confStruct); | |
28 | + void sendToGallery(struct ConfigStruct *confStruct); | |
29 | + | |
30 | +#ifdef __cplusplus | |
31 | +} | |
32 | +#endif | |
33 | + | |
34 | + | |
35 | +@end | ... | ... |
... | ... | @@ -0,0 +1,23 @@ |
1 | +fileFormatVersion: 2 | |
2 | +guid: c9d0251cf02d34161b7a753f8a2c1fee | |
3 | +timeCreated: 1490842313 | |
4 | +licenseType: Free | |
5 | +PluginImporter: | |
6 | + serializedVersion: 1 | |
7 | + iconMap: {} | |
8 | + executionOrder: {} | |
9 | + isPreloaded: 0 | |
10 | + platformData: | |
11 | + Any: | |
12 | + enabled: 0 | |
13 | + settings: {} | |
14 | + Editor: | |
15 | + enabled: 0 | |
16 | + settings: | |
17 | + DefaultValueInitialized: true | |
18 | + iOS: | |
19 | + enabled: 1 | |
20 | + settings: {} | |
21 | + userData: | |
22 | + assetBundleName: | |
23 | + assetBundleVariant: | ... | ... |
... | ... | @@ -0,0 +1,173 @@ |
1 | +#import "iOSNativeShare.h" | |
2 | + | |
3 | +@implementation iOSNativeShare{ | |
4 | +} | |
5 | + | |
6 | +#ifdef UNITY_4_0 || UNITY_5_0 | |
7 | + | |
8 | +#import "iPhone_View.h" | |
9 | + | |
10 | +#else | |
11 | + | |
12 | +extern UIViewController* UnityGetGLViewController(); | |
13 | + | |
14 | +#endif | |
15 | + | |
16 | ++(id) withTitle:(char*)title withMessage:(char*)message{ | |
17 | + | |
18 | + return [[iOSNativeShare alloc] initWithTitle:title withMessage:message]; | |
19 | +} | |
20 | + | |
21 | +-(id) initWithTitle:(char*)title withMessage:(char*)message{ | |
22 | + | |
23 | + self = [super init]; | |
24 | + | |
25 | + if( !self ) return self; | |
26 | + | |
27 | + ShowAlertMessage([[NSString alloc] initWithUTF8String:title], [[NSString alloc] initWithUTF8String:message]); | |
28 | + | |
29 | + return self; | |
30 | + | |
31 | +} | |
32 | + | |
33 | ++(id) withTitle:(char*)path{ | |
34 | + | |
35 | + return [[iOSNativeShare alloc] initWithTitle:path]; | |
36 | +} | |
37 | + | |
38 | +-(id) initWithTitle:(char*)path { | |
39 | + | |
40 | + self = [super init]; | |
41 | + | |
42 | + if( !self ) return self; | |
43 | + | |
44 | + SendToGallery([[NSString alloc] initWithUTF8String:path]); | |
45 | + | |
46 | + return self; | |
47 | + | |
48 | +} | |
49 | + | |
50 | +void SendToGallery(NSString *path){ | |
51 | + if(UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(path)){ | |
52 | + UISaveVideoAtPathToSavedPhotosAlbum (path,nil, nil, nil); | |
53 | + } | |
54 | +} | |
55 | + | |
56 | +void ShowAlertMessage (NSString *title, NSString *message){ | |
57 | + | |
58 | + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title | |
59 | + | |
60 | + message:message | |
61 | + | |
62 | + delegate:nil | |
63 | + | |
64 | + cancelButtonTitle:@"OK" | |
65 | + | |
66 | + otherButtonTitles: nil]; | |
67 | + | |
68 | + [alert show]; | |
69 | + | |
70 | +} | |
71 | + | |
72 | ++(id) withText:(char*)text withURL:(char*)url withImage:(char*)image withSubject:(char*)subject{ | |
73 | + | |
74 | + return [[iOSNativeShare alloc] initWithText:text withURL:url withImage:image withSubject:subject]; | |
75 | +} | |
76 | + | |
77 | +-(id) initWithText:(char*)text withURL:(char*)url withImage:(char*)image withSubject:(char*)subject{ | |
78 | + | |
79 | + self = [super init]; | |
80 | + | |
81 | + if( !self ) return self; | |
82 | + | |
83 | + | |
84 | + | |
85 | + NSString *mText = text ? [[NSString alloc] initWithUTF8String:text] : nil; | |
86 | + | |
87 | + NSString *mUrl = url ? [[NSString alloc] initWithUTF8String:url] : nil; | |
88 | + | |
89 | + NSString *mImage = image ? [[NSString alloc] initWithUTF8String:image] : nil; | |
90 | + | |
91 | + NSString *mSubject = subject ? [[NSString alloc] initWithUTF8String:subject] : nil; | |
92 | + | |
93 | + | |
94 | + //NSMutableArray *items = [NSMutableArray new]; | |
95 | + NSArray *postItems = [NSArray new]; | |
96 | + | |
97 | + if(mImage != NULL && mImage.length > 0){ | |
98 | + | |
99 | + NSFileManager *fileMgr = [NSFileManager defaultManager]; | |
100 | + if([fileMgr fileExistsAtPath:mImage]){ | |
101 | + | |
102 | + //NSData *dataImage = [NSData dataWithContentsOfFile:mImage]; | |
103 | + | |
104 | + // UIImage *imageFromUrl = [UIImage imageWithData:dataImage]; | |
105 | + NSData *data = [[NSData alloc] initWithContentsOfFile:mImage]; | |
106 | + NSURL *videoURL = [NSURL fileURLWithPath:mImage]; | |
107 | + | |
108 | + // [items addObject:videoURL]; | |
109 | + postItems = @[videoURL]; | |
110 | + //NSArray *postItems = @[videoURL]; | |
111 | + }else{ | |
112 | + ShowAlertMessage(@"Error", @"Cannot find image"); | |
113 | + } | |
114 | + | |
115 | + } | |
116 | + | |
117 | + // UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:Nil]; | |
118 | + // | |
119 | + // if(mSubject != NULL) { | |
120 | + // [activity setValue:mSubject forKey:@"subject"]; | |
121 | + // } else { | |
122 | + // [activity setValue:@"" forKey:@"subject"]; | |
123 | + // } | |
124 | + // | |
125 | + // UIViewController *rootViewController = UnityGetGLViewController(); | |
126 | + // //if iPhone | |
127 | + // if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { | |
128 | + // [rootViewController presentViewController:activity animated:YES completion:Nil]; | |
129 | + // } | |
130 | + // //if iPad | |
131 | + // else { | |
132 | + // // Change Rect to position Popover | |
133 | + // UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activity]; | |
134 | + // [popup presentPopoverFromRect:CGRectMake(rootViewController.view.frame.size.width/2, rootViewController.view.frame.size.height/4, 0, 0)inView:rootViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; | |
135 | + // } | |
136 | + | |
137 | + UIActivityViewController *activityVc = [[UIActivityViewController alloc]initWithActivityItems:postItems applicationActivities:nil]; | |
138 | + if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && [activityVc respondsToSelector:@selector(popoverPresentationController)] ) { | |
139 | + UIPopoverController *popup = [[UIPopoverController alloc] initWithContentViewController:activityVc]; | |
140 | + [popup presentPopoverFromRect:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/4, 0, 0) | |
141 | + inView:[UIApplication sharedApplication].keyWindow.rootViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; | |
142 | + } | |
143 | + else | |
144 | + [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:activityVc animated:YES completion:nil]; | |
145 | + | |
146 | + | |
147 | + return self; | |
148 | +} | |
149 | + | |
150 | +-(BOOL) isStringValideBase64:(NSString*)string{ | |
151 | + | |
152 | + NSString *regExPattern = @"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"; | |
153 | + | |
154 | + NSRegularExpression *regEx = [[NSRegularExpression alloc] initWithPattern:regExPattern options:NSRegularExpressionCaseInsensitive error:nil]; | |
155 | + NSUInteger regExMatches = [regEx numberOfMatchesInString:string options:0 range:NSMakeRange(0, [string length])]; | |
156 | + return regExMatches != 0; | |
157 | +} | |
158 | + | |
159 | +# pragma mark - C API | |
160 | +iOSNativeShare* instance; | |
161 | + | |
162 | +void showAlertMessage(struct ConfigStruct *confStruct) { | |
163 | + instance = [iOSNativeShare withTitle:confStruct->title withMessage:confStruct->message]; | |
164 | +} | |
165 | +void sendToGallery(struct ConfigStruct *confStruct) { | |
166 | + instance = [iOSNativeShare withTitle:confStruct->title]; | |
167 | +} | |
168 | + | |
169 | +void showSocialSharing(struct SocialSharingStruct *confStruct) { | |
170 | + instance = [iOSNativeShare withText:confStruct->text withURL:confStruct->url withImage:confStruct->image withSubject:confStruct->subject]; | |
171 | +} | |
172 | + | |
173 | +@end | ... | ... |
... | ... | @@ -0,0 +1,23 @@ |
1 | +fileFormatVersion: 2 | |
2 | +guid: 811884d43308440c69d9b36ec817ceed | |
3 | +timeCreated: 1490842313 | |
4 | +licenseType: Free | |
5 | +PluginImporter: | |
6 | + serializedVersion: 1 | |
7 | + iconMap: {} | |
8 | + executionOrder: {} | |
9 | + isPreloaded: 0 | |
10 | + platformData: | |
11 | + Any: | |
12 | + enabled: 0 | |
13 | + settings: {} | |
14 | + Editor: | |
15 | + enabled: 0 | |
16 | + settings: | |
17 | + DefaultValueInitialized: true | |
18 | + iOS: | |
19 | + enabled: 1 | |
20 | + settings: {} | |
21 | + userData: | |
22 | + assetBundleName: | |
23 | + assetBundleVariant: | ... | ... |
Assets/Resources/ANIMS/Ç.anim
Assets/Scenes/Main.unity
... | ... | @@ -3592,53 +3592,53 @@ Animation: |
3592 | 3592 | m_GameObject: {fileID: 535548070} |
3593 | 3593 | m_Enabled: 1 |
3594 | 3594 | serializedVersion: 3 |
3595 | - m_Animation: {fileID: 7400000, guid: 365e5f41595503c48915848d883fabfe, type: 2} | |
3595 | + m_Animation: {fileID: 7400000, guid: e0b82ea10d92c45a49236639d7e127a7, type: 2} | |
3596 | 3596 | m_Animations: |
3597 | - - {fileID: 7400000, guid: f1f36f20657e5244e9c1e21117d9a452, type: 2} | |
3598 | - - {fileID: 7400000, guid: 55bec2c04d14e74488ef127ee380a080, type: 2} | |
3599 | - - {fileID: 7400000, guid: b368bfe0efa37c04bb9c661058ccedb9, type: 2} | |
3600 | - - {fileID: 7400000, guid: 365e5f41595503c48915848d883fabfe, type: 2} | |
3601 | - - {fileID: 7400000, guid: fa9ef8a15fe08a143bc89dc00289fc17, type: 2} | |
3602 | - - {fileID: 7400000, guid: 939bebf16bb2dba44894c5745c5dc1f8, type: 2} | |
3603 | - - {fileID: 7400000, guid: aecdf652be04b444f84644ba7c403960, type: 2} | |
3604 | - - {fileID: 7400000, guid: 53ed20623f5573345a4fb057db454b05, type: 2} | |
3605 | - - {fileID: 7400000, guid: b0bafda258c57414ebfbc4cf89719795, type: 2} | |
3606 | - - {fileID: 7400000, guid: 67caa6e2d05387848a9448b57fffcb0f, type: 2} | |
3607 | - - {fileID: 7400000, guid: a79227e28dd60fa4c9812a51ab9d455e, type: 2} | |
3608 | - - {fileID: 7400000, guid: 8b1d930398178064795f5d23af67dce4, type: 2} | |
3609 | - - {fileID: 7400000, guid: af8192a32a30ab746be40ff1dcb8bc0a, type: 2} | |
3610 | - - {fileID: 7400000, guid: e282c734045b47241988e2b9fdf0dc7e, type: 2} | |
3611 | - - {fileID: 7400000, guid: 698d03f46785361449a10cc0003862eb, type: 2} | |
3612 | - - {fileID: 7400000, guid: e193836512c744c4299651990fc3ca10, type: 2} | |
3613 | - - {fileID: 7400000, guid: c4d452a56e2f4ee4a83e5679f969a354, type: 2} | |
3614 | - - {fileID: 7400000, guid: 220a675640cc72d4f9c8d364c9a377b4, type: 2} | |
3615 | - - {fileID: 7400000, guid: 9a1e34a6954967f4fb3982394bf61eef, type: 2} | |
3616 | - - {fileID: 7400000, guid: 039911b68664f7b40b97e2665893a1e5, type: 2} | |
3617 | - - {fileID: 7400000, guid: b4a4a507b5b85404f9ca30cf2855b359, type: 2} | |
3618 | - - {fileID: 7400000, guid: 3b67cb87e08f4e34badc00f7b49d2591, type: 2} | |
3619 | - - {fileID: 7400000, guid: dc854de773a9e3f488c7a1b42d6a460b, type: 2} | |
3620 | - - {fileID: 7400000, guid: 21b376087ddd4ec46a1da0c3ba1181d9, type: 2} | |
3621 | - - {fileID: 7400000, guid: db84b318b67dbc54fa1fab6d31dfeb6e, type: 2} | |
3622 | - - {fileID: 7400000, guid: 47e5da18eda740844ba111cfab49d0eb, type: 2} | |
3623 | - - {fileID: 7400000, guid: ba9dc32834cf193429f27449b1d9d701, type: 2} | |
3624 | - - {fileID: 7400000, guid: 22f7b3c892f0e5e41b120798d7953026, type: 2} | |
3625 | - - {fileID: 7400000, guid: 9396f2d833a082446b36b0cda61ba87c, type: 2} | |
3626 | - - {fileID: 7400000, guid: 289449396bffd4045b8657269df378f2, type: 2} | |
3627 | - - {fileID: 7400000, guid: 99bb7e6adbe6d5f4984c51d5d5e92045, type: 2} | |
3628 | - - {fileID: 7400000, guid: b6faf58a03a0dc24cb9777c70fda828b, type: 2} | |
3629 | - - {fileID: 7400000, guid: b2b18bfa970783a4ab32945b1c4bc54b, type: 2} | |
3630 | - - {fileID: 7400000, guid: a8b0488b23a43b3499d2b1d8b81f0707, type: 2} | |
3631 | - - {fileID: 7400000, guid: ccdf6bab5e56c0447abfc0a8f745b62c, type: 2} | |
3632 | - - {fileID: 7400000, guid: 8d2c7cdb67fea144e9660db7edd82239, type: 2} | |
3633 | - - {fileID: 7400000, guid: 6191f3fb2e8027b48ac60aa48c11065d, type: 2} | |
3634 | - - {fileID: 7400000, guid: dbf77a3c567182846bad50598584109d, type: 2} | |
3635 | - - {fileID: 7400000, guid: d2f41e4d1ce31a4458ccdab2cd91faae, type: 2} | |
3636 | - - {fileID: 7400000, guid: fc72e7fd88de0b94fb9b050fc1368547, type: 2} | |
3637 | - - {fileID: 7400000, guid: 5b7bf0ae891107f4aaa366ba42eac9ee, type: 2} | |
3638 | - - {fileID: 7400000, guid: d9c72b1fb167df045ae7ac711d1dee6c, type: 2} | |
3639 | - - {fileID: 7400000, guid: d927185f3fb021844834f7086d346e3a, type: 2} | |
3640 | - - {fileID: 7400000, guid: e62d77cfc7d0d104b84d8beb5ef72c33, type: 2} | |
3641 | - - {fileID: 7400000, guid: 1dd400df2179f94469eb2480a313a8cf, type: 2} | |
3597 | + - {fileID: 7400000, guid: 094c9782dfd1a4419b4300050525a196, type: 2} | |
3598 | + - {fileID: 7400000, guid: 0a25b7eb696464a9ba3fedba28052f44, type: 2} | |
3599 | + - {fileID: 7400000, guid: 212a470f4d8764d3aab828715dcceadd, type: 2} | |
3600 | + - {fileID: 7400000, guid: 24ccfe8cc110546aab2e9ea1edab0997, type: 2} | |
3601 | + - {fileID: 7400000, guid: 255d4ddbbcdac46d9917908e6dc83fbf, type: 2} | |
3602 | + - {fileID: 7400000, guid: 2fdb4638c75f24f0aabd6cc76fb610c4, type: 2} | |
3603 | + - {fileID: 7400000, guid: 353f223b7116a4871a1ed9cb10953fec, type: 2} | |
3604 | + - {fileID: 7400000, guid: 38aa20a48a06548d9946da7f3491fd79, type: 2} | |
3605 | + - {fileID: 7400000, guid: 3953996c14ada434e8bece627ea272fb, type: 2} | |
3606 | + - {fileID: 7400000, guid: 3b02e44ef03c5471c873718351272938, type: 2} | |
3607 | + - {fileID: 7400000, guid: 3ff67392ee17d46e8b75e23614754596, type: 2} | |
3608 | + - {fileID: 7400000, guid: 46db7a3a687d6491c87b272ba4a3af9b, type: 2} | |
3609 | + - {fileID: 7400000, guid: 48640d5b0a6804e8a892d7e3f9878338, type: 2} | |
3610 | + - {fileID: 7400000, guid: 6867e7a4c4a93433b85dd978831a5789, type: 2} | |
3611 | + - {fileID: 7400000, guid: 723477075e06c43dca279006c68f629a, type: 2} | |
3612 | + - {fileID: 7400000, guid: 75289ce9809d340a39e5d2d9896ef14e, type: 2} | |
3613 | + - {fileID: 7400000, guid: 773b86077b0a9459eb0d40f9c6147238, type: 2} | |
3614 | + - {fileID: 7400000, guid: 7ccd4c6ab0ec54ceaa2946562f1a9498, type: 2} | |
3615 | + - {fileID: 7400000, guid: 7f65fa3885c054b49ae6e5271be81d3f, type: 2} | |
3616 | + - {fileID: 7400000, guid: 8043026f4179c4e36bf9c52857439067, type: 2} | |
3617 | + - {fileID: 7400000, guid: 829700cfb4bf84f01a308423418d482d, type: 2} | |
3618 | + - {fileID: 7400000, guid: 87310cd5c3519409081aad5bc7d001f4, type: 2} | |
3619 | + - {fileID: 7400000, guid: 8b46d8bdc57654882b802d8a424bbc64, type: 2} | |
3620 | + - {fileID: 7400000, guid: 8c3b08031b41a4af6a38cddd30b6b711, type: 2} | |
3621 | + - {fileID: 7400000, guid: 922333c7fb2f24607a2b6bc7eddc0c92, type: 2} | |
3622 | + - {fileID: 7400000, guid: 93c97cf7199d14c8a85c6a47dfe96fdd, type: 2} | |
3623 | + - {fileID: 7400000, guid: 99e6d1fa06bef4cffb3985c33858ab7f, type: 2} | |
3624 | + - {fileID: 7400000, guid: 9a03fa44cc4e74406a490fa7a601eb2d, type: 2} | |
3625 | + - {fileID: 7400000, guid: 9d20ba4e0319344f29101e050835449a, type: 2} | |
3626 | + - {fileID: 7400000, guid: 9f404de03117c44fcbf5c4bebbdebc39, type: 2} | |
3627 | + - {fileID: 7400000, guid: 9fac8b289e9c34268bade7f7dc070255, type: 2} | |
3628 | + - {fileID: 7400000, guid: a2f710de3a93149d981cfd3643c29f5d, type: 2} | |
3629 | + - {fileID: 7400000, guid: a55f62e68785e4f16b38373c27770c2c, type: 2} | |
3630 | + - {fileID: 7400000, guid: ad8d4c5f8f40746fb809287d36da0da4, type: 2} | |
3631 | + - {fileID: 7400000, guid: b0298c4a0832c4567a80f0293805f766, type: 2} | |
3632 | + - {fileID: 7400000, guid: b90260b13c6b043008a3231f0e325d8b, type: 2} | |
3633 | + - {fileID: 7400000, guid: bd4784c7f8ccc4dd6b9c0d3bca313258, type: 2} | |
3634 | + - {fileID: 7400000, guid: d3a14cd4d3aef472f81d58456286f1da, type: 2} | |
3635 | + - {fileID: 7400000, guid: d902aa4db6b5e44fe9153e04e901b357, type: 2} | |
3636 | + - {fileID: 7400000, guid: d9a3268b5233b489489a6b406f5b560d, type: 2} | |
3637 | + - {fileID: 7400000, guid: daceeb12c57434b03ab14733724787b0, type: 2} | |
3638 | + - {fileID: 7400000, guid: e0b82ea10d92c45a49236639d7e127a7, type: 2} | |
3639 | + - {fileID: 7400000, guid: e0e4fafd1c404477a9330c24fad5c5d5, type: 2} | |
3640 | + - {fileID: 7400000, guid: e5df376619b5547418da0a4bb053a736, type: 2} | |
3641 | + - {fileID: 7400000, guid: edc0fe305be934cfdaf262b2372efc9f, type: 2} | |
3642 | 3642 | m_WrapMode: 0 |
3643 | 3643 | m_PlayAutomatically: 1 |
3644 | 3644 | m_AnimatePhysics: 0 | ... | ... |
No preview for this file type
Assets/Scripts/Export Video/ExportVideo.cs
... | ... | @@ -37,6 +37,7 @@ public class ExportVideo : MonoBehaviour { |
37 | 37 | public ScreenManager screenManager; |
38 | 38 | public MediaShareIOS MediaShareIOS; |
39 | 39 | |
40 | + private MediaShareIOS share = new MediaShareIOS(); | |
40 | 41 | private const string SERVER_URL = "http://150.165.205.84:80/video"; |
41 | 42 | |
42 | 43 | |
... | ... | @@ -44,7 +45,7 @@ public class ExportVideo : MonoBehaviour { |
44 | 45 | private static string gloss = "Gloss"; |
45 | 46 | |
46 | 47 | |
47 | - /* Strings related to the Android Dialog*/ | |
48 | + /* Strings related to the IOS Dialog*/ | |
48 | 49 | private string title = "Download"; |
49 | 50 | private string message = "Para compartilhar é preciso realizar o download do vídeo. Tamanho do Download: "; |
50 | 51 | private string yesOp = "DOWNLOAD"; |
... | ... | @@ -81,26 +82,16 @@ public class ExportVideo : MonoBehaviour { |
81 | 82 | private void onClickExport() |
82 | 83 | { |
83 | 84 | PlayerLogger.Log("ExportVideo", "OnClickExport", "Starting Export..."); |
84 | - | |
85 | - /* Aqui é o começo do processo de Exportar vídeo. Antes do processo realmente começar, deve-se checar se o app tem permissões para escrever | |
86 | - * no aparelho. Deve-se então trocar essa parte do código por uma abordagem iOS. NÃO ESQUECER DO CALLBACK PERMITTED. Caso contrário não | |
87 | - * será direcionado para próxima etapa do processo.*/ | |
88 | - | |
89 | - | |
90 | - /* | |
91 | - NoodlePermissionGranter.PermissionRequestCallback = Permitted; | |
92 | - NoodlePermissionGranter.GrantPermission(NoodlePermissionGranter.NoodleAndroidPermission.WRITE_EXTERNAL_STORAGE); | |
93 | - */ | |
94 | - Permitted(true); | |
85 | + export(); | |
95 | 86 | |
96 | 87 | |
97 | 88 | } |
98 | 89 | |
99 | 90 | |
100 | 91 | |
101 | - private void Permitted(bool PermissionGranted) | |
92 | + private void export() | |
102 | 93 | { |
103 | - if (PermissionGranted) | |
94 | + if (true) | |
104 | 95 | { |
105 | 96 | int fiveTimesCount; |
106 | 97 | |
... | ... | @@ -280,18 +271,17 @@ public class ExportVideo : MonoBehaviour { |
280 | 271 | Action errorAction = () => |
281 | 272 | { |
282 | 273 | screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); |
283 | - /*new AndroidToast().showToast("Erro ao compartilhar mídia.", "LONG");*/ | |
274 | + | |
275 | + share.showAlert ("Vlibras Vídeo","Erro ao compartilhar mídia."); | |
284 | 276 | }; |
285 | - | |
286 | - /*Essa chamada é a que compartilha o video baixado, criando a intent. Achar equivalente no iOS. NÃO ESQUECER DO | |
287 | - * CALLBACK "errorAction", o qual é chamado quando não se pode compartilhar o vídeo.*/ | |
288 | - StartCoroutine(MediaShareIOS.ShareIntent(errorAction)); | |
277 | + StartCoroutine(share.ShareIntent(errorAction)); | |
289 | 278 | } |
290 | 279 | |
291 | 280 | else |
292 | 281 | { |
293 | 282 | /*new AndroidToast().showToast("Erro ao compartilhar mídia.", "LONG");*/ |
294 | 283 | screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); |
284 | + share.showAlert ("Vlibras Vídeo","Erro ao compartilhar mídia."); | |
295 | 285 | } |
296 | 286 | |
297 | 287 | |
... | ... | @@ -498,6 +488,7 @@ public class ExportVideo : MonoBehaviour { |
498 | 488 | private IEnumerator videoDownload() |
499 | 489 | { |
500 | 490 | videoDownloadRunning = true; |
491 | + | |
501 | 492 | WWW DownloadVideo = new WWW(SERVER_URL + "/" + videoFile); |
502 | 493 | |
503 | 494 | while (!DownloadVideo.isDone) |
... | ... | @@ -540,11 +531,10 @@ public class ExportVideo : MonoBehaviour { |
540 | 531 | { |
541 | 532 | bytes = DownloadVideo.bytesDownloaded; |
542 | 533 | videoContent = DownloadVideo.bytes; |
543 | - Action callBack = () => { OnDownloadFinished();/* new AndroidToast().showToast("Vídeo salvo na Galeria.", "SHORT");*/ }; | |
544 | - Action errorWriting = () => { screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); }; | |
545 | - videoDownloadRunning = false; | |
546 | - StartCoroutine(MediaShareIOS.WriteOnIOS(videoContent, bytes, System.DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss"), callBack, errorWriting)); | |
547 | - | |
534 | + Action callBack = () => { OnDownloadFinished(); share.showAlert("Vlibras Vídeo", "Vídeo salvo na Galeria."); }; | |
535 | + Action errorWriting = () => { screenManager.changeExportStates(ExportLayers.ExportLayer.All, true);share.showAlert ("Vlibras Vídeo","Erro ao salvar vídeo, tente novamente."); }; | |
536 | + videoDownloadRunning = false; | |
537 | + StartCoroutine(share.WriteOnIOS(videoContent, bytes, System.DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss"), callBack, errorWriting)); | |
548 | 538 | } |
549 | 539 | else |
550 | 540 | { |
... | ... | @@ -586,20 +576,25 @@ public class ExportVideo : MonoBehaviour { |
586 | 576 | { |
587 | 577 | switch (error) |
588 | 578 | { |
589 | - case ExportLayers.ConnectionStatusError.CONNECTION_TIMEOUT_FAILURE: | |
579 | + case ExportLayers.ConnectionStatusError.CONNECTION_TIMEOUT_FAILURE: | |
590 | 580 | /*new AndroidToast().showToast("Erro de conexão. Tente novamente.", "LONG");*/ |
581 | + share.showAlert ("Vlibras Vídeo","Erro de conexão. Tente novamente."); | |
591 | 582 | break; |
592 | 583 | case ExportLayers.ConnectionStatusError.DOWNLOAD_CONNECTION_FAILURE: |
593 | 584 | /* new AndroidToast().showToast("Erro ao efetuar download, tente novamente.", "LONG");*/ |
585 | + share.showAlert ("Vlibras Vídeo","Erro ao efetuar download, tente novamente."); | |
594 | 586 | break; |
595 | 587 | case ExportLayers.ConnectionStatusError.INTERNET_CONNECTION_FAILURE: |
596 | 588 | /* new AndroidToast().showToast("Não há acesso à internet. Verifique sua conexão", "LONG");*/ |
589 | + share.showAlert ("Vlibras Vídeo","Não há acesso à internet. Verifique sua conexão"); | |
597 | 590 | break; |
598 | 591 | case ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE: |
599 | 592 | /* new AndroidToast().showToast("Problema na conexão. Aguarde e tente novamente.", "LONG");*/ |
593 | + share.showAlert ("Vlibras Vídeo","Problema na conexão. Aguarde e tente novamente."); | |
600 | 594 | break; |
601 | 595 | default: |
602 | 596 | /*new AndroidToast().showToast("Ocorreu um erro. Estamos trabalhando para solucioná-lo!", "LONG");*/ |
597 | + share.showAlert ("Vlibras Vídeo","Ocorreu um erro. Estamos trabalhando para solucioná-lo!"); | |
603 | 598 | break; |
604 | 599 | } |
605 | 600 | ... | ... |
Assets/Scripts/Export Video/MediaShareIOS.cs
... | ... | @@ -14,6 +14,8 @@ |
14 | 14 | *Author: Thiago Filipe |
15 | 15 | *thiago.filipe@lavid.ufpb.br |
16 | 16 | ***********************/ |
17 | + | |
18 | + | |
17 | 19 | using UnityEngine; |
18 | 20 | using System.Collections; |
19 | 21 | using System; |
... | ... | @@ -22,36 +24,22 @@ using System.IO; |
22 | 24 | |
23 | 25 | |
24 | 26 | |
25 | -public class MediaShareIOS : MonoBehaviour | |
26 | -{ | |
27 | - | |
28 | - private string MediaType = "video/*"; | |
27 | +public class MediaShareIOS : MonoBehaviour { | |
29 | 28 | private static string path; |
30 | 29 | private string VlibrasFolder = "VLibras"; |
31 | 30 | private string Filen = "VLibrasVideo_"; |
32 | 31 | private static string FilePath = ""; |
33 | 32 | |
34 | 33 | |
35 | - /*Makes sure that Vlibras Folder gets created and write the video bytes in it.*/ | |
36 | - public void Awake() | |
37 | - { | |
38 | - path = Path.Combine(Application.persistentDataPath, VlibrasFolder); | |
39 | - } | |
34 | + | |
40 | 35 | |
41 | 36 | public IEnumerator WriteOnIOS(byte[] videoContent, int bytes,string CurrentTime, Action finishWriting, Action errorWriting) |
42 | - { | |
37 | + { | |
38 | + path = Application.persistentDataPath; | |
39 | + PlayerLogger.Log("ExportVideo", "VideoDownload", "Writing at: " + path); | |
43 | 40 | /*FilePath se refere ao nome que o arquivo será salvo. Este deve ser mantido como está.*/ |
44 | 41 | FilePath = Filen + CurrentTime + ".mp4"; |
45 | - | |
46 | - /* A partir daqui deve ser feita a implementação IOS, onde deve-se utilizar dos callbacks "finishWriting" e "errorWriting". O primeiro | |
47 | - * chamado em caso de sucesso na escrita do vídeo, o segundo em caso de algum erro.*/ | |
48 | - /*É necessário que o arquivo seja salvo numa pasta própria do Vlibras de maneira que o usuário iOS possa visualizar o vídeo na galeria*/ | |
49 | - | |
50 | - | |
51 | - | |
52 | - | |
53 | 42 | /* Checking if folder Vlibras exists*/ |
54 | - | |
55 | 43 | DirectoryInfo dir = new DirectoryInfo(path); |
56 | 44 | if (!dir.Exists) |
57 | 45 | { |
... | ... | @@ -61,11 +49,11 @@ public class MediaShareIOS : MonoBehaviour |
61 | 49 | try |
62 | 50 | { |
63 | 51 | FileStream SourceStream = new FileStream(Path.Combine(path, FilePath), FileMode.OpenOrCreate); |
64 | - | |
65 | 52 | if (SourceStream.CanWrite) |
66 | 53 | { |
67 | 54 | SourceStream.Write(videoContent, 0, bytes); |
68 | 55 | SourceStream.Close(); |
56 | + ShareIOS.CallSendToGallery(Path.Combine(path,FilePath)); | |
69 | 57 | finishWriting(); |
70 | 58 | |
71 | 59 | yield break; |
... | ... | @@ -74,6 +62,7 @@ public class MediaShareIOS : MonoBehaviour |
74 | 62 | else |
75 | 63 | { |
76 | 64 | // new AndroidToast().showToast("Erro ao salvar vídeo.", "LONG"); |
65 | + | |
77 | 66 | errorWriting(); |
78 | 67 | } |
79 | 68 | |
... | ... | @@ -81,10 +70,8 @@ public class MediaShareIOS : MonoBehaviour |
81 | 70 | } |
82 | 71 | catch (Exception e) |
83 | 72 | { |
84 | - PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.Message); | |
85 | - PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.StackTrace); | |
86 | - // new AndroidToast().showToast("Você precisa dá permissão ao aplicativo", "LONG"); | |
87 | - | |
73 | + PlayerLogger.Log("MediaShareIOS", "WriteOnIOS", "Message: " + e.Message); | |
74 | + PlayerLogger.Log("MediaShareIOS", "WriteOnIOS", "Message: " + e.StackTrace); | |
88 | 75 | errorWriting(); |
89 | 76 | } |
90 | 77 | |
... | ... | @@ -92,19 +79,37 @@ public class MediaShareIOS : MonoBehaviour |
92 | 79 | |
93 | 80 | } |
94 | 81 | |
82 | + public void showAlert(string title,string message){ | |
83 | + ShareIOS.CallSocialShare (title, message); | |
95 | 84 | |
85 | + } | |
96 | 86 | |
97 | 87 | /* Calling Android Services to create Share Intent*/ |
98 | 88 | |
99 | 89 | public IEnumerator ShareIntent(Action errorAction) { |
100 | 90 | |
101 | - /* Aqui deve ser feita a implementação iOS da função que permitirá o usuário compartilhar o vídeo com as redes sociais*/ | |
102 | - /*O callback errorAction deve ser chamado em caso de algum erro no processo, por exemplo: usuário baixou o vídeo e foi salvo | |
103 | - * corretamente, porém antes de clicar compartilhar, ele foi no diretório do vídeo e o excluiu, para então clicar compartilhar.*/ | |
104 | - | |
91 | + #if UNITY_IOS | |
92 | + if(File.Exists(Path.Combine(path,FilePath))){ | |
93 | + ShareIOS share = new ShareIOS(); | |
94 | + PlayerLogger.Log("MediaShareIOS","ShareIntent","Trying to share video."); | |
95 | + try{ | |
96 | + share.Share("Vlibras Video",Path.Combine(path,FilePath),"",""); | |
97 | + }catch(Exception e){ | |
98 | + PlayerLogger.Log("MediaShareIOS", "ShareIntent", "Message: " + e.Message); | |
99 | + PlayerLogger.Log("MediaShareIOS", "ShareIntent", "Message: " + e.StackTrace); | |
100 | + errorAction(); | |
101 | + } | |
102 | + | |
103 | + }else{ | |
104 | + PlayerLogger.Log("MediaShareIOS","ShareIntent","File doesnt exist"); | |
105 | + errorAction(); | |
106 | + } | |
107 | + | |
108 | + | |
109 | + //GeneralSharingiOSBridge.ShareTextWithImage (Path.Combine(path, FilePath), "Vlibras video"); | |
110 | + #endif | |
111 | + | |
105 | 112 | yield break; |
106 | 113 | } |
107 | 114 | |
108 | -} | |
109 | - | |
110 | - | |
115 | +} | |
111 | 116 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,71 @@ |
1 | +using UnityEngine; | |
2 | +using System.Collections; | |
3 | +using System.Runtime.InteropServices; | |
4 | +using System.IO; | |
5 | + | |
6 | +/* | |
7 | + * https://github.com/ChrisMaire/unity-native-sharing | |
8 | + */ | |
9 | + | |
10 | +public class ShareIOS : MonoBehaviour { | |
11 | + | |
12 | + public void Share(string shareText, string imagePath, string url, string subject) | |
13 | + { | |
14 | + #if UNITY_IOS | |
15 | + CallSocialShareAdvanced(shareText, subject, url, imagePath); | |
16 | + #else | |
17 | + Debug.Log("No sharing set up for this platform."); | |
18 | + #endif | |
19 | + } | |
20 | + | |
21 | + #if UNITY_IOS | |
22 | + public struct ConfigStruct | |
23 | + { | |
24 | + public string title; | |
25 | + public string message; | |
26 | + } | |
27 | + | |
28 | + [DllImport ("__Internal")] private static extern void showAlertMessage(ref ConfigStruct conf); | |
29 | + | |
30 | + public struct SocialSharingStruct | |
31 | + { | |
32 | + public string text; | |
33 | + public string url; | |
34 | + public string image; | |
35 | + public string subject; | |
36 | + } | |
37 | + | |
38 | + [DllImport ("__Internal")] private static extern void showSocialSharing(ref SocialSharingStruct conf); | |
39 | + | |
40 | + | |
41 | + public static void CallSocialShare(string title, string message) | |
42 | + { | |
43 | + ConfigStruct conf = new ConfigStruct(); | |
44 | + conf.title = title; | |
45 | + conf.message = message; | |
46 | + showAlertMessage(ref conf); | |
47 | + } | |
48 | + | |
49 | + | |
50 | + public static void CallSocialShareAdvanced(string defaultTxt, string subject, string url, string img) | |
51 | + { | |
52 | + SocialSharingStruct conf = new SocialSharingStruct(); | |
53 | + conf.text = defaultTxt; | |
54 | + conf.url = url; | |
55 | + conf.image = img; | |
56 | + conf.subject = subject; | |
57 | + | |
58 | + showSocialSharing(ref conf); | |
59 | + } | |
60 | + [DllImport ("__Internal")] private static extern void sendToGallery(ref ConfigStruct conf); | |
61 | + | |
62 | + public static void CallSendToGallery(string path){ | |
63 | + ConfigStruct conf = new ConfigStruct (); | |
64 | + conf.title = path; | |
65 | + conf.message = ""; | |
66 | + sendToGallery (ref conf); | |
67 | + | |
68 | + } | |
69 | + | |
70 | + #endif | |
71 | +} | ... | ... |
... | ... | @@ -0,0 +1,12 @@ |
1 | +fileFormatVersion: 2 | |
2 | +guid: 184b416e499e94d8ba8d1a429c05c11f | |
3 | +timeCreated: 1490842858 | |
4 | +licenseType: Free | |
5 | +MonoImporter: | |
6 | + serializedVersion: 2 | |
7 | + defaultReferences: [] | |
8 | + executionOrder: 0 | |
9 | + icon: {instanceID: 0} | |
10 | + userData: | |
11 | + assetBundleName: | |
12 | + assetBundleVariant: | ... | ... |
ProjectSettings/ProjectSettings.asset