Exemple #1
0
        /// <summary>
        /// Generates the android manifest.
        /// </summary>
        /// <param name="needTokenPermissions">If set to <c>true</c> need token permissions.</param>
        public static void GenerateAndroidManifest(bool needTokenPermissions)
        {
            string destFilename = GPGSUtil.SlashesToPlatformSeparator(
                "Assets/Plugins/Android/MainLibProj/AndroidManifest.xml");

            // Generate AndroidManifest.xml
            string manifestBody = GPGSUtil.ReadEditorTemplate("template-AndroidManifest");

            Dictionary <string, string> overrideValues =
                new Dictionary <string, string>();

            if (!needTokenPermissions)
            {
                overrideValues[TOKENPERMISSIONKEY]     = string.Empty;
                overrideValues[WEBCLIENTIDPLACEHOLDER] = string.Empty;
            }
            else
            {
                overrideValues[TOKENPERMISSIONKEY] = TokenPermissions;
            }

            foreach (KeyValuePair <string, string> ent in replacements)
            {
                string value =
                    GPGSProjectSettings.Instance.Get(ent.Value, overrideValues);
                manifestBody = manifestBody.Replace(ent.Key, value);
            }

            GPGSUtil.WriteFile(destFilename, manifestBody);
            GPGSUtil.UpdateGameInfo();
        }
        /// <summary>
        /// Performs the setup.  This is called externally to facilitate
        /// build automation.
        /// </summary>
        /// <param name="clientId">Client identifier.</param>
        /// <param name="bundleId">Bundle identifier.</param>
        /// <param name="webClientId">web app client id.</param>
        /// <param name="nearbySvcId">Nearby connections service Id.</param>
        /// <param name="requiresGooglePlus">App requires G+ access</param>
        public static bool PerformSetup(string clientId, string bundleId,
                                        string webClientId, string nearbySvcId, bool requiresGooglePlus)
        {
            if (!GPGSUtil.LooksLikeValidClientId(clientId))
            {
                GPGSUtil.Alert(GPGSStrings.Setup.ClientIdError);
                return(false);
            }

            if (!GPGSUtil.LooksLikeValidBundleId(bundleId))
            {
                GPGSUtil.Alert(GPGSStrings.IOSSetup.BundleIdError);
                return(false);
            }

            // nearby is optional - only set it up if present.
            if (nearbySvcId != null)
            {
                bool ok = NearbyConnectionUI.PerformSetup(nearbySvcId, false);
                if (!ok)
                {
                    Debug.LogError("NearbyConnection Setup failed, returing false.");
                    return(false);
                }
            }

            Save(clientId, bundleId, webClientId, requiresGooglePlus);
            GPGSUtil.UpdateGameInfo();

            // Finished!
            GPGSProjectSettings.Instance.Set(GPGSUtil.IOSSETUPDONEKEY, true);
            GPGSProjectSettings.Instance.Save();
            AssetDatabase.Refresh();
            return(true);
        }
        /// <summary>
        /// Provide static access to setup for facilitating automated builds.
        /// </summary>
        /// <param name="webClientId">The oauth2 client id for the game.  This is only
        /// needed if the ID Token or access token are needed.</param>
        /// <param name="appId">App identifier.</param>
        /// <param name="nearbySvcId">Optional nearby connection serviceId</param>
        /// <param name="requiresGooglePlus">Indicates that GooglePlus should be enabled</param>
        /// <returns>true if successful</returns>
        public static bool PerformSetup(string webClientId, string appId, string nearbySvcId)
        {
            if (!string.IsNullOrEmpty(webClientId))
            {
                if (!GPGSUtil.LooksLikeValidClientId(webClientId))
                {
                    GPGSUtil.Alert(GPGSStrings.Setup.ClientIdError);
                    return(false);
                }

                string serverAppId = webClientId.Split('-')[0];
                if (!serverAppId.Equals(appId))
                {
                    GPGSUtil.Alert(GPGSStrings.Setup.AppIdMismatch);
                    return(false);
                }
            }

            // check for valid app id
            if (!GPGSUtil.LooksLikeValidAppId(appId) && string.IsNullOrEmpty(nearbySvcId))
            {
                GPGSUtil.Alert(GPGSStrings.Setup.AppIdError);
                return(false);
            }

            if (nearbySvcId != null)
            {
                if (!NearbyConnectionUI.PerformSetup(nearbySvcId, true))
                {
                    return(false);
                }
            }

            GPGSProjectSettings.Instance.Set(GPGSUtil.APPIDKEY, appId);
            GPGSProjectSettings.Instance.Set(GPGSUtil.WEBCLIENTIDKEY, webClientId);
            GPGSProjectSettings.Instance.Save();
            GPGSUtil.UpdateGameInfo();

            // check that Android SDK is there
            if (!GPGSUtil.HasAndroidSdk())
            {
                Debug.LogError("Android SDK not found.");
                EditorUtility.DisplayDialog(
                    GPGSStrings.AndroidSetup.SdkNotFound,
                    GPGSStrings.AndroidSetup.SdkNotFoundBlurb,
                    GPGSStrings.Ok);
                return(false);
            }

            // Generate AndroidManifest.xml
            GPGSUtil.GenerateAndroidManifest();

            // refresh assets, and we're done
            AssetDatabase.Refresh();
            GPGSProjectSettings.Instance.Set(GPGSUtil.ANDROIDSETUPDONEKEY, true);
            GPGSProjectSettings.Instance.Save();

            return(true);
        }
Exemple #4
0
        /// <summary>
        /// Generates the android manifest.
        /// </summary>
        public static void GenerateAndroidManifest()
        {
            string destFilename = GPGSUtil.SlashesToPlatformSeparator(ManifestPath);

            // Generate AndroidManifest.xml
            string manifestBody = GPGSUtil.ReadEditorTemplate("template-AndroidManifest");

            Dictionary <string, string> overrideValues =
                new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(GPGSProjectSettings.Instance.Get(SERVICEIDKEY)))
            {
                overrideValues [NEARBY_PERMISSIONS_PLACEHOLDER] =
                    "        <!-- Required for Nearby Connections -->\n" +
                    "        <uses-permission android:name=\"android.permission.BLUETOOTH\" />\n" +
                    "        <uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\" />\n" +
                    "        <uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />\n" +
                    "        <uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\" />\n" +
                    "        <uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" />\n";
                overrideValues [SERVICEID_ELEMENT_PLACEHOLDER] =
                    "             <!-- Required for Nearby Connections API -->\n" +
                    "             <meta-data android:name=\"com.google.android.gms.nearby.connection.SERVICE_ID\"\n" +
                    "                  android:value=\"__NEARBY_SERVICE_ID__\" />\n";
            }
            else
            {
                overrideValues [NEARBY_PERMISSIONS_PLACEHOLDER] = "";
                overrideValues [SERVICEID_ELEMENT_PLACEHOLDER]  = "";
            }

            foreach (KeyValuePair <string, string> ent in replacements)
            {
                string value =
                    GPGSProjectSettings.Instance.Get(ent.Value, overrideValues);
                manifestBody = manifestBody.Replace(ent.Key, value);
            }
            GPGSUtil.WriteFile(destFilename, manifestBody);


            string idsBody = ReadFile(SlashesToPlatformSeparator(ResIdPath));

            destFilename = GPGSUtil.SlashesToPlatformSeparator(ResIdPath);
            foreach (KeyValuePair <string, string> ent in replacements)
            {
                string value =
                    GPGSProjectSettings.Instance.Get(ent.Value, overrideValues);
                idsBody = idsBody.Replace(ent.Key, value);
            }
            GPGSUtil.WriteFile(destFilename, idsBody);


            GPGSUtil.UpdateGameInfo();
            TabTale.PSDK.Social.Editor.PSDK_GPGSUtils.CompressMainLibProjToAAR();
        }
Exemple #5
0
        /// <summary>
        /// Generates the android manifest.
        /// </summary>
        public static void GenerateAndroidManifest()
        {
            string destFilename = GPGSUtil.SlashesToPlatformSeparator(ManifestPath);

            // Generate AndroidManifest.xml
            string manifestBody = GPGSUtil.ReadEditorTemplate("template-AndroidManifest");

            Dictionary <string, string> overrideValues =
                new Dictionary <string, string>();

            foreach (KeyValuePair <string, string> ent in replacements)
            {
                string value =
                    GPGSProjectSettings.Instance.Get(ent.Value, overrideValues);
                manifestBody = manifestBody.Replace(ent.Key, value);
            }

            GPGSUtil.WriteFile(destFilename, manifestBody);
            GPGSUtil.UpdateGameInfo();
        }
        /// <summary>
        /// Generates the android manifest.
        /// </summary>
        public static void GenerateAndroidManifest()
        {
            var destFilename = GPGSUtil.SlashesToPlatformSeparator(
                "Assets/Plugins/Android/MainLibProj/AndroidManifest.xml");

            // Generate AndroidManifest.xml
            var manifestBody = GPGSUtil.ReadEditorTemplate("template-AndroidManifest");

            var overrideValues =
                new Dictionary <string, string>();

            foreach (var ent in replacements)
            {
                var value =
                    GPGSProjectSettings.Instance.Get(ent.Value, overrideValues);
                manifestBody = manifestBody.Replace(ent.Key, value);
            }

            GPGSUtil.WriteFile(destFilename, manifestBody);
            GPGSUtil.UpdateGameInfo();
        }