You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
4.1 KiB
96 lines
4.1 KiB
#!/bin/bash
|
|
|
|
# TimeSafari Android Icon Generation Script
|
|
# Generates all required Android launcher icon sizes from assets/icon.png
|
|
# Author: Matthew Raymer
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
ASSETS_DIR="$PROJECT_ROOT/assets"
|
|
ANDROID_RES_DIR="$PROJECT_ROOT/android/app/src/main/res"
|
|
|
|
echo "=== TimeSafari Android Icon Generation ==="
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [INFO] Starting Android icon generation"
|
|
|
|
# Check if source icon exists
|
|
if [ ! -f "$ASSETS_DIR/icon.png" ]; then
|
|
echo "[ERROR] Source icon not found: $ASSETS_DIR/icon.png"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if ImageMagick is available
|
|
if ! command -v convert &> /dev/null; then
|
|
echo "[ERROR] ImageMagick (convert) not found. Please install ImageMagick."
|
|
echo " Arch: sudo pacman -S imagemagick"
|
|
echo " Ubuntu: sudo apt-get install imagemagick"
|
|
echo " macOS: brew install imagemagick"
|
|
exit 1
|
|
fi
|
|
|
|
# Create mipmap directories if they don't exist
|
|
mkdir -p "$ANDROID_RES_DIR/mipmap-hdpi"
|
|
mkdir -p "$ANDROID_RES_DIR/mipmap-mdpi"
|
|
mkdir -p "$ANDROID_RES_DIR/mipmap-xhdpi"
|
|
mkdir -p "$ANDROID_RES_DIR/mipmap-xxhdpi"
|
|
mkdir -p "$ANDROID_RES_DIR/mipmap-xxxhdpi"
|
|
|
|
echo "[INFO] Generating launcher icons..."
|
|
|
|
# Generate launcher icons for different densities
|
|
# Android launcher icon sizes: mdpi=48, hdpi=72, xhdpi=96, xxhdpi=144, xxxhdpi=192
|
|
convert "$ASSETS_DIR/icon.png" -resize 48x48 "$ANDROID_RES_DIR/mipmap-mdpi/ic_launcher.png"
|
|
convert "$ASSETS_DIR/icon.png" -resize 72x72 "$ANDROID_RES_DIR/mipmap-hdpi/ic_launcher.png"
|
|
convert "$ASSETS_DIR/icon.png" -resize 96x96 "$ANDROID_RES_DIR/mipmap-xhdpi/ic_launcher.png"
|
|
convert "$ASSETS_DIR/icon.png" -resize 144x144 "$ANDROID_RES_DIR/mipmap-xxhdpi/ic_launcher.png"
|
|
convert "$ASSETS_DIR/icon.png" -resize 192x192 "$ANDROID_RES_DIR/mipmap-xxxhdpi/ic_launcher.png"
|
|
|
|
# Generate round launcher icons
|
|
convert "$ASSETS_DIR/icon.png" -resize 48x48 "$ANDROID_RES_DIR/mipmap-mdpi/ic_launcher_round.png"
|
|
convert "$ASSETS_DIR/icon.png" -resize 72x72 "$ANDROID_RES_DIR/mipmap-hdpi/ic_launcher_round.png"
|
|
convert "$ASSETS_DIR/icon.png" -resize 96x96 "$ANDROID_RES_DIR/mipmap-xhdpi/ic_launcher_round.png"
|
|
convert "$ASSETS_DIR/icon.png" -resize 144x144 "$ANDROID_RES_DIR/mipmap-xxhdpi/ic_launcher_round.png"
|
|
convert "$ASSETS_DIR/icon.png" -resize 192x192 "$ANDROID_RES_DIR/mipmap-xxxhdpi/ic_launcher_round.png"
|
|
|
|
# Create background and foreground mipmap files
|
|
# These reference the existing drawable files
|
|
cat > "$ANDROID_RES_DIR/mipmap-anydpi-v26/ic_launcher_background.xml" << 'EOF'
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
|
<background android:drawable="@drawable/ic_launcher_background"/>
|
|
</adaptive-icon>
|
|
EOF
|
|
|
|
cat > "$ANDROID_RES_DIR/mipmap-anydpi-v26/ic_launcher_foreground.xml" << 'EOF'
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
|
</adaptive-icon>
|
|
EOF
|
|
|
|
# Update the existing launcher XML files to reference the correct resources
|
|
cat > "$ANDROID_RES_DIR/mipmap-anydpi-v26/ic_launcher.xml" << 'EOF'
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
|
<background android:drawable="@drawable/ic_launcher_background"/>
|
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
|
</adaptive-icon>
|
|
EOF
|
|
|
|
cat > "$ANDROID_RES_DIR/mipmap-anydpi-v26/ic_launcher_round.xml" << 'EOF'
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
|
<background android:drawable="@drawable/ic_launcher_background"/>
|
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
|
</adaptive-icon>
|
|
EOF
|
|
|
|
echo "[SUCCESS] Generated Android launcher icons:"
|
|
echo " - mipmap-mdpi/ic_launcher.png (48x48)"
|
|
echo " - mipmap-hdpi/ic_launcher.png (72x72)"
|
|
echo " - mipmap-xhdpi/ic_launcher.png (96x96)"
|
|
echo " - mipmap-xxhdpi/ic_launcher.png (144x144)"
|
|
echo " - mipmap-xxxhdpi/ic_launcher.png (192x192)"
|
|
echo " - Updated mipmap-anydpi-v26 XML files"
|
|
echo "[SUCCESS] Android icon generation completed successfully!"
|