diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index aebc304..2c58e10 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: 365e5f41595503c48915848d883fabfe, type: 2} + m_Animation: {fileID: 7400000, guid: 56fd236d710575546b549738e3dc9933, type: 2} m_Animations: - - {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} + - {fileID: 7400000, guid: 00ba6a68a60cf8348913c1e1d08225e3, type: 2} + - {fileID: 7400000, guid: 024064fef8ad0984aa83a059ef0e97c8, type: 2} + - {fileID: 7400000, guid: 0373e89bc94f97f42aefada1a5e994ac, type: 2} + - {fileID: 7400000, guid: 0dbce6a38bccda54b8d8443be19c2905, type: 2} + - {fileID: 7400000, guid: 27f596f7fb38c374986ba04b5bf611e8, type: 2} + - {fileID: 7400000, guid: 2e44a90255a34fc4daaf3501a03ba3f3, type: 2} + - {fileID: 7400000, guid: 2eb5f0288bd3a974ea446273239d009a, type: 2} + - {fileID: 7400000, guid: 338176eab422f4343ae0ae772d51dfa6, type: 2} + - {fileID: 7400000, guid: 360cc2b0364920c4ebc83c179b438ec1, type: 2} + - {fileID: 7400000, guid: 36d0b9cf63020da4286cf20b16b495c5, type: 2} + - {fileID: 7400000, guid: 37682432023174c4e9a65c33c5bcf6ad, type: 2} + - {fileID: 7400000, guid: 37acbbb29e9f37645bc036795319ac94, type: 2} + - {fileID: 7400000, guid: 37c181c0836f84d4a8e25e67948031dd, type: 2} + - {fileID: 7400000, guid: 3d4889193e5c46d4a8a9ea1282279390, type: 2} + - {fileID: 7400000, guid: 3dca07e4550670b4e842986e06aa5a41, type: 2} + - {fileID: 7400000, guid: 3fd16a68343cc144cb70cb3db4b0aa9b, type: 2} + - {fileID: 7400000, guid: 40d0a790b3070ce4d81fc3da05bb1963, type: 2} + - {fileID: 7400000, guid: 4876b0814a4a3fd4386a47aead3d7207, type: 2} + - {fileID: 7400000, guid: 48f6c6bc2bc27744e9f12e87e4b504eb, type: 2} + - {fileID: 7400000, guid: 5600eee8fa75c8d4c92845cd1176bceb, type: 2} + - {fileID: 7400000, guid: 56fd236d710575546b549738e3dc9933, type: 2} + - {fileID: 7400000, guid: 5e103a53e53391843a93077f19061252, type: 2} + - {fileID: 7400000, guid: 640c9d6234220764b893b1f4610cdd7e, type: 2} + - {fileID: 7400000, guid: 67ff80d2ea811764582b3c4cfb2add22, type: 2} + - {fileID: 7400000, guid: 6feff12708ff8c74282adac908065059, type: 2} + - {fileID: 7400000, guid: 7391bb14ca59ae34582bb754db53a460, type: 2} + - {fileID: 7400000, guid: 7952ed760df457746864064d057a1d9f, type: 2} + - {fileID: 7400000, guid: 85921d4ab9939a74b8d2a58fc4163730, type: 2} + - {fileID: 7400000, guid: 8d22d5e519d6b8e498f48b51631ce8f7, type: 2} + - {fileID: 7400000, guid: 9d3f854d217779e47b726e84a47da4fe, type: 2} + - {fileID: 7400000, guid: a1df8cb05298af045b2be5384f26437c, type: 2} + - {fileID: 7400000, guid: ab8c477aa3617b348ac1537726e6842f, type: 2} + - {fileID: 7400000, guid: b51aee90ed0d25840b3c3d07b0138c89, type: 2} + - {fileID: 7400000, guid: beca8deb081aa4b4997e3d50fa3c04cc, type: 2} + - {fileID: 7400000, guid: bee4bcce8696adb44b4af556524884d8, type: 2} + - {fileID: 7400000, guid: bf04328d95b211f4b96bc4d5e4f5523c, type: 2} + - {fileID: 7400000, guid: c1e3354da9dc9b74cacf65993ca5639e, type: 2} + - {fileID: 7400000, guid: c888b74092e95d647bde3a70261c79a7, type: 2} + - {fileID: 7400000, guid: d071f97fc9e45a745ad417f099115813, type: 2} + - {fileID: 7400000, guid: d369df1e9db31e74e8bec69b7e1eeaef, type: 2} + - {fileID: 7400000, guid: d4a1fa94131f32c418ffdadf548db9f2, type: 2} + - {fileID: 7400000, guid: e1bee7fd96ded354aa9bd72e4008a4c5, type: 2} + - {fileID: 7400000, guid: e3f85472d697c2b48a0f45c19e777c61, type: 2} + - {fileID: 7400000, guid: ed5c2ec7af4ecdf46bc8ad611a9bbe9e, type: 2} + - {fileID: 7400000, guid: f631fe8169818ba4aaf06daed9e39a7e, type: 2} m_WrapMode: 0 m_PlayAutomatically: 1 m_AnimatePhysics: 0 diff --git a/Assets/Scripts/Export Video/AndroidToast.cs b/Assets/Scripts/Export Video/AndroidToast.cs index 9c3cd89..72073e3 100644 --- a/Assets/Scripts/Export Video/AndroidToast.cs +++ b/Assets/Scripts/Export Video/AndroidToast.cs @@ -25,7 +25,7 @@ public class AndroidToast AndroidJavaObject context; public void showToast(string toastString,string lenght){ -#if UNITY_ANDROID + if (Application.platform == RuntimePlatform.Android) { UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); @@ -38,6 +38,6 @@ public class AndroidToast toast.Call("show"); } } -#endif + } diff --git a/Assets/Scripts/Export Video/ExportVideo.cs b/Assets/Scripts/Export Video/ExportVideo.cs index dc88cf5..95cde07 100644 --- a/Assets/Scripts/Export Video/ExportVideo.cs +++ b/Assets/Scripts/Export Video/ExportVideo.cs @@ -32,7 +32,8 @@ public class ExportVideo : MonoBehaviour { public ScreenManager screenManager; public MediaShareAndroid MediaShareAndroid; - private const string SERVER_URL = "http://150.165.205.57/video/"; + private const string SERVER_URL = "http://150.165.205.84:80/video"; + private static string gloss = "Gloss"; @@ -49,6 +50,7 @@ public class ExportVideo : MonoBehaviour { private int videoSize = 0; private int bytes = 0; private string videoId = ""; + private string videoFile = ""; private byte[] videoContent = null; /*Coroutine flags */ @@ -71,9 +73,10 @@ public class ExportVideo : MonoBehaviour { private void onClickExport() { PlayerLogger.Log("ExportVideo", "OnClickExport", "Starting Export..."); - - NoodlePermissionGranter.PermissionRequestCallback = Permitted; - NoodlePermissionGranter.GrantPermission(NoodlePermissionGranter.NoodleAndroidPermission.WRITE_EXTERNAL_STORAGE); + + NoodlePermissionGranter.PermissionRequestCallback = Permitted; + NoodlePermissionGranter.GrantPermission(NoodlePermissionGranter.NoodleAndroidPermission.WRITE_EXTERNAL_STORAGE); + } @@ -84,9 +87,33 @@ public class ExportVideo : MonoBehaviour { { if (PermissionGranted) { + int fiveTimesCount; + + if (PlayerPrefs.HasKey("fiveTimesCount")) + { + fiveTimesCount = PlayerPrefs.GetInt("fiveTimesCount"); + if(fiveTimesCount < 5) + { + fiveTimesCount++; + PlayerPrefs.SetInt("fiveTimesCount", fiveTimesCount); + PlayerPrefs.Save(); + + } + else + { + fiveTimesCount = 0; + PlayerPrefs.SetString("exportDialog", "declined"); + PlayerPrefs.Save(); + } + + }else + { + PlayerPrefs.SetFloat("fiveTimesCount", 0); + PlayerPrefs.Save(); + } bool accepted = false; - string message = "A geração do vídeo pode levar algum tempo."; + string message = "A geração de vídeo pode levar algum tempo."; if (PlayerPrefs.HasKey("exportDialog")) { accepted = PlayerPrefs.GetString("exportDialog").Equals("accepted"); @@ -110,6 +137,7 @@ public class ExportVideo : MonoBehaviour { screenManager.showPermissionDialog("Para salvar e compartilhar as animações, permita que o Vlibras acesse mídia e arquivos de seu aparelho.", "Exportar Vìdeo"); // new AndroidToast().showToast("Você precisa dá permissão ao aplicativo.", "LONG"); } + } @@ -136,7 +164,7 @@ public class ExportVideo : MonoBehaviour { * shows the progress bar while getting video info*/ public void startExport() { - new AndroidToast().showToast("Gerando Video...", "SHORT"); + // new AndroidToast().showToast("Gerando Video...", "SHORT"); screenManager.changeExportStates(ExportLayers.ExportLayer.Export_Layer, false); screenManager.changeExportStates(ExportLayers.ExportLayer.Progress_Layer, true); @@ -310,7 +338,7 @@ public class ExportVideo : MonoBehaviour { FileContent fileContent = new FileContent(); fileContent = FileContent.CreateFromJSON(videoInfoRequest.text); - videoId = fileContent.file; + videoId = fileContent.id; StartCoroutine("VideoStatus"); } @@ -332,12 +360,10 @@ public class ExportVideo : MonoBehaviour { private IEnumerator VideoStatus() { - - WWWForm JsonRequest = new WWWForm(); - JsonRequest.AddField("id", videoId); while (true) { - WWW videoStatusRequest = new WWW(SERVER_URL, JsonRequest); + WWW videoStatusRequest = new WWW(SERVER_URL + "/status/" + videoId); + Debug.Log(SERVER_URL + "/" + WWW.EscapeURL("status") + "/" + WWW.EscapeURL(videoId)); yield return WaitForResponse(videoStatusRequest); @@ -395,9 +421,11 @@ public class ExportVideo : MonoBehaviour { FileContent fileContent = new FileContent(); - fileContent = FileContent.CreateFromJSON(videoStatusRequest.text); - if(fileContent.status == "done") + fileContent = FileContent.CreateFromJSON(videoStatusRequest.text); + if(fileContent.status.Equals("success")) { + + videoFile = fileContent.file; videoSize = int.Parse(fileContent.size); OnFinishGetVideoInfo(); break; @@ -415,10 +443,11 @@ public class ExportVideo : MonoBehaviour { videoRequestRunning = false; } - yield break; + }// while + yield break; } @@ -428,11 +457,11 @@ public class ExportVideo : MonoBehaviour { private IEnumerator videoDownload() { videoDownloadRunning = true; - WWW DownloadVideo = new WWW(SERVER_URL + videoId); + WWW DownloadVideo = new WWW(SERVER_URL + "/" + videoFile); while (!DownloadVideo.isDone) { - screenManager.updateProgressDownloadSprite(DownloadVideo.progress); + screenManager.updateProgressDownloadSprite(DownloadVideo.psrogress); yield return null; } @@ -504,7 +533,7 @@ public class ExportVideo : MonoBehaviour { } /* Error states to show a Toast to user*/ - private static void GetConnectionStatusError(ExportLayers.ConnectionStatusError error) + private void GetConnectionStatusError(ExportLayers.ConnectionStatusError error) { switch (error) { diff --git a/Assets/Scripts/Export Video/FileContent.cs b/Assets/Scripts/Export Video/FileContent.cs index 5fd85a5..431208c 100644 --- a/Assets/Scripts/Export Video/FileContent.cs +++ b/Assets/Scripts/Export Video/FileContent.cs @@ -6,6 +6,7 @@ public class FileContent { public string file; public string size; public string status; + public string id; public static FileContent CreateFromJSON(string jsonString) diff --git a/Assets/Scripts/Export Video/MediaShareAndroid.cs b/Assets/Scripts/Export Video/MediaShareAndroid.cs index 8c35680..ae10b4f 100644 --- a/Assets/Scripts/Export Video/MediaShareAndroid.cs +++ b/Assets/Scripts/Export Video/MediaShareAndroid.cs @@ -49,28 +49,29 @@ public class MediaShareAndroid : MonoBehaviour public IEnumerator WriteOnAndroid(byte[] videoContent, int bytes,string CurrentTime, Action finishWriting, Action errorWriting) { -#if UNITY_ANDROID + if (Application.platform == RuntimePlatform.Android) + { - FilePath = Filen + CurrentTime + ".mp4"; - destination = Path.Combine(AndroidPath, Vlibras); - + FilePath = Filen + CurrentTime + ".mp4"; + destination = Path.Combine(AndroidPath, Vlibras); - /* Checking if folder Vlibras exists*/ - DirectoryInfo dir = new DirectoryInfo(destination); - if (!dir.Exists) - { - dir.Create(); - } - - try - { + /* Checking if folder Vlibras exists*/ + + DirectoryInfo dir = new DirectoryInfo(destination); + if (!dir.Exists) + { + dir.Create(); + } + + try + { FileStream SourceStream = new FileStream(Path.Combine(destination, FilePath), FileMode.OpenOrCreate); if (SourceStream.CanWrite) { SourceStream.Write(videoContent, 0, bytes); SourceStream.Close(); - + Refresh(FilePath); finishWriting(); yield break; @@ -78,23 +79,23 @@ public class MediaShareAndroid : MonoBehaviour } else { - new AndroidToast().showToast("Erro ao salvar vídeo.","LONG"); + new AndroidToast().showToast("Erro ao salvar vídeo.", "LONG"); errorWriting(); } - - } - catch (Exception e) - { - PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid","Message: " + e.Message); - PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.StackTrace); - new AndroidToast().showToast("Você precisa dá permissão ao aplicativo","LONG"); - errorWriting(); - } - - -#endif + } + catch (Exception e) + { + PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.Message); + PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.StackTrace); + new AndroidToast().showToast("Você precisa dá permissão ao aplicativo", "LONG"); + errorWriting(); + } + + + + } @@ -105,19 +106,20 @@ public class MediaShareAndroid : MonoBehaviour private void Refresh(string FilePath) { -#if UNITY_ANDROID + if (Application.platform == RuntimePlatform.Android) + { - AndroidJavaClass jcUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); + AndroidJavaClass jcUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject joActivity = jcUnityPlayer.GetStatic("currentActivity"); AndroidJavaObject joContext = joActivity.Call("getApplicationContext"); AndroidJavaClass jcMediaScannerConnection = new AndroidJavaClass("android.media.MediaScannerConnection"); - //AndroidJavaClass jcEnvironment = new AndroidJavaClass("android.os.Environment"); - // AndroidJavaObject joExDir = jcEnvironment.CallStatic("getExternalStorageDirectory"); - string path = destination; - jcMediaScannerConnection.CallStatic("scanFile", joContext, new string[] { path }, new string[] { "video/mp4" },null ); + //AndroidJavaClass jcEnvironment = new AndroidJavaClass("android.os.Environment"); + // AndroidJavaObject joExDir = jcEnvironment.CallStatic("getExternalStorageDirectory"); + string path = destination; + jcMediaScannerConnection.CallStatic("scanFile", joContext, new string[] { path }, new string[] { "video/mp4" }, null); -#endif + } } @@ -125,38 +127,39 @@ public class MediaShareAndroid : MonoBehaviour public IEnumerator ShareIntent(Action errorAction) { -#if UNITY_ANDROID - if (File.Exists(Path.Combine(destination, FilePath))) - { - - // block to open the file and share it ------------START - AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); - AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent"); - intentObject.Call("setAction", intentClass.GetStatic("ACTION_SEND")); - - AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); - AndroidJavaObject uriObject = uriClass.CallStatic("parse", "file://" + Path.Combine(destination, FilePath)); - - intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_STREAM"), uriObject); - intentObject.Call("setType", MediaType); - - //add data to be passed to the other activity i.e., the data to be sent - intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_SUBJECT"), "VLibras"); - intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_TEXT"), SubtitleMessage); - intentObject.Call("setType", "video/*"); - AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); - AndroidJavaObject jChooser = intentClass.CallStatic("createChooser", intentObject, "Compartilhar via"); - AndroidJavaObject currentActivity = unity.GetStatic("currentActivity"); - currentActivity.Call("startActivity", jChooser); - yield break; - }else + if (Application.platform == RuntimePlatform.Android) { - errorAction(); - - yield break; + if (File.Exists(Path.Combine(destination, FilePath))) + { + + // block to open the file and share it ------------START + AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); + AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent"); + intentObject.Call("setAction", intentClass.GetStatic("ACTION_SEND")); + + AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); + AndroidJavaObject uriObject = uriClass.CallStatic("parse", "file://" + Path.Combine(destination, FilePath)); + + intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_STREAM"), uriObject); + intentObject.Call("setType", MediaType); + + //add data to be passed to the other activity i.e., the data to be sent + intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_SUBJECT"), "VLibras"); + intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_TEXT"), SubtitleMessage); + intentObject.Call("setType", "video/*"); + AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); + AndroidJavaObject jChooser = intentClass.CallStatic("createChooser", intentObject, "Compartilhar via"); + AndroidJavaObject currentActivity = unity.GetStatic("currentActivity"); + currentActivity.Call("startActivity", jChooser); + yield break; + } + else + { + errorAction(); + + yield break; + } } - -#endif } } -- libgit2 0.21.2