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AU,+BAA+B,CAAC,WAAmB;IAChE,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,MAAM,CAAC,MAAM,CAAC,iBAAS,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;QACpD,MAAM,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,wBAAgB,EAAE,UAAU,CAAC,CAAC;QAC9E,MAAM,kBAAE,CAAC,MAAM,CAAC,cAAI,CAAC,OAAO,CAAC,aAAa,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport { compositeImagesAsync, generateImageAsync } from '@expo/image-utils';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withDangerousMod } from '../plugins/core-plugins';\nimport { writeXMLAsync } from '../utils/XML';\nimport * as Colors from './Colors';\nimport { buildResourceItem, readResourcesXMLAsync } from './Resources';\n\ntype DPIString = 'mdpi' | 'hdpi' | 'xhdpi' | 'xxhdpi' | 'xxxhdpi';\ntype dpiMap = Record<DPIString, { folderName: string; scale: number }>;\n\nexport const dpiValues: dpiMap = {\n mdpi: { folderName: 'mipmap-mdpi', scale: 1 },\n hdpi: { folderName: 'mipmap-hdpi', scale: 1.5 },\n xhdpi: { folderName: 'mipmap-xhdpi', scale: 2 },\n xxhdpi: { folderName: 'mipmap-xxhdpi', scale: 3 },\n xxxhdpi: { folderName: 'mipmap-xxxhdpi', scale: 4 },\n};\nconst BASELINE_PIXEL_SIZE = 48;\nexport const ANDROID_RES_PATH = 'android/app/src/main/res/';\nconst MIPMAP_ANYDPI_V26 = 'mipmap-anydpi-v26';\nconst ICON_BACKGROUND = 'iconBackground';\nconst IC_LAUNCHER_PNG = 'ic_launcher.png';\nconst IC_LAUNCHER_ROUND_PNG = 'ic_launcher_round.png';\nconst IC_LAUNCHER_BACKGROUND_PNG = 'ic_launcher_background.png';\nconst IC_LAUNCHER_FOREGROUND_PNG = 'ic_launcher_foreground.png';\nconst IC_LAUNCHER_XML = 'ic_launcher.xml';\nconst IC_LAUNCHER_ROUND_XML = 'ic_launcher_round.xml';\n\nexport const withIcons: ConfigPlugin = config => {\n return withDangerousMod(config, [\n 'android',\n async config => {\n await setIconAsync(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nexport function getIcon(config: ExpoConfig) {\n return config.icon || config.android?.icon || null;\n}\n\nexport function getAdaptiveIcon(config: ExpoConfig) {\n return {\n foregroundImage: config.android?.adaptiveIcon?.foregroundImage ?? null,\n backgroundColor: config.android?.adaptiveIcon?.backgroundColor ?? null,\n backgroundImage: config.android?.adaptiveIcon?.backgroundImage ?? null,\n };\n}\n\n/**\n * Resizes the user-provided icon to create a set of legacy icon files in\n * their respective \"mipmap\" directories for <= Android 7, and creates a set of adaptive\n * icon files for > Android 7 from the adaptive icon files (if provided).\n */\nexport async function setIconAsync(config: ExpoConfig, projectRoot: string) {\n const { foregroundImage, backgroundColor, backgroundImage } = getAdaptiveIcon(config);\n const icon = foregroundImage ?? getIcon(config);\n\n if (!icon) {\n return null;\n }\n\n await configureLegacyIconAsync(projectRoot, icon, backgroundImage, backgroundColor);\n\n await configureAdaptiveIconAsync(\n projectRoot,\n icon,\n backgroundImage,\n backgroundColor ?? '#FFFFFF'\n );\n\n return true;\n}\n\n/**\n * Configures legacy icon files to be used on Android 7 and earlier. If adaptive icon configuration\n * was provided, we create a pseudo-adaptive icon by layering the provided files (or background\n * color if no backgroundImage is provided. If no backgroundImage and no backgroundColor are provided,\n * the background is set to transparent.)\n */\nasync function configureLegacyIconAsync(\n projectRoot: string,\n icon: string,\n backgroundImage: string | null,\n backgroundColor: string | null\n) {\n await Promise.all(\n Object.values(dpiValues).map(async ({ folderName, scale }) => {\n const dpiFolderPath = path.resolve(projectRoot, ANDROID_RES_PATH, folderName);\n const iconSizePx = BASELINE_PIXEL_SIZE * scale;\n\n // backgroundImage overrides backgroundColor\n backgroundColor = backgroundImage ? 'transparent' : backgroundColor ?? 'transparent';\n\n let squareIconImage: Buffer = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-standard-square' },\n {\n src: icon,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor,\n }\n )\n ).source;\n let roundIconImage: Buffer = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-standard-circle' },\n {\n src: icon,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor,\n borderRadius: iconSizePx / 2,\n }\n )\n ).source;\n\n if (backgroundImage) {\n // Layer the buffers we just created on top of the background image that's provided\n const squareBackgroundLayer = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-standard-square-background' },\n {\n src: backgroundImage,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor: 'transparent',\n }\n )\n ).source;\n const roundBackgroundLayer = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-standard-round-background' },\n {\n src: backgroundImage,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor: 'transparent',\n borderRadius: iconSizePx / 2,\n }\n )\n ).source;\n squareIconImage = await compositeImagesAsync({\n foreground: squareIconImage,\n background: squareBackgroundLayer,\n });\n roundIconImage = await compositeImagesAsync({\n foreground: roundIconImage,\n background: roundBackgroundLayer,\n });\n }\n\n await fs.ensureDir(dpiFolderPath);\n await fs.writeFile(path.resolve(dpiFolderPath, IC_LAUNCHER_PNG), squareIconImage);\n await fs.writeFile(path.resolve(dpiFolderPath, IC_LAUNCHER_ROUND_PNG), roundIconImage);\n })\n );\n}\n\n/**\n * Configures adaptive icon files to be used on Android 8 and up. A foreground image must be provided,\n * and will have a transparent background unless:\n * - A backgroundImage is provided, or\n * - A backgroundColor was specified\n */\nexport async function configureAdaptiveIconAsync(\n projectRoot: string,\n foregroundImage: string,\n backgroundImage: string | null,\n backgroundColor: string\n) {\n await setBackgroundColorAsync(projectRoot, backgroundColor);\n\n await Promise.all(\n Object.values(dpiValues).map(async ({ folderName, scale }) => {\n const dpiFolderPath = path.resolve(projectRoot, ANDROID_RES_PATH, folderName);\n const iconSizePx = BASELINE_PIXEL_SIZE * scale;\n\n try {\n const adpativeIconForeground = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-adaptive-foreground' },\n {\n src: foregroundImage,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor: 'transparent',\n }\n )\n ).source;\n await fs.writeFile(\n path.resolve(dpiFolderPath, IC_LAUNCHER_FOREGROUND_PNG),\n adpativeIconForeground\n );\n\n if (backgroundImage) {\n const adpativeIconBackground = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-adaptive-background' },\n {\n src: backgroundImage,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor: 'transparent',\n }\n )\n ).source;\n await fs.writeFile(\n path.resolve(dpiFolderPath, IC_LAUNCHER_BACKGROUND_PNG),\n adpativeIconBackground\n );\n } else {\n // Remove any instances of ic_launcher_background.png that are there from previous icons\n await removeBackgroundImageFilesAsync(projectRoot);\n }\n } catch (e) {\n throw new Error('Encountered an issue resizing adaptive app icon: ' + e);\n }\n })\n );\n\n // create ic_launcher.xml and ic_launcher_round.xml\n const icLauncherXmlString = createAdaptiveIconXmlString(backgroundImage);\n await createAdaptiveIconXmlFiles(projectRoot, icLauncherXmlString);\n}\n\nasync function setBackgroundColorAsync(projectRoot: string, backgroundColor: string | null) {\n const colorsXmlPath = await Colors.getProjectColorsXMLPathAsync(projectRoot);\n let colorsJson = await readResourcesXMLAsync({ path: colorsXmlPath });\n if (backgroundColor) {\n const colorItemToAdd = buildResourceItem({ name: ICON_BACKGROUND, value: backgroundColor });\n colorsJson = Colors.setColorItem(colorItemToAdd, colorsJson);\n } else {\n colorsJson = Colors.removeColorItem(ICON_BACKGROUND, colorsJson);\n }\n\n await writeXMLAsync({ path: colorsXmlPath, xml: colorsJson });\n}\n\nexport const createAdaptiveIconXmlString = (backgroundImage: string | null) => {\n let background = `<background android:drawable=\"@color/iconBackground\"/>`;\n if (backgroundImage) {\n background = `<background android:drawable=\"@mipmap/ic_launcher_background\"/>`;\n }\n\n return `<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n ${background}\n <foreground android:drawable=\"@mipmap/ic_launcher_foreground\"/>\n</adaptive-icon>`;\n};\n\nasync function createAdaptiveIconXmlFiles(projectRoot: string, icLauncherXmlString: string) {\n const anyDpiV26Directory = path.resolve(projectRoot, ANDROID_RES_PATH, MIPMAP_ANYDPI_V26);\n await fs.ensureDir(anyDpiV26Directory);\n await fs.writeFile(path.resolve(anyDpiV26Directory, IC_LAUNCHER_XML), icLauncherXmlString);\n await fs.writeFile(path.resolve(anyDpiV26Directory, IC_LAUNCHER_ROUND_XML), icLauncherXmlString);\n}\n\nasync function removeBackgroundImageFilesAsync(projectRoot: string) {\n return await Promise.all(\n Object.values(dpiValues).map(async ({ folderName }) => {\n const dpiFolderPath = path.resolve(projectRoot, ANDROID_RES_PATH, folderName);\n await fs.remove(path.resolve(dpiFolderPath, IC_LAUNCHER_BACKGROUND_PNG));\n })\n );\n}\n"]} |