42 lines
1.1 KiB
Bash
Executable File
42 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# rasterizes assets/androidIcon.svg edge-to-edge into the android mipmap-density buckets used by the launcher.
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
SVG="$ROOT/assets/androidIcon.svg"
|
|
RES="$ROOT/android/app/src/main/res"
|
|
|
|
if [[ ! -f "$SVG" ]]; then
|
|
echo "ERROR: $SVG not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v rsvg-convert >/dev/null 2>&1; then
|
|
echo "ERROR: rsvg-convert not on PATH (brew install librsvg)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# launcher icon density buckets per the android docs.
|
|
DENSITIES=(
|
|
"mdpi 48"
|
|
"hdpi 72"
|
|
"xhdpi 96"
|
|
"xxhdpi 144"
|
|
"xxxhdpi 192"
|
|
)
|
|
|
|
for entry in "${DENSITIES[@]}"; do
|
|
bucket="${entry%% *}"
|
|
size="${entry##* }"
|
|
dir="$RES/mipmap-$bucket"
|
|
mkdir -p "$dir"
|
|
rsvg-convert --width="$size" --height="$size" "$SVG" -o "$dir/ic_launcher.png"
|
|
done
|
|
|
|
# 512x512 play-store icon staged alongside the launcher buckets
|
|
mkdir -p "$RES/mipmap-xxxhdpi"
|
|
rsvg-convert --width=512 --height=512 "$SVG" -o "$RES/mipmap-xxxhdpi/ic_launcher_play.png"
|
|
|
|
echo "wrote launcher icons across ${#DENSITIES[@]} density buckets + play store size"
|