support background images on android icon
This commit is contained in:
parent
ad9aab4a46
commit
ec993b7337
|
@ -123,7 +123,7 @@ $(ANDROID_BUILD_DIR): $(SDL_SRC)/android-project/ $(SB_SRC_DIR)/android/revise_s
|
|||
ln -nsf $(SDL_MIXER_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_mixer
|
||||
ln -nsf $(SDL_TTF_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_ttf
|
||||
$(SB_SRC_DIR)/android/revise_skeleton.sh $(ANDROID_PACKAGE) $(ANDROID_BUILD_DIR) $(ANDROID_MANIFEST) $(ANDROID_APP_MK) $(ANDROID_MK) $(ANDROID_CLASS) \
|
||||
$(ANDROID_APP_NAME) $(ANDROID_MIN_TARGET) $(ANDROID_NDK)
|
||||
$(ANDROID_APP_NAME) $(ANDROID_MIN_TARGET) $(ANDROID_NDK) "Fill Screen Test" "18" "22.1.7171670"
|
||||
|
||||
# Extend the SDLActivity class
|
||||
|
||||
|
@ -132,8 +132,8 @@ $(ANDROID_BUILD_DIR)/$(ANDROID_CLASS_DIR)/$(ANDROID_CLASS).java: $(SB_SRC_DIR)/a
|
|||
|
||||
# Generate icon
|
||||
|
||||
$(ANDROID_BUILD_DIR)/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: $(SB_SRC_DIR)/android/generate_icon.sh $(SB_DIR)/icons
|
||||
$(SB_SRC_DIR)/android/generate_icon.sh $(ANDROID_BUILD_DIR)
|
||||
$(ANDROID_BUILD_DIR)/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: $(SB_SRC_DIR)/android/generate_icon.sh $(SB_DIR)/icon
|
||||
$(SB_SRC_DIR)/android/generate_icon.sh $(ANDROID_BUILD_DIR) "../../icon/foreground.png" "../../icon/background.png"
|
||||
|
||||
# Run gradle and generate an APK
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 124 KiB |
BIN
icon/static.png
BIN
icon/static.png
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 130 KiB |
|
@ -14,16 +14,14 @@
|
|||
#
|
||||
# Create legacy, adaptive, and monochrome adaptive icons as mipmaps, one per device DPI. Draw the foreground onto the background to create
|
||||
# the legacy icons. Draw the foreground onto a transparent background to create the adaptive icons and save them in mipmap-anydpi-v26 to
|
||||
# to target Android API 26 and up. Set the adaptive background by writing the color value to XML.
|
||||
# to target Android API 26 and up.
|
||||
#
|
||||
# The background can be either a hex color or a path to an existing file. If the background is an existing file, mipmaps will be created.
|
||||
# Otherwise, it is assumed to be a color, and color values will be added to the XML.
|
||||
|
||||
ANDROID_BUILD_DIR=$1
|
||||
FOREGROUND=../../icon/foreground.png
|
||||
BACKGROUND=#000000
|
||||
MANIFEST='<?xml version="1.0" encoding="utf-8"?>\n<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/iconBackground" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@mipmap/ic_launcher_foreground_mono" />
|
||||
</adaptive-icon>'
|
||||
FOREGROUND=$2
|
||||
BACKGROUND=$3
|
||||
COLORS=$ANDROID_BUILD_DIR/app/src/main/res/values/colors.xml
|
||||
XXXHDPI=$ANDROID_BUILD_DIR/app/src/main/res/mipmap-xxxhdpi
|
||||
XXHDPI=$ANDROID_BUILD_DIR/app/src/main/res/mipmap-xxhdpi
|
||||
|
@ -31,31 +29,61 @@ XHDPI=$ANDROID_BUILD_DIR/app/src/main/res/mipmap-xhdpi
|
|||
HDPI=$ANDROID_BUILD_DIR/app/src/main/res/mipmap-hdpi
|
||||
MDPI=$ANDROID_BUILD_DIR/app/src/main/res/mipmap-mdpi
|
||||
|
||||
# Create all the XXXHDPI versions
|
||||
convert xc:$BACKGROUND -resize 432x432 $FOREGROUND -gravity center -composite $XXXHDPI/ic_launcher.png
|
||||
convert xc:none -resize 432x432 $FOREGROUND -gravity center -composite $XXXHDPI/ic_launcher_foreground.png
|
||||
convert xc:none -resize 432x432 $FOREGROUND -gravity center -composite -threshold 0 -negate $XXXHDPI/ic_launcher_foreground_mono.png
|
||||
# If the background is a file, use a mipmap. Otherwise, assume it is a color.
|
||||
if [ -f "$BACKGROUND" ]
|
||||
then
|
||||
DRAWABLE="@mipmap/ic_launcher_background"
|
||||
BASE="$BACKGROUND"
|
||||
else
|
||||
DRAWABLE="@color/iconBackground"
|
||||
BASE="xc:$BACKGROUND"
|
||||
fi
|
||||
|
||||
# Android adaptive icon XML
|
||||
MANIFEST="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">
|
||||
<background android:drawable=\"$DRAWABLE\" />
|
||||
<foreground android:drawable=\"@mipmap/ic_launcher_foreground\" />
|
||||
<monochrome android:drawable=\"@mipmap/ic_launcher_foreground_mono\" />
|
||||
</adaptive-icon>"
|
||||
|
||||
# Create the XXXHDPI versions
|
||||
convert "$BASE" -resize 432x432 "$FOREGROUND" -gravity center -composite "$XXXHDPI/ic_launcher.png"
|
||||
convert "xc:none" -resize 432x432 "$FOREGROUND" -gravity center -composite "$XXXHDPI/ic_launcher_foreground.png"
|
||||
convert "xc:none" -resize 432x432 "$FOREGROUND" -gravity center -composite -threshold 0 -negate "$XXXHDPI/ic_launcher_foreground_mono.png"
|
||||
|
||||
# Use the XXXHDPI versions to create the lower resolutions
|
||||
convert $XXXHDPI/ic_launcher.png -resize 324x324 $XXHDPI/ic_launcher.png
|
||||
convert $XXXHDPI/ic_launcher_foreground.png -resize 324x324 $XXHDPI/ic_launcher_foreground.png
|
||||
convert $XXXHDPI/ic_launcher_foreground_mono.png -resize 324x324 $XXHDPI/ic_launcher_foreground_mono.png
|
||||
convert $XXXHDPI/ic_launcher.png -resize 216x216 $XHDPI/ic_launcher.png
|
||||
convert $XXXHDPI/ic_launcher_foreground.png -resize 216x216 $XHDPI/ic_launcher_foreground.png
|
||||
convert $XXXHDPI/ic_launcher_foreground_mono.png -resize 216x216 $XHDPI/ic_launcher_foreground_mono.png
|
||||
convert $XXXHDPI/ic_launcher.png -resize 162x162 $HDPI/ic_launcher.png
|
||||
convert $XXXHDPI/ic_launcher_foreground.png -resize 162x162 $HDPI/ic_launcher_foreground.png
|
||||
convert $XXXHDPI/ic_launcher_foreground_mono.png -resize 162x162 $HDPI/ic_launcher_foreground_mono.png
|
||||
convert $XXXHDPI/ic_launcher.png -resize 108x108 $MDPI/ic_launcher.png
|
||||
convert $XXXHDPI/ic_launcher_foreground.png -resize 108x108 $MDPI/ic_launcher_foreground.png
|
||||
convert $XXXHDPI/ic_launcher_foreground_mono.png -resize 108x108 $MDPI/ic_launcher_foreground_mono.png
|
||||
convert "$XXXHDPI/ic_launcher.png" -resize 324x324 "$XXHDPI/ic_launcher.png"
|
||||
convert "$XXXHDPI/ic_launcher_foreground.png" -resize 324x324 "$XXHDPI/ic_launcher_foreground.png"
|
||||
convert "$XXXHDPI/ic_launcher_foreground_mono.png" -resize 324x324 "$XXHDPI/ic_launcher_foreground_mono.png"
|
||||
convert "$XXXHDPI/ic_launcher.png" -resize 216x216 "$XHDPI/ic_launcher.png"
|
||||
convert "$XXXHDPI/ic_launcher_foreground.png" -resize 216x216 "$XHDPI/ic_launcher_foreground.png"
|
||||
convert "$XXXHDPI/ic_launcher_foreground_mono.png" -resize 216x216 "$XHDPI/ic_launcher_foreground_mono.png"
|
||||
convert "$XXXHDPI/ic_launcher.png" -resize 162x162 "$HDPI/ic_launcher.png"
|
||||
convert "$XXXHDPI/ic_launcher_foreground.png" -resize 162x162 "$HDPI/ic_launcher_foreground.png"
|
||||
convert "$XXXHDPI/ic_launcher_foreground_mono.png" -resize 162x162 "$HDPI/ic_launcher_foreground_mono.png"
|
||||
convert "$XXXHDPI/ic_launcher.png" -resize 108x108 "$MDPI/ic_launcher.png"
|
||||
convert "$XXXHDPI/ic_launcher_foreground.png" -resize 108x108 "$MDPI/ic_launcher_foreground.png"
|
||||
convert "$XXXHDPI/ic_launcher_foreground_mono.png" -resize 108x108 "$MDPI/ic_launcher_foreground_mono.png"
|
||||
|
||||
# Create background mipmaps if necessary
|
||||
if [ -f "$BACKGROUND" ]
|
||||
then
|
||||
convert "$BASE" -resize 432x432 "$XXXHDPI/ic_launcher_background.png"
|
||||
convert "$XXXHDPI/ic_launcher_background.png" -resize 324x324 "$XXHDPI/ic_launcher_background.png"
|
||||
convert "$XXXHDPI/ic_launcher_background.png" -resize 216x216 "$XHDPI/ic_launcher_background.png"
|
||||
convert "$XXXHDPI/ic_launcher_background.png" -resize 162x162 "$HDPI/ic_launcher_background.png"
|
||||
convert "$XXXHDPI/ic_launcher_background.png" -resize 108x108 "$MDPI/ic_launcher_background.png"
|
||||
fi
|
||||
|
||||
# Create the adaptive icons XML
|
||||
mkdir -p $ANDROID_BUILD_DIR/app/src/main/res/mipmap-anydpi-v26/
|
||||
echo $MANIFEST > $ANDROID_BUILD_DIR/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
|
||||
if [ -z "$(grep iconBackground $COLORS)" ]
|
||||
mkdir -p "$ANDROID_BUILD_DIR/app/src/main/res/mipmap-anydpi-v26/"
|
||||
echo "$MANIFEST" > "$ANDROID_BUILD_DIR/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml"
|
||||
if [ ! -f "$BACKGROUND" ]
|
||||
then
|
||||
sed -i "6i\ <color name=\"iconBackground\">$BACKGROUND</color>" $COLORS
|
||||
else
|
||||
sed -i "s|\(iconBackground\">\).*\(</color>\)|\1$BACKGROUND\2|" $COLORS
|
||||
if [ -z "$(grep iconBackground $COLORS)" ]
|
||||
then
|
||||
sed -i "6i\ <color name=\"iconBackground\">$BACKGROUND</color>" $COLORS
|
||||
else
|
||||
sed -i "s|\(iconBackground\">\).*\(</color>\)|\1$BACKGROUND\2|" $COLORS
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -26,5 +26,5 @@ public class $ANDROID_CLASS extends SDLActivity {
|
|||
}
|
||||
}"
|
||||
|
||||
mkdir -p $ANDROID_CLASS_DIR
|
||||
echo $ANDROID_CLASS_SRC > $ANDROID_CLASS_DIR/$ANDROID_CLASS.java
|
||||
mkdir -p "$ANDROID_CLASS_DIR"
|
||||
echo "$ANDROID_CLASS_SRC" > "$ANDROID_CLASS_DIR/$ANDROID_CLASS.java"
|
||||
|
|
|
@ -18,25 +18,25 @@ ANDROID_MANIFEST=$3
|
|||
ANDROID_APP_MK=$4
|
||||
ANDROID_MK=$5
|
||||
ANDROID_CLASS=$6
|
||||
ANDROID_APP_NAME="Fill Screen Test"
|
||||
ANDROID_MIN_TARGET=18
|
||||
ANDROID_NDK="22.1.7171670"
|
||||
ANDROID_APP_NAME=$7
|
||||
ANDROID_MIN_TARGET=$8
|
||||
ANDROID_NDK=$9
|
||||
|
||||
sed -i s/org.libsdl.app/$ANDROID_PACKAGE/ $ANDROID_BUILD_DIR/app/build.gradle $ANDROID_BUILD_DIR/$ANDROID_MANIFEST
|
||||
sed -i "s/^#.*\(APP_STL\)/\1/" $ANDROID_BUILD_DIR/$ANDROID_APP_MK
|
||||
echo "APP_CPPFLAGS := -std=c++17 -fexceptions -frtti" >> $ANDROID_BUILD_DIR/$ANDROID_APP_MK
|
||||
sed -i -e 's/^LOCAL_LDLIBS.*/& -lGLESv3/' $ANDROID_BUILD_DIR/$ANDROID_MK
|
||||
sed -i 's/0x0002/0x0003/' $ANDROID_BUILD_DIR/$ANDROID_MANIFEST
|
||||
sed -i "s/\(minSdkVersion\).*16/\1 $ANDROID_MIN_TARGET/" $ANDROID_BUILD_DIR/app/build.gradle $ANDROID_BUILD_DIR/$ANDROID_APP_MK
|
||||
sed -i "s/\(android\)-16/\1-$ANDROID_MIN_TARGET/" $ANDROID_BUILD_DIR/app/build.gradle $ANDROID_BUILD_DIR/$ANDROID_APP_MK
|
||||
sed -i "11i\ ndkVersion \"$ANDROID_NDK\"" $ANDROID_BUILD_DIR/app/build.gradle
|
||||
sed -i 's/1536m/4096m/' $ANDROID_BUILD_DIR/gradle.properties
|
||||
sed -i "s/^#.*\(org.gradle.parallel\)/\1/" $ANDROID_BUILD_DIR/gradle.properties
|
||||
sed -i 's/^LOCAL_SHARED_LIBRARIES.*/& SDL2_image SDL2_mixer SDL2_ttf/' $ANDROID_BUILD_DIR/$ANDROID_MK
|
||||
sed -i "s/org.libsdl.app/$ANDROID_PACKAGE/" "$ANDROID_BUILD_DIR/app/build.gradle" "$ANDROID_BUILD_DIR/$ANDROID_MANIFEST"
|
||||
sed -i "s/^#.*\(APP_STL\)/\1/" "$ANDROID_BUILD_DIR/$ANDROID_APP_MK"
|
||||
echo "APP_CPPFLAGS := -std=c++17 -fexceptions -frtti" >> "$ANDROID_BUILD_DIR/$ANDROID_APP_MK"
|
||||
sed -i -e 's/^LOCAL_LDLIBS.*/& -lGLESv3/' "$ANDROID_BUILD_DIR/$ANDROID_MK"
|
||||
sed -i 's/0x0002/0x0003/' "$ANDROID_BUILD_DIR/$ANDROID_MANIFEST"
|
||||
sed -i "s/\(minSdkVersion\).*16/\1 $ANDROID_MIN_TARGET/" "$ANDROID_BUILD_DIR/app/build.gradle" "$ANDROID_BUILD_DIR/$ANDROID_APP_MK"
|
||||
sed -i "s/\(android\)-16/\1-$ANDROID_MIN_TARGET/" "$ANDROID_BUILD_DIR/app/build.gradle" "$ANDROID_BUILD_DIR/$ANDROID_APP_MK"
|
||||
sed -i "11i\ ndkVersion \"$ANDROID_NDK\"" "$ANDROID_BUILD_DIR/app/build.gradle"
|
||||
sed -i 's/1536m/4096m/' "$ANDROID_BUILD_DIR/gradle.properties"
|
||||
sed -i "s/^#.*\(org.gradle.parallel\)/\1/" "$ANDROID_BUILD_DIR/gradle.properties"
|
||||
sed -i 's/^LOCAL_SHARED_LIBRARIES.*/& SDL2_image SDL2_mixer SDL2_ttf/' "$ANDROID_BUILD_DIR/$ANDROID_MK"
|
||||
sed -i 's#^LOCAL_C_INCLUDES.*#& $(LOCAL_PATH)/../../../../../../../../lib $(LOCAL_PATH)/../../../../../../../../src#' \
|
||||
$ANDROID_BUILD_DIR/$ANDROID_MK
|
||||
sed -i 's#YourSourceHere.c#$(LOCAL_PATH)/../../../../../../fill_screen.cpp#' $ANDROID_BUILD_DIR/$ANDROID_MK
|
||||
sed -i 's#^LOCAL_SRC_FILES.*#& $(wildcard $(LOCAL_PATH)/../../../../../../../../src/*.cpp)#' $ANDROID_BUILD_DIR/$ANDROID_MK
|
||||
sed -i 's#^LOCAL_SRC_FILES.*#& $(wildcard $(LOCAL_PATH)/../../../../../../../../lib/sdl2-gfx/*.c)#' $ANDROID_BUILD_DIR/$ANDROID_MK
|
||||
sed -i "s/\(name=\)\"SDLActivity\"/\1\"$ANDROID_CLASS\"/" $ANDROID_BUILD_DIR/$ANDROID_MANIFEST
|
||||
sed -i "s/Game/$ANDROID_APP_NAME/" $ANDROID_BUILD_DIR/app/src/main/res/values/strings.xml
|
||||
"$ANDROID_BUILD_DIR/$ANDROID_MK"
|
||||
sed -i 's#YourSourceHere.c#$(LOCAL_PATH)/../../../../../../fill_screen.cpp#' "$ANDROID_BUILD_DIR/$ANDROID_MK"
|
||||
sed -i 's#^LOCAL_SRC_FILES.*#& $(wildcard $(LOCAL_PATH)/../../../../../../../../src/*.cpp)#' "$ANDROID_BUILD_DIR/$ANDROID_MK"
|
||||
sed -i 's#^LOCAL_SRC_FILES.*#& $(wildcard $(LOCAL_PATH)/../../../../../../../../lib/sdl2-gfx/*.c)#' "$ANDROID_BUILD_DIR/$ANDROID_MK"
|
||||
sed -i "s/\(name=\)\"SDLActivity\"/\1\"$ANDROID_CLASS\"/" "$ANDROID_BUILD_DIR/$ANDROID_MANIFEST"
|
||||
sed -i "s/Game/$ANDROID_APP_NAME/" "$ANDROID_BUILD_DIR/app/src/main/res/values/strings.xml"
|
||||
|
|
Loading…
Reference in New Issue