Android pkg now supports icons through --apk-icon. #3

This commit is contained in:
Antonin Décimo
2014-09-20 00:28:03 +02:00
parent de470cb930
commit 02f1738297
5 changed files with 93 additions and 27 deletions

View File

@@ -96,6 +96,12 @@ it will automatically detect which version your project uses.
#### ANDROID
Note that every argument passed to the options should be alphanumerical,
with eventual underscores (i.e. [a-zA-Z0-9\_]), otherwise you'll get errors.
`--apk-icon` Path to a single folder where icons are stored.
The script will first look up for filename that contains
`42x42`, `72x72`, `96x96` or `144x144`.
It will then search the icon directory for subdirectories like
`drawable-mdpi`, `drawable-hdpi`, `drawable-xhdpi` and `drawable-xxhdpi`
to find an `ic_launcher.png` image.
`--activity` The name of the class that extends GameActivity.
By default it is the name of the project with Activity appended,
eventual spaces and dashes replaced by underscores.

View File

@@ -9,7 +9,7 @@ _love-release()
opts="-l"
opts="$opts -w --win-icon"
opts="$opts -d --deb-icon --deb-package-version --deb-maintainer-name --maintainer-email --deb-package-name"
opts="$opts -a --activity --apk-package-version --apk-maintainer-name --apk-package-name --update-android"
opts="$opts -a --apk-icon --activity --apk-package-version --apk-maintainer-name --apk-package-name --update-android"
opts="$opts -m --osx-icon --osx-maintainer-name"
opts="$opts -h -n -r -v -x --config --homepage --description --clean --help"

View File

@@ -121,6 +121,14 @@ Set the version of your package.
Note that every argument passed to the options should be alphanumerical,
with eventual underscores (i.e. [a-zA-Z0-9_]), otherwise you'll get errors.
.TP
.B \-\-apk\-icon \fIdir\fR
Path to a single folder where icons are stored.
The script will first look up for filename that contains
\fI42x42\fR, \fI72x72\fR, \fI96x96\fR or \fI144x144\fR.
It will then search the icon directory for subdirectories like
\fIdrawable-mdpi\fR, \fIdrawable-hdpi\fR, \fIdrawable-xhdpi\fR and \fIdrawable-xxhdpi\fR
to find an \fIic_launcher.png\fR image.
.TP
.B \-\-activity \fIactivity\fR
The name of the class that extends GameActivity.
By default it is the name of the project with 'Activity' appended,

View File

@@ -23,15 +23,15 @@ SCRIPT_ARGS="w. win-icon: $SCRIPT_ARGS"
SCRIPT_ARGS="d; deb-icon: deb-package-version: deb-maintainer-name: maintainer-email: deb-package-name: $SCRIPT_ARGS"
## Android
SCRIPT_ARGS="a; activity: apk-package-version: apk-maintainer-name: apk-package-name: update-android; $SCRIPT_ARGS"
SCRIPT_ARGS="a; apk-icon: activity: apk-package-version: apk-maintainer-name: apk-package-name: update-android; $SCRIPT_ARGS"
## Mac OS X
SCRIPT_ARGS="m; osx-icon: osx-maintainer-name: $SCRIPT_ARGS"
## List the options that require a file/directory that should be excluded by zip.
EXCLUDE_OPTIONS=("win-icon" "osx-icon" "deb-icon")
EXCLUDE_CONFIG=("INI__windows__icon" "INI__macosx__icon" "INI__debian__icon")
EXCLUDE_OPTIONS=("win-icon" "osx-icon" "deb-icon" "apk-icon")
EXCLUDE_CONFIG=("INI__windows__icon" "INI__macosx__icon" "INI__debian__icon" "INI__android__icon")
## Add a short summary of your platform script here

View File

@@ -19,6 +19,11 @@ if [ "$CONFIG" = true ]; then
if [ -n "${INI__android__maintainer_name}" ]; then
MAINTAINER_NAME=${INI__android__maintainer_name}
fi
if [ -n "${INI__android__icon}" ]; then
IFS=$'\n'
ICON_DIR=${INI__android__icon}
ICON_FILES=( $(ls -AC1 "$ICON_DIR") )
fi
fi
@@ -28,6 +33,10 @@ do
if [ "$OPTOPT" = "activity" ]; then
ACTIVITY=$OPTARG
activity_defined_argument=true
elif [ "$OPTOPT" = "apk-icon" ]; then
IFS=$'\n'
ICON_DIR=$OPTARG
ICON_FILES=( $(ls -AC1 "$ICON_DIR") )
elif [ "$OPTOPT" = "apk-package-version" ]; then
PACKAGE_VERSION=$OPTARG
elif [ "$OPTOPT" = "apk-maintainer-name" ]; then
@@ -91,9 +100,9 @@ ANDROID_VERSION=$(grep -Eo -m 1 "[0-9]+.[0-9]+.[0-9]+[a-z]*" "$LOVE_ANDROID_DIR"
ANDROID_LOVE_VERSION=$(echo "$ANDROID_VERSION" | grep -Eo "[0-9]+.[0-9]+.[0-9]+")
if [ "$LOVE_VERSION" != "$ANDROID_LOVE_VERSION" ]; then
echo "Love version ($LOVE_VERSION) differs from love-android-sdl2 version ($ANDROID_LOVE_VERSION). Could not create package."
exit_module 1 "Love version ($LOVE_VERSION) differs from love-android-sdl2 version ($ANDROID_LOVE_VERSION). Could not create package."
fi
else
mkdir -p "$LOVE_ANDROID_DIR"/assets
cp "$LOVE_FILE" "$LOVE_ANDROID_DIR"/assets/game.love
cd "$LOVE_ANDROID_DIR"
@@ -110,10 +119,53 @@ else
public class $ACTIVITY extends GameActivity {}
" > src/com/$MAINTAINER_NAME/$PACKAGE_NAME/${ACTIVITY}.java
if [ -n "$ICON_DIR" ]; then
for ICON in "${ICON_FILES[@]}"
do
RES=$(echo "$ICON" | grep -Eo "[0-9]+x[0-9]+")
EXT=$(echo "$ICON" | sed -e 's/.*\.//g')
if [ "$RES" = "42x42" ]; then
cp "$PROJECT_DIR"/"$ICON_DIR"/"$ICON" \
"$LOVE_ANDROID_DIR"/res/drawable-mdpi/ic_launcher.png
echo "HERE"
elif [ "$RES" = "72x72" ]; then
cp "$PROJECT_DIR"/"$ICON_DIR"/"$ICON" \
"$LOVE_ANDROID_DIR"/res/drawable-hdpi/ic_launcher.png
elif [ "$RES" = "96x96" ]; then
cp "$PROJECT_DIR"/"$ICON_DIR"/"$ICON" \
"$LOVE_ANDROID_DIR"/res/drawable-xhdpi/ic_launcher.png
elif [ "$RES" = "144x144" ]; then
cp "$PROJECT_DIR"/"$ICON_DIR"/"$ICON" \
"$LOVE_ANDROID_DIR"/res/drawable-xxhdpi/ic_launcher.png
fi
done
if [ -f "$PROJECT_DIR/$ICON_DIR/drawable-mdpi/ic_launcher.png" ]; then
cp "$PROJECT_DIR"/"$ICON_DIR"/drawable-mdpi/ic_launcher.png \
"$LOVE_ANDROID_DIR"/res/drawable-mdpi/ic_launcher.png
fi
if [ -f "$PROJECT_DIR/$ICON_DIR/drawable-hdpi/ic_launcher.png" ]; then
cp "$PROJECT_DIR"/"$ICON_DIR"/drawable-hdpi/ic_launcher.png \
"$LOVE_ANDROID_DIR"/res/drawable-hdpi/ic_launcher.png
echo "THERE"
fi
if [ -f "$PROJECT_DIR/$ICON_DIR/drawable-xhdpi/ic_launcher.png" ]; then
cp "$PROJECT_DIR"/"$ICON_DIR"/drawable-xhdpi/ic_launcher.png \
"$LOVE_ANDROID_DIR"/res/drawable-xhdpi/ic_launcher.png
fi
if [ -f "$PROJECT_DIR/$ICON_DIR/drawable-xxhdpi/ic_launcher.png" ]; then
cp "$PROJECT_DIR"/"$ICON_DIR"/drawable-xxhdpi/ic_launcher.png \
"$LOVE_ANDROID_DIR"/res/drawable-xxhdpi/ic_launcher.png
fi
fi
ant debug
cp bin/love_android_sdl2-debug.apk "$RELEASE_DIR"
git checkout -- .
rm -rf src/com bin gen
cd "$RELEASE_DIR"
fi
unset ACTIVITY PACKAGE_NAME PACKAGE_VERSION MAINTAINER_NAME