Exemple #1
0
        public XamarinAndroidApplicationProject()
        {
            SetProperty("AndroidApplication", "True");

            SetProperty("AndroidResgenClass", "Resource");
            SetProperty("AndroidResgenFile", () => "Resources\\Resource.designer" + Language.DefaultExtension);
            SetProperty("AndroidManifest", "Properties\\AndroidManifest.xml");
            SetProperty(DebugProperties, "AndroidLinkMode", "None");
            SetProperty(ReleaseProperties, "AndroidLinkMode", "SdkOnly");

            AndroidManifest = default_android_manifest;
            LayoutMain      = default_layout_main;
            StringsXml      = default_strings_xml;
            PackageName     = PackageName ?? string.Format("{0}.{0}", ProjectName);

            OtherBuildItems.Add(new BuildItem.NoActionResource("Properties\\AndroidManifest.xml")
            {
                TextContent = () =>
                              AndroidManifest.Replace("${PROJECT_NAME}", ProjectName).
                              Replace("${PACKAGENAME}", PackageName)
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Main.axml")
            {
                TextContent = () => LayoutMain
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml")
            {
                TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName)
            });

            Sources.Add(new BuildItem.Source(() => "MainActivity" + Language.DefaultExtension)
            {
                TextContent = () => ProcessSourceTemplate(MainActivity ?? DefaultMainActivity)
            });
        }
        public XamarinAndroidApplicationProject(string debugConfigurationName = "Debug", string releaseConfigurationName = "Release", [CallerMemberName] string packageName = "")
            : base(debugConfigurationName, releaseConfigurationName)
        {
            if (Builder.UseDotNet)
            {
                SetProperty(KnownProperties.OutputType, "Exe");
                SetProperty("XamarinAndroidSupportSkipVerifyVersions", "True");
                SetProperty("_FastDeploymentDiagnosticLogging", "True");

                // Workaround for AndroidX, see: https://github.com/xamarin/AndroidSupportComponents/pull/239
                Imports.Add(new Import(() => "Directory.Build.targets")
                {
                    TextContent = () =>
                                  @"<Project>
							<PropertyGroup>
								<VectorDrawableCheckBuildToolsVersionTaskBeforeTargets />
							</PropertyGroup>
						</Project>"
                });
            }
            else
            {
                SetProperty("_FastDeploymentDiagnosticLogging", "True");
                SetProperty("AndroidApplication", "True");
                SetProperty("AndroidResgenClass", "Resource");
                SetProperty("AndroidResgenFile", () => "Resources\\Resource.designer" + Language.DefaultDesignerExtension);
                SetProperty("AndroidManifest", "Properties\\AndroidManifest.xml");
                SetProperty(DebugProperties, "AndroidLinkMode", "None");
                SetProperty(ReleaseProperties, "AndroidLinkMode", "SdkOnly");
                SetProperty(DebugProperties, KnownProperties.EmbedAssembliesIntoApk, "False", "'$(EmbedAssembliesIntoApk)' == ''");
                SetProperty(ReleaseProperties, KnownProperties.EmbedAssembliesIntoApk, "True", "'$(EmbedAssembliesIntoApk)' == ''");
            }

            AndroidManifest  = default_android_manifest;
            TargetSdkVersion = AndroidSdkResolver.GetMaxInstalledPlatform().ToString();
            LayoutMain       = default_layout_main;
            StringsXml       = default_strings_xml;
            PackageName      = $"com.xamarin.{(packageName ?? ProjectName).ToLower ()}";
            JavaPackageName  = JavaPackageName ?? PackageName.ToLowerInvariant();

            OtherBuildItems.Add(new BuildItem.NoActionResource("Properties\\AndroidManifest.xml")
            {
                TextContent = ProcessManifestTemplate,
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Main.axml")
            {
                TextContent = () => LayoutMain
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml")
            {
                TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName)
            });

            Sources.Add(new BuildItem.Source(() => "MainActivity" + Language.DefaultExtension)
            {
                TextContent = () => ProcessSourceTemplate(MainActivity ?? DefaultMainActivity)
            });
        }
        public XamarinAndroidLibraryProject()
        {
            SetProperty("AndroidApplication", "False");

            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml")
            {
                TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName)
            });
            StringsXml = default_strings_xml;
        }
Exemple #4
0
        public XamarinAndroidLibraryProject(string debugConfigurationName = "Debug", string releaseConfigurationName = "Release")
            : base(debugConfigurationName, releaseConfigurationName)
        {
            SetProperty("AndroidApplication", "False");

            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml")
            {
                TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName)
            });
            StringsXml = default_strings_xml;
        }
Exemple #5
0
 public MSBuildSdkExtrasProject()
 {
     Sdk = "MSBuild.Sdk.Extras/2.0.41";
     Sources.Add(new BuildItem.Source("Class1.cs")
     {
         TextContent = () => "public class Class1 { }"
     });
     Sources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml")
     {
         TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName)
     });
     StringsXml       = XamarinAndroidLibraryProject.default_strings_xml;
     TargetFrameworks = "MonoAndroid10.0";
 }
Exemple #6
0
        public XamarinAndroidLibraryProject(string debugConfigurationName = "Debug", string releaseConfigurationName = "Release")
            : base(debugConfigurationName, releaseConfigurationName)
        {
            if (!Builder.UseDotNet)
            {
                SetProperty("AndroidApplication", "False");
                SetProperty("AndroidResgenFile", Path.Combine("Resources", "Resource.designer.cs"));
            }

            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml")
            {
                TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName)
            });
            StringsXml = default_strings_xml;
        }
        public XamarinAndroidApplicationProject(string debugConfigurationName = "Debug", string releaseConfigurationName = "Release")
            : base(debugConfigurationName, releaseConfigurationName)
        {
            SetProperty("AndroidApplication", "True");

            SetProperty("AndroidResgenClass", "Resource");
            SetProperty("AndroidResgenFile", () => "Resources\\Resource.designer" + Language.DefaultDesignerExtension);
            SetProperty("AndroidManifest", "Properties\\AndroidManifest.xml");
            SetProperty(DebugProperties, "AndroidLinkMode", "None");
            SetProperty(ReleaseProperties, "AndroidLinkMode", "SdkOnly");
            SetProperty(DebugProperties, KnownProperties.EmbedAssembliesIntoApk, "False", "'$(EmbedAssembliesIntoApk)' == ''");
            SetProperty(ReleaseProperties, KnownProperties.EmbedAssembliesIntoApk, "True", "'$(EmbedAssembliesIntoApk)' == ''");

            AndroidManifest = default_android_manifest;
            LayoutMain      = default_layout_main;
            StringsXml      = default_strings_xml;
            PackageName     = PackageName ?? string.Format("{0}.{0}", ProjectName);
            JavaPackageName = JavaPackageName ?? PackageName.ToLowerInvariant();

            OtherBuildItems.Add(new BuildItem.NoActionResource("Properties\\AndroidManifest.xml")
            {
                TextContent = () =>
                              AndroidManifest.Replace("${PROJECT_NAME}", ProjectName).
                              Replace("${PACKAGENAME}", PackageName)
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\layout\\Main.axml")
            {
                TextContent = () => LayoutMain
            });
            AndroidResources.Add(new AndroidItem.AndroidResource("Resources\\values\\Strings.xml")
            {
                TextContent = () => StringsXml.Replace("${PROJECT_NAME}", ProjectName)
            });

            Sources.Add(new BuildItem.Source(() => "MainActivity" + Language.DefaultExtension)
            {
                TextContent = () => ProcessSourceTemplate(MainActivity ?? DefaultMainActivity)
            });
        }
        /// <summary>
        /// 应用用户自定义数据.
        /// </summary>
        /// <param name="iGameName">游戏名.</param>
        protected override void ApplyUserData(string iGameName)
        {
            // 本地设定
            {
                const string name  = "Local";
                var          value = TiangeSdkSettings.GetInstance().Local.ToString();
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
                if (TiangeSdkSettings.GetInstance().Local == false)
                {
                    return;
                }
            }

            // 游戏名
            {
                const string name  = "GameName";
                var          value = iGameName;
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value);
                }
            }

            // SDK自动初始化
            {
                const string name  = "AutoSdkInit";
                var          value = TiangeSdkSettings.GetInstance().AutoSdkInit.ToString();
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
                if (TiangeSdkSettings.GetInstance().Local == false)
                {
                    return;
                }
            }

            // 自动登录
            {
                const string name  = "AutoLogin";
                var          value = TiangeSdkSettings.GetInstance().AutoLogin.ToString();
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
                if (TiangeSdkSettings.GetInstance().Local == false)
                {
                    return;
                }
            }
            // 屏幕方向
            {
                const string name        = "Orientation";
                var          value       = "1";
                var          orientation = TiangeSdkSettings.GetInstance().Orientation;
                if (UIOrientation.LandscapeLeft == orientation ||
                    UIOrientation.LandscapeRight == orientation)
                {
                    value = "2";
                }
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
            }

            // 易接SDK 设定
            if (TiangeSdkSettings.GetInstance().data.Options.IsOptionValid(SDKOptions.OneSDK))
            {
                // 易接SDK Key
                {
                    const string name  = "zy_class_name";
                    var          value = TiangeSdkSettings.GetInstance().data.Options.OneSDK.zyClassName;
                    if (false == string.IsNullOrEmpty(value))
                    {
                        AddUserDefineNode(name, value);
                    }
                }

                // 易接SDK MetaDatas
                {
                    var metaDatas = TiangeSdkSettings.GetInstance().data.Options.OneSDK.metaDatas;
                    foreach (var metaData in metaDatas)
                    {
                        if (null != metaData &&
                            false == string.IsNullOrEmpty(metaData.name) &&
                            false == string.IsNullOrEmpty(metaData.value))
                        {
                            AddUserDefineNode(metaData.name, metaData.value, false);
                        }
                    }
                }
            }

            // 保存strings.xml
            StringsXml?.Save();
        }
        /// <summary>
        /// 应用用户自定义数据.
        /// </summary>
        /// <param name="iGameName">游戏名.</param>
        protected override void ApplyUserData(string iGameName)
        {
            // 本地设定
            {
                const string name  = "Huawei_Local";
                var          value = HuaweiSdkSettings.GetInstance().Local.ToString();
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
                if (HuaweiSdkSettings.GetInstance().Local == false)
                {
                    return;
                }
            }

            // 游戏名
            {
                const string name  = "Huawei_GameName";
                var          value = iGameName;
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value);
                }
            }

            // 自动登录
            {
                const string name  = "Huawei_AutoLogin";
                var          value = HuaweiSdkSettings.GetInstance().AutoLogin.ToString();
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
                if (HuaweiSdkSettings.GetInstance().Local == false)
                {
                    return;
                }
            }

            // AppID
            {
                const string name  = "Huawei_AppID";
                var          value = HuaweiSdkSettings.GetInstance().AppId;
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value);
                }
            }
            // 浮标密钥
            {
                const string name  = "Huawei_BuoySecret";
                var          value = HuaweiSdkSettings.GetInstance().BuoySecret;
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value);
                }
            }
            // 支付ID
            {
                const string name  = "Huawei_PayID";
                var          value = HuaweiSdkSettings.GetInstance().PayId;
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value);
                }
            }
            // 支付私钥
            {
                const string name  = "Huawei_PayPrivateRsa";
                var          value = HuaweiSdkSettings.GetInstance().PayPrivateRsa;
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value);
                }
            }
            // 支付公钥
            {
                const string name  = "Huawei_PayPublicRsa";
                var          value = HuaweiSdkSettings.GetInstance().PayPublicRsa;
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value);
                }
            }
            // CPID
            {
                const string name  = "Huawei_CPID";
                var          value = HuaweiSdkSettings.GetInstance().Cpid;
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value);
                }
            }
            // 登录签名公钥
            {
                const string name  = "Huawei_LoginPublicRsa";
                var          value = HuaweiSdkSettings.GetInstance().LoginPublicRsa;
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value);
                }
            }
            // 屏幕方向
            {
                const string name         = "Huawei_Orientation";
                var          value        = "1";
                var          _orientation = HuaweiSdkSettings.GetInstance().Orientation;
                if (UIOrientation.LandscapeLeft == _orientation ||
                    UIOrientation.LandscapeRight == _orientation)
                {
                    value = "2";
                }
                if (false == string.IsNullOrEmpty(value))
                {
                    AddUserDefineNode(name, value, false);
                }
            }

            // 保存strings.xml
            StringsXml?.Save();
        }