diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index e1d17a117..571e6e1ba 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -13,8 +13,5 @@ # limitations under the License. add_subdirectory(app) -add_subdirectory(analytics) -add_subdirectory(auth) add_subdirectory(crashlytics) -add_subdirectory(dynamic_links) add_subdirectory(messaging) diff --git a/editor/analytics/CMakeLists.txt b/editor/analytics/CMakeLists.txt deleted file mode 100644 index 68b778956..000000000 --- a/editor/analytics/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2019 Google -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# CMake file for the firebase analytics unity editor plugin - -if(FIREBASE_UNITY_EAP) - set(firebase_analytics_editor_eap_src - src/eap/AnalyticsConfig.cs - src/eap/Strings.Designer.cs - src/eap/Strings.resx - ) -else() - set(firebase_analytics_editor_eap_src "") -endif() - -set(firebase_analytics_editor_src - src/Empty.cs - ${firebase_analytics_editor_eap_src} -) - -mono_add_library(firebase_analytics_editor_cs - MODULE - Firebase.Analytics.Editor - SOURCES - ${firebase_analytics_editor_src} - REFERENCES - unity_editor_cs - unity_engine_cs - XBUILD_EXE - ${XBUILD_EXE} -) - -unity_pack_cs(firebase_analytics_editor_cs - PACK_PATH "Firebase/Editor/" -) diff --git a/editor/analytics/src/Empty.cs b/editor/analytics/src/Empty.cs deleted file mode 100644 index 2f9a3ab69..000000000 --- a/editor/analytics/src/Empty.cs +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Fixes build issue for non eap builds with no files -// Remove once Config UI is no longer in EAP diff --git a/editor/analytics/src/eap/AnalyticsConfig.cs b/editor/analytics/src/eap/AnalyticsConfig.cs deleted file mode 100644 index 925383b49..000000000 --- a/editor/analytics/src/eap/AnalyticsConfig.cs +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permanentlyissions and - * limitations under the License. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using UnityEditor.iOS.Xcode; -using Firebase.Editor; - -namespace Firebase.Analytics.Editor { - - internal class AndroidAnalyticsConfig : ScriptableObject { - // Should you want to manually configure this plugin settings and not - // generate an AndroidManifest.xml set this to false. - public bool autoConfigure; - - // Should you wish to disable collection of the Advertising ID in your - // Android app set this to true - public bool disableAndroidADID; - - // Should you wish to disable collection of Android Secure ID set this to - // true - public bool disableAndroidSSAID; - - internal static readonly string temporaryDisableKey = - "firebase_analytics_collection_enabled"; - internal static readonly string permanentlyDisableKey = - "firebase_analytics_collection_deactivated"; - internal static readonly string personalAdsKey = - "google_analytics_default_allow_ad_personalization_signals"; - internal static readonly string adidCollectionKey = - "google_analytics_adid_collection_enabled"; - internal static readonly string ssaidCollectionKey = - "google_analytics_ssaid_collection_enabled"; - } - - internal class IOSAnalyticsConfig : ScriptableObject { - // Should you want to manually configure this plugin settings and not - // configure XCode project automatically set this to false. - public bool autoConfigure; - - // Should you wish to disable collection of the Advertising ID in your iOS - // app set this to true - public bool permanentlyDisableAppleIDFA; - - // Should you wish to disable collection of the Vendor ID in your iOS app - // set this to true - public bool permanentlyDisableAppleIDFV; - - internal static readonly string temporaryDisableKey = - "FIREBASE_ANALYTICS_COLLECTION_ENABLED"; - internal static readonly string permanentlyDisableKey = - "FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED"; - internal static readonly string personalAdsKey = - "GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS"; - internal static readonly string idfvCollectionKey = - "GOOGLE_ANALYTICS_IDFV_COLLECTION_ENABLED"; - } - - /// - /// Unity asset that represents configuration required for Firebase Analytics - /// - [ConfigAsset("analytics")] - internal class AnalyticsConfig : ScriptableObject { - // Should you want to get end user consent before collectiong data you can - // set this value to true. If you want to re-enable call - // FirebaseAnalytics.SetAnalyticsCollectionEnabled(true); - public bool temporaryDisableCollection; - - // Should you want to never enable analytics in this application, set this - // to true - public bool permanentlyDisableCollection; - - // Should you want to indicate that a users analytics should not be used for - // personalized advertising set this to true. If you want to re-enable call - // FirebaseAnalytics.SetUserProperty("allow_personalized_ads", "true"); - public bool temporaryDisablePersonalizedAdvert; - - // Android configuration - public AndroidAnalyticsConfig android = new AndroidAnalyticsConfig(); - - // iOS configuration - public IOSAnalyticsConfig iOS = new IOSAnalyticsConfig(); - - /// - /// Setup config on first use in a Unity Editor Project - /// - public void Initialize() { - android.autoConfigure = true; - iOS.autoConfigure = true; - } - } - - /// - /// Class handles all utility functions for config including rendering UI and - /// modifing build projects. - /// - [InitializeOnLoad] - internal class AnalyticsConfigUtil { - /// - /// Gets called on first load and registers callbacks for UI and project - /// modification. - /// - static AnalyticsConfigUtil() { - // Common settings tab ui - ConfigWindow.RegisterTab( - "Analytics", "fb_analytics", - delegate(AnalyticsConfig config) { OnGUI(config); }); - - ConfigWindow.RegisterSubTab( - "Analytics", "Analytics - iOS", - delegate(AnalyticsConfig config) { OnGUIiOS(config); }); - - ConfigWindow.RegisterSubTab( - "Analytics", "Analytics - Android", - delegate(AnalyticsConfig config) { OnGUIAndroid(config); }); - - AndroidManifestModifier.RegisterDelegate( - delegate(AndroidManifestModifier info, AnalyticsConfig config) { - OnAndroidPreGen(info, config); - }); - - XcodeProjectModifier.RegisterDelegate( - delegate(XcodeProjectModifier info, AnalyticsConfig config) { - OnXCodePostGen(info, config); - }); - } - - /// - /// Options to show on UI about the three states analytics can be configured - /// to run in. - /// - static readonly string[] options = new string[]{ - Strings.OptionEnabled, - Strings.OptionTemporaryDisabled, - Strings.OptionPermanetlyDisabled, - }; - - /// - /// Callback to render common tab page - /// - /// Analytics config - internal static void OnGUI(AnalyticsConfig config) { - string selected = Strings.OptionEnabled; - - if (config.permanentlyDisableCollection == true) { - selected = Strings.OptionPermanetlyDisabled; - } else if (config.temporaryDisableCollection == true) { - selected = Strings.OptionTemporaryDisabled; - } - - selected = FirebaseGUILayout.Popup(Strings.AnalyticsCollection, selected, - options); - - if (selected == Strings.OptionTemporaryDisabled) { - config.permanentlyDisableCollection = false; - config.temporaryDisableCollection = true; - } else if (selected == Strings.OptionPermanetlyDisabled) { - config.permanentlyDisableCollection = true; - config.temporaryDisableCollection = false; - } else // (selected == Strings.OptionEnabled) - { - config.permanentlyDisableCollection = false; - config.temporaryDisableCollection = false; - } - - SerializedObject so = new SerializedObject(config); - - FirebaseGUILayout.PropertyField(so, "temporaryDisablePersonalizedAdvert", - Strings.DisablePersonalAds, - Strings.DisablePersonalAdsDescription); - - so.ApplyModifiedProperties(); - } - - /// - /// Callback to render iOS sub tab page - /// - /// Messaging config - internal static void OnGUIiOS(AnalyticsConfig config) { - SerializedObject so = new SerializedObject(config.iOS); - - FirebaseGUILayout.PropertyField(so, "autoConfigure", - Strings.AutoConfigureIOS, - Strings.AutoConfigureIOSDescription); - - FirebaseGUILayout.PropertyField( - so, "permanentlyDisableAppleIDFA", - Strings.PermanentlyDisableAppleIDFA, - Strings.PermanentlyDisableAppleIDFADescription); - - FirebaseGUILayout.PropertyField( - so, "permanentlyDisableAppleIDFV", - Strings.PermanentlyDisableAppleIDFV, - Strings.PermanentlyDisableAppleIDFVDescription); - - so.ApplyModifiedProperties(); - } - - /// - /// Callback to render Android sub tab page - /// - /// Messaging config - internal static void OnGUIAndroid(AnalyticsConfig config) { - SerializedObject so = new SerializedObject(config.android); - - FirebaseGUILayout.PropertyField(so, "autoConfigure", - Strings.AutoConfigureAndroid, - Strings.AutoConfigureAndroidDescription); - - FirebaseGUILayout.PropertyField( - so, "disableAndroidADID", Strings.PermanentlyDisableAndroidADID, - Strings.PermanentlyDisableAndroidADIDDescription); - - FirebaseGUILayout.PropertyField( - so, "disableAndroidSSAID", Strings.PermanentlyDisableAndroidSSAID, - Strings.PermanentlyDisableAndroidSSAIDDescription); - - so.ApplyModifiedProperties(); - } - - /// - /// Callback to setup android manifest file - /// - /// Android manifest info - /// Analytics config - internal static void OnAndroidPreGen(AndroidManifestModifier info, - AnalyticsConfig config) { - if (config.android.autoConfigure == false) { - return; - } - - info.SetMetaDataValue(AndroidAnalyticsConfig.temporaryDisableKey, - config.temporaryDisableCollection == false); - info.SetMetaDataValue(AndroidAnalyticsConfig.permanentlyDisableKey, - config.permanentlyDisableCollection == false); - info.SetMetaDataValue(AndroidAnalyticsConfig.personalAdsKey, - config.temporaryDisablePersonalizedAdvert == false); - - info.SetMetaDataValue(AndroidAnalyticsConfig.adidCollectionKey, - config.android.disableAndroidADID == false); - info.SetMetaDataValue(AndroidAnalyticsConfig.ssaidCollectionKey, - config.android.disableAndroidSSAID == false); - } - - /// - /// Callback to setup Xcode project settings - /// - /// Xcode project info - /// Analytics config - internal static void OnXCodePostGen(XcodeProjectModifier info, - AnalyticsConfig config) { - if (config.iOS.autoConfigure == false) { - return; - } - - var projectInfo = (PlistElementDict)info.ProjectInfo; - projectInfo.SetBoolean(IOSAnalyticsConfig.temporaryDisableKey, - config.temporaryDisableCollection == false); - projectInfo.SetBoolean(IOSAnalyticsConfig.permanentlyDisableKey, - config.permanentlyDisableCollection); - projectInfo.SetBoolean( - IOSAnalyticsConfig.personalAdsKey, - config.temporaryDisablePersonalizedAdvert == false); - - projectInfo.SetBoolean( - IOSAnalyticsConfig.idfvCollectionKey, - config.iOS.permanentlyDisableAppleIDFV == false); - - if (config.iOS.permanentlyDisableAppleIDFA == true) { - ((PBXProject)info.Project).RemoveFrameworkFromProject(info.TargetGUID, - "AdSupport.framework"); - } - } - } -} diff --git a/editor/analytics/src/eap/Strings.Designer.cs b/editor/analytics/src/eap/Strings.Designer.cs deleted file mode 100644 index 2da80115a..000000000 --- a/editor/analytics/src/eap/Strings.Designer.cs +++ /dev/null @@ -1,225 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Firebase.Analytics.Editor { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Firebase.Analytics.Editor.Strings", typeof(Strings).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Analytics Collection. - /// - internal static string AnalyticsCollection { - get { - return ResourceManager.GetString("AnalyticsCollection", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Auto Configure Android. - /// - internal static string AutoConfigureAndroid { - get { - return ResourceManager.GetString("AutoConfigureAndroid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Allow Firebase Analytics to auto configure required Android settings.. - /// - internal static string AutoConfigureAndroidDescription { - get { - return ResourceManager.GetString("AutoConfigureAndroidDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Auto Configure XCode. - /// - internal static string AutoConfigureIOS { - get { - return ResourceManager.GetString("AutoConfigureIOS", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Allow Firebase Analytics to auto configure required iOS XCode settings.. - /// - internal static string AutoConfigureIOSDescription { - get { - return ResourceManager.GetString("AutoConfigureIOSDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable Personal Ads. - /// - internal static string DisablePersonalAds { - get { - return ResourceManager.GetString("DisablePersonalAds", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable using user's future Analytics data for personalized advertising.. - /// - internal static string DisablePersonalAdsDescription { - get { - return ResourceManager.GetString("DisablePersonalAdsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enabled. - /// - internal static string OptionEnabled { - get { - return ResourceManager.GetString("OptionEnabled", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Permanently Disabled. - /// - internal static string OptionPermanetlyDisabled { - get { - return ResourceManager.GetString("OptionPermanetlyDisabled", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Temporary Disabled. - /// - internal static string OptionTemporaryDisabled { - get { - return ResourceManager.GetString("OptionTemporaryDisabled", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable Advert Id. - /// - internal static string PermanentlyDisableAndroidADID { - get { - return ResourceManager.GetString("PermanentlyDisableAndroidADID", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable collection of ADID (Advertising Identifier).. - /// - internal static string PermanentlyDisableAndroidADIDDescription { - get { - return ResourceManager.GetString("PermanentlyDisableAndroidADIDDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable Vendor Id. - /// - internal static string PermanentlyDisableAndroidSSAID { - get { - return ResourceManager.GetString("PermanentlyDisableAndroidSSAID", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable collection of SSAID (Secure Android Identifier).. - /// - internal static string PermanentlyDisableAndroidSSAIDDescription { - get { - return ResourceManager.GetString("PermanentlyDisableAndroidSSAIDDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable Advert Id. - /// - internal static string PermanentlyDisableAppleIDFA { - get { - return ResourceManager.GetString("PermanentlyDisableAppleIDFA", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable collection of IDFA (Advertising Identifier).. - /// - internal static string PermanentlyDisableAppleIDFADescription { - get { - return ResourceManager.GetString("PermanentlyDisableAppleIDFADescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable Vendor Id. - /// - internal static string PermanentlyDisableAppleIDFV { - get { - return ResourceManager.GetString("PermanentlyDisableAppleIDFV", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable collection of IDFV (Identifier for Vendor).. - /// - internal static string PermanentlyDisableAppleIDFVDescription { - get { - return ResourceManager.GetString("PermanentlyDisableAppleIDFVDescription", resourceCulture); - } - } - } -} diff --git a/editor/analytics/src/eap/Strings.resx b/editor/analytics/src/eap/Strings.resx deleted file mode 100644 index 69af4c697..000000000 --- a/editor/analytics/src/eap/Strings.resx +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Analytics Collection - - - Auto Configure Android - - - Allow Firebase Analytics to auto configure required Android settings. - - - Auto Configure XCode - - - Allow Firebase Analytics to auto configure required iOS XCode settings. - - - Disable Personal Ads - - - Disable using user's future Analytics data for personalized advertising. - - - Enabled - - - Permanently Disabled - - - Temporary Disabled - - - Disable Advert Id - - - Disable collection of ADID (Advertising Identifier). - - - Disable Vendor Id - - - Disable collection of SSAID (Secure Android Identifier). - - - Disable Advert Id - - - Disable collection of IDFA (Advertising Identifier). - - - Disable Vendor Id - - - Disable collection of IDFV (Identifier for Vendor). - - \ No newline at end of file diff --git a/editor/app/CMakeLists.txt b/editor/app/CMakeLists.txt index 56fd2dd86..42b159f7d 100644 --- a/editor/app/CMakeLists.txt +++ b/editor/app/CMakeLists.txt @@ -14,15 +14,6 @@ # CMake file for the firebase app unity editor plugin -if(FIREBASE_UNITY_EAP) - set(firebase_app_editor_eap_src - src/eap/ConfigApi.cs - src/eap/ConfigWindow.cs - ) -else() - set(firebase_app_editor_eap_src "") -endif() - set(firebase_app_editor_src src/AnalyticsFixPropertyRemover.cs src/AndroidAPILevelChecker.cs @@ -48,7 +39,6 @@ set(firebase_app_editor_src src/DocRef.resx src/Link.Designer.cs src/Link.resx - ${firebase_app_editor_eap_src} ) set(firebase_app_editor_reference diff --git a/editor/app/src/eap/ConfigApi.cs b/editor/app/src/eap/ConfigApi.cs deleted file mode 100644 index 381908d1d..000000000 --- a/editor/app/src/eap/ConfigApi.cs +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Xml; -using UnityEditor; -using UnityEngine; - -namespace Firebase.Editor { - - -/// -/// Marks a class as being a Firebase Editor config asset for loading and saving. -/// -/// Note: Class must inherit from ScriptableObject -/// -[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)] -internal class ConfigAssetAttribute : Attribute { - internal readonly string configAssetName; - - internal ConfigAssetAttribute(string configAssetName) { - this.configAssetName = configAssetName; - } -} - -// This class is an Api that can be used to pragmatically configure Firebase extensions for Unity. -internal static class ConfigApi { - - // Token asset to find to work out default place to save configuration assets. - static readonly string tokenAssestGuid = ""; // TODO(markchandler) update to actual asset guid - - // Default location to save settings assets too if the token asset can't be found. - static readonly string defaultAssetPath = "Assets/Resources/Editor/Firebase"; - - // Logger - static readonly CategoryLogger logger = new CategoryLogger("ConfigApi"); - - /// - /// Checks if a Firebase Config object has a saved asset file - /// - /// Type of config object to load. i.e. - /// AnalyticsConfig - /// bool if there exists an asset file - internal static bool HasConfigAsset(Type configType) { - if (IsValidAssetType(configType) == false) { - return false; - } - - var assetPath = GetAssetPathFromAttribute(configType); - - if (String.IsNullOrEmpty(assetPath) == true) { - return false; - } - - var validPath = - String.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(assetPath)) == false; - - return validPath == true && File.Exists(assetPath) == true; - } - - /// - /// Find and load values for a Firebase Editor config object - /// - /// - /// Type of config object to load. i.e. AnalyticsConfig - /// - /// - /// Null if configType is not a ScriptableObject and doesnt contain - /// TabConfig attribute else config object - /// - internal static ScriptableObject LoadConfigAsset(Type configType) { - if (IsValidAssetType(configType) == false) { - return null; - } - - var assetPath = GetAssetPathFromAttribute(configType); - - if (String.IsNullOrEmpty(assetPath) == true) { - return null; - } - - var raw = AssetDatabase.LoadAssetAtPath(assetPath, configType) as ScriptableObject; - - if (raw == null) { - logger.LogDebug("Failed to load asset at path {0}. Creating new asset.", assetPath); - CreateAllAssetFolders(Path.GetDirectoryName(assetPath)); - raw = ScriptableObject.CreateInstance(configType); - AssetDatabase.CreateAsset(raw, assetPath); - } - - return raw; - } - - /// - /// Saves an existing Firebase Config object - /// - /// Config object that has been loaded using LoadConfig - internal static void SaveConfigAsset(ScriptableObject config) { - EditorUtility.SetDirty(config); - } - - /// - /// Apply defaults to config object if marked with the InitialValue attribute - /// - /// Firebase Editor config object - internal static void ApplyDefaults(ScriptableObject config) { - var applyMethod = config.GetType().GetMethod("ApplyDefaults"); - - if (applyMethod != null) { - applyMethod.Invoke(config, null); - } - } - - // Is the type a valid type that can be used for config assets - private static bool IsValidAssetType(Type configType) { - // Check if it inheirts from ScriptableObject - if (typeof(ScriptableObject).IsAssignableFrom(configType) == false) { - logger.LogError("Object of type '{0}' is not a valid asset type as it does not inherit from ScriptableObject. " + - "This type is not usable with Firebase Editor Config Api. " + - "Please ensure '{0}' inheirts from ScriptableObject.", - configType.FullName); - return false; - } - - return true; - } - - // Get the asset path for a config object type based on the ConfigAsset attribute - private static string GetAssetPathFromAttribute(Type configType) { - var config = Utility.GetAttribute(configType); - - if (config == null || String.IsNullOrEmpty(config.configAssetName) == true) { - logger.LogError("Object of type '{0}' is missing ConfigAsset attribute with a valid value. " + - "This type is not usable with Firebase Editor Config Api. " + - "Please ensure '{0}' has a TabConfig attribute describing the name its config asset.", - configType.FullName); - return null; - } - - var tokenPath = AssetDatabase.GUIDToAssetPath(tokenAssestGuid); - - if (String.IsNullOrEmpty(tokenPath) == false) { - return Path.Combine(Path.GetDirectoryName(tokenPath), config.configAssetName + ".asset"); - } - - return Path.Combine(defaultAssetPath, config.configAssetName + ".asset"); - } - - // Create all the required folders for saving the asset at path - private static void CreateAllAssetFolders(string relativeFolderPath) { - string projectDir = Path.Combine(Application.dataPath, ".."); - string outputDir = Path.Combine(projectDir, relativeFolderPath); - if (!Directory.Exists(outputDir)) { - try { - Directory.CreateDirectory(outputDir); - } catch (Exception e) { - Debug.LogError( - String.Format("Unable to create folders for config asset at {0}", outputDir)); - Debug.LogException(e); - return; - } - } - } -} -} diff --git a/editor/app/src/eap/ConfigWindow.cs b/editor/app/src/eap/ConfigWindow.cs deleted file mode 100644 index a847419ed..000000000 --- a/editor/app/src/eap/ConfigWindow.cs +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEditor; -using UnityEditor.AnimatedValues; -using UnityEditor.Callbacks; -using UnityEngine; -using UnityEngine.Events; - -namespace Firebase.Editor { - -// This class is the outer window for all the tab pages used to configure Firebase extensions. -// It handles finding the classes, creating instances, drawing the ui and loading/saving the config. -internal class ConfigWindow : EditorWindow { - - private static CategoryLogger logger = new CategoryLogger("ConfigWindow"); - - // Redraw event - private static UnityAction onRepaint; - - // Tab icon look up by tab name - private static Dictionary tabIconNames = new Dictionary(); - - // Icons look up by icon name - private static Dictionary icons = new Dictionary(); - - // Tab Gui callbacks keyed by sub tab name - private static Dictionary>> guiCallbacks = - new Dictionary>>(); - - // Config objects instances look up by type - private static Dictionary configObjects = - new Dictionary(); - - private static readonly int minWindowWidth = 250; - private static readonly int iconOnlyListWidth = 40; - private static readonly int iconTextListWidth = 150; - private static readonly int widthDeadzone = 50; - - private GUIMenuSelector selector = new GUIMenuSelector(minWindowWidth, iconOnlyListWidth, - iconTextListWidth, widthDeadzone); - - // Keeps track of the scroll position for the menu segment - private Vector2 menuScrollPos = new Vector2(); - - // Keeps track of the scroll position for the tab segment - private Vector2 tabScrollPos = new Vector2(); - - // Name of the currently selected tab - private string selectedTab; - - // Theme used to render tab pages and sub segments - private IGUITheme theme; - - // TODO: Hide configuration windows until this feature is ready. -#if false - [MenuItem("Window/Firebase/Configuration")] - private static void Init() { - GetWindow("Firebase Configuration"); - } -#endif - - /// - /// Registers a new tab to display in the configuration window. - /// - /// Tab display name - /// Icon name in the editor/firebase folder (no ext) - /// Callback that is invoked when the tab needs to show UI - internal static void RegisterTab(string tabName, string icon, Action onGuiCallback = null) - where T : ScriptableObject { - logger.LogDebug("Registering tab with name {0} and icon {1} with type {2}.", - tabName, icon, typeof(T).FullName); - - if (tabIconNames.ContainsKey(tabName) == true) { - logger.LogWarn("RegisterTab was called twice with the same tab name '{0}'. " - + "Skipping registration. Please ensure that RegisterTab is only called once " - + "per unique tab name.", tabName); - } - else { - tabIconNames.Add(tabName, icon); - } - - if (onGuiCallback != null) { - RegisterSubTab(tabName, "", onGuiCallback); - } - } - - /// - /// Registers a new sub tab to display within a main tab in the configuration window. - /// - /// Tab display name - /// Sub tab display name - /// Callback that is invoked when the tab needs to show UI - internal static void RegisterSubTab(string tabName, string subTabName, Action onGuiCallback) - where T : ScriptableObject { - logger.LogDebug("Registering sub tab with name {0} on tab {1} with type {2}.", - subTabName, tabName, typeof(T).FullName); - - Dictionary> callbacks = null; - - if (guiCallbacks.TryGetValue(tabName, out callbacks) == false) { - callbacks = new Dictionary>(); - guiCallbacks.Add(tabName, callbacks); - } - - if (callbacks.ContainsKey(subTabName) == true) { - logger.LogWarn("RegisterSubTab was called twice with the same sub tab name '{0}' and tab name" - + " '{1}'. Skipping registration. Please ensure that RegisterSubTab is only" - + " called once per unique sub tab name.", subTabName, tabName); - return; - } - - var abool = new AnimBool(true); - abool.valueChanged.AddListener(onRepaint); - - callbacks.Add(subTabName, delegate(IGUITheme theme){ - FirebaseGUILayout.SubTab(theme, subTabName, abool, delegate() { - var obj = GetConfigObject(); - onGuiCallback(obj); - }); - }); - } - - // Gets a existing config object of type T or creates a new one and loads the config for it - // before returning - private static T GetConfigObject() where T : ScriptableObject { - var type = typeof(T); - ScriptableObject obj = null; - - if (configObjects.TryGetValue(type, out obj) == false) { - obj = ConfigApi.LoadConfigAsset(type); - configObjects.Add(type, obj); - } - - return obj as T; - } - - // Unity Editor calls this when the window is shown for the first time. - // Load the theme and setup any thing required for rendering the GUI - private void OnEnable() { - if (EditorGUIUtility.isProSkin == true) { - theme = new GUIDarkTheme(); - } else { - theme = new GUILightTheme(); - } - - // Clear icons as theme might of changed - icons.Clear(); - - // Load icons for each tab - foreach (var icon in tabIconNames) { - icons.Add(icon.Key, theme.LoadImage(icon.Value)); - } - - // Add a null icon for all tab - icons.Add("All", null); - - // Reset config objects - configObjects.Clear(); - - // Reset current tab - selectedTab = null; - - // Reset scroll pos - tabScrollPos = new Vector2(); - - // Add the all tab - if (guiCallbacks.ContainsKey("All") == false) { - guiCallbacks.Add("All", null); - } - - onRepaint += base.Repaint; - } - - // Unity Editor calls when GUI needs to be drawn - private void OnGUI() { - Action cleanup = null; - - var keyList = guiCallbacks.Keys.ToList(); - keyList.Sort(); - - if (string.IsNullOrEmpty(selectedTab) || - keyList.Contains(selectedTab) == false) { - selectedTab = keyList.First(); - } - - var index = keyList.FindIndex(a => a == selectedTab); - - var buttons = - keyList.Select(a => new GUIContent(" " + a, icons[a])) - .ToArray(); - - var menuOption = selector.GetMenuOption(position.width); - - if (menuOption == GUIMenuSelector.MenuOption.LeftFull) { - EditorGUILayout.BeginHorizontal(); - index = FirebaseGUILayout.IconMenu(buttons, index, iconTextListWidth, theme, - ref menuScrollPos); - - cleanup = delegate() { EditorGUILayout.EndHorizontal(); }; - } else if (menuOption == GUIMenuSelector.MenuOption.LeftIcon) { - Func getImageButton = - delegate(GUIContent content) { - if (content.image != null) { - return new GUIContent("", content.image, content.text); - } - - return content; - }; - - var imageButtons = buttons.Select(a => getImageButton(a)).ToArray(); - - EditorGUILayout.BeginHorizontal(); - index = FirebaseGUILayout.IconMenu(imageButtons, index, iconOnlyListWidth, - theme, ref menuScrollPos); - - cleanup = delegate() { EditorGUILayout.EndHorizontal(); }; - } else { - index = FirebaseGUILayout.ComboMenu(buttons, index); - } - - if (selectedTab != keyList[index]) { - selectedTab = keyList[index]; - tabScrollPos = new Vector2(); - } - - var style = new GUIStyle("scrollview"); - style.padding.bottom = 10; - - EditorGUILayout.BeginVertical(); - tabScrollPos = EditorGUILayout.BeginScrollView(tabScrollPos, style); - - if (selectedTab == "All") { - foreach (var key in keyList) { - if (key == "All") { - continue; - } - - foreach (var cb in guiCallbacks[key]) { - cb.Value(theme); - } - } - } - else { - foreach (var cb in guiCallbacks[selectedTab]) { - cb.Value(theme); - } - } - - EditorGUILayout.EndScrollView(); - - var horzStyle = new GUIStyle("scrollview"); - horzStyle.padding.bottom = 5; - - EditorGUILayout.BeginHorizontal(horzStyle); - EditorGUILayout.Space(); - - if (GUILayout.Button("Save") == true) { - Save(); - } - - EditorGUILayout.EndHorizontal(); - EditorGUILayout.EndVertical(); - - if (cleanup != null) { - cleanup(); - } - } - - // Unity Editor calls this when the window is being destoryed - private void OnDestroy() { - Save(); - onRepaint -= base.Repaint; - } - - // Save out the configuration - internal void Save() { - foreach (var obj in configObjects) { - ConfigApi.SaveConfigAsset(obj.Value); - } - } -} - -} diff --git a/editor/auth/CMakeLists.txt b/editor/auth/CMakeLists.txt deleted file mode 100644 index b353c3f50..000000000 --- a/editor/auth/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2019 Google -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# CMake file for the firebase auth unity editor plugin - -if(FIREBASE_UNITY_EAP) - set(firebase_auth_editor_eap_src - src/eap/AuthConfig.cs - src/eap/Strings.Designer.cs - src/eap/Strings.resx - ) -else() - set(firebase_auth_editor_eap_src "") -endif() - -set(firebase_auth_editor_src - src/Empty.cs - ${firebase_auth_editor_eap_src} -) - -mono_add_library(firebase_auth_editor_cs - MODULE - Firebase.Auth.Editor - SOURCES - ${firebase_auth_editor_src} - REFERENCES - unity_editor_cs - unity_engine_cs - XBUILD_EXE - ${XBUILD_EXE} -) - -unity_pack_cs(firebase_auth_editor_cs - PACK_PATH "Firebase/Editor/" -) diff --git a/editor/auth/src/Empty.cs b/editor/auth/src/Empty.cs deleted file mode 100644 index 2f9a3ab69..000000000 --- a/editor/auth/src/Empty.cs +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Fixes build issue for non eap builds with no files -// Remove once Config UI is no longer in EAP diff --git a/editor/auth/src/eap/AuthConfig.cs b/editor/auth/src/eap/AuthConfig.cs deleted file mode 100644 index 1bd2025dc..000000000 --- a/editor/auth/src/eap/AuthConfig.cs +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Linq; -using System.Collections.Generic; -using UnityEditor; -using UnityEditor.iOS.Xcode; -using UnityEngine; -using Firebase.Editor; - -namespace Firebase.Auth.Editor { - /// - /// Unity asset that represents configuration required for Firebase - /// Authentication - /// - [ConfigAsset("authentication")] - internal class AuthConfig : ScriptableObject { - /// - /// Should Xcode projects be auto configured for dynamic links - /// - public bool autoConfigureXCode; - - /// - /// Setup config on first use in a Unity Editor Project - /// - public void Initialize() { autoConfigureXCode = true; } - } - - /// - /// Class handles all utility functions for config including rendering UI and - /// modifing build projects. - /// - [InitializeOnLoad] - internal class AuthConfigUtil { - /// - /// Gets called on first load and registers callbacks for UI and project - /// modification. - /// - static AuthConfigUtil() { - // Common settings tab ui - ConfigWindow.RegisterTab("Authentication", "fb_auth"); - - ConfigWindow.RegisterSubTab( - "Authentication", "Authentication - iOS", - delegate(AuthConfig config) { OnGUIiOS(config); }); - - XcodeProjectModifier.RegisterDelegate( - delegate(XcodeProjectModifier info, AuthConfig config) { - OnXCodePostGen(info, config); - }); - } - - /// - /// Callback to render iOS sub tab page - /// - /// Authentication config - private static void OnGUIiOS(AuthConfig config) { - SerializedObject so = new SerializedObject(config); - - FirebaseGUILayout.PropertyField(so, "autoConfigureXCode", - Strings.AutoConfigureIOS, - Strings.AutoConfigureIOSDescription); - - so.ApplyModifiedProperties(); - } - - static readonly string pushNotificationKey = "aps-environment"; - static readonly string pushNotificationValue = "production"; - - /// - /// Callback to setup Xcode project settings - /// - /// Xcode project info - /// Authentication config - private static void OnXCodePostGen(XcodeProjectModifier info, - AuthConfig config) { - if (config.autoConfigureXCode == false) { - return; - } - - ((PBXProject)info.Project).AddFrameworkToProject(info.TargetGUID, - "UserNotifications.framework", false); - - try { - ((PlistElementDict)info.Capabilities).SetString(pushNotificationKey, pushNotificationValue); - } catch (Exception e) { - Debug.Log("Failed to set push notifications for XCode [" + - e.ToString() + "]"); - } - } - } -} diff --git a/editor/auth/src/eap/Strings.Designer.cs b/editor/auth/src/eap/Strings.Designer.cs deleted file mode 100644 index 7da3f4cf8..000000000 --- a/editor/auth/src/eap/Strings.Designer.cs +++ /dev/null @@ -1,81 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Firebase.Auth.Editor { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Firebase.Auth.Editor.Strings", typeof(Strings).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Auto Configure Xcode for iOS. - /// - internal static string AutoConfigureIOS { - get { - return ResourceManager.GetString("AutoConfigureIOS", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Allow Firebase Authentication to auto configure required iOS XCode settings.. - /// - internal static string AutoConfigureIOSDescription { - get { - return ResourceManager.GetString("AutoConfigureIOSDescription", resourceCulture); - } - } - } -} diff --git a/editor/auth/src/eap/Strings.resx b/editor/auth/src/eap/Strings.resx deleted file mode 100644 index 18e71a992..000000000 --- a/editor/auth/src/eap/Strings.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Auto Configure Xcode for iOS - - - Allow Firebase Authentication to auto configure required iOS XCode settings. - - \ No newline at end of file diff --git a/editor/dynamic_links/CMakeLists.txt b/editor/dynamic_links/CMakeLists.txt deleted file mode 100644 index b2a1f4a9c..000000000 --- a/editor/dynamic_links/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2019 Google -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# CMake file for the firebase dynamic links unity editor plugin - -if(FIREBASE_UNITY_EAP) - set(firebase_dynamic_links_editor_eap_src - src/eap/DynamicLinksConfig.cs - src/eap/Strings.Designer.cs - src/eap/Strings.resx - ) -else() - set(firebase_dynamic_links_editor_eap_src "") -endif() - -set(firebase_dynamic_links_editor_src - src/Empty.cs - ${firebase_dynamic_links_editor_eap_src} -) - -mono_add_library(firebase_dynamic_links_editor_cs - MODULE - Firebase.DynamicLinks.Editor - SOURCES - ${firebase_dynamic_links_editor_src} - REFERENCES - unity_editor_cs - unity_engine_cs - XBUILD_EXE - ${XBUILD_EXE} -) - -unity_pack_cs(firebase_dynamic_links_editor_cs - PACK_PATH "Firebase/Editor/" -) diff --git a/editor/dynamic_links/src/Empty.cs b/editor/dynamic_links/src/Empty.cs deleted file mode 100644 index 2f9a3ab69..000000000 --- a/editor/dynamic_links/src/Empty.cs +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Fixes build issue for non eap builds with no files -// Remove once Config UI is no longer in EAP diff --git a/editor/dynamic_links/src/eap/DynamicLinksConfig.cs b/editor/dynamic_links/src/eap/DynamicLinksConfig.cs deleted file mode 100644 index 7d2e7570c..000000000 --- a/editor/dynamic_links/src/eap/DynamicLinksConfig.cs +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using UnityEditor.iOS.Xcode; -using GooglePlayServices; -using Firebase.Editor; - -namespace Firebase.DynamicLinks.Editor { - /// - /// Unity asset that represents configuration required for Firebase Dynamic - /// Links - /// - [ConfigAsset("dynamic_links")] - internal class DynamicLinksConfig : ScriptableObject { - /// - /// Should Xcode projects be auto configured for dynamic links - /// - public bool autoConfigureXCode; - - /// - /// List of keychain access groups for dynamic links - /// - public string[] keychainAccessGroups; - - // Disable the warning about unused fields as this is set via reflection. - #pragma warning disable 649 - /// - /// List of associated domains for dynamic links. - /// - public string[] associatedDomains; - #pragma warning restore 649 - - /// - /// Setup config on first use in a Unity Editor Project - /// - public void Initialize() { - autoConfigureXCode = true; - keychainAccessGroups = - new string[]{"$(AppIdentifierPrefix)" + - UnityCompat.GetApplicationId(BuildTarget.iOS)}; - } - } - - /// - /// Class handles all utility functions for config including rendering UI and - /// modifing build projects. - /// - [InitializeOnLoad] - internal class DynamicLinksConfigUtil { - /// - /// Gets called on first load and registers callbacks for UI and project - /// modification. - /// - static DynamicLinksConfigUtil() { - ConfigWindow.RegisterTab("Dynamic Links", - "fb_dynamic_links"); - - ConfigWindow.RegisterSubTab( - "Dynamic Links", "Dynamic Links - iOS", - delegate(DynamicLinksConfig config) { OnGUIiOS(config); }); - - XcodeProjectModifier.RegisterDelegate( - delegate(XcodeProjectModifier info, DynamicLinksConfig config) { - OnXCodePostGen(info, config); - }); - } - - /// - /// Callback to render iOS sub tab page - /// - /// Dynamic LInks config - private static void OnGUIiOS(DynamicLinksConfig config) { - SerializedObject so = new SerializedObject(config); - - FirebaseGUILayout.PropertyField(so, "autoConfigureXCode", - Strings.AutoConfigureIOS, - Strings.AutoConfigureIOSDescription); - - EditorGUILayout.Space(); - - FirebaseGUILayout.PropertyField(so, "keychainAccessGroups", - Strings.KeychainAccessGroups, - Strings.KeychainAccessGroupsDescription); - - EditorGUILayout.Space(); - - FirebaseGUILayout.PropertyField(so, "associatedDomains", - Strings.AssociatedDomains, - Strings.AssociatedDomainsDescription); - - so.ApplyModifiedProperties(); - } - - static readonly string keychainKey = "keychain-access-groups"; - static readonly string associatedDomainsKey = - "com.apple.developer.associated-domains"; - static readonly string associatedDomainsPrefix = "applinks:"; - - /// - /// Callback to setup Xcode project settings - /// - /// Xcode project info - /// Dynamic Links config - private static void OnXCodePostGen(XcodeProjectModifier info, - DynamicLinksConfig config) { - if (config.autoConfigureXCode == false) { - return; - } - - var capabilities = (PlistElementDict)info.Capabilities; - var oldKeyChains = GetStringArray(capabilities, keychainKey); - var oldAssociatedDomains = GetStringArray(capabilities, associatedDomainsKey); - - var keychainAccessGroups = capabilities.CreateArray(keychainKey); - - // Add existing keys chains - foreach (var i in oldKeyChains) { - keychainAccessGroups.AddString(i); - } - - // Add ours that are not in the existing list - foreach (var i in config.keychainAccessGroups) { - if (oldKeyChains.Contains(i) == false) { - keychainAccessGroups.AddString(i); - } - } - - var associatedDomains = capabilities.CreateArray(associatedDomainsKey); - - // Add in our custom values for associated domains - foreach (var i in config.associatedDomains) { - if (i.StartsWith(associatedDomainsPrefix) == false) { - associatedDomains.AddString(associatedDomainsPrefix + i); - } else { - associatedDomains.AddString(i); - } - } - - // Add existing values that are not ours back to the plist - foreach (var i in oldAssociatedDomains) { - if (i.StartsWith(associatedDomainsPrefix) == true) { - continue; - } - - associatedDomains.AddString(i); - } - } - - private static List GetStringArray(object plistElementDict, - string key) { - var dict = (PlistElementDict)plistElementDict; - var ret = new List(); - - try { - foreach (var v in dict [key] - .AsArray() - .values) { - ret.Add(v.AsString()); - } - } catch (Exception) { - } - - return ret; - } - } - -} diff --git a/editor/dynamic_links/src/eap/Strings.Designer.cs b/editor/dynamic_links/src/eap/Strings.Designer.cs deleted file mode 100644 index 4c17ee850..000000000 --- a/editor/dynamic_links/src/eap/Strings.Designer.cs +++ /dev/null @@ -1,117 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Firebase.DynamicLinks.Editor { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Firebase.DynamicLinks.Editor.Strings", typeof(Strings).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Xcode Dynamic Links Domain. - /// - internal static string AssociatedDomains { - get { - return ResourceManager.GetString("AssociatedDomains", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If using custom domains for links, enter the domain URI prefix below. For example: 'xyz.app.goo.gl'. - /// - internal static string AssociatedDomainsDescription { - get { - return ResourceManager.GetString("AssociatedDomainsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Auto Configure Xcode for iOS. - /// - internal static string AutoConfigureIOS { - get { - return ResourceManager.GetString("AutoConfigureIOS", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Allow Firebase Dynamic Links to auto configure required iOS XCode settings.. - /// - internal static string AutoConfigureIOSDescription { - get { - return ResourceManager.GetString("AutoConfigureIOSDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Xcode Keychain Access Groups. - /// - internal static string KeychainAccessGroups { - get { - return ResourceManager.GetString("KeychainAccessGroups", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Keychain Sharing (Access Groups) is required on iOS 10 and above for Google Sign-In to send invites.. - /// - internal static string KeychainAccessGroupsDescription { - get { - return ResourceManager.GetString("KeychainAccessGroupsDescription", resourceCulture); - } - } - } -} diff --git a/editor/dynamic_links/src/eap/Strings.resx b/editor/dynamic_links/src/eap/Strings.resx deleted file mode 100644 index 041d84d1d..000000000 --- a/editor/dynamic_links/src/eap/Strings.resx +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Xcode Dynamic Links Domain - - - If using custom domains for links, enter the domain URI prefix below. For example: 'xyz.app.goo.gl' - - - Auto Configure Xcode for iOS - - - Allow Firebase Dynamic Links to auto configure required iOS XCode settings. - - - Xcode Keychain Access Groups - - - Keychain Sharing (Access Groups) is required on iOS 10 and above for Google Sign-In to send invites. - - \ No newline at end of file diff --git a/editor/messaging/CMakeLists.txt b/editor/messaging/CMakeLists.txt index 918107995..3720c5fe8 100644 --- a/editor/messaging/CMakeLists.txt +++ b/editor/messaging/CMakeLists.txt @@ -14,20 +14,9 @@ # CMake file for the firebase messaging unity editor plugin -if(FIREBASE_UNITY_EAP) - set(firebase_messaging_editor_eap_src - src/eap/MessagingConfig.cs - src/eap/Strings.Designer.cs - src/eap/Strings.resx - ) -else() - set(firebase_messaging_editor_eap_src "") -endif() - set(firebase_messaging_editor_src ../../messaging/activity/AndroidManifest.xml src/AndroidManifestPatcher.cs - ${firebase_messaging_editor_eap_src} ) mono_add_library(firebase_messaging_editor_cs diff --git a/editor/messaging/src/eap/MessagingConfig.cs b/editor/messaging/src/eap/MessagingConfig.cs deleted file mode 100644 index 53852b653..000000000 --- a/editor/messaging/src/eap/MessagingConfig.cs +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Linq; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using UnityEditor.iOS.Xcode; -using Firebase.Editor; - -namespace Firebase.Messaging.Editor { - /// - /// Unity asset that represents configuration required for Firebase Messaging - /// - [ConfigAsset("messaging")] - internal class MessagingConfig : ScriptableObject { - /// - /// Should Xcode projects be auto configured for dynamic links - /// - public bool autoConfigureXCode; - - /// - /// Should XCode projects be auto configured for dynamic links - /// - public bool autoConfigureAndroid; - - /// - /// Disable auto init messaging on android application start - /// - public bool disableAutoInitAndroid; - - /// - /// Display icon for notifications - /// - public Texture2D notificationIcon; - - /// - /// Display color for notifications - /// - public Color notificationColor; - - /// - /// Custom channel id for notifications - /// - public string notificationChannelId; - - /// - /// Setup config on first use in a Unity Editor Project - /// - public void Initialize() { - autoConfigureXCode = true; - autoConfigureAndroid = true; - } - } - - /// - /// Class handles all utility functions for config including rendering UI and - /// modifing build projects. - /// - [InitializeOnLoad] - internal class MessagingConfigUtil { - /// - /// Gets called on first load and registers callbacks for UI and project - /// modification. - /// - static MessagingConfigUtil() { - ConfigWindow.RegisterTab("Messaging", - "fb_cloud_messaging"); - - ConfigWindow.RegisterSubTab( - "Messaging", "Messaging - iOS", - delegate(MessagingConfig config) { OnGUIiOS(config); }); - - ConfigWindow.RegisterSubTab( - "Messaging", "Messaging - Android", - delegate(MessagingConfig config) { OnGUIAndroid(config); }); - - AndroidManifestModifier.RegisterDelegate( - delegate(AndroidManifestModifier info, MessagingConfig config) { - OnAndroidPreGen(info, config); - }); - - XcodeProjectModifier.RegisterDelegate( - delegate(XcodeProjectModifier info, MessagingConfig config) { - OnXCodePostGen(info, config); - }); - } - - /// - /// Callback to render iOS sub tab page - /// - /// Messaging config - private static void OnGUIiOS(MessagingConfig config) { - SerializedObject so = new SerializedObject(config); - - FirebaseGUILayout.PropertyField(so, "autoConfigureXCode", - Strings.AutoConfigureIOS, - Strings.AutoConfigureIOSDescription); - - so.ApplyModifiedProperties(); - } - - /// - /// Callback to render Android sub tab page - /// - /// Messaging config - private static void OnGUIAndroid(MessagingConfig config) { - SerializedObject so = new SerializedObject(config); - - FirebaseGUILayout.PropertyField(so, "autoConfigureAndroid", - Strings.AutoConfigureAndroid, - Strings.AutoConfigureAndroidDescription); - - FirebaseGUILayout.PropertyField(so, "disableAutoInitAndroid", - Strings.DisableAutoId, - Strings.DisableAutoIdDescription); - - FirebaseGUILayout.PropertyField(so, "notificationIcon", - Strings.NotificationIcon, - Strings.NotificationIconDescription); - - FirebaseGUILayout.PropertyField(so, "notificationColor", - Strings.NotificationColor, - Strings.NotificationColorDescription); - - FirebaseGUILayout.PropertyField(so, "notificationChannelId", - Strings.NotificationChannelId, - Strings.NotificationChannelIdDescription); - - so.ApplyModifiedProperties(); - } - - static readonly string autoInitEnabledKey = - "firebase_messaging_auto_init_enabled"; - static readonly string notificationIconKey = - "com.google.firebase.messaging.default_notification_icon"; - static readonly string notificationColorKey = - "com.google.firebase.messaging.default_notification_color"; - static readonly string notificationChannelIdKey = - "com.google.firebase.messaging.default_notification_channel_id"; - - /// - /// Callback to setup android manifest file - /// - /// Android manifest info - /// Messaging config - private static void OnAndroidPreGen(AndroidManifestModifier info, - MessagingConfig config) { - - if (config.autoConfigureAndroid == false) { - return; - } - - info.SetMetaDataValue(autoInitEnabledKey, - config.disableAutoInitAndroid == true); - - if (config.notificationIcon == null) { - info.DeleteMetaData(notificationIconKey); - } else { - info.SetMetaDataResource(notificationIconKey, config.notificationIcon); - } - - if (config.notificationColor == null) { - info.DeleteMetaData(notificationColorKey); - } else { - info.SetMetaDataResource(notificationColorKey, - config.notificationColor); - } - - if (String.IsNullOrEmpty(config.notificationChannelId)) { - info.DeleteMetaData(notificationChannelIdKey); - } else { - info.SetMetaDataValue(notificationChannelIdKey, - config.notificationChannelId); - } - } - - static readonly string backgroundModesKey = "UIBackgroundModes"; - static readonly string remoteNotificationKey = "remote-notification"; - - static readonly string pushNotificationKey = "aps-environment"; - static readonly string pushNotificationValue = "production"; - - /// - /// Callback to setup Xcode project settings - /// - /// Xcode project info - /// Messaging config - private static void OnXCodePostGen(XcodeProjectModifier info, - MessagingConfig config) { - if (config.autoConfigureXCode == false) { - return; - } - - ((PBXProject)info.Project).AddFrameworkToProject( - info.TargetGUID, "UserNotifications.framework", false); - - try { - var array = ((PlistElementDict)info.ProjectInfo)[backgroundModesKey].AsArray(); - - var hasRemoteNotification = - array.values.Where(a => a.ToString() == remoteNotificationKey) - .Count(); - - if (hasRemoteNotification == 0) { - array.AddString(remoteNotificationKey); - } - } catch (Exception e) { - Debug.Log("Failed to set background modes for XCode [" + e.ToString() + - "]"); - - var list = ((PlistElementDict)info.ProjectInfo).CreateArray(backgroundModesKey); - list.AddString(remoteNotificationKey); - } - - try { - ((PlistElementDict)info.Capabilities).SetString(pushNotificationKey, pushNotificationValue); - } catch (Exception e) { - Debug.Log("Failed to set push notifications for XCode [" + - e.ToString() + "]"); - } - } - } - -} diff --git a/editor/messaging/src/eap/Strings.Designer.cs b/editor/messaging/src/eap/Strings.Designer.cs deleted file mode 100644 index 3b5f56909..000000000 --- a/editor/messaging/src/eap/Strings.Designer.cs +++ /dev/null @@ -1,171 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Firebase.Messaging.Editor { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Firebase.Messaging.Editor.Strings", typeof(Strings).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to . - /// - internal static string AutoConfigureAndroid { - get { - return ResourceManager.GetString("AutoConfigureAndroid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to . - /// - internal static string AutoConfigureAndroidDescription { - get { - return ResourceManager.GetString("AutoConfigureAndroidDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Auto Configure Xcode for iOS. - /// - internal static string AutoConfigureIOS { - get { - return ResourceManager.GetString("AutoConfigureIOS", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Allow Firebase Messaging to auto configure required iOS XCode settings.. - /// - internal static string AutoConfigureIOSDescription { - get { - return ResourceManager.GetString("AutoConfigureIOSDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disable Auto Id. - /// - internal static string DisableAutoId { - get { - return ResourceManager.GetString("DisableAutoId", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Disables Instance ID autogeneration for messaging services.. - /// - internal static string DisableAutoIdDescription { - get { - return ResourceManager.GetString("DisableAutoIdDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Notification Channel Id. - /// - internal static string NotificationChannelId { - get { - return ResourceManager.GetString("NotificationChannelId", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set custom channel id for Android notifications. - /// - internal static string NotificationChannelIdDescription { - get { - return ResourceManager.GetString("NotificationChannelIdDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Notification Color. - /// - internal static string NotificationColor { - get { - return ResourceManager.GetString("NotificationColor", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set color used to display Android notifications. - /// - internal static string NotificationColorDescription { - get { - return ResourceManager.GetString("NotificationColorDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Notification Icon. - /// - internal static string NotificationIcon { - get { - return ResourceManager.GetString("NotificationIcon", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set icon used to display Android notifications. - /// - internal static string NotificationIconDescription { - get { - return ResourceManager.GetString("NotificationIconDescription", resourceCulture); - } - } - } -} diff --git a/editor/messaging/src/eap/Strings.resx b/editor/messaging/src/eap/Strings.resx deleted file mode 100644 index bec710977..000000000 --- a/editor/messaging/src/eap/Strings.resx +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - - - - - Auto Configure Xcode for iOS - - - Allow Firebase Messaging to auto configure required iOS XCode settings. - - - Disable Auto Id - - - Disables Instance ID autogeneration for messaging services. - - - Notification Channel Id - - - Set custom channel id for Android notifications - - - Notification Color - - - Set color used to display Android notifications - - - Notification Icon - - - Set icon used to display Android notifications - - \ No newline at end of file