You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/10/22 21:20:06 UTC
[08/16] android commit: [CB-4198] bin/create should handle spaces in
activity better.
[CB-4198] bin/create should handle spaces in activity better.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/624a8d37
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/624a8d37
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/624a8d37
Branch: refs/heads/2.9.x
Commit: 624a8d370cef21d9d6c1f991aba6f7ca3c97dd3e
Parents: 5814d66
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jul 24 21:21:41 2013 -0700
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Oct 22 15:12:03 2013 -0400
----------------------------------------------------------------------
bin/create | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/624a8d37/bin/create
----------------------------------------------------------------------
diff --git a/bin/create b/bin/create
index 4dfd20f..3883227 100755
--- a/bin/create
+++ b/bin/create
@@ -38,7 +38,8 @@ VERSION=$(cat "$BUILD_PATH"/VERSION)
PROJECT_PATH="${1:-'./example'}"
PACKAGE=${2:-"org.apache.cordova.example"}
-ACTIVITY=${3:-"cordovaExample"}
+ACTIVITY=$(echo ${3:-"cordovaExample"} | tr -d ' ')
+APP_LABEL=${3:-"Cordova Example"};
# clobber any existing example
if [ -d "$PROJECT_PATH" ]
@@ -67,7 +68,7 @@ function replace {
# Mac OS X requires -i argument
if [[ "$OSTYPE" =~ "darwin" ]]
then
- /usr/bin/sed -i '' -e $pattern "$filename"
+ /usr/bin/sed -i '' -e "$pattern" "$filename"
elif [[ "$OSTYPE" =~ "linux" ]]
then
/bin/sed -i -e $pattern "$filename"
@@ -82,6 +83,7 @@ ANDROID_BIN="${ANDROID_BIN:=$( which android )}"
PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g')
ACTIVITY_PATH="$PROJECT_PATH"/src/$PACKAGE_AS_PATH/$ACTIVITY.java
MANIFEST_PATH="$PROJECT_PATH"/AndroidManifest.xml
+STRINGS_PATH="$PROJECT_PATH"/res/values/strings.xml
TARGET=$("$ANDROID_BIN" list targets | grep id: | tail -1 | cut -f 2 -d ' ' )
API_LEVEL=$("$ANDROID_BIN" list target | grep "API level:" | tail -n 1 | cut -f 2 -d ':' | tr -d ' ')
@@ -129,6 +131,9 @@ cp "$BUILD_PATH"/bin/templates/project/Activity.java "$ACTIVITY_PATH"
replace "s/__ACTIVITY__/${ACTIVITY}/g" "$ACTIVITY_PATH"
replace "s/__ID__/${PACKAGE}/g" "$ACTIVITY_PATH"
+# interpolate the app name into strings.xml
+replace "s/>${ACTIVITY}</>${APP_LABEL}</g" "$STRINGS_PATH"
+
cp "$BUILD_PATH"/bin/templates/project/AndroidManifest.xml "$MANIFEST_PATH"
replace "s/__ACTIVITY__/${ACTIVITY}/g" "$MANIFEST_PATH"
replace "s/__PACKAGE__/${PACKAGE}/g" "$MANIFEST_PATH"