diff --git a/Assets/Plugins/Android/AndroidManifest.xml b/Assets/Plugins/Android/AndroidManifest.xml
index 0b22c86..89c3a4c 100644
--- a/Assets/Plugins/Android/AndroidManifest.xml
+++ b/Assets/Plugins/Android/AndroidManifest.xml
@@ -24,6 +24,6 @@
-
+
\ No newline at end of file
diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity
index 2d8dd45..37774b1 100644
--- a/Assets/Scenes/Main.unity
+++ b/Assets/Scenes/Main.unity
@@ -793,7 +793,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
- m_IsActive: 1
+ m_IsActive: 0
--- !u!224 &160532052
RectTransform:
m_ObjectHideFlags: 0
@@ -1314,6 +1314,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
screenManager: {fileID: 2131993094}
+ MediaShareAndroid: {fileID: 1120909430}
--- !u!4 &210788817
Transform:
m_ObjectHideFlags: 0
@@ -7721,6 +7722,46 @@ MonoBehaviour:
m_Calls: []
m_TypeName: UnityEngine.UI.ScrollRect+ScrollRectEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
+--- !u!1 &1120909429
+GameObject:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ serializedVersion: 4
+ m_Component:
+ - 4: {fileID: 1120909431}
+ - 114: {fileID: 1120909430}
+ m_Layer: 0
+ m_Name: MediaShareAndroid
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!114 &1120909430
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1120909429}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: fd1b12a178cf08b4284859e93194c7a4, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+--- !u!4 &1120909431
+Transform:
+ m_ObjectHideFlags: 0
+ m_PrefabParentObject: {fileID: 0}
+ m_PrefabInternal: {fileID: 0}
+ m_GameObject: {fileID: 1120909429}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 234.47318, y: 151.18846, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 8
--- !u!1 &1124983616
GameObject:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/Export Video/AndroidJavaUti.cs b/Assets/Scripts/Export Video/AndroidJavaUti.cs
index 7048fb5..8c246c8 100644
--- a/Assets/Scripts/Export Video/AndroidJavaUti.cs
+++ b/Assets/Scripts/Export Video/AndroidJavaUti.cs
@@ -1,67 +1,48 @@
-/**********************
-********LAVID**********
-***VLibras Project*****
-*------------------------------------------------------------------------
-*Description:
-*This class is an Android Plugin that gets the current sd card path from
-* Android Device, making available the access to files folder.
-*---------------------------------------------------------------------------
-*Plugin directory:
-* - Assets/Plugins/Android
-*References:
-* - http://docs.unity3d.com/ScriptReference/AndroidJavaClass.html
-*------------------------------------------------------------------------
-*Author: Thiago Filipe
-*thiago.filipe@lavid.ufpb.br
-***********************/
-
-using UnityEngine;
-using System.Collections;
+using UnityEngine;
using System;
+using System.Collections;
-public class AndroidJavaUti{
+public class AndroidJavaUti : MonoBehaviour {
-
- private static string m_pkgName;
- private static string m_sdCardPath;
- public static AndroidJavaObject Activity
+ private static string m_pkgName;
+ private static string m_sdCardPath;
+ public static AndroidJavaObject Activity
+ {
+ get
{
- get
- {
- AndroidJavaClass jcPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
- return jcPlayer.GetStatic("currentActivity");
- }
+ AndroidJavaClass jcPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
+ return jcPlayer.GetStatic("currentActivity");
}
+ }
- public static string CurrentPkgName
+ public static string CurrentPkgName
+ {
+ get
{
- get
- {
- if (m_pkgName == null)
- m_pkgName = Activity.Call("getPackageName");
- return m_pkgName;
- }
+ if (m_pkgName == null)
+ m_pkgName = Activity.Call("getPackageName");
+ return m_pkgName;
}
- public static string CurrentSDCardPath
+ }
+ public static string CurrentSDCardPath
+ {
+ get
{
- get
+ if (m_sdCardPath == null)
{
- if (m_sdCardPath == null)
- {
- AndroidJavaClass jc = new AndroidJavaClass("android.os.Environment");
- IntPtr getExternalStorageDirectoryMethod = AndroidJNI.GetStaticMethodID(jc.GetRawClass(), "getExternalStorageDirectory", "()Ljava/io/File;");
- IntPtr file = AndroidJNI.CallStaticObjectMethod(jc.GetRawClass(), getExternalStorageDirectoryMethod, new jvalue[] { });
- IntPtr getPathMethod = AndroidJNI.GetMethodID(AndroidJNI.GetObjectClass(file), "getPath", "()Ljava/lang/String;");
- IntPtr path = AndroidJNI.CallObjectMethod(file, getPathMethod, new jvalue[] { });
- m_sdCardPath = AndroidJNI.GetStringUTFChars(path);
- AndroidJNI.DeleteLocalRef(file);
- AndroidJNI.DeleteLocalRef(path);
- Debug.Log("m_sdCardPath = " + m_sdCardPath);
- }
- return m_sdCardPath;
+ AndroidJavaClass jc = new AndroidJavaClass("android.os.Environment");
+ IntPtr getExternalStorageDirectoryMethod = AndroidJNI.GetStaticMethodID(jc.GetRawClass(), "getExternalStorageDirectory", "()Ljava/io/File;");
+ IntPtr file = AndroidJNI.CallStaticObjectMethod(jc.GetRawClass(), getExternalStorageDirectoryMethod, new jvalue[] { });
+ IntPtr getPathMethod = AndroidJNI.GetMethodID(AndroidJNI.GetObjectClass(file), "getPath", "()Ljava/lang/String;");
+ IntPtr path = AndroidJNI.CallObjectMethod(file, getPathMethod, new jvalue[] { });
+ m_sdCardPath = AndroidJNI.GetStringUTFChars(path);
+ AndroidJNI.DeleteLocalRef(file);
+ AndroidJNI.DeleteLocalRef(path);
+ Debug.Log("m_sdCardPath = " + m_sdCardPath);
}
-
+ return m_sdCardPath;
}
-}
+ }
+}
diff --git a/Assets/Scripts/Export Video/AndroidJavaUti.cs.meta b/Assets/Scripts/Export Video/AndroidJavaUti.cs.meta
index 35c512d..1246113 100644
--- a/Assets/Scripts/Export Video/AndroidJavaUti.cs.meta
+++ b/Assets/Scripts/Export Video/AndroidJavaUti.cs.meta
@@ -1,6 +1,6 @@
fileFormatVersion: 2
-guid: 437223d76094ce840a68de8b6ea60fe8
-timeCreated: 1486222942
+guid: e79be87b2ce96744e9141cee2058779b
+timeCreated: 1486833877
licenseType: Free
MonoImporter:
serializedVersion: 2
diff --git a/Assets/Scripts/Export Video/AndroidPath.cs b/Assets/Scripts/Export Video/AndroidPath.cs
deleted file mode 100644
index 8d7e577..0000000
--- a/Assets/Scripts/Export Video/AndroidPath.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using UnityEngine;
-using System.Collections;
-using System;
-
-
-public class AndroidPaths : MonoBehaviour {
-
- public static string GetAndroidContextExternalFilesDir
- {
- get
- {
- string path = "";
-
- if (Application.platform == RuntimePlatform.Android)
- {
- try
- {
- using (AndroidJavaClass ajc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
- {
- using (AndroidJavaObject ajo = ajc.GetStatic("currentActivity"))
- {
- path = ajo.Call("getExternalFilesDir", null).Call("getAbsolutePath");
- }
- }
- }
- catch (Exception e)
- {
- Debug.LogWarning("Error fetching native Android external storage dir: " + e.Message);
- }
- }
- return path;
- }
- }
-
- public static string GetAndroidContextInternalFilesDir
- {
- get
- {
- string path = "";
-
- if (Application.platform == RuntimePlatform.Android)
- {
- try
- {
- using (AndroidJavaClass ajc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
- {
- using (AndroidJavaObject ajo = ajc.GetStatic("currentActivity"))
- {
- path = ajo.Call("getFilesDir").Call("getAbsolutePath");
- }
- }
- }
- catch (Exception e)
- {
- Debug.LogWarning("Error fetching native Android internal storage dir: " + e.Message);
- }
- }
- return path;
- }
- }
-
-
-}
diff --git a/Assets/Scripts/Export Video/AndroidPath.cs.meta b/Assets/Scripts/Export Video/AndroidPath.cs.meta
deleted file mode 100644
index 91e32b2..0000000
--- a/Assets/Scripts/Export Video/AndroidPath.cs.meta
+++ /dev/null
@@ -1,12 +0,0 @@
-fileFormatVersion: 2
-guid: 71dacb9b6a7d04349b9913751ef87ad4
-timeCreated: 1486607668
-licenseType: Free
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/Scripts/Export Video/AndroidToast.cs b/Assets/Scripts/Export Video/AndroidToast.cs
index bbf4d6c..7c64b81 100644
--- a/Assets/Scripts/Export Video/AndroidToast.cs
+++ b/Assets/Scripts/Export Video/AndroidToast.cs
@@ -18,7 +18,7 @@
using UnityEngine;
using System.Collections;
-public class AndroidToast : MonoBehaviour
+public class AndroidToast
{
AndroidJavaObject currentActivity;
AndroidJavaClass UnityPlayer;
diff --git a/Assets/Scripts/Export Video/ExportVideo.cs b/Assets/Scripts/Export Video/ExportVideo.cs
index 93e5147..c37549c 100644
--- a/Assets/Scripts/Export Video/ExportVideo.cs
+++ b/Assets/Scripts/Export Video/ExportVideo.cs
@@ -30,12 +30,18 @@ public class ExportVideo : MonoBehaviour {
public ScreenManager screenManager;
- private MobileNativeDialog nativeDialog;
+ public MediaShareAndroid MediaShareAndroid;
+ private const string SERVER_URL = "http://150.165.205.57/video/";
+
+ /*Strings to Compare glosses*/
private static string gloss = "Gloss";
private string currentGloss = "CurrentGloss";
+
+ /* Sharing Current Time - Video Name*/
private string currentTime = "";
- private const string SERVER_URL = "http://150.165.205.38/video/";
+
+
/* Strings related to the Android Dialog*/
private string title = "Download";
@@ -43,13 +49,15 @@ public class ExportVideo : MonoBehaviour {
private string yesOp = "DOWNLOAD";
private string noOp = "CANCELAR";
+ /* Data related to the Video*/
- private float videoSize = 0;
+ private int videoSize = 0;
private int bytes = 0;
private string videoId = "";
private byte[] videoContent = null;
-
+ /*Coroutine flags */
+
private bool videoRequestRunning = false;
private bool videoDownloadRunning = false;
@@ -67,12 +75,12 @@ public class ExportVideo : MonoBehaviour {
public void onClickExport()
{
-
- Debug.Log("onClickShare pressed");
+
+ PlayerLogger.Log("ExportVideo", "OnClickExport", "Starting Export...");
screenManager.changeExportStates(ExportLayers.ExportLayer.Export_Layer,false);
screenManager.changeExportStates(ExportLayers.ExportLayer.Progress_Layer, true);
StartCoroutine("requestVideoInfo");
- Debug.Log("Hiding export button and showing progress loading");
+ PlayerLogger.Log("ExportVideo", "OnClickExport", "Making request to server.");
}
@@ -81,10 +89,10 @@ public class ExportVideo : MonoBehaviour {
* button*/
public void OnFinishGetVideoInfo()
{
- Debug.Log("Video is ready to be downloaded");
+ PlayerLogger.Log("ExportVideo","OnFinishGetVideoInfo","Video is ready to be downloaded.");
screenManager.changeExportStates(ExportLayers.ExportLayer.Progress_Layer, false);
screenManager.changeExportStates(ExportLayers.ExportLayer.Download_Layer, true);
- Debug.Log("Hiding progress loading and showing download button");
+ PlayerLogger.Log("ExportVideo", "OnFinishGetVideoInfo", "Hiding progress loading and showing download button");
}
@@ -93,10 +101,12 @@ public class ExportVideo : MonoBehaviour {
public void onDownloadClick()
{
-
- Debug.Log("Asking for permition to download");
- nativeDialog = new MobileNativeDialog(title, message + ((videoSize/1024f)/1024f).ToString("0.00") + " MB.", yesOp, noOp);
- nativeDialog.OnComplete = OnComplete;
+ MobileNativeDialog nativeDialog;
+
+
+
+ nativeDialog = new MobileNativeDialog(title, message + ((videoSize/1024f)/1024f).ToString("0.00") + " MB.", yesOp, noOp);
+ nativeDialog.OnComplete = OnComplete;
}
@@ -108,13 +118,13 @@ public class ExportVideo : MonoBehaviour {
{
if(result == MNDialogResult.YES)
{
- Debug.Log("User pressed yes");
+ PlayerLogger.Log("ExportVideo", "OnDownloadClick", "Starting Video Download...");
StartCoroutine("videoDownload");
screenManager.changeExportStates(ExportLayers.ExportLayer.Download_Layer, false);
screenManager.changeExportStates(ExportLayers.ExportLayer.Progress_Download_Layer, true);
}else if(result == MNDialogResult.NO)
{
- Debug.Log("User pressed no");
+ PlayerLogger.Log("ExportVideo", "OnDownloadClick", "Resetting states to default...");
screenManager.changeExportStates(ExportLayers.ExportLayer.All, true);
}
@@ -124,7 +134,7 @@ public class ExportVideo : MonoBehaviour {
public void OnDownloadFinished()
{
- Debug.Log("Download has finished. Setting layer to Share Layer");
+ PlayerLogger.Log("ExportVideo", "OnDownloadFinished", "Video Downloaded, able to share it.");
screenManager.changeExportStates(ExportLayers.ExportLayer.Progress_Download_Layer, false);
screenManager.changeExportStates(ExportLayers.ExportLayer.Share_Layer, true);
}
@@ -155,75 +165,42 @@ public class ExportVideo : MonoBehaviour {
public void OnShareVideo()
{
- Debug.Log("Sharing video content");
- if(gloss == currentGloss)
- {
- try
- {
- if (videoContent != null)
- new MediaShareAndroid().ShareActivity(videoContent,bytes, currentTime);
- else
- {
- new AndroidToast().showToast("Erro ao compartilhar vídeo");
- screenManager.changeExportStates(ExportLayers.ExportLayer.All, true);
- }
- }
- catch (Exception e)
- {
- new AndroidToast().showToast(e.Message);
- new AndroidToast().showToast(e.StackTrace);
- }
-
+ PlayerLogger.Log("ExportVideo", "OnShareVideo", "Sharing Video...");
+ if (gloss == currentGloss) //Checking if user is trying to share the same animation
+ {
+ Share();
}
else
{
currentGloss = gloss;
- currentTime = System.DateTime.Now.ToString("yyyy-MM-dd_HH:mm:ss");
-
- if (videoContent != null)
- new MediaShareAndroid().ShareActivity(videoContent,bytes, currentTime);
- else
- {
- screenManager.changeExportStates(ExportLayers.ExportLayer.All, true);
- new AndroidToast().showToast("Erro ao compartilhar vídeo");
- }
-
- }
-
+ currentTime = System.DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss");
+ Share();
+ }
}
- /*Coroutine that downloads the video and update the progress download layer*/
-
- private IEnumerator videoDownload()
+ private void Share()
{
- videoDownloadRunning = true;
- // WWW DownloadVideo = new WWW(SERVER_URL + videoId);
- WWW DownloadVideo = new WWW("http://caiomcg.com/rural.mp4");
- while (!DownloadVideo.isDone)
- {
- screenManager.updateProgressDownloadSprite(DownloadVideo.progress);
- yield return null;
- }
try
{
- if (DownloadVideo.bytesDownloaded > 0 )
+ if (videoContent != null)
{
- bytes = DownloadVideo.bytesDownloaded;
- videoContent = DownloadVideo.bytes;
- OnDownloadFinished();
+
+ MediaShareAndroid.ShareActivity(videoContent, bytes, currentTime);
}
else
{
- GetConnectionStatusError(ExportLayers.ConnectionStatusError.DOWNLOAD_CONNECTION_FAILURE);
+ new AndroidToast().showToast("Erro ao compartilhar vídeo");
+ screenManager.changeExportStates(ExportLayers.ExportLayer.All, true);
}
-
-
}
- finally
+ catch (Exception e)
{
- videoDownloadRunning = false;
+ PlayerLogger.Log("ExportVideo", "Share", "Exception thrown: " + e.Message);
+ // new AndroidToast().showToast(e.Message);
+ new AndroidToast().showToast("É necessário dá permissão ao aplicativo.");
+
}
}
@@ -234,11 +211,11 @@ public class ExportVideo : MonoBehaviour {
videoRequestRunning = true;
WWWForm JsonRequest = new WWWForm();
JsonRequest.AddField("gloss", gloss);
- WWW videoInfoRequest = new WWW(SERVER_URL,JsonRequest);
-
+ WWW videoInfoRequest = new WWW(SERVER_URL, JsonRequest);
+
PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Request for: " + SERVER_URL);
- yield return WaitForResponse(videoInfoRequest);
+ yield return WaitForResponse(videoInfoRequest);
try
{
@@ -251,7 +228,7 @@ public class ExportVideo : MonoBehaviour {
}
else if (videoInfoRequest.error != null)
{
-
+
screenManager.changeExportStates(ExportLayers.ExportLayer.All, true);
GetConnectionStatusError(ExportLayers.ConnectionStatusError.INTERNET_CONNECTION_FAILURE);
PlayerLogger.Log("ExportVideo", "requestVideoInfo", "(WWW) Error: " + videoInfoRequest.error);
@@ -261,19 +238,19 @@ public class ExportVideo : MonoBehaviour {
PlayerLogger.Log("ExportVideo", "requestVideoInfo", "(WWW) Unsucessful Answer");
GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE);
screenManager.changeExportStates(ExportLayers.ExportLayer.All, true);
-
+
}
else if (!videoInfoRequest.responseHeaders["STATUS"].Contains("200"))
{
-
+
PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Unsuccessful answer (" + videoInfoRequest.responseHeaders["STATUS"] + ").");
GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE);
screenManager.changeExportStates(ExportLayers.ExportLayer.All, true);
-
+
}
else if (String.IsNullOrEmpty(videoInfoRequest.text))
{
-
+
screenManager.changeExportStates(ExportLayers.ExportLayer.All, true);
GetConnectionStatusError(ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE);
PlayerLogger.Log("ExportVideo", "requestVideoInfo", "Empty answer.");
@@ -285,24 +262,56 @@ public class ExportVideo : MonoBehaviour {
FileContent fileContent = new FileContent();
fileContent = FileContent.CreateFromJSON(videoInfoRequest.text);
videoId = fileContent.file;
- videoSize = float.Parse(fileContent.size);
+ videoSize = int.Parse(fileContent.size);
OnFinishGetVideoInfo();
yield break;
}
-
+
}
finally
{
videoRequestRunning = false;
-
-
+
+
}
}
+ /*Coroutine that downloads the video and update the progress download layer*/
+ private IEnumerator videoDownload()
+ {
+ videoDownloadRunning = true;
+ WWW DownloadVideo = new WWW(SERVER_URL + videoId);
+ // WWW DownloadVideo = new WWW("http://caiomcg.com/rural.mp4");
+ while (!DownloadVideo.isDone)
+ {
+ screenManager.updateProgressDownloadSprite(DownloadVideo.progress);
+ yield return null;
+ }
+
+ try
+ {
+ if (DownloadVideo.bytesDownloaded > 0 && DownloadVideo.bytesDownloaded<=videoSize)
+ {
+ bytes = DownloadVideo.bytesDownloaded;
+ videoContent = DownloadVideo.bytes;
+ OnDownloadFinished();
+ }
+ else
+ {
+ GetConnectionStatusError(ExportLayers.ConnectionStatusError.DOWNLOAD_CONNECTION_FAILURE);
+ }
+
+
+ }
+ finally
+ {
+ videoDownloadRunning = false;
+ }
+ }
public IEnumerator WaitForResponse(WWW www, Events.RequestSuccess success, Events.RequestError error)
{
@@ -315,7 +324,7 @@ public class ExportVideo : MonoBehaviour {
yield return WaitForResponse(www, null, null);
}
- public static void GetConnectionStatusError(ExportLayers.ConnectionStatusError error)
+ private static void GetConnectionStatusError(ExportLayers.ConnectionStatusError error)
{
switch (error)
{
diff --git a/Assets/Scripts/Export Video/MediaShareAndroid.cs b/Assets/Scripts/Export Video/MediaShareAndroid.cs
index be05cf4..5e821a3 100644
--- a/Assets/Scripts/Export Video/MediaShareAndroid.cs
+++ b/Assets/Scripts/Export Video/MediaShareAndroid.cs
@@ -26,19 +26,24 @@ public class MediaShareAndroid : MonoBehaviour
private string MediaType = "video/*";
- private string SubtitleMessage = "VLibras";
+ private string SubtitleMessage = "VLibras na Playstore - https://play.google.com/store/apps/details?id=com.lavid.vlibrasdroid&hl=pt_BR";
- private string AndroidPath = AndroidJavaUti.CurrentSDCardPath;
+ private string AndroidPath;
private string destination = "";
- private string Vlibras = "VLibras";
- private string FileName = "VLibrasVideo_";
+ private string Vlibras = "DCIM/VLibras";
+ private string File = "VLibrasVideo_";
private byte[] videoContent;
private int bytes;
+ private void Awake()
+ {
+ AndroidPath = AndroidJavaUti.CurrentSDCardPath;
+ }
+
- /*Makes sure that Vlibras Folder gets created and write the video bytes in it.*/
+ /*Makes sure that Vlibras Folder gets created and write the video bytes in it.*/
/* Creates the sharing activity and shows the chooser to the user*/
@@ -46,61 +51,31 @@ public class MediaShareAndroid : MonoBehaviour
{
#if UNITY_ANDROID
+
this.videoContent = videoContent;
this.bytes = bytes;
- FileName += CurrentTime + ".mp4";
- ShareIntent();
- /*
- // Create Refernece of AndroidJavaClass class for intent
- AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
- // Create Refernece of AndroidJavaObject class intent
- AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
- // Set action for intent
- intentObject.Call("setAction", intentClass.GetStatic("ACTION_SEND"));
- intentObject.Call("setType", MediaType);
- //Set Subject of action
- intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_SUBJECT"), SubtitleMessage);
- //Set title of action or intent
- intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_TITLE"), TitleMessage);
-
- /*
- // Set actual data which you want to share
- intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_TEXT"), Media);
- AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
- AndroidJavaObject currentActivity = unity.GetStatic("currentActivity");
- // Invoke android activity for passing intent to share data
- currentActivity.Call("startActivity", intentObject);
- AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
-
- AndroidJavaObject fileObject = new AndroidJavaObject("java.io.File", Path.Combine(AndroidPath + Vlibras, FileName));// Set Image Path Here
- AndroidJavaObject uriObject = uriClass.CallStatic("fromFile", fileObject);
- // string uriPath = uriObject.Call("getPath");
- bool fileExist = fileObject.Call("exists");
- Debug.Log("File exist : " + fileExist);
- // Attach image to intent
- if (fileExist)
- intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_STREAM"), uriObject);
- AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
- AndroidJavaObject currentActivity = unity.GetStatic("currentActivity");
- currentActivity.Call("startActivity", intentObject);
-
- */
+ StartCoroutine(WriteOnAndroid(File + CurrentTime + ".mp4"));
#endif
- }
+ }
- private void ShareIntent()
+ private IEnumerator WriteOnAndroid(string FileName)
{
destination = Path.Combine(AndroidPath, Vlibras);
+
+ /* Checking if folder Vlibras exists*/
+
DirectoryInfo dir = new DirectoryInfo(destination);
- new AndroidToast().showToast(destination);
if (!dir.Exists)
{
dir.Create();
}
+ /*Checking if there's a file with same name - If so, means user's trying
+ * to share the same video*/
+
dir = new DirectoryInfo(Path.Combine(destination, FileName));
if (!dir.Exists)
{
@@ -113,28 +88,56 @@ public class MediaShareAndroid : MonoBehaviour
}
else
{
- new AndroidToast().showToast("Erro ao escrever arquivo");
+ new AndroidToast().showToast("Erro ao compartilhar arquivo.");
}
}
-
+ yield return null;
+ Refresh(FileName);
+
+
+
+
+ }
+
+ private void Refresh(string FileName)
+ {
+
+ 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 = Path.Combine(destination,FileName);
+ jcMediaScannerConnection.CallStatic("scanFile", joContext, new string[] { path }, null, null);
+ StartCoroutine(ShareIntent(FileName));
+
+ }
+
+ private IEnumerator ShareIntent(string FileName) {
+
// 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,FileName));
+
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"), SubtitleMessage);
- intentObject.Call("putExtra", intentClass.GetStatic("EXTRA_TEXT"), "Vlibras Video");
- intentObject.Call("setType", "video/mp4");
+ 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);
+ currentActivity.Call("startActivity", jChooser);
+ yield break;
}
diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset
index 5983b70..d85d964 100644
--- a/ProjectSettings/EditorBuildSettings.asset
+++ b/ProjectSettings/EditorBuildSettings.asset
@@ -7,5 +7,3 @@ EditorBuildSettings:
m_Scenes:
- enabled: 1
path: Assets/Scenes/Main.unity
- - enabled: 0
- path: Assets/Plugins/StansAssets/Modules/MobileNativePopUps/Example/MobilePopUpsExample.unity
--
libgit2 0.21.2