From 67ddca5244581f9ed79a209d7c5007da81aac503 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 24 Oct 2024 19:58:57 +0100 Subject: [PATCH] fix: Android icons output round and sharp --- .../generators/generateAndroidIcons.ts | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/fetch-icons/generators/generateAndroidIcons.ts b/scripts/fetch-icons/generators/generateAndroidIcons.ts index 3f69e421..bb3dee77 100644 --- a/scripts/fetch-icons/generators/generateAndroidIcons.ts +++ b/scripts/fetch-icons/generators/generateAndroidIcons.ts @@ -12,15 +12,22 @@ export const generateAndroidIcons = (outputDir: string, iconManifest: IconManife createFolder(outputDir); for (const icon of iconManifest) { const definition = icon[1]; - const svg = readFileSync(definition.roundPath).toString(); - try { - const file = generateAndroidIcon(svg); - if (file) { - writeFileSync(`${outputDir}/${getAndroidIconFileName(definition.name)}`, file); - } - } catch (e) { - console.error(`Error generating Android icon for ${definition.name}`); + outputAndroidFile(definition.roundPath, "round", definition.name, outputDir); + outputAndroidFile(definition.sharpPath, "sharp", definition.name, outputDir); + } +}; + +const outputAndroidFile = (svg: string, type: string, iconName: string, outputDir: string) => { + const svg2 = readFileSync(svg).toString(); + try { + const file = generateAndroidIcon(svg2); + if (file) { + writeFileSync(`${outputDir}/${getAndroidIconFileName(iconName, type)}`, file); + } else { + throw new Error("Error generating Android icon"); } + } catch (e) { + console.error(`Error generating Android icon for ${type} ${iconName}`, e); } }; @@ -29,7 +36,7 @@ export const generateAndroidIcons = (outputDir: string, iconManifest: IconManife * @param iconName The name of the icon. * @returns The file name for the Android icon. */ -export const getAndroidIconFileName = (iconName: string) => `ic_${toSnakeCase(iconName)}.xml`; +export const getAndroidIconFileName = (iconName: string, type: String) => `ic_${toSnakeCase(iconName)}_${type}.xml`; /** * Creates the contents of an xml file for an Android icon.