/// <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(); }
static void GenerateAdaptiveIcons(List <string> folderNames, string path, Locale locale, AdaptiveIconsInfo iconInfo) { //Adaptive Background Icons // We get the folder path of the respective density qualifier by combining the android `res' folder path and // the localized folder name from the folderNames list, for exmaple "mipmap-ar-hdpi" which is icon folder for arabic Locale // The k_AdaptiveIconBackgroundName variable contains the name for background icon which we use it for our Adaptive icon, // which will be used as file name for saving the respective LocalizedTexture to a ".png" file. GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[0]), k_AdaptiveIconBackgroundName), locale, iconInfo.AdaptiveHdpi.Background); GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[1]), k_AdaptiveIconBackgroundName), locale, iconInfo.AdaptiveIdpi.Background); GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[2]), k_AdaptiveIconBackgroundName), locale, iconInfo.AdaptiveMdpi.Background); GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[3]), k_AdaptiveIconBackgroundName), locale, iconInfo.AdaptiveXhdpi.Background); GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[4]), k_AdaptiveIconBackgroundName), locale, iconInfo.AdaptiveXXHdpi.Background); GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[5]), k_AdaptiveIconBackgroundName), locale, iconInfo.AdaptiveXXXHdpi.Background); //Adaptive Foreground Icons // We get the folder path of the respective density qualifier by combining the android `res' folder path and // the localized folder name from the folderNames list, for exmaple "mipmap-ar-hdpi" which is icon folder for arabic Locale // The k_AdaptiveIconForegroundName variable contains the name for foreground icon which we use it for our Adaptive icon. // which will be used as file name for saving the respective LocalizedTexture to a ".png" file. GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[0]), k_AdaptiveIconForegroundName), locale, iconInfo.AdaptiveHdpi.Foreground); GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[1]), k_AdaptiveIconForegroundName), locale, iconInfo.AdaptiveIdpi.Foreground); GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[2]), k_AdaptiveIconForegroundName), locale, iconInfo.AdaptiveMdpi.Foreground); GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[3]), k_AdaptiveIconForegroundName), locale, iconInfo.AdaptiveXhdpi.Foreground); GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[4]), k_AdaptiveIconForegroundName), locale, iconInfo.AdaptiveXXHdpi.Foreground); GenerateLocalizedIcon(Path.Combine(Path.Combine(path, folderNames[5]), k_AdaptiveIconForegroundName), locale, iconInfo.AdaptiveXXXHdpi.Foreground); WriteAdaptiveIconsXML(Path.Combine(Path.Combine(path, folderNames[6]), k_AdaptiveIcon_AppIconInfo)); WriteAdaptiveIconsXML(Path.Combine(Path.Combine(path, folderNames[6]), k_AdaptiveIcon_AppRoundIconInfo)); }