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 @@ - - - - - - - - - - - - - -