private void FixLauncherActivity(AN_ApplicationTemplate application) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Learn More...", GUILayout.Width(100))) { Application.OpenURL("https://unionassets.com/android-native-plugin/compatibility-154"); } if (GUILayout.Button("FIX", GUILayout.Width(100))) { foreach (KeyValuePair <int, AN_ActivityTemplate> pair in application.Activities) { pair.Value.SetAsLauncher(false); } AN_ActivityTemplate bridgeLauncher = application.GetOrCreateActivityWithName("com.androidnative.AndroidNativeBridge"); bridgeLauncher.SetAsLauncher(true); bridgeLauncher.SetValue("android:launchMode", "singleTask"); AN_ManifestManager.SaveManifest(); UpdateManifest(); } EditorGUILayout.EndHorizontal(); }
public static void UpdateManifest() { if (!GoogleMobileAdSettings.Instance.KeepManifestClean) { return; } AN_ManifestManager.Refresh(); AN_ManifestTemplate Manifest = AN_ManifestManager.GetManifest(); AN_ApplicationTemplate application = Manifest.ApplicationTemplate; AN_ActivityTemplate launcherActivity = application.GetLauncherActivity(); AN_ActivityTemplate AdActivity = application.GetOrCreateActivityWithName("com.google.android.gms.ads.AdActivity"); AdActivity.SetValue("android:configChanges", "keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"); if (launcherActivity != null) { AN_PropertyTemplate ForwardNativeEventsToDalvik = launcherActivity.GetOrCreatePropertyWithName("meta-data", "unityplayer.ForwardNativeEventsToDalvik"); ForwardNativeEventsToDalvik.SetValue("android:value", "true"); } AN_PropertyTemplate games_version = application.GetOrCreatePropertyWithName("meta-data", "com.google.android.gms.version"); games_version.SetValue("android:value", GoogleMobileAdSettings.PLAY_SERVICE_VERSION); AN_ManifestManager.SaveManifest(); }
void OnGUI() { GUILayout.Label("Android Manifest Manager", EditorStyles.boldLabel); if (!AN_ManifestManager.HasManifest) { GUILayout.BeginHorizontal(); EditorGUILayout.Space(); GUILayout.Label("You have NO AndroidManifest file in your project!", GUILayout.Width(300.0f)); EditorGUILayout.Space(); GUILayout.EndHorizontal(); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Create Default Manifest", new GUILayoutOption[] { GUILayout.Width(200.0f), GUILayout.Height(50.0f) })) { AN_ManifestManager.CreateDefaultManifest(); } EditorGUILayout.Space(); GUILayout.EndHorizontal(); } else { string[] toolbarButtons = new string[] { "Manifest", "Application", "Permissions" }; toolbarButtonIndex = GUILayout.Toolbar(toolbarButtonIndex, toolbarButtons, new GUILayoutOption[] { GUILayout.Height(30.0f) }); switch (toolbarButtons[toolbarButtonIndex]) { case "Manifest": { AN_ManifestTemplate manifest = AN_ManifestManager.GetManifest(); if (manifest != null) { GUILayout.Label("Values", EditorStyles.boldLabel); foreach (string key in manifest.Values.Keys) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(key); if (key.Equals("xmlns:android") || key.Equals("android:installLocation") || key.Equals("package") || key.Equals("android:versionName") || key.Equals("android:versionCode") || key.Equals("android:theme")) { GUI.enabled = false; GUILayout.TextField(AN_ManifestManager.GetManifest().Values[key], GUILayout.Width(300.0f)); } else { GUI.enabled = true; string input = AN_ManifestManager.GetManifest().Values[key]; EditorGUI.BeginChangeCheck(); input = GUILayout.TextField(AN_ManifestManager.GetManifest().Values[key], GUILayout.Width(276.0f)); if (EditorGUI.EndChangeCheck()) { AN_ManifestManager.GetManifest().SetValue(key, input); return; } if (GUILayout.Button("X", GUILayout.Width(20.0f))) { AN_ManifestManager.GetManifest().RemoveValue(key); return; } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Value", GUILayout.Width(100.0f))) { AddValueDialog(AN_ManifestManager.GetManifest()); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); GUILayout.Label("Properties", EditorStyles.boldLabel); DrawProperties(AN_ManifestManager.GetManifest()); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Property", GUILayout.Width(100.0f))) { AddPropertyDialog(AN_ManifestManager.GetManifest()); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Save Manifest", GUILayout.Height(22.0f))) { AN_ManifestManager.SaveManifest(); } } else { EditorGUILayout.HelpBox("Selected build platform DOESN'T support AndroidManifest.xml file", MessageType.Info); } } break; case "Application": { AN_ManifestTemplate manifest = AN_ManifestManager.GetManifest(); if (manifest != null) { scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 50f)); GUILayout.Label("Values", EditorStyles.boldLabel); foreach (string key in manifest.ApplicationTemplate.Values.Keys) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(key); string input = AN_ManifestManager.GetManifest().ApplicationTemplate.Values[key]; EditorGUI.BeginChangeCheck(); input = GUILayout.TextField(AN_ManifestManager.GetManifest().ApplicationTemplate.Values[key], GUILayout.Width(200.0f)); if (EditorGUI.EndChangeCheck()) { AN_ManifestManager.GetManifest().ApplicationTemplate.SetValue(key, input); return; } if (GUILayout.Button("X", GUILayout.Width(20.0f))) { AN_ManifestManager.GetManifest().ApplicationTemplate.RemoveValue(key); return; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Value", GUILayout.Width(100.0f))) { AddValueDialog(AN_ManifestManager.GetManifest().ApplicationTemplate); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); GUILayout.Label("Activities", EditorStyles.boldLabel); int launcherActivities = 0; foreach (int id in AN_ManifestManager.GetManifest().ApplicationTemplate.Activities.Keys) { AN_ActivityTemplate activity = AN_ManifestManager.GetManifest().ApplicationTemplate.Activities[id]; if (activity.IsLauncher) { launcherActivities++; } EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.BeginHorizontal(); activity.IsOpen = EditorGUILayout.Foldout(activity.IsOpen, activity.Name); if (GUILayout.Button("X", GUILayout.Width(20.0f))) { AN_ManifestManager.GetManifest().ApplicationTemplate.RemoveActivity(activity); return; } EditorGUILayout.EndHorizontal(); if (activity.IsOpen) { EditorGUILayout.BeginVertical(); bool isLauncher = activity.IsLauncher; EditorGUI.BeginChangeCheck(); isLauncher = EditorGUILayout.Toggle("Is Launcher", activity.IsLauncher); if (EditorGUI.EndChangeCheck()) { activity.SetAsLauncher(isLauncher); } foreach (string k in activity.Values.Keys) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(k); EditorGUILayout.Space(); string input = activity.Values[k]; EditorGUI.BeginChangeCheck(); if (k.Equals("android:name")) { input = GUILayout.TextField(activity.Values[k], GUILayout.Width(224.0f)); } else { input = GUILayout.TextField(activity.Values[k], GUILayout.Width(200.0f)); } if (EditorGUI.EndChangeCheck()) { activity.SetValue(k, input); return; } if (!k.Equals("android:name")) { if (GUILayout.Button("X", GUILayout.Width(20.0f))) { activity.RemoveValue(k); return; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } DrawProperties(activity); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Value", GUILayout.Width(100.0f))) { AddValueDialog(activity); } if (GUILayout.Button("Add Property", GUILayout.Width(100.0f))) { AddPropertyDialog(activity); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Activity", GUILayout.Width(100.0f))) { AddPermissionDialog dlg = EditorWindow.CreateInstance <AddPermissionDialog>(); dlg.onClose += OnPermissionDlgClose; dlg.onAddClick += OnAddActivityClick; #if UNITY_5 && !UNITY_5_0 dlg.titleContent.text = "Add Activity"; #else dlg.title = "Add Activity"; #endif dlg.ShowAuxWindow(); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); if (launcherActivities > 1) { EditorGUILayout.HelpBox("There is MORE THAN ONE Launcher Activity in Manifest", MessageType.Warning); } else if (launcherActivities < 1) { EditorGUILayout.HelpBox("There is NO Launcher Activities in Manifest", MessageType.Warning); } GUILayout.Label("Properties", EditorStyles.boldLabel); DrawProperties(AN_ManifestManager.GetManifest().ApplicationTemplate); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Property", GUILayout.Width(100.0f))) { AddPropertyDialog(AN_ManifestManager.GetManifest().ApplicationTemplate); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndScrollView(); } else { EditorGUILayout.HelpBox("Selected build platform DOESN'T support AndroidManifest.xml file", MessageType.Info); } } break; case "Permissions": { AN_ManifestTemplate manifest = AN_ManifestManager.GetManifest(); if (manifest != null) { scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 50f)); EditorGUILayout.BeginVertical(); foreach (AN_PropertyTemplate permission in AN_ManifestManager.GetManifest().Permissions) { EditorGUILayout.BeginHorizontal(GUI.skin.box); EditorGUILayout.LabelField(permission.Values["android:name"]); if (GUILayout.Button("X", GUILayout.Width(20.0f))) { AN_ManifestManager.GetManifest().RemovePermission(permission); return; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add Android Permission")) { GenericMenu permissionsMenu = new GenericMenu(); foreach (string pStr in PermissionsStrings) { permissionsMenu.AddItem(new GUIContent(pStr), false, SelectPermission, pStr); } permissionsMenu.ShowAsContext(); } if (GUILayout.Button("Add Other Permission")) { AddPermissionDialog dlg = EditorWindow.CreateInstance <AddPermissionDialog>(); dlg.onClose += OnPermissionDlgClose; dlg.onAddClick += OnAddPermissionClick; #if UNITY_5 && !UNITY_5_0 dlg.titleContent.text = "Add Permission"; #else dlg.title = "Add Permission"; #endif dlg.ShowAuxWindow(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); } else { EditorGUILayout.HelpBox("Selected build platform DOESN'T support AndroidManifest.xml file", MessageType.Info); } } break; default: break; } AboutGUI(); } }
public static void UpdateManifest() { if (!SocialPlatfromSettings.Instance.KeepManifestClean) { return; } AN_ManifestManager.Refresh(); AN_ManifestTemplate Manifest = AN_ManifestManager.GetManifest(); AN_ApplicationTemplate application = Manifest.ApplicationTemplate; AN_ActivityTemplate launcherActivity = application.GetLauncherActivity(); AN_ActivityTemplate AndroidNativeProxy = application.GetOrCreateActivityWithName("com.androidnative.AndroidNativeProxy"); AndroidNativeProxy.SetValue("android:launchMode", "singleTask"); AndroidNativeProxy.SetValue("android:label", "@string/app_name"); AndroidNativeProxy.SetValue("android:configChanges", "fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"); AndroidNativeProxy.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar"); // Remove VIEW intent filter from AndroidNativeProxy activity if (AndroidNativeProxy != null) { AN_PropertyTemplate intent_filter = AndroidNativeProxy.GetOrCreateIntentFilterWithName("android.intent.action.VIEW"); AndroidNativeProxy.RemoveProperty(intent_filter); } AN_ActivityTemplate SocialProxyActivity = application.GetOrCreateActivityWithName("com.androidnative.features.social.common.SocialProxyActivity"); SocialProxyActivity.SetValue("android:launchMode", "singleTask"); SocialProxyActivity.SetValue("android:label", "@string/app_name"); SocialProxyActivity.SetValue("android:configChanges", "fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"); SocialProxyActivity.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar"); if (launcherActivity.Name == "com.androidnative.AndroidNativeBridge") { launcherActivity.SetName("com.unity3d.player.UnityPlayerNativeActivity"); } //////////////////////// //TwitterAPI //////////////////////// foreach (KeyValuePair <int, AN_ActivityTemplate> entry in application.Activities) { //TODO get intents array AN_ActivityTemplate act = entry.Value; AN_PropertyTemplate intent = act.GetIntentFilterWithName("android.intent.action.VIEW"); if (intent != null) { AN_PropertyTemplate data = intent.GetOrCreatePropertyWithTag("data"); if (data.GetValue("android:scheme") == "oauth") { act.RemoveProperty(intent); } } } if (SocialPlatfromSettings.Instance.TwitterAPI) { if (SocialProxyActivity != null) { AN_PropertyTemplate intent_filter = SocialProxyActivity.GetOrCreateIntentFilterWithName("android.intent.action.VIEW"); intent_filter.GetOrCreatePropertyWithName("category", "android.intent.category.DEFAULT"); intent_filter.GetOrCreatePropertyWithName("category", "android.intent.category.BROWSABLE"); AN_PropertyTemplate data = intent_filter.GetOrCreatePropertyWithTag("data"); data.SetValue("android:scheme", "oauth"); data.SetValue("android:host", PlayerSettings.bundleIdentifier); } } else { if (SocialProxyActivity != null) { AN_PropertyTemplate intent_filter = SocialProxyActivity.GetOrCreateIntentFilterWithName("android.intent.action.VIEW"); SocialProxyActivity.RemoveProperty(intent_filter); } } //////////////////////// //FB API //////////////////////// AN_PropertyTemplate ApplicationId_meta = application.GetOrCreatePropertyWithName("meta-data", "com.facebook.sdk.ApplicationId"); AN_ActivityTemplate LoginActivity = application.GetOrCreateActivityWithName("com.facebook.LoginActivity"); AN_ActivityTemplate FBUnityLoginActivity = application.GetOrCreateActivityWithName("com.facebook.unity.FBUnityLoginActivity"); AN_ActivityTemplate FBUnityDeepLinkingActivity = application.GetOrCreateActivityWithName("com.facebook.unity.FBUnityDeepLinkingActivity"); AN_ActivityTemplate FBUnityDialogsActivity = application.GetOrCreateActivityWithName("com.facebook.unity.FBUnityDialogsActivity"); if (IsFacebookInstalled) { ApplicationId_meta.SetValue("android:value", "\\ " + FBSettings.AppId); LoginActivity.SetValue("android:label", "@string/app_name"); LoginActivity.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar"); LoginActivity.SetValue("android:configChanges", "keyboardHidden|orientation"); FBUnityLoginActivity.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar.Fullscreen"); FBUnityLoginActivity.SetValue("android:configChanges", "fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"); FBUnityDialogsActivity.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar.Fullscreen"); FBUnityDialogsActivity.SetValue("android:configChanges", "fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"); FBUnityDeepLinkingActivity.SetValue("android:exported", "true"); } else { application.RemoveProperty(ApplicationId_meta); application.RemoveActivity(LoginActivity); application.RemoveActivity(FBUnityLoginActivity); application.RemoveActivity(FBUnityDeepLinkingActivity); application.RemoveActivity(FBUnityDialogsActivity); } //////////////////////// //NativeSharingAPI //////////////////////// AN_PropertyTemplate provider = application.GetOrCreatePropertyWithName("provider", "android.support.v4.content.FileProvider"); if (SocialPlatfromSettings.Instance.NativeSharingAPI) { #if !(UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6) //Remove FileProvider description from AndroidManifest.xml in Unity 5 application.RemoveProperty(provider); #else provider.SetValue("android:authorities", PlayerSettings.bundleIdentifier + ".fileprovider"); provider.SetValue("android:exported", "false"); provider.SetValue("android:grantUriPermissions", "true"); AN_PropertyTemplate provider_meta = provider.GetOrCreatePropertyWithName("meta-data", "android.support.FILE_PROVIDER_PATHS"); provider_meta.SetValue("android:resource", "@xml/file_paths"); #endif } else { application.RemoveProperty(provider); } List <string> permissions = GetRequiredPermissions(); foreach (string p in permissions) { Manifest.AddPermission(p); } AN_ManifestManager.SaveManifest(); }
public static void UpdateManifest() { if (!SocialPlatfromSettings.Instance.KeepManifestClean) { return; } AN_ManifestManager.Refresh(); AN_ManifestTemplate Manifest = AN_ManifestManager.GetManifest(); AN_ApplicationTemplate application = Manifest.ApplicationTemplate; AN_ActivityTemplate launcherActivity = application.GetLauncherActivity(); //////////////////////// //TwitterAPI //////////////////////// foreach (KeyValuePair <int, AN_ActivityTemplate> entry in application.Activities) { //TODO get intents array AN_ActivityTemplate act = entry.Value; AN_PropertyTemplate intent = act.GetIntentFilterWithName("android.intent.action.VIEW"); if (intent != null) { AN_PropertyTemplate data = intent.GetPropertyWithTag("data"); if (data.GetValue("android:scheme") == "oauth") { act.RemoveProperty(intent); } } } if (SocialPlatfromSettings.Instance.TwitterAPI) { if (launcherActivity != null) { AN_PropertyTemplate intent_filter = launcherActivity.GetOrCreateIntentFilterWithName("android.intent.action.VIEW"); intent_filter.GetOrCreatePropertyWithName("category", "android.intent.category.DEFAULT"); intent_filter.GetOrCreatePropertyWithName("category", "android.intent.category.BROWSABLE"); AN_PropertyTemplate data = intent_filter.GetOrCreatePropertyWithTag("data"); data.SetValue("android:scheme", "oauth"); data.SetValue("android:host", PlayerSettings.bundleIdentifier); } } else { if (launcherActivity != null) { AN_PropertyTemplate intent_filter = launcherActivity.GetOrCreateIntentFilterWithName("android.intent.action.VIEW"); launcherActivity.RemoveProperty(intent_filter); } } //////////////////////// //FB API //////////////////////// AN_PropertyTemplate ApplicationId_meta = application.GetOrCreatePropertyWithName("meta-data", "com.facebook.sdk.ApplicationId"); AN_ActivityTemplate LoginActivity = application.GetOrCreateActivityWithName("com.facebook.LoginActivity"); AN_ActivityTemplate FBUnityLoginActivity = application.GetOrCreateActivityWithName("com.facebook.unity.FBUnityLoginActivity"); AN_ActivityTemplate FBUnityDeepLinkingActivity = application.GetOrCreateActivityWithName("com.facebook.unity.FBUnityDeepLinkingActivity"); if (IsFacebookInstalled) { ApplicationId_meta.Value = "fb_app_id"; LoginActivity.SetValue("android:label", "@string/app_name"); LoginActivity.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar"); FBUnityLoginActivity.SetValue("android:theme", "@android:style/Theme.Translucent.NoTitleBar.Fullscreen"); FBUnityDeepLinkingActivity.SetValue("android:exported", "true"); } else { application.RemoveProperty(ApplicationId_meta); application.RemoveActivity(LoginActivity); application.RemoveActivity(FBUnityLoginActivity); application.RemoveActivity(FBUnityDeepLinkingActivity); } //////////////////////// //NativeSharingAPI //////////////////////// AN_PropertyTemplate provider = application.GetOrCreatePropertyWithName("provider", "android.support.v4.content.FileProvider"); if (SocialPlatfromSettings.Instance.NativeSharingAPI) { provider.SetValue("android:authorities", PlayerSettings.bundleIdentifier + ".fileprovider"); provider.SetValue("android:exported", "false"); provider.SetValue("android:grantUriPermissions", "true"); AN_PropertyTemplate provider_meta = provider.GetOrCreatePropertyWithName("meta-data", "android.support.FILE_PROVIDER_PATHS"); provider_meta.SetValue("android:resource", "@xml/file_paths"); } else { application.RemoveProperty(provider); } List <string> permissions = GetRequiredPermissions(); foreach (string p in permissions) { Manifest.AddPermission(p); } AN_ManifestManager.SaveManifest(); }
public static void UpdateManifest() { if (!AndroidNativeSettings.Instance.KeepManifestClean) { return; } AN_ManifestManager.Refresh(); int UpdateId = 0; AN_ManifestTemplate Manifest = AN_ManifestManager.GetManifest(); AN_ApplicationTemplate application = Manifest.ApplicationTemplate; AN_ActivityTemplate launcherActivity = application.GetLauncherActivity(); //////////////////////// //Google Play Service API //////////////////////// AN_PropertyTemplate games_version = application.GetOrCreatePropertyWithName("meta-data", "com.google.android.gms.version"); if (AndroidNativeSettings.Instance.EnablePSAPI) { games_version.SetValue("android:value", "@integer/google_play_services_version"); } else { application.RemoveProperty(games_version); } //////////////////////// //GooglePlayServicesAPI //////////////////////// UpdateId++; AN_PropertyTemplate games_APP_ID = application.GetOrCreatePropertyWithName("meta-data", "com.google.android.gms.games.APP_ID"); if (!AndroidNativeSettings.Instance.GooglePlayServicesAPI) { application.RemoveProperty(games_APP_ID); } else { games_APP_ID.SetValue("android:value", "@string/app_id"); } //////////////////////// //GoogleCloudSaveAPI //////////////////////// UpdateId++; AN_PropertyTemplate appstate_APP_ID = application.GetOrCreatePropertyWithName("meta-data", "com.google.android.gms.appstate.APP_ID"); if (AndroidNativeSettings.Instance.GoogleCloudSaveAPI) { appstate_APP_ID.SetValue("android:value", "@string/app_id"); AndroidNativeSettings.Instance.EnableAppStateAPI = true; } else { AndroidNativeSettings.Instance.EnableAppStateAPI = false; application.RemoveProperty(appstate_APP_ID); } //////////////////////// //AnalyticsAPI //////////////////////// UpdateId++; if (AndroidNativeSettings.Instance.AnalyticsAPI) { //Nothing to do } //////////////////////// //PushNotificationsAPI //////////////////////// UpdateId++; AN_PropertyTemplate GcmBroadcastReceiver = application.GetOrCreatePropertyWithName("receiver", "com.androidnative.gcm.GcmBroadcastReceiver"); AN_PropertyTemplate GcmIntentService = application.GetOrCreatePropertyWithName("service", "com.androidnative.gcm.GcmIntentService"); AN_PropertyTemplate permission_C2D_MESSAGE = Manifest.GetOrCreatePropertyWithName("permission", "com.example.gcm.permission.C2D_MESSAGE"); if (AndroidNativeSettings.Instance.PushNotificationsAPI) { GcmBroadcastReceiver.SetValue("android:permission", "com.google.android.c2dm.permission.SEND"); AN_PropertyTemplate intent_filter = GcmBroadcastReceiver.GetOrCreateIntentFilterWithName("com.google.android.c2dm.intent.RECEIVE"); AN_PropertyTemplate category = intent_filter.GetOrCreatePropertyWithTag("category"); category.SetValue("android:name", PlayerSettings.bundleIdentifier); permission_C2D_MESSAGE.SetValue("android:protectionLevel", "signature"); } else { application.RemoveProperty(GcmBroadcastReceiver); application.RemoveProperty(GcmIntentService); Manifest.RemoveProperty(permission_C2D_MESSAGE); } //////////////////////// //GoogleMobileAdAPI //////////////////////// UpdateId++; AN_ActivityTemplate AdActivity = application.GetOrCreateActivityWithName("com.google.android.gms.ads.AdActivity"); if (AndroidNativeSettings.Instance.GoogleMobileAdAPI) { if (launcherActivity != null) { AN_PropertyTemplate ForwardNativeEventsToDalvik = launcherActivity.GetOrCreatePropertyWithName("meta-data", "unityplayer.ForwardNativeEventsToDalvik"); ForwardNativeEventsToDalvik.SetValue("android:value", "true"); } AdActivity.SetValue("android:configChanges", "keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"); } else { application.RemoveActivity(AdActivity); } //////////////////////// //GoogleButtonAPI //////////////////////// UpdateId++; if (AndroidNativeSettings.Instance.GoogleButtonAPI) { //Nothing to do } //////////////////////// //LocalNotificationsAPI //////////////////////// AN_PropertyTemplate LocalNotificationReceiver = application.GetOrCreatePropertyWithName("receiver", "com.androidnative.features.notifications.LocalNotificationReceiver"); if (AndroidNativeSettings.Instance.LocalNotificationsAPI) { } else { application.RemoveProperty(LocalNotificationReceiver); } //////////////////////// //ImmersiveModeAPI //////////////////////// if (AndroidNativeSettings.Instance.ImmersiveModeAPI) { //Nothing to do } //////////////////////// //ApplicationInformationAPI //////////////////////// if (AndroidNativeSettings.Instance.ApplicationInformationAPI) { //Nothing to do } //////////////////////// //ExternalAppsAPI //////////////////////// if (AndroidNativeSettings.Instance.ExternalAppsAPI) { //Nothing to do } //////////////////////// //PoupsandPreloadersAPI //////////////////////// if (AndroidNativeSettings.Instance.PoupsandPreloadersAPI) { //Nothing to do } //////////////////////// //InAppPurchasesAPI //////////////////////// if (AndroidNativeSettings.Instance.InAppPurchasesAPI) { //Nothing to do } //////////////////////// //CameraAPI //////////////////////// if (AndroidNativeSettings.Instance.CameraAPI) { //Nothing to do } //////////////////////// //GalleryAPI //////////////////////// if (AndroidNativeSettings.Instance.GalleryAPI) { //Nothing to do } List <string> permissions = GetRequiredPermissions(); foreach (string p in permissions) { Manifest.AddPermission(p); } AN_ManifestManager.SaveManifest(); SocialPlatfromSettingsEditor.UpdateManifest(); }
private void PluginSetting() { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Plugin Settings", MessageType.None); AN_ManifestManager.Refresh(); AN_ManifestTemplate Manifest = AN_ManifestManager.GetManifest(); AN_ApplicationTemplate application = Manifest.ApplicationTemplate; AN_ActivityTemplate Launcher = application.GetLauncherActivity(); if (Launcher == null) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("No Launcher Activity founded in the Manifest", MessageType.Warning); EditorGUILayout.EndHorizontal(); FixLauncherActivity(application); EditorGUILayout.Space(); } else { if (!Launcher.Name.Equals("com.androidnative.AndroidNativeBridge")) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("Current Launcher Activity is " + Launcher.Name + ".\n" + "But AndroidNativeBridge required to be Launcher. Some features may not work.", MessageType.Warning); EditorGUILayout.EndHorizontal(); FixLauncherActivity(application); EditorGUILayout.Space(); } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Keep Android Mnifest Clean"); EditorGUI.BeginChangeCheck(); AndroidNativeSettings.Instance.KeepManifestClean = EditorGUILayout.Toggle(AndroidNativeSettings.Instance.KeepManifestClean); SocialPlatfromSettings.Instance.KeepManifestClean = AndroidNativeSettings.Instance.KeepManifestClean; if (EditorGUI.EndChangeCheck()) { UpdateManifest(); } if (GUILayout.Button("[?]", GUILayout.Width(27))) { Application.OpenURL("http://goo.gl/syIebl"); } EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); AndroidNativeSettings.Instance.ShowAppPermissions = EditorGUILayout.Foldout(AndroidNativeSettings.Instance.ShowAppPermissions, "Application Permissions"); if (AndroidNativeSettings.Instance.ShowAppPermissions) { AN_ManifestManager.Refresh(); //EditorGUI.indentLevel++; EditorGUILayout.LabelField("Required By Android Native:", EditorStyles.boldLabel); List <string> permissions = GetRequiredPermissions(); foreach (string p in permissions) { EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.BeginHorizontal(); EditorGUILayout.SelectableLabel(p, GUILayout.Height(16)); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Other Permissions in Manifest:", EditorStyles.boldLabel); foreach (AN_PropertyTemplate tpl in AN_ManifestManager.GetManifest().Permissions) { if (!permissions.Contains(tpl.Name)) { EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.BeginHorizontal(); EditorGUILayout.SelectableLabel(tpl.Name, GUILayout.Height(16)); if (GUILayout.Button("x", GUILayout.Width(20))) { AN_ManifestManager.GetManifest().RemovePermission(tpl); AN_ManifestManager.SaveManifest(); return; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } } //EditorGUI.indentLevel--; } AndroidNativeSettings.Instance.ShowPluginSettings = EditorGUILayout.Foldout(AndroidNativeSettings.Instance.ShowPluginSettings, "Android Native Libs"); if (AndroidNativeSettings.Instance.ShowPluginSettings) { EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); //Native Lib API EditorGUILayout.BeginHorizontal(); settings.ExpandNativeAPI = EditorGUILayout.Foldout(settings.ExpandNativeAPI, "Enable Native Lib"); SuperSpace(); GUI.enabled = false; EditorGUILayout.Toggle(true); GUI.enabled = true; EditorGUILayout.EndHorizontal(); if (settings.ExpandNativeAPI) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); settings.LocalNotificationsAPI = EditorGUILayout.Toggle(AN_API_NAME.LocalNotifications, settings.LocalNotificationsAPI); settings.ImmersiveModeAPI = EditorGUILayout.Toggle(AN_API_NAME.ImmersiveMode, settings.ImmersiveModeAPI); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); settings.ApplicationInformationAPI = EditorGUILayout.Toggle(AN_API_NAME.ApplicationInformation, settings.ApplicationInformationAPI); settings.ExternalAppsAPI = EditorGUILayout.Toggle(AN_API_NAME.RunExternalApp, settings.ExternalAppsAPI); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); settings.PoupsandPreloadersAPI = EditorGUILayout.Toggle(AN_API_NAME.PoupsandPreloaders, settings.PoupsandPreloadersAPI); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; EditorGUILayout.Space(); } EditorGUILayout.BeginHorizontal(); settings.ExpandBillingAPI = EditorGUILayout.Foldout(settings.ExpandBillingAPI, "Enable Billing Lib"); SuperSpace(); settings.EnableBillingAPI = EditorGUILayout.Toggle(settings.EnableBillingAPI); EditorGUILayout.EndHorizontal(); if (settings.ExpandBillingAPI) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); settings.InAppPurchasesAPI = EditorGUILayout.Toggle(AN_API_NAME.InAppPurchases, settings.InAppPurchasesAPI); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; EditorGUILayout.Space(); } //GOOGLE PLAY API EditorGUILayout.BeginHorizontal(); settings.ExpandPSAPI = EditorGUILayout.Foldout(settings.ExpandPSAPI, "Enable Google Play Lib"); SuperSpace(); settings.EnablePSAPI = EditorGUILayout.Toggle(settings.EnablePSAPI); EditorGUILayout.EndHorizontal(); if (settings.ExpandPSAPI) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); settings.GooglePlayServicesAPI = EditorGUILayout.Toggle(AN_API_NAME.GooglePlayServices, settings.GooglePlayServicesAPI); settings.PlayServicesAdvancedSignInAPI = EditorGUILayout.Toggle(AN_API_NAME.GooglePlayServicesAdvancedSignIn, settings.PlayServicesAdvancedSignInAPI); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); settings.PushNotificationsAPI = EditorGUILayout.Toggle(AN_API_NAME.PushNotifications, settings.PushNotificationsAPI); settings.GoogleCloudSaveAPI = EditorGUILayout.Toggle(AN_API_NAME.GoogleCloudSave, settings.GoogleCloudSaveAPI); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); settings.AnalyticsAPI = EditorGUILayout.Toggle(AN_API_NAME.Analytics, settings.AnalyticsAPI); settings.GoogleMobileAdAPI = EditorGUILayout.Toggle(AN_API_NAME.GoogleMobileAd, settings.GoogleMobileAdAPI); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); settings.GoogleButtonAPI = EditorGUILayout.Toggle(AN_API_NAME.GoogleButton, settings.GoogleButtonAPI); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; EditorGUILayout.Space(); } EditorGUILayout.BeginHorizontal(); settings.ExpandSocialAPI = EditorGUILayout.Foldout(settings.ExpandSocialAPI, "Enable Social Lib"); SuperSpace(); settings.EnableSocialAPI = EditorGUILayout.Toggle(settings.EnableSocialAPI); EditorGUILayout.EndHorizontal(); if (settings.ExpandSocialAPI) { EditorGUI.indentLevel++; SocialPlatfromSettingsEditor.DrawAPIsList(); EditorGUI.indentLevel--; EditorGUILayout.Space(); } EditorGUILayout.BeginHorizontal(); settings.ExpandCameraAPI = EditorGUILayout.Foldout(settings.ExpandCameraAPI, "Enable Camera Lib"); SuperSpace(); settings.EnableCameraAPI = EditorGUILayout.Toggle(settings.EnableCameraAPI); EditorGUILayout.EndHorizontal(); if (settings.ExpandCameraAPI) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); settings.CameraAPI = EditorGUILayout.Toggle(AN_API_NAME.CameraAPI, settings.CameraAPI); settings.GalleryAPI = EditorGUILayout.Toggle(AN_API_NAME.Gallery, settings.GalleryAPI); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; EditorGUILayout.Space(); } EditorGUI.indentLevel--; if (EditorGUI.EndChangeCheck()) { UpdateAPIsInstalation(); } } Actions(); EditorGUILayout.Space(); }