1#!/usr/bin/env bash
2# generate_android_icons.sh
3# Generuje ic_launcher PNG pro všechny Android hustoty + Play Store ikonu.
4# Použití: ./scripts/generate_android_icons.sh /cesta/k/logo.png
5#
6# Zdroj musí být min. 512×512 px (čtvercový PNG).
7# Vyžaduje: macOS sips (součást macOS, žádné závislosti).
8
9set -e
10
11SRC="${1:-}"
12if [ -z "$SRC" ]; then
13 echo "Použití: $0 <cesta_k_logo.png>"
14 exit 1
15fi
16if [ ! -f "$SRC" ]; then
17 echo "Soubor nenalezen: $SRC"
18 exit 1
19fi
20
21SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
22REPO_ROOT="$(dirname "$SCRIPT_DIR")"
23BASE="$REPO_ROOT/android/app/src/main/res"
24STORE="$REPO_ROOT/store_assets"
25
26echo "→ Generuji Android ikony z: $SRC"
27
28# mipmap hustoty: "density:size"
29DENSITIES=(mdpi:48 hdpi:72 xhdpi:96 xxhdpi:144 xxxhdpi:192)
30
31for ENTRY in "${DENSITIES[@]}"; do
32 DENSITY="${ENTRY%%:*}"
33 SIZE="${ENTRY##*:}"
34 DIR="$BASE/mipmap-$DENSITY"
35 mkdir -p "$DIR"
36 sips -z "$SIZE" "$SIZE" "$SRC" --out "$DIR/ic_launcher.png" > /dev/null
37 cp "$DIR/ic_launcher.png" "$DIR/ic_launcher_round.png"
38 echo " ✓ mipmap-$DENSITY (${SIZE}×${SIZE}px)"
39done
40
41# Play Store ikona — 512×512
42mkdir -p "$STORE"
43sips -z 512 512 "$SRC" --out "$STORE/play_store_icon.png" > /dev/null
44echo " ✓ store_assets/play_store_icon.png (512×512px)"
45
46# Adaptivní ikona — foreground
47for ENTRY in "${DENSITIES[@]}"; do
48 DENSITY="${ENTRY%%:*}"
49 DIR="$BASE/mipmap-$DENSITY"
50 cp "$DIR/ic_launcher.png" "$DIR/ic_launcher_foreground.png"
51done
52
53# ic_launcher_background.xml — jednobarevné pozadí (bílé)
54for DENSITY in mdpi hdpi xhdpi xxhdpi xxxhdpi; do
55 DIR="$BASE/mipmap-$DENSITY"
56 cat > "$DIR/ic_launcher_background.xml" << 'XMLEOF'
57<?xml version="1.0" encoding="utf-8"?>
58<shape xmlns:android="http://schemas.android.com/apk/res/android">
59 <solid android:color="#FFFFFF"/>
60</shape>
61XMLEOF
62done
63
64# Adaptivní ikona XML (API 26+)
65DRAWABLE="$BASE/drawable"
66mkdir -p "$DRAWABLE"
67cat > "$DRAWABLE/ic_launcher.xml" << 'XMLEOF'
68<?xml version="1.0" encoding="utf-8"?>
69<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
70 <background android:drawable="@mipmap/ic_launcher_background"/>
71 <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
72</adaptive-icon>
73XMLEOF
74
75echo ""
76echo "✓ Android ikony vygenerovány"
77echo "✓ Adaptivní ikona nakonfigurována (API 26+)"
78echo ""
79echo "Play Store: $STORE/play_store_icon.png"