Commit 1f82cfb41fbc298f3fdac12701de9e8086121bfd
1 parent
1cd22e49
Exists in
master
and in
3 other branches
Finish Handle Download
Showing
5 changed files
with
144 additions
and
108 deletions
Show diff stats
Assets/Scenes/Main.unity
| ... | ... | @@ -811,7 +811,7 @@ RectTransform: |
| 811 | 811 | m_AnchorMin: {x: 0, y: 1.7} |
| 812 | 812 | m_AnchorMax: {x: 0.97, y: 2.2} |
| 813 | 813 | m_AnchoredPosition: {x: 0, y: 0} |
| 814 | - m_SizeDelta: {x: 0, y: 0} | |
| 814 | + m_SizeDelta: {x: -239.8714, y: 0} | |
| 815 | 815 | m_Pivot: {x: 1, y: 0} |
| 816 | 816 | --- !u!114 &160532053 |
| 817 | 817 | MonoBehaviour: |
| ... | ... | @@ -3963,7 +3963,7 @@ RectTransform: |
| 3963 | 3963 | m_AnchorMin: {x: 0, y: 1.7} |
| 3964 | 3964 | m_AnchorMax: {x: 0.97, y: 2.2} |
| 3965 | 3965 | m_AnchoredPosition: {x: 0, y: 0} |
| 3966 | - m_SizeDelta: {x: 0, y: 0} | |
| 3966 | + m_SizeDelta: {x: -239.8714, y: 0} | |
| 3967 | 3967 | m_Pivot: {x: 1, y: 0} |
| 3968 | 3968 | --- !u!114 &581668678 |
| 3969 | 3969 | MonoBehaviour: |
| ... | ... | @@ -7238,13 +7238,12 @@ RectTransform: |
| 7238 | 7238 | m_AnchorMin: {x: 0, y: 1.7} |
| 7239 | 7239 | m_AnchorMax: {x: 0.97, y: 2.2} |
| 7240 | 7240 | m_AnchoredPosition: {x: 0, y: 0} |
| 7241 | - m_SizeDelta: {x: 0, y: 0} | |
| 7241 | + m_SizeDelta: {x: -239.8714, y: 0} | |
| 7242 | 7242 | m_Pivot: {x: 1, y: 0} |
| 7243 | 7243 | --- !u!114 &1059619784 |
| 7244 | 7244 | MonoBehaviour: |
| 7245 | 7245 | m_ObjectHideFlags: 0 |
| 7246 | - m_PrefabParentObject: {fileID: 11431640, guid: 5ccb0ba277304a14b9bb8d4e34161675, | |
| 7247 | - type: 2} | |
| 7246 | + m_PrefabParentObject: {fileID: 0} | |
| 7248 | 7247 | m_PrefabInternal: {fileID: 0} |
| 7249 | 7248 | m_GameObject: {fileID: 1059619782} |
| 7250 | 7249 | m_Enabled: 1 |
| ... | ... | @@ -7253,7 +7252,7 @@ MonoBehaviour: |
| 7253 | 7252 | m_Name: |
| 7254 | 7253 | m_EditorClassIdentifier: |
| 7255 | 7254 | m_Navigation: |
| 7256 | - m_Mode: 0 | |
| 7255 | + m_Mode: 3 | |
| 7257 | 7256 | m_SelectOnUp: {fileID: 0} |
| 7258 | 7257 | m_SelectOnDown: {fileID: 0} |
| 7259 | 7258 | m_SelectOnLeft: {fileID: 0} | ... | ... |
Assets/Scripts/Export Video/ExportLayers.cs
| ... | ... | @@ -11,6 +11,7 @@ public class ExportLayers{ |
| 11 | 11 | Share_Layer, |
| 12 | 12 | Progress_Download_Layer, |
| 13 | 13 | OnLockExport, |
| 14 | + OnLockShare, | |
| 14 | 15 | All |
| 15 | 16 | } |
| 16 | 17 | |
| ... | ... | @@ -19,6 +20,7 @@ public class ExportLayers{ |
| 19 | 20 | INTERNET_CONNECTION_FAILURE, |
| 20 | 21 | DOWNLOAD_CONNECTION_FAILURE, |
| 21 | 22 | CONNECTION_TIMEOUT_FAILURE, |
| 22 | - ERROR_CONNECTION_FAILURE | |
| 23 | + ERROR_CONNECTION_FAILURE, | |
| 24 | + DEFAULT | |
| 23 | 25 | } |
| 24 | 26 | } | ... | ... |
Assets/Scripts/Export Video/ExportVideo.cs
| ... | ... | @@ -34,14 +34,9 @@ public class ExportVideo : MonoBehaviour { |
| 34 | 34 | |
| 35 | 35 | private const string SERVER_URL = "http://150.165.205.57/video/"; |
| 36 | 36 | |
| 37 | - /*Strings to Compare glosses*/ | |
| 38 | - private static string gloss = "Gloss"; | |
| 39 | - private string currentGloss = "CurrentGloss"; | |
| 40 | - | |
| 41 | - /* Sharing Current Time - Video Name*/ | |
| 42 | - private string currentTime = ""; | |
| 43 | - | |
| 44 | 37 | |
| 38 | + private static string gloss = "Gloss"; | |
| 39 | + | |
| 45 | 40 | |
| 46 | 41 | /* Strings related to the Android Dialog*/ |
| 47 | 42 | private string title = "Download"; |
| ... | ... | @@ -101,15 +96,12 @@ public class ExportVideo : MonoBehaviour { |
| 101 | 96 | |
| 102 | 97 | public void onDownloadClick() |
| 103 | 98 | { |
| 104 | - MobileNativeDialog nativeDialog; | |
| 105 | - | |
| 106 | - | |
| 99 | + MobileNativeDialog nativeDialog; | |
| 107 | 100 | |
| 108 | 101 | nativeDialog = new MobileNativeDialog(title, message + ((videoSize/1024f)/1024f).ToString("0.00") + " MB.", yesOp, noOp); |
| 109 | 102 | nativeDialog.OnComplete = OnComplete; |
| 110 | 103 | |
| 111 | - } | |
| 112 | - | |
| 104 | + } | |
| 113 | 105 | |
| 114 | 106 | /** Delegate function which waits for YES or NO from the MobileDialog |
| 115 | 107 | * and attach a action to each option**/ |
| ... | ... | @@ -165,33 +157,19 @@ public class ExportVideo : MonoBehaviour { |
| 165 | 157 | |
| 166 | 158 | public void OnShareVideo() |
| 167 | 159 | { |
| 168 | - PlayerLogger.Log("ExportVideo", "OnShareVideo", "Sharing Video..."); | |
| 169 | - | |
| 170 | - if (gloss == currentGloss) //Checking if user is trying to share the same animation | |
| 171 | - { | |
| 172 | - Share(); | |
| 173 | - } | |
| 174 | - else | |
| 175 | - { | |
| 176 | - currentGloss = gloss; | |
| 177 | - currentTime = System.DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss"); | |
| 178 | - Share(); | |
| 179 | - } | |
| 180 | - } | |
| 181 | - | |
| 182 | - private void Share() | |
| 183 | - { | |
| 184 | 160 | |
| 185 | 161 | try |
| 186 | 162 | { |
| 187 | 163 | if (videoContent != null) |
| 188 | 164 | { |
| 165 | + Action errorAction = () => { screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | |
| 166 | + new AndroidToast().showToast("Erro ao compartilhar mídia."); }; | |
| 189 | 167 | |
| 190 | - MediaShareAndroid.ShareActivity(videoContent, bytes, currentTime); | |
| 168 | + StartCoroutine(MediaShareAndroid.ShareIntent(errorAction)); | |
| 191 | 169 | } |
| 192 | 170 | else |
| 193 | 171 | { |
| 194 | - new AndroidToast().showToast("Erro ao compartilhar vídeo"); | |
| 172 | + new AndroidToast().showToast("Erro ao compartilhar mídia."); | |
| 195 | 173 | screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); |
| 196 | 174 | } |
| 197 | 175 | } |
| ... | ... | @@ -235,24 +213,25 @@ public class ExportVideo : MonoBehaviour { |
| 235 | 213 | } |
| 236 | 214 | else if (videoInfoRequest.responseHeaders.Count == 0) |
| 237 | 215 | { |
| 216 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | |
| 238 | 217 | PlayerLogger.Log("ExportVideo", "requestVideoInfo", "(WWW) Unsucessful Answer"); |
| 239 | 218 | GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); |
| 240 | - screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | |
| 219 | + | |
| 241 | 220 | |
| 242 | 221 | } |
| 243 | 222 | else if (!videoInfoRequest.responseHeaders["STATUS"].Contains("200")) |
| 244 | 223 | { |
| 245 | - | |
| 224 | + screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | |
| 246 | 225 | PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Unsuccessful answer (" + videoInfoRequest.responseHeaders["STATUS"] + ")."); |
| 247 | 226 | GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); |
| 248 | - screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | |
| 227 | + | |
| 249 | 228 | |
| 250 | 229 | } |
| 251 | 230 | else if (String.IsNullOrEmpty(videoInfoRequest.text)) |
| 252 | 231 | { |
| 253 | 232 | |
| 254 | 233 | screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); |
| 255 | - GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); | |
| 234 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.DEFAULT); | |
| 256 | 235 | PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Empty answer."); |
| 257 | 236 | } |
| 258 | 237 | else |
| ... | ... | @@ -285,24 +264,49 @@ public class ExportVideo : MonoBehaviour { |
| 285 | 264 | { |
| 286 | 265 | videoDownloadRunning = true; |
| 287 | 266 | WWW DownloadVideo = new WWW(SERVER_URL + videoId); |
| 288 | - // WWW DownloadVideo = new WWW("http://caiomcg.com/rural.mp4"); | |
| 267 | + | |
| 289 | 268 | while (!DownloadVideo.isDone) |
| 290 | 269 | { |
| 291 | 270 | screenManager.updateProgressDownloadSprite(DownloadVideo.progress); |
| 271 | + | |
| 292 | 272 | yield return null; |
| 293 | 273 | } |
| 294 | 274 | |
| 295 | 275 | try |
| 296 | 276 | { |
| 297 | - if (DownloadVideo.bytesDownloaded > 0 && DownloadVideo.bytesDownloaded<=videoSize) | |
| 277 | + | |
| 278 | + if(DownloadVideo.error != null) | |
| 279 | + { | |
| 280 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.INTERNET_CONNECTION_FAILURE); | |
| 281 | + ErrorDownloading(); | |
| 282 | + | |
| 283 | + } | |
| 284 | + else if(DownloadVideo.responseHeaders.Count == 0) | |
| 285 | + { | |
| 286 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); | |
| 287 | + ErrorDownloading(); | |
| 288 | + | |
| 289 | + } | |
| 290 | + else if (!DownloadVideo.responseHeaders["STATUS"].Contains("200")) | |
| 291 | + { | |
| 292 | + GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE); | |
| 293 | + ErrorDownloading(); | |
| 294 | + | |
| 295 | + } | |
| 296 | + else if ( DownloadVideo.bytesDownloaded == videoSize) | |
| 298 | 297 | { |
| 299 | 298 | bytes = DownloadVideo.bytesDownloaded; |
| 300 | 299 | videoContent = DownloadVideo.bytes; |
| 301 | - OnDownloadFinished(); | |
| 300 | + Action callBack = () => { OnDownloadFinished(); new AndroidToast().showToast("Vídeo salvo na Galeria."); }; | |
| 301 | + Action errorWriting = () => { screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); }; | |
| 302 | + videoDownloadRunning = false; | |
| 303 | + StartCoroutine(MediaShareAndroid.WriteOnAndroid(videoContent, bytes, System.DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss"),callBack,errorWriting)); | |
| 304 | + | |
| 302 | 305 | } |
| 303 | 306 | else |
| 304 | 307 | { |
| 305 | 308 | GetConnectionStatusError(ExportLayers.ConnectionStatusError.DOWNLOAD_CONNECTION_FAILURE); |
| 309 | + ErrorDownloading(); | |
| 306 | 310 | } |
| 307 | 311 | |
| 308 | 312 | |
| ... | ... | @@ -313,6 +317,16 @@ public class ExportVideo : MonoBehaviour { |
| 313 | 317 | } |
| 314 | 318 | } |
| 315 | 319 | |
| 320 | + /* In case of error during the video download, the user gets a new chance to download the file, but | |
| 321 | + * is also able to start a new fresh animation and export it */ | |
| 322 | + private void ErrorDownloading() | |
| 323 | + { | |
| 324 | + screenManager.changeExportStates(ExportLayers.ExportLayer.Progress_Download_Layer, false); | |
| 325 | + screenManager.changeExportStates(ExportLayers.ExportLayer.Download_Layer, true); | |
| 326 | + screenManager.changeExportStates(ExportLayers.ExportLayer.OnLockExport, false); | |
| 327 | + screenManager.changeExportStates(ExportLayers.ExportLayer.OnLockShare, false); | |
| 328 | + } | |
| 329 | + | |
| 316 | 330 | public IEnumerator WaitForResponse(WWW www, Events.RequestSuccess success, Events.RequestError error) |
| 317 | 331 | { |
| 318 | 332 | yield return Methods.WaitForResponse(www, 60*5f, success, error); |
| ... | ... | @@ -324,6 +338,7 @@ public class ExportVideo : MonoBehaviour { |
| 324 | 338 | yield return WaitForResponse(www, null, null); |
| 325 | 339 | } |
| 326 | 340 | |
| 341 | + /* Error states to show a Toast to user*/ | |
| 327 | 342 | private static void GetConnectionStatusError(ExportLayers.ConnectionStatusError error) |
| 328 | 343 | { |
| 329 | 344 | switch (error) | ... | ... |
Assets/Scripts/Export Video/MediaShareAndroid.cs
| ... | ... | @@ -18,6 +18,7 @@ using UnityEngine; |
| 18 | 18 | using System.Collections; |
| 19 | 19 | using System.IO; |
| 20 | 20 | using System; |
| 21 | +using LAViD.Unity.Utils; | |
| 21 | 22 | |
| 22 | 23 | |
| 23 | 24 | |
| ... | ... | @@ -30,9 +31,10 @@ public class MediaShareAndroid : MonoBehaviour |
| 30 | 31 | |
| 31 | 32 | private string AndroidPath; |
| 32 | 33 | |
| 33 | - private string destination = ""; | |
| 34 | + private static string destination = ""; | |
| 34 | 35 | private string Vlibras = "DCIM/VLibras"; |
| 35 | - private string File = "VLibrasVideo_"; | |
| 36 | + private string Filen = "VLibrasVideo_"; | |
| 37 | + private static string FilePath = ""; | |
| 36 | 38 | |
| 37 | 39 | private byte[] videoContent; |
| 38 | 40 | private int bytes; |
| ... | ... | @@ -45,25 +47,12 @@ public class MediaShareAndroid : MonoBehaviour |
| 45 | 47 | |
| 46 | 48 | /*Makes sure that Vlibras Folder gets created and write the video bytes in it.*/ |
| 47 | 49 | |
| 48 | - /* Creates the sharing activity and shows the chooser to the user*/ | |
| 49 | - | |
| 50 | - public void ShareActivity(byte[] videoContent,int bytes, string CurrentTime) | |
| 50 | + public IEnumerator WriteOnAndroid(byte[] videoContent, int bytes,string CurrentTime, Action finishWriting, Action errorWriting) | |
| 51 | 51 | { |
| 52 | - | |
| 53 | 52 | #if UNITY_ANDROID |
| 54 | - | |
| 55 | - this.videoContent = videoContent; | |
| 56 | - this.bytes = bytes; | |
| 57 | - | |
| 58 | - | |
| 59 | - StartCoroutine(WriteOnAndroid(File + CurrentTime + ".mp4")); | |
| 60 | - | |
| 61 | -#endif | |
| 62 | - } | |
| 63 | - | |
| 64 | - private IEnumerator WriteOnAndroid(string FileName) | |
| 65 | - { | |
| 53 | + FilePath = Filen + CurrentTime + ".mp4"; | |
| 66 | 54 | destination = Path.Combine(AndroidPath, Vlibras); |
| 55 | + | |
| 67 | 56 | |
| 68 | 57 | /* Checking if folder Vlibras exists*/ |
| 69 | 58 | |
| ... | ... | @@ -72,72 +61,98 @@ public class MediaShareAndroid : MonoBehaviour |
| 72 | 61 | { |
| 73 | 62 | dir.Create(); |
| 74 | 63 | } |
| 75 | - | |
| 76 | - /*Checking if there's a file with same name - If so, means user's trying | |
| 77 | - * to share the same video*/ | |
| 78 | - | |
| 79 | - dir = new DirectoryInfo(Path.Combine(destination, FileName)); | |
| 80 | - if (!dir.Exists) | |
| 64 | + | |
| 65 | + try | |
| 66 | + { | |
| 67 | + FileStream SourceStream = new FileStream(Path.Combine(destination, FilePath), FileMode.OpenOrCreate); | |
| 68 | + if (SourceStream.CanWrite) | |
| 69 | + { | |
| 70 | + SourceStream.Write(videoContent, 0, bytes); | |
| 71 | + SourceStream.Close(); | |
| 72 | + | |
| 73 | + Refresh(FilePath); | |
| 74 | + finishWriting(); | |
| 75 | + yield break; | |
| 76 | + | |
| 77 | + } | |
| 78 | + else | |
| 79 | + { | |
| 80 | + new AndroidToast().showToast("Erro ao salvar vídeo."); | |
| 81 | + errorWriting(); | |
| 82 | + } | |
| 83 | + | |
| 84 | + | |
| 85 | + } | |
| 86 | + catch (Exception e) | |
| 81 | 87 | { |
| 82 | - FileStream SourceStream = new FileStream(Path.Combine(destination, FileName), FileMode.OpenOrCreate); | |
| 83 | - if (SourceStream.CanWrite) | |
| 84 | - { | |
| 85 | - SourceStream.Write(videoContent, 0, bytes); | |
| 86 | - SourceStream.Close(); | |
| 87 | - | |
| 88 | - } | |
| 89 | - else | |
| 90 | - { | |
| 91 | - new AndroidToast().showToast("Erro ao compartilhar arquivo."); | |
| 92 | - } | |
| 93 | - | |
| 88 | + PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid","Message: " + e.Message); | |
| 89 | + PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.StackTrace); | |
| 90 | + new AndroidToast().showToast("Você precisa dá permissão ao aplicativo"); | |
| 91 | + errorWriting(); | |
| 94 | 92 | } |
| 95 | 93 | |
| 96 | - yield return null; | |
| 97 | - Refresh(FileName); | |
| 98 | 94 | |
| 95 | + | |
| 96 | +#endif | |
| 97 | + | |
| 99 | 98 | |
| 100 | 99 | |
| 101 | 100 | |
| 102 | 101 | } |
| 103 | 102 | |
| 104 | - private void Refresh(string FileName) | |
| 105 | - { | |
| 103 | + /* Calling Android Services to refresh the video path, making available to show in gallery*/ | |
| 106 | 104 | |
| 105 | + private void Refresh(string FilePath) | |
| 106 | + { | |
| 107 | + | |
| 107 | 108 | AndroidJavaClass jcUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); |
| 108 | 109 | AndroidJavaObject joActivity = jcUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); |
| 109 | 110 | AndroidJavaObject joContext = joActivity.Call<AndroidJavaObject>("getApplicationContext"); |
| 110 | 111 | AndroidJavaClass jcMediaScannerConnection = new AndroidJavaClass("android.media.MediaScannerConnection"); |
| 111 | - //AndroidJavaClass jcEnvironment = new AndroidJavaClass("android.os.Environment"); | |
| 112 | - // AndroidJavaObject joExDir = jcEnvironment.CallStatic<AndroidJavaObject>("getExternalStorageDirectory"); | |
| 113 | - string path = Path.Combine(destination,FileName); | |
| 114 | - jcMediaScannerConnection.CallStatic("scanFile", joContext, new string[] { path }, null, null); | |
| 115 | - StartCoroutine(ShareIntent(FileName)); | |
| 112 | + //AndroidJavaClass jcEnvironment = new AndroidJavaClass("android.os.Environment"); | |
| 113 | + // AndroidJavaObject joExDir = jcEnvironment.CallStatic<AndroidJavaObject>("getExternalStorageDirectory"); | |
| 114 | + string path = destination; | |
| 115 | + jcMediaScannerConnection.CallStatic("scanFile", joContext, new string[] { path }, new string[] { "video/mp4" },null ); | |
| 116 | + | |
| 117 | + | |
| 116 | 118 | |
| 117 | 119 | } |
| 118 | 120 | |
| 119 | - private IEnumerator ShareIntent(string FileName) { | |
| 120 | 121 | |
| 121 | - // block to open the file and share it ------------START | |
| 122 | - AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); | |
| 123 | - AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent"); | |
| 124 | - intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND")); | |
| 122 | + /* Calling Android Services to create Share Intent*/ | |
| 125 | 123 | |
| 126 | - AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); | |
| 127 | - AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + Path.Combine(destination,FileName)); | |
| 128 | - | |
| 129 | - intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject); | |
| 130 | - intentObject.Call<AndroidJavaObject>("setType", MediaType); | |
| 124 | + public IEnumerator ShareIntent(Action errorAction) { | |
| 125 | + | |
| 126 | + | |
| 127 | + if(File.Exists(Path.Combine(destination, FilePath))) | |
| 128 | + { | |
| 131 | 129 | |
| 132 | - //add data to be passed to the other activity i.e., the data to be sent | |
| 133 | - intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "VLibras"); | |
| 134 | - intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), SubtitleMessage); | |
| 135 | - intentObject.Call<AndroidJavaObject>("setType", "video/*"); | |
| 136 | - AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | |
| 137 | - AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Compartilhar via"); | |
| 138 | - AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity"); | |
| 139 | - currentActivity.Call("startActivity", jChooser); | |
| 140 | - yield break; | |
| 130 | + // block to open the file and share it ------------START | |
| 131 | + AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); | |
| 132 | + AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent"); | |
| 133 | + intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND")); | |
| 134 | + | |
| 135 | + AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); | |
| 136 | + AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + Path.Combine(destination, FilePath)); | |
| 137 | + | |
| 138 | + intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject); | |
| 139 | + intentObject.Call<AndroidJavaObject>("setType", MediaType); | |
| 140 | + | |
| 141 | + //add data to be passed to the other activity i.e., the data to be sent | |
| 142 | + intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "VLibras"); | |
| 143 | + intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), SubtitleMessage); | |
| 144 | + intentObject.Call<AndroidJavaObject>("setType", "video/*"); | |
| 145 | + AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | |
| 146 | + AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Compartilhar via"); | |
| 147 | + AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity"); | |
| 148 | + currentActivity.Call("startActivity", jChooser); | |
| 149 | + yield break; | |
| 150 | + }else | |
| 151 | + { | |
| 152 | + errorAction(); | |
| 153 | + | |
| 154 | + yield break; | |
| 155 | + } | |
| 141 | 156 | |
| 142 | 157 | |
| 143 | 158 | } | ... | ... |
Assets/Scripts/UI/ScreenManager.cs
| ... | ... | @@ -317,6 +317,8 @@ public class ScreenManager : MonoBehaviour { |
| 317 | 317 | this.shareLayer.SetActive(active); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | + | |
| 321 | + | |
| 320 | 322 | public void setTranslateButtonActive(bool active) |
| 321 | 323 | { |
| 322 | 324 | this.textButton.SetActive(active); |
| ... | ... | @@ -379,6 +381,9 @@ public class ScreenManager : MonoBehaviour { |
| 379 | 381 | case ExportLayers.ExportLayer.OnLockExport: |
| 380 | 382 | onLockExport = show_Layer; |
| 381 | 383 | break; |
| 384 | + case ExportLayers.ExportLayer.OnLockShare: | |
| 385 | + onLockShare = show_Layer; | |
| 386 | + break; | |
| 382 | 387 | default: |
| 383 | 388 | onLockShare = false; |
| 384 | 389 | onLockExport = false; | ... | ... |