/// <summary> /// Updates the Android Gradle project file with localized values using <see cref="AppInfo"/>. /// </summary> /// <param name="projectDirectory">The root project directory to be updated. This is where the Android player was built to.</param> /// <param name="appInfo">Contains the localized values for the App.</param> /// <param name="roundIconsInfo">Contains the localized values for Android Round Icon. Refer Android documentation for more details : https://developer.android.com/about/versions/nougat/android-7.1.html#circular-icons</param> /// <param name="legacyIconsInfo">Contains the localized values for Android Legacy Icon.</param> /// <param name="adaptiveIconsInfo">Contains the localized values for Android Adaptive Icon. . Refer Android documentation for more details : https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive</param> public static void AddLocalizationToAndroidGradleProject(string projectDirectory, AppInfo appInfo, RoundIconsInfo roundIconsInfo = null, LegacyIconsInfo legacyIconsInfo = null, AdaptiveIconsInfo adaptiveIconsInfo = null) { if (appInfo == null) { throw new ArgumentNullException(nameof(appInfo)); } var project = new GradleProjectSettings(); foreach (var locale in LocalizationEditorSettings.GetLocales()) { var localeIdentifier = locale.Identifier.Code.Replace("-", "-r"); GenerateLocalizedXmlFile("App Name", Path.Combine(Directory.CreateDirectory(Path.Combine(project.GetResFolderPath(projectDirectory), "values-b+" + localeIdentifier)).FullName, k_InfoFile), locale, appInfo); //Generate icons var folderNames = new List <string> { $"mipmap-{localeIdentifier}-hdpi", $"mipmap-{localeIdentifier}-ldpi", $"mipmap-{localeIdentifier}-mdpi", $"mipmap-{localeIdentifier}-xhdpi", $"mipmap-{localeIdentifier}-xxhdpi", $"mipmap-{localeIdentifier}-xxxhdpi", $"mipmap-{localeIdentifier}-anydpi-v26" }; if (roundIconsInfo != null || legacyIconsInfo != null || adaptiveIconsInfo != null) { GenerateIconDirectory(folderNames, project.GetResFolderPath(projectDirectory), locale); } if (roundIconsInfo != null) { GenerateRoundIcons(folderNames, project.GetResFolderPath(projectDirectory), locale, roundIconsInfo); } if (legacyIconsInfo != null) { GenerateLegacyIcons(folderNames, project.GetResFolderPath(projectDirectory), locale, legacyIconsInfo); } if (adaptiveIconsInfo != null) { GenerateAdaptiveIcons(folderNames, project.GetResFolderPath(projectDirectory), locale, adaptiveIconsInfo); } } var androidManifest = new AndroidManifest(project.GetManifestPath(projectDirectory)); androidManifest.SetAtrribute("label", project.LabelName); if (adaptiveIconsInfo != null || legacyIconsInfo != null || roundIconsInfo != null) { androidManifest.SetAtrribute("icon", project.IconLabelName); androidManifest.SetAtrribute("roundIcon", project.RoundIconLabelName); } androidManifest.SaveIfModified(); }
public void SaveIfModified() { var manifestOnDisk = new AndroidManifest(m_Path); // We do this check for incremental pipeline i.e.., when we update the AndroidManifest file in our gradle project instead of overriding it on every build. // we check whether our changes are new and only then we save the Updated Manifest file. if (manifestOnDisk.OuterXml != OuterXml) { Save(); } }