From 8cf00fc7883102e709619ca25a1ef1b8b4a4170d Mon Sep 17 00:00:00 2001 From: davejohnson Date: Sat, 20 Aug 2011 13:27:53 -0700 Subject: [PATCH] Moved default plugins.xml, www, and manifest.xml into a folder structure that can be straight copied over a new android project. change the bash script to update the target of the phonegap framework dir before building --- .gitignore | 2 + bin/create | 20 ++++---- bin/templates/project/AndroidManifest.xml | 50 +++++++++++++++++++ .../{ => project/assets}/www/index.html | 0 .../{ => project/assets}/www/main.js | 0 .../{ => project/assets}/www/master.css | 0 .../{ => project/res/xml}/plugins.xml | 0 bin/templates/uses-permission-elements | 14 ------ 8 files changed, 61 insertions(+), 25 deletions(-) create mode 100644 bin/templates/project/AndroidManifest.xml rename bin/templates/{ => project/assets}/www/index.html (100%) rename bin/templates/{ => project/assets}/www/main.js (100%) rename bin/templates/{ => project/assets}/www/master.css (100%) rename bin/templates/{ => project/res/xml}/plugins.xml (100%) mode change 100755 => 100644 delete mode 100644 bin/templates/uses-permission-elements diff --git a/.gitignore b/.gitignore index 98ecdb28..0d47668d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ framework/assets/www/.DS_Store framework/assets/www/phonegap-*.js example test +tmp +*.tmp \ No newline at end of file diff --git a/bin/create b/bin/create index 502e831e..a97486e0 100755 --- a/bin/create +++ b/bin/create @@ -10,6 +10,7 @@ PACKAGE=${2:-"com.phonegap.example"} ACTIVITY=${3:-"PhoneGapExample"} PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g') ACTIVITY_PATH=$PROJECT_PATH/src/$PACKAGE_AS_PATH/$ACTIVITY.java +MANIFEST_PATH=$PROJECT_PATH/AndroidManifest.xml TARGET=$(android list targets | grep 'id: ' | sed 's/id: \([0-9]\).*/\1/g' | tail -1) VERSION=$(cat ./VERSION) @@ -19,14 +20,17 @@ then rm -rf $PROJECT_PATH fi +# update the phonegap-android framework for the desired target +android update project --target $TARGET --path ./framework + # compile phonegap.js and phonegap.jar cd ./framework && ant jar && cd ../ # create the project android create project --target $TARGET --path $PROJECT_PATH --package $PACKAGE --activity $ACTIVITY -# copy in www -mkdir -p $PROJECT_PATH/assets && cp -r ./bin/templates/www $PROJECT_PATH/assets/www +# copy in all default project files (plugins.xml, manifest, www etc) +cp -r ./bin/templates/project $PROJECT_PATH # copy in phonegap.js cp ./framework/assets/www/phonegap-$VERSION.js $PROJECT_PATH/assets/www/phonegap-$VERSION.js @@ -41,15 +45,9 @@ cat ./bin/templates/Activity.java > $ACTIVITY_PATH find "$ACTIVITY_PATH" | xargs grep '__ACTIVITY__' -sl | xargs -L1 sed -i "" "s/__ACTIVITY__/${ACTIVITY}/g" find "$ACTIVITY_PATH" | xargs grep '__ID__' -sl | xargs -L1 sed -i "" "s/__ID__/${PACKAGE}/g" -# copy in uses-permission elements -sed '$d' < $PROJECT_PATH/AndroidManifest.xml > tmpFile ; mv tmpFile $PROJECT_PATH/AndroidManifest.xml -cat ./bin/templates/uses-permission-elements >> $PROJECT_PATH/AndroidManifest.xml -echo '' >> $PROJECT_PATH/AndroidManifest.xml - -# copy in plugins.xml -mkdir -p $PROJECT_PATH/res/xml -cp ./bin/templates/plugins.xml $PROJECT_PATH/res/xml/plugins.xml +find "$MANIFEST_PATH" | xargs grep '__ACTIVITY__' -sl | xargs -L1 sed -i "" "s/__ACTIVITY__/${ACTIVITY}/g" +find "$MANIFEST_PATH" | xargs grep '__PACKAGE__' -sl | xargs -L1 sed -i "" "s/__PACKAGE__/${PACKAGE}/g" # leave the id for launching touch $PROJECT_PATH/package-activity -echo $PACKAGE/$PACKAGE.$ACTIVITY > $PROJECT_PATH/package-activity +echo $PACKAGE/$PACKAGE.$ACTIVITY > $PROJECT_PATH/package-activity \ No newline at end of file diff --git a/bin/templates/project/AndroidManifest.xml b/bin/templates/project/AndroidManifest.xml new file mode 100644 index 00000000..7f654257 --- /dev/null +++ b/bin/templates/project/AndroidManifest.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/templates/www/index.html b/bin/templates/project/assets/www/index.html similarity index 100% rename from bin/templates/www/index.html rename to bin/templates/project/assets/www/index.html diff --git a/bin/templates/www/main.js b/bin/templates/project/assets/www/main.js similarity index 100% rename from bin/templates/www/main.js rename to bin/templates/project/assets/www/main.js diff --git a/bin/templates/www/master.css b/bin/templates/project/assets/www/master.css similarity index 100% rename from bin/templates/www/master.css rename to bin/templates/project/assets/www/master.css diff --git a/bin/templates/plugins.xml b/bin/templates/project/res/xml/plugins.xml old mode 100755 new mode 100644 similarity index 100% rename from bin/templates/plugins.xml rename to bin/templates/project/res/xml/plugins.xml diff --git a/bin/templates/uses-permission-elements b/bin/templates/uses-permission-elements deleted file mode 100644 index 271e37d2..00000000 --- a/bin/templates/uses-permission-elements +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - -