Skip to content

Commit

Permalink
fix: Android icons output round and sharp
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 24, 2024
1 parent 10a6077 commit 67ddca5
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions scripts/fetch-icons/generators/generateAndroidIcons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand All @@ -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.
Expand Down

0 comments on commit 67ddca5

Please sign in to comment.