Commit 4e172001eb76caf0474e44b671b0a25eee56ec72
1 parent
a6d83150
Exists in
IosBuild
Build IOS Preparation
Showing
13 changed files
with
119 additions
and
450 deletions
Show diff stats
Assets/Scenes/Main.unity
| @@ -1286,7 +1286,7 @@ MonoBehaviour: | @@ -1286,7 +1286,7 @@ MonoBehaviour: | ||
| 1286 | m_Name: | 1286 | m_Name: |
| 1287 | m_EditorClassIdentifier: | 1287 | m_EditorClassIdentifier: |
| 1288 | screenManager: {fileID: 2131993094} | 1288 | screenManager: {fileID: 2131993094} |
| 1289 | - MediaShareAndroid: {fileID: 1120909430} | 1289 | + MediaShareIOS: {fileID: 0} |
| 1290 | --- !u!4 &210788817 | 1290 | --- !u!4 &210788817 |
| 1291 | Transform: | 1291 | Transform: |
| 1292 | m_ObjectHideFlags: 0 | 1292 | m_ObjectHideFlags: 0 |
| @@ -7959,7 +7959,7 @@ GameObject: | @@ -7959,7 +7959,7 @@ GameObject: | ||
| 7959 | - 4: {fileID: 1120909431} | 7959 | - 4: {fileID: 1120909431} |
| 7960 | - 114: {fileID: 1120909430} | 7960 | - 114: {fileID: 1120909430} |
| 7961 | m_Layer: 0 | 7961 | m_Layer: 0 |
| 7962 | - m_Name: MediaShareAndroid | 7962 | + m_Name: MediaShareIOS |
| 7963 | m_TagString: Untagged | 7963 | m_TagString: Untagged |
| 7964 | m_Icon: {fileID: 0} | 7964 | m_Icon: {fileID: 0} |
| 7965 | m_NavMeshLayer: 0 | 7965 | m_NavMeshLayer: 0 |
| @@ -7973,7 +7973,7 @@ MonoBehaviour: | @@ -7973,7 +7973,7 @@ MonoBehaviour: | ||
| 7973 | m_GameObject: {fileID: 1120909429} | 7973 | m_GameObject: {fileID: 1120909429} |
| 7974 | m_Enabled: 1 | 7974 | m_Enabled: 1 |
| 7975 | m_EditorHideFlags: 0 | 7975 | m_EditorHideFlags: 0 |
| 7976 | - m_Script: {fileID: 11500000, guid: fd1b12a178cf08b4284859e93194c7a4, type: 3} | 7976 | + m_Script: {fileID: 11500000, guid: ff208f584beb2bd43a9751619a94e506, type: 3} |
| 7977 | m_Name: | 7977 | m_Name: |
| 7978 | m_EditorClassIdentifier: | 7978 | m_EditorClassIdentifier: |
| 7979 | --- !u!4 &1120909431 | 7979 | --- !u!4 &1120909431 |
Assets/Scripts/Export Video/AndroidJavaUti.cs
| @@ -1,48 +0,0 @@ | @@ -1,48 +0,0 @@ | ||
| 1 | -using UnityEngine; | ||
| 2 | -using System; | ||
| 3 | -using System.Collections; | ||
| 4 | - | ||
| 5 | -public class AndroidJavaUti : MonoBehaviour { | ||
| 6 | - | ||
| 7 | - private static string m_pkgName; | ||
| 8 | - private static string m_sdCardPath; | ||
| 9 | - public static AndroidJavaObject Activity | ||
| 10 | - { | ||
| 11 | - get | ||
| 12 | - { | ||
| 13 | - AndroidJavaClass jcPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | ||
| 14 | - return jcPlayer.GetStatic<AndroidJavaObject>("currentActivity"); | ||
| 15 | - } | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - public static string CurrentPkgName | ||
| 20 | - { | ||
| 21 | - get | ||
| 22 | - { | ||
| 23 | - if (m_pkgName == null) | ||
| 24 | - m_pkgName = Activity.Call<string>("getPackageName"); | ||
| 25 | - return m_pkgName; | ||
| 26 | - } | ||
| 27 | - } | ||
| 28 | - public static string CurrentSDCardPath | ||
| 29 | - { | ||
| 30 | - get | ||
| 31 | - { | ||
| 32 | - if (m_sdCardPath == null) | ||
| 33 | - { | ||
| 34 | - AndroidJavaClass jc = new AndroidJavaClass("android.os.Environment"); | ||
| 35 | - IntPtr getExternalStorageDirectoryMethod = AndroidJNI.GetStaticMethodID(jc.GetRawClass(), "getExternalStorageDirectory", "()Ljava/io/File;"); | ||
| 36 | - IntPtr file = AndroidJNI.CallStaticObjectMethod(jc.GetRawClass(), getExternalStorageDirectoryMethod, new jvalue[] { }); | ||
| 37 | - IntPtr getPathMethod = AndroidJNI.GetMethodID(AndroidJNI.GetObjectClass(file), "getPath", "()Ljava/lang/String;"); | ||
| 38 | - IntPtr path = AndroidJNI.CallObjectMethod(file, getPathMethod, new jvalue[] { }); | ||
| 39 | - m_sdCardPath = AndroidJNI.GetStringUTFChars(path); | ||
| 40 | - AndroidJNI.DeleteLocalRef(file); | ||
| 41 | - AndroidJNI.DeleteLocalRef(path); | ||
| 42 | - Debug.Log("m_sdCardPath = " + m_sdCardPath); | ||
| 43 | - } | ||
| 44 | - return m_sdCardPath; | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - } | ||
| 48 | -} |
Assets/Scripts/Export Video/AndroidJavaUti.cs.meta
| @@ -1,12 +0,0 @@ | @@ -1,12 +0,0 @@ | ||
| 1 | -fileFormatVersion: 2 | ||
| 2 | -guid: e79be87b2ce96744e9141cee2058779b | ||
| 3 | -timeCreated: 1486833877 | ||
| 4 | -licenseType: Free | ||
| 5 | -MonoImporter: | ||
| 6 | - serializedVersion: 2 | ||
| 7 | - defaultReferences: [] | ||
| 8 | - executionOrder: 0 | ||
| 9 | - icon: {instanceID: 0} | ||
| 10 | - userData: | ||
| 11 | - assetBundleName: | ||
| 12 | - assetBundleVariant: |
Assets/Scripts/Export Video/AndroidPermission.cs
| @@ -1,122 +0,0 @@ | @@ -1,122 +0,0 @@ | ||
| 1 | -/////////////////////////////////////////////////////////// | ||
| 2 | -///////////////// NoodlePermissionGranter ///////////////// | ||
| 3 | -/// Implements runtime granting of Android permissions. /// | ||
| 4 | -/// This is necessary for Android M (6.0) and above. ////// | ||
| 5 | -/////////////////////////////////////////////////////////// | ||
| 6 | -//////////////////// Noodlecake Studios /////////////////// | ||
| 7 | -/////////////////////////////////////////////////////////// | ||
| 8 | - | ||
| 9 | -using UnityEngine; | ||
| 10 | -using System.Collections; | ||
| 11 | -using System; | ||
| 12 | - | ||
| 13 | -public class NoodlePermissionGranter : MonoBehaviour | ||
| 14 | -{ | ||
| 15 | - | ||
| 16 | - // subscribe to this callback to see if your permission was granted. | ||
| 17 | - public static Action<bool> PermissionRequestCallback; | ||
| 18 | - public static Action<bool> PermittedAction; | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - // for now, it only implements the external storage permission | ||
| 22 | - public enum NoodleAndroidPermission | ||
| 23 | - { | ||
| 24 | - WRITE_EXTERNAL_STORAGE | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | - public static void IsPermitted(NoodleAndroidPermission permission) | ||
| 28 | - { | ||
| 29 | - if (!initialized) | ||
| 30 | - initialize(); | ||
| 31 | - noodlePermissionGranterClass.CallStatic("CheckPermission", activity, (int)permission); | ||
| 32 | - | ||
| 33 | - } | ||
| 34 | - public static void GrantPermission(NoodleAndroidPermission permission) | ||
| 35 | - { | ||
| 36 | - if (!initialized) | ||
| 37 | - initialize(); | ||
| 38 | - | ||
| 39 | - noodlePermissionGranterClass.CallStatic("grantPermission", activity, (int)permission); | ||
| 40 | - | ||
| 41 | - | ||
| 42 | - | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - ////////////////////////////// | ||
| 46 | - /// Initialization Stuff ///// | ||
| 47 | - ////////////////////////////// | ||
| 48 | - | ||
| 49 | - // it's a singleton, but no one needs to know about it. hush hush. dont touch me. | ||
| 50 | - private static NoodlePermissionGranter instance; | ||
| 51 | - private static bool initialized = false; | ||
| 52 | - | ||
| 53 | - public void Awake() | ||
| 54 | - { | ||
| 55 | - // instance is also set in initialize. | ||
| 56 | - // having it here ensures this thing doesnt break | ||
| 57 | - // if you added this component to the scene manually | ||
| 58 | - instance = this; | ||
| 59 | - DontDestroyOnLoad(this.gameObject); | ||
| 60 | - // object name must match UnitySendMessage call in NoodlePermissionGranter.java | ||
| 61 | - if (name != NOODLE_PERMISSION_GRANTER) | ||
| 62 | - name = NOODLE_PERMISSION_GRANTER; | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - | ||
| 66 | - private static void initialize() | ||
| 67 | - { | ||
| 68 | - // runs once when you call GrantPermission | ||
| 69 | - | ||
| 70 | - // add object to scene | ||
| 71 | - if (instance == null) | ||
| 72 | - { | ||
| 73 | - GameObject go = new GameObject(); | ||
| 74 | - // instance will also be set in awake, but having it here as well seems extra safe | ||
| 75 | - instance = go.AddComponent<NoodlePermissionGranter>(); | ||
| 76 | - // object name must match UnitySendMessage call in NoodlePermissionGranter.java | ||
| 77 | - go.name = NOODLE_PERMISSION_GRANTER; | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - // get the jni stuff. we need the activty class and the NoodlePermissionGranter class. | ||
| 81 | - noodlePermissionGranterClass = new AndroidJavaClass("com.vlibras.permissionplugin.NoodlePermissionGranter"); | ||
| 82 | - AndroidJavaClass u3d = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | ||
| 83 | - activity = u3d.GetStatic<AndroidJavaObject>("currentActivity"); | ||
| 84 | - | ||
| 85 | - initialized = true; | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - | ||
| 89 | - | ||
| 90 | - | ||
| 91 | - | ||
| 92 | - | ||
| 93 | - | ||
| 94 | - /////////////////// | ||
| 95 | - //// JNI Stuff //// | ||
| 96 | - /////////////////// | ||
| 97 | - | ||
| 98 | - static AndroidJavaClass noodlePermissionGranterClass; | ||
| 99 | - static AndroidJavaObject activity; | ||
| 100 | - private const string WRITE_EXTERNAL_STORAGE = "WRITE_EXTERNAL_STORAGE"; | ||
| 101 | - private const string PERMISSION_GRANTED = "PERMISSION_GRANTED"; // must match NoodlePermissionGranter.java | ||
| 102 | - private const string PERMISSION_DENIED = "PERMISSION_DENIED"; // must match NoodlePermissionGranter.java | ||
| 103 | - private const string NOODLE_PERMISSION_GRANTER = "NoodlePermissionGranter"; // must match UnitySendMessage call in NoodlePermissionGranter.java | ||
| 104 | - | ||
| 105 | - private void permissionRequestCallbackInternal(string message) | ||
| 106 | - { | ||
| 107 | - // were calling this method from the java side. | ||
| 108 | - // the method name and gameobject must match NoodlePermissionGranter.java's UnitySendMessage | ||
| 109 | - bool permissionGranted = (message == PERMISSION_GRANTED); | ||
| 110 | - if (PermissionRequestCallback != null) | ||
| 111 | - PermissionRequestCallback(permissionGranted); | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - private void permittedActionCallBack(string message) | ||
| 115 | - { | ||
| 116 | - bool permissionGranted = (message == PERMISSION_GRANTED); | ||
| 117 | - if (PermittedAction != null) | ||
| 118 | - PermittedAction(permissionGranted); | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - | ||
| 122 | -} | ||
| 123 | \ No newline at end of file | 0 | \ No newline at end of file |
Assets/Scripts/Export Video/AndroidPermission.cs.meta
| @@ -1,12 +0,0 @@ | @@ -1,12 +0,0 @@ | ||
| 1 | -fileFormatVersion: 2 | ||
| 2 | -guid: a7fa4a3e85ddd024f98f4f9f78540b35 | ||
| 3 | -timeCreated: 1487423780 | ||
| 4 | -licenseType: Free | ||
| 5 | -MonoImporter: | ||
| 6 | - serializedVersion: 2 | ||
| 7 | - defaultReferences: [] | ||
| 8 | - executionOrder: 0 | ||
| 9 | - icon: {instanceID: 0} | ||
| 10 | - userData: | ||
| 11 | - assetBundleName: | ||
| 12 | - assetBundleVariant: |
Assets/Scripts/Export Video/AndroidToast.cs
| @@ -1,43 +0,0 @@ | @@ -1,43 +0,0 @@ | ||
| 1 | -/********************** | ||
| 2 | -********LAVID********** | ||
| 3 | -***VLibras Project***** | ||
| 4 | -*------------------------------------------------------------------------ | ||
| 5 | -*Description: | ||
| 6 | -*This class is a Android Plugin that allows the creation of Toast | ||
| 7 | -* notifications. | ||
| 8 | -*--------------------------------------------------------------------------- | ||
| 9 | -*Plugin directory: | ||
| 10 | -* - Assets/Plugins/Android | ||
| 11 | -*References: | ||
| 12 | -* - http://docs.unity3d.com/ScriptReference/AndroidJavaClass.html | ||
| 13 | -*------------------------------------------------------------------------ | ||
| 14 | -*Author: Thiago Filipe | ||
| 15 | -*thiago.filipe@lavid.ufpb.br | ||
| 16 | -***********************/ | ||
| 17 | - | ||
| 18 | -using UnityEngine; | ||
| 19 | -using System.Collections; | ||
| 20 | - | ||
| 21 | -public class AndroidToast | ||
| 22 | -{ | ||
| 23 | - AndroidJavaObject currentActivity; | ||
| 24 | - AndroidJavaClass UnityPlayer; | ||
| 25 | - AndroidJavaObject context; | ||
| 26 | - | ||
| 27 | - public void showToast(string toastString,string lenght){ | ||
| 28 | - | ||
| 29 | - if (Application.platform == RuntimePlatform.Android) | ||
| 30 | - { | ||
| 31 | - UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | ||
| 32 | - currentActivity = UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); | ||
| 33 | - context = currentActivity.Call<AndroidJavaObject>("getApplicationContext"); | ||
| 34 | - | ||
| 35 | - AndroidJavaClass Toast = new AndroidJavaClass("android.widget.Toast"); | ||
| 36 | - AndroidJavaObject javaString = new AndroidJavaObject("java.lang.String", toastString); | ||
| 37 | - AndroidJavaObject toast = Toast.CallStatic<AndroidJavaObject>("makeText", context, javaString, Toast.GetStatic<int>("LENGTH_" + lenght)); //Toast Duration Time | ||
| 38 | - toast.Call("show"); | ||
| 39 | - } | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - | ||
| 43 | -} |
Assets/Scripts/Export Video/AndroidToast.cs.meta
| @@ -1,12 +0,0 @@ | @@ -1,12 +0,0 @@ | ||
| 1 | -fileFormatVersion: 2 | ||
| 2 | -guid: f4af3594fb207274dbd1d303e7079acb | ||
| 3 | -timeCreated: 1486225591 | ||
| 4 | -licenseType: Free | ||
| 5 | -MonoImporter: | ||
| 6 | - serializedVersion: 2 | ||
| 7 | - defaultReferences: [] | ||
| 8 | - executionOrder: 0 | ||
| 9 | - icon: {instanceID: 0} | ||
| 10 | - userData: | ||
| 11 | - assetBundleName: | ||
| 12 | - assetBundleVariant: |
Assets/Scripts/Export Video/ExportVideo.cs
| @@ -28,9 +28,14 @@ using LAViD.Unity.Utils; | @@ -28,9 +28,14 @@ using LAViD.Unity.Utils; | ||
| 28 | 28 | ||
| 29 | public class ExportVideo : MonoBehaviour { | 29 | public class ExportVideo : MonoBehaviour { |
| 30 | 30 | ||
| 31 | + /* Durante o código, estarão presentes alguns Toast Notifications, no caso, servem apenas para Android. Alguns desses Toasts são responsáveis | ||
| 32 | + * apenas por notificar o usuário do ínicio de uma exportação de vídeo, ou do ínicio e fim de download. Outros, mais importantes, são responsá- | ||
| 33 | + * veis por notificar o usuário de algum erro durante o processo. Caso exista algum equivalente do toast no iOS, usá-lo. Caso contrário, | ||
| 34 | + * substituir apenas os toasts de erro por um alerta no iOS, onde o usuário deve clicar "OK".*/ | ||
| 35 | + | ||
| 31 | 36 | ||
| 32 | public ScreenManager screenManager; | 37 | public ScreenManager screenManager; |
| 33 | - public MediaShareAndroid MediaShareAndroid; | 38 | + public MediaShareIOS MediaShareIOS; |
| 34 | 39 | ||
| 35 | private const string SERVER_URL = "http://150.165.205.84:80/video"; | 40 | private const string SERVER_URL = "http://150.165.205.84:80/video"; |
| 36 | 41 | ||
| @@ -69,28 +74,37 @@ public class ExportVideo : MonoBehaviour { | @@ -69,28 +74,37 @@ public class ExportVideo : MonoBehaviour { | ||
| 69 | PlayerLogger.Log("ExportVideo", "SetGloss", "Setting current gloss to gloss property from ExportVideo"); | 74 | PlayerLogger.Log("ExportVideo", "SetGloss", "Setting current gloss to gloss property from ExportVideo"); |
| 70 | gloss = _gloss; | 75 | gloss = _gloss; |
| 71 | 76 | ||
| 72 | - } | ||
| 73 | - | 77 | + } |
| 74 | 78 | ||
| 79 | + | ||
| 80 | + /* RunTime Android Permission being asked*/ | ||
| 75 | private void onClickExport() | 81 | private void onClickExport() |
| 76 | { | 82 | { |
| 77 | PlayerLogger.Log("ExportVideo", "OnClickExport", "Starting Export..."); | 83 | PlayerLogger.Log("ExportVideo", "OnClickExport", "Starting Export..."); |
| 78 | 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 | + /* | ||
| 79 | NoodlePermissionGranter.PermissionRequestCallback = Permitted; | 91 | NoodlePermissionGranter.PermissionRequestCallback = Permitted; |
| 80 | NoodlePermissionGranter.GrantPermission(NoodlePermissionGranter.NoodleAndroidPermission.WRITE_EXTERNAL_STORAGE); | 92 | NoodlePermissionGranter.GrantPermission(NoodlePermissionGranter.NoodleAndroidPermission.WRITE_EXTERNAL_STORAGE); |
| 81 | - | 93 | + */ |
| 82 | 94 | ||
| 83 | 95 | ||
| 84 | } | 96 | } |
| 85 | 97 | ||
| 86 | 98 | ||
| 87 | - /* RunTime Android Permission being asked*/ | 99 | + |
| 88 | private void Permitted(bool PermissionGranted) | 100 | private void Permitted(bool PermissionGranted) |
| 89 | { | 101 | { |
| 90 | if (PermissionGranted) | 102 | if (PermissionGranted) |
| 91 | { | 103 | { |
| 92 | int fiveTimesCount; | 104 | int fiveTimesCount; |
| 93 | 105 | ||
| 106 | + /* Making the app shows the dialog for the user every five times.*/ | ||
| 107 | + | ||
| 94 | if (PlayerPrefs.HasKey("fiveTimesCount")) | 108 | if (PlayerPrefs.HasKey("fiveTimesCount")) |
| 95 | { | 109 | { |
| 96 | fiveTimesCount = PlayerPrefs.GetInt("fiveTimesCount"); | 110 | fiveTimesCount = PlayerPrefs.GetInt("fiveTimesCount"); |
| @@ -137,7 +151,7 @@ public class ExportVideo : MonoBehaviour { | @@ -137,7 +151,7 @@ public class ExportVideo : MonoBehaviour { | ||
| 137 | else | 151 | else |
| 138 | { | 152 | { |
| 139 | screenManager.showPermissionDialog("Para salvar e compartilhar as animações, permita que o Vlibras acesse mídia e arquivos de seu aparelho.", "Exportar Vìdeo"); | 153 | screenManager.showPermissionDialog("Para salvar e compartilhar as animações, permita que o Vlibras acesse mídia e arquivos de seu aparelho.", "Exportar Vìdeo"); |
| 140 | - // new AndroidToast().showToast("Você precisa dá permissão ao aplicativo.", "LONG"); | 154 | + |
| 141 | } | 155 | } |
| 142 | 156 | ||
| 143 | 157 | ||
| @@ -208,7 +222,8 @@ public class ExportVideo : MonoBehaviour { | @@ -208,7 +222,8 @@ public class ExportVideo : MonoBehaviour { | ||
| 208 | { | 222 | { |
| 209 | if (result == MNDialogResult.YES) | 223 | if (result == MNDialogResult.YES) |
| 210 | { | 224 | { |
| 211 | - new AndroidToast().showToast("Download iniciado.", "SHORT"); | 225 | + |
| 226 | + /* new AndroidToast().showToast("Download iniciado.", "SHORT");*/ | ||
| 212 | PlayerLogger.Log("ExportVideo", "OnDownloadClick", "Starting Video Download..."); | 227 | PlayerLogger.Log("ExportVideo", "OnDownloadClick", "Starting Video Download..."); |
| 213 | StartCoroutine("videoDownload"); | 228 | StartCoroutine("videoDownload"); |
| 214 | screenManager.changeExportStates(ExportLayers.ExportLayer.Download_Layer, false); | 229 | screenManager.changeExportStates(ExportLayers.ExportLayer.Download_Layer, false); |
| @@ -264,15 +279,17 @@ public class ExportVideo : MonoBehaviour { | @@ -264,15 +279,17 @@ public class ExportVideo : MonoBehaviour { | ||
| 264 | Action errorAction = () => | 279 | Action errorAction = () => |
| 265 | { | 280 | { |
| 266 | screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | 281 | screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); |
| 267 | - new AndroidToast().showToast("Erro ao compartilhar mídia.", "LONG"); | 282 | + /*new AndroidToast().showToast("Erro ao compartilhar mídia.", "LONG");*/ |
| 268 | }; | 283 | }; |
| 269 | 284 | ||
| 270 | - StartCoroutine(MediaShareAndroid.ShareIntent(errorAction)); | 285 | + /*Essa chamada é a que compartilha o video baixado, criando a intent. Achar equivalente no iOS. NÃO ESQUECER DO |
| 286 | + * CALLBACK "errorAction", o qual é chamado quando não se pode compartilhar o vídeo.*/ | ||
| 287 | + StartCoroutine(MediaShareIOS.ShareIntent(errorAction)); | ||
| 271 | } | 288 | } |
| 272 | 289 | ||
| 273 | else | 290 | else |
| 274 | { | 291 | { |
| 275 | - new AndroidToast().showToast("Erro ao compartilhar mídia.", "LONG"); | 292 | + /*new AndroidToast().showToast("Erro ao compartilhar mídia.", "LONG");*/ |
| 276 | screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); | 293 | screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); |
| 277 | } | 294 | } |
| 278 | 295 | ||
| @@ -498,10 +515,13 @@ public class ExportVideo : MonoBehaviour { | @@ -498,10 +515,13 @@ public class ExportVideo : MonoBehaviour { | ||
| 498 | { | 515 | { |
| 499 | bytes = DownloadVideo.bytesDownloaded; | 516 | bytes = DownloadVideo.bytesDownloaded; |
| 500 | videoContent = DownloadVideo.bytes; | 517 | videoContent = DownloadVideo.bytes; |
| 501 | - Action callBack = () => { OnDownloadFinished(); new AndroidToast().showToast("Vídeo salvo na Galeria.", "SHORT"); }; | 518 | + Action sucessWriting = () => { OnDownloadFinished(); /* new AndroidToast().showToast("Vídeo salvo na Galeria.", "SHORT");*/ }; |
| 502 | Action errorWriting = () => { screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); }; | 519 | Action errorWriting = () => { screenManager.changeExportStates(ExportLayers.ExportLayer.All, true); }; |
| 503 | videoDownloadRunning = false; | 520 | videoDownloadRunning = false; |
| 504 | - StartCoroutine(MediaShareAndroid.WriteOnAndroid(videoContent, bytes, System.DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss"), callBack, errorWriting)); | 521 | + |
| 522 | + /* Essa chamada é responsável por escrever os dados baixados do vídeo no aparelho, para que então ele esteja dispónivel para copartilhamento. | ||
| 523 | + * NÃO ESQUECER DOS CALLBACKS "sucessWriting" e "errorWriting"*/ | ||
| 524 | + StartCoroutine(MediaShareIOS.WriteOnIOS(videoContent, bytes, System.DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss"), sucessWriting, errorWriting)); | ||
| 505 | 525 | ||
| 506 | } | 526 | } |
| 507 | else | 527 | else |
| @@ -545,19 +565,19 @@ public class ExportVideo : MonoBehaviour { | @@ -545,19 +565,19 @@ public class ExportVideo : MonoBehaviour { | ||
| 545 | switch (error) | 565 | switch (error) |
| 546 | { | 566 | { |
| 547 | case ExportLayers.ConnectionStatusError.CONNECTION_TIMEOUT_FAILURE: | 567 | case ExportLayers.ConnectionStatusError.CONNECTION_TIMEOUT_FAILURE: |
| 548 | - new AndroidToast().showToast("Erro de conexão. Tente novamente.", "LONG"); | 568 | + /*new AndroidToast().showToast("Erro de conexão. Tente novamente.", "LONG");*/ |
| 549 | break; | 569 | break; |
| 550 | case ExportLayers.ConnectionStatusError.DOWNLOAD_CONNECTION_FAILURE: | 570 | case ExportLayers.ConnectionStatusError.DOWNLOAD_CONNECTION_FAILURE: |
| 551 | - new AndroidToast().showToast("Erro ao efetuar download, tente novamente.", "LONG"); | 571 | + /* new AndroidToast().showToast("Erro ao efetuar download, tente novamente.", "LONG");*/ |
| 552 | break; | 572 | break; |
| 553 | case ExportLayers.ConnectionStatusError.INTERNET_CONNECTION_FAILURE: | 573 | case ExportLayers.ConnectionStatusError.INTERNET_CONNECTION_FAILURE: |
| 554 | - new AndroidToast().showToast("Não há acesso à internet. Verifique sua conexão", "LONG"); | 574 | + /* new AndroidToast().showToast("Não há acesso à internet. Verifique sua conexão", "LONG");*/ |
| 555 | break; | 575 | break; |
| 556 | case ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE: | 576 | case ExportLayers.ConnectionStatusError.ERROR_CONNECTION_FAILURE: |
| 557 | - new AndroidToast().showToast("Problema na conexão. Aguarde e tente novamente.", "LONG"); | 577 | + /* new AndroidToast().showToast("Problema na conexão. Aguarde e tente novamente.", "LONG");*/ |
| 558 | break; | 578 | break; |
| 559 | default: | 579 | default: |
| 560 | - new AndroidToast().showToast("Ocorreu um erro. Estamos trabalhando para solucioná-lo!", "LONG"); | 580 | + /*new AndroidToast().showToast("Ocorreu um erro. Estamos trabalhando para solucioná-lo!", "LONG");*/ |
| 561 | break; | 581 | break; |
| 562 | } | 582 | } |
| 563 | 583 |
Assets/Scripts/Export Video/MediaShareAndroid.cs
| @@ -1,167 +0,0 @@ | @@ -1,167 +0,0 @@ | ||
| 1 | -/********************** | ||
| 2 | -********LAVID********** | ||
| 3 | -***VLibras Project***** | ||
| 4 | -*------------------------------------------------------------------------ | ||
| 5 | -*Description: | ||
| 6 | -* | ||
| 7 | -*This class is a Android Plugin that makes available the sharing function. | ||
| 8 | -*--------------------------------------------------------------------------- | ||
| 9 | -*Plugin directory: | ||
| 10 | -* - Assets/Plugins/Android | ||
| 11 | -*References: | ||
| 12 | -* - http://docs.unity3d.com/ScriptReference/AndroidJavaClass.html | ||
| 13 | -*------------------------------------------------------------------------ | ||
| 14 | -*Author: Thiago Filipe | ||
| 15 | -*thiago.filipe@lavid.ufpb.br | ||
| 16 | -***********************/ | ||
| 17 | -using UnityEngine; | ||
| 18 | -using System.Collections; | ||
| 19 | -using System.IO; | ||
| 20 | -using System; | ||
| 21 | -using LAViD.Unity.Utils; | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | -public class MediaShareAndroid : MonoBehaviour | ||
| 26 | -{ | ||
| 27 | - | ||
| 28 | - private string MediaType = "video/*"; | ||
| 29 | - | ||
| 30 | - private string SubtitleMessage = "VLibras na Playstore - https://play.google.com/store/apps/details?id=com.lavid.vlibrasdroid&hl=pt_BR"; | ||
| 31 | - | ||
| 32 | - private string AndroidPath; | ||
| 33 | - | ||
| 34 | - private static string destination = ""; | ||
| 35 | - private string Vlibras = "DCIM/VLibras"; | ||
| 36 | - private string Filen = "VLibrasVideo_"; | ||
| 37 | - private static string FilePath = ""; | ||
| 38 | - | ||
| 39 | - private byte[] videoContent; | ||
| 40 | - private int bytes; | ||
| 41 | - | ||
| 42 | - private void Awake() | ||
| 43 | - { | ||
| 44 | - AndroidPath = AndroidJavaUti.CurrentSDCardPath; | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - | ||
| 48 | - /*Makes sure that Vlibras Folder gets created and write the video bytes in it.*/ | ||
| 49 | - | ||
| 50 | - public IEnumerator WriteOnAndroid(byte[] videoContent, int bytes,string CurrentTime, Action finishWriting, Action errorWriting) | ||
| 51 | - { | ||
| 52 | - if (Application.platform == RuntimePlatform.Android) | ||
| 53 | - { | ||
| 54 | - | ||
| 55 | - FilePath = Filen + CurrentTime + ".mp4"; | ||
| 56 | - destination = Path.Combine(AndroidPath, Vlibras); | ||
| 57 | - | ||
| 58 | - | ||
| 59 | - /* Checking if folder Vlibras exists*/ | ||
| 60 | - | ||
| 61 | - DirectoryInfo dir = new DirectoryInfo(destination); | ||
| 62 | - if (!dir.Exists) | ||
| 63 | - { | ||
| 64 | - dir.Create(); | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - try | ||
| 68 | - { | ||
| 69 | - FileStream SourceStream = new FileStream(Path.Combine(destination, FilePath), FileMode.OpenOrCreate); | ||
| 70 | - if (SourceStream.CanWrite) | ||
| 71 | - { | ||
| 72 | - SourceStream.Write(videoContent, 0, bytes); | ||
| 73 | - SourceStream.Close(); | ||
| 74 | - | ||
| 75 | - Refresh(FilePath); | ||
| 76 | - finishWriting(); | ||
| 77 | - yield break; | ||
| 78 | - | ||
| 79 | - } | ||
| 80 | - else | ||
| 81 | - { | ||
| 82 | - new AndroidToast().showToast("Erro ao salvar vídeo.", "LONG"); | ||
| 83 | - errorWriting(); | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - | ||
| 87 | - } | ||
| 88 | - catch (Exception e) | ||
| 89 | - { | ||
| 90 | - PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.Message); | ||
| 91 | - PlayerLogger.Log("MediaShareAndroid", "WriteOnAndroid", "Message: " + e.StackTrace); | ||
| 92 | - new AndroidToast().showToast("Você precisa dá permissão ao aplicativo", "LONG"); | ||
| 93 | - errorWriting(); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - | ||
| 97 | - | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - | ||
| 101 | - | ||
| 102 | - | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - /* Calling Android Services to refresh the video path, making available to show in gallery*/ | ||
| 106 | - | ||
| 107 | - private void Refresh(string FilePath) | ||
| 108 | - { | ||
| 109 | - if (Application.platform == RuntimePlatform.Android) | ||
| 110 | - { | ||
| 111 | - | ||
| 112 | - AndroidJavaClass jcUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | ||
| 113 | - AndroidJavaObject joActivity = jcUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); | ||
| 114 | - AndroidJavaObject joContext = joActivity.Call<AndroidJavaObject>("getApplicationContext"); | ||
| 115 | - AndroidJavaClass jcMediaScannerConnection = new AndroidJavaClass("android.media.MediaScannerConnection"); | ||
| 116 | - //AndroidJavaClass jcEnvironment = new AndroidJavaClass("android.os.Environment"); | ||
| 117 | - // AndroidJavaObject joExDir = jcEnvironment.CallStatic<AndroidJavaObject>("getExternalStorageDirectory"); | ||
| 118 | - string path = destination; | ||
| 119 | - jcMediaScannerConnection.CallStatic("scanFile", joContext, new string[] { path }, new string[] { "video/mp4" }, null); | ||
| 120 | - | ||
| 121 | - | ||
| 122 | - } | ||
| 123 | - } | ||
| 124 | - | ||
| 125 | - | ||
| 126 | - /* Calling Android Services to create Share Intent*/ | ||
| 127 | - | ||
| 128 | - public IEnumerator ShareIntent(Action errorAction) { | ||
| 129 | - | ||
| 130 | - if (Application.platform == RuntimePlatform.Android) | ||
| 131 | - { | ||
| 132 | - if (File.Exists(Path.Combine(destination, FilePath))) | ||
| 133 | - { | ||
| 134 | - | ||
| 135 | - // block to open the file and share it ------------START | ||
| 136 | - AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); | ||
| 137 | - AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent"); | ||
| 138 | - intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND")); | ||
| 139 | - | ||
| 140 | - AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); | ||
| 141 | - AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + Path.Combine(destination, FilePath)); | ||
| 142 | - | ||
| 143 | - intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject); | ||
| 144 | - intentObject.Call<AndroidJavaObject>("setType", MediaType); | ||
| 145 | - | ||
| 146 | - //add data to be passed to the other activity i.e., the data to be sent | ||
| 147 | - intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "VLibras"); | ||
| 148 | - intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), SubtitleMessage); | ||
| 149 | - intentObject.Call<AndroidJavaObject>("setType", "video/*"); | ||
| 150 | - AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); | ||
| 151 | - AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Compartilhar via"); | ||
| 152 | - AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity"); | ||
| 153 | - currentActivity.Call("startActivity", jChooser); | ||
| 154 | - yield break; | ||
| 155 | - } | ||
| 156 | - else | ||
| 157 | - { | ||
| 158 | - errorAction(); | ||
| 159 | - | ||
| 160 | - yield break; | ||
| 161 | - } | ||
| 162 | - } | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | -} | ||
| 166 | - | ||
| 167 | - |
Assets/Scripts/Export Video/MediaShareAndroid.cs.meta
| @@ -1,12 +0,0 @@ | @@ -1,12 +0,0 @@ | ||
| 1 | -fileFormatVersion: 2 | ||
| 2 | -guid: fd1b12a178cf08b4284859e93194c7a4 | ||
| 3 | -timeCreated: 1485791307 | ||
| 4 | -licenseType: Free | ||
| 5 | -MonoImporter: | ||
| 6 | - serializedVersion: 2 | ||
| 7 | - defaultReferences: [] | ||
| 8 | - executionOrder: 0 | ||
| 9 | - icon: {instanceID: 0} | ||
| 10 | - userData: | ||
| 11 | - assetBundleName: | ||
| 12 | - assetBundleVariant: |
| @@ -0,0 +1,65 @@ | @@ -0,0 +1,65 @@ | ||
| 1 | +/********************** | ||
| 2 | +********LAVID********** | ||
| 3 | +***VLibras Project***** | ||
| 4 | +*------------------------------------------------------------------------ | ||
| 5 | +*Description: | ||
| 6 | +* | ||
| 7 | +*This class is a Android Plugin that makes available the sharing function. | ||
| 8 | +*--------------------------------------------------------------------------- | ||
| 9 | +*Plugin directory: | ||
| 10 | +* - Assets/Plugins/Android | ||
| 11 | +*References: | ||
| 12 | +* - http://docs.unity3d.com/ScriptReference/AndroidJavaClass.html | ||
| 13 | +*------------------------------------------------------------------------ | ||
| 14 | +*Author: Thiago Filipe | ||
| 15 | +*thiago.filipe@lavid.ufpb.br | ||
| 16 | +***********************/ | ||
| 17 | +using UnityEngine; | ||
| 18 | +using System.Collections; | ||
| 19 | +using System; | ||
| 20 | +using LAViD.Unity.Utils; | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +public class MediaShareIOS : MonoBehaviour | ||
| 25 | +{ | ||
| 26 | + | ||
| 27 | + private string MediaType = "video/*"; | ||
| 28 | + private static string destination = ""; | ||
| 29 | + private string VlibrasFolder = "DCIM/VLibras"; | ||
| 30 | + private string Filen = "VLibrasVideo_"; | ||
| 31 | + private static string FilePath = ""; | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + /*Makes sure that Vlibras Folder gets created and write the video bytes in it.*/ | ||
| 35 | + | ||
| 36 | + public IEnumerator WriteOnIOS(byte[] videoContent, int bytes,string CurrentTime, Action finishWriting, Action errorWriting) | ||
| 37 | + { | ||
| 38 | + /*FilePath se refere ao nome que o arquivo será salvo. Este deve ser mantido como está.*/ | ||
| 39 | + FilePath = Filen + CurrentTime + ".mp4"; | ||
| 40 | + | ||
| 41 | + /* A partir daqui deve ser feita a implementação IOS, onde deve-se utilizar dos callbacks "finishWriting" e "errorWriting". O primeiro | ||
| 42 | + * chamado em caso de sucesso na escrita do vídeo, o segundo em caso de algum erro.*/ | ||
| 43 | + /*É 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*/ | ||
| 44 | + | ||
| 45 | + | ||
| 46 | + yield break; | ||
| 47 | + | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + | ||
| 52 | + /* Calling Android Services to create Share Intent*/ | ||
| 53 | + | ||
| 54 | + public IEnumerator ShareIntent(Action errorAction) { | ||
| 55 | + | ||
| 56 | + /* Aqui deve ser feita a implementação iOS da função que permitirá o usuário compartilhar o vídeo com as redes sociais*/ | ||
| 57 | + /*O callback errorAction deve ser chamado em caso de algum erro no processo, por exemplo: usuário baixou o vídeo e foi salvo | ||
| 58 | + * corretamente, porém antes de clicar compartilhar, ele foi no diretório do vídeo e o excluiu, para então clicar compartilhar.*/ | ||
| 59 | + | ||
| 60 | + yield break; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | + |
| @@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
| 1 | +fileFormatVersion: 2 | ||
| 2 | +guid: ff208f584beb2bd43a9751619a94e506 | ||
| 3 | +timeCreated: 1489757228 | ||
| 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
| @@ -114,12 +114,12 @@ PlayerSettings: | @@ -114,12 +114,12 @@ PlayerSettings: | ||
| 114 | ForceSDCardPermission: 1 | 114 | ForceSDCardPermission: 1 |
| 115 | CreateWallpaper: 0 | 115 | CreateWallpaper: 0 |
| 116 | APKExpansionFiles: 0 | 116 | APKExpansionFiles: 0 |
| 117 | - preloadShaders: 0 | 117 | + preloadShaders: 1 |
| 118 | StripUnusedMeshComponents: 0 | 118 | StripUnusedMeshComponents: 0 |
| 119 | VertexChannelCompressionMask: | 119 | VertexChannelCompressionMask: |
| 120 | serializedVersion: 2 | 120 | serializedVersion: 2 |
| 121 | m_Bits: 238 | 121 | m_Bits: 238 |
| 122 | - iPhoneSdkVersion: 988 | 122 | + iPhoneSdkVersion: 989 |
| 123 | iPhoneTargetOSVersion: 22 | 123 | iPhoneTargetOSVersion: 22 |
| 124 | tvOSSdkVersion: 0 | 124 | tvOSSdkVersion: 0 |
| 125 | tvOSTargetOSVersion: 900 | 125 | tvOSTargetOSVersion: 900 |