#!/bin/sh

set -e
set -u

ROOT_DIR=$(dirname $(realpath "$0"))/..
ART_DIR="$ROOT_DIR/art"
RES_DIR="$ROOT_DIR/app/src/main/res"
ICON_ART="$ART_DIR/app-icon.svg"

gen_icons() {
    while read size name; do
        DST_DIR="$RES_DIR/mipmap-$name"
        mkdir -p "$DST_DIR"
        DST="$DST_DIR/ic_launcher.png"
        rsvg-convert --background-color none "$ICON_ART" -w $size -h $size \
            -o "$DST"
        optipng "$DST"
    done
}

cat <<EOF | gen_icons
36 ldpi
48 mdpi
64 tvdpi
72 hdpi
96 xhdpi
144 xxhdpi
192 xxxhdpi
EOF
