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

This commit is contained in:
davejohnson 2011-08-20 13:27:53 -07:00
parent 1c064b0922
commit 8cf00fc788
8 changed files with 61 additions and 25 deletions

2
.gitignore vendored
View File

@ -11,3 +11,5 @@ framework/assets/www/.DS_Store
framework/assets/www/phonegap-*.js framework/assets/www/phonegap-*.js
example example
test test
tmp
*.tmp

View File

@ -10,6 +10,7 @@ PACKAGE=${2:-"com.phonegap.example"}
ACTIVITY=${3:-"PhoneGapExample"} ACTIVITY=${3:-"PhoneGapExample"}
PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g') PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g')
ACTIVITY_PATH=$PROJECT_PATH/src/$PACKAGE_AS_PATH/$ACTIVITY.java 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) TARGET=$(android list targets | grep 'id: ' | sed 's/id: \([0-9]\).*/\1/g' | tail -1)
VERSION=$(cat ./VERSION) VERSION=$(cat ./VERSION)
@ -19,14 +20,17 @@ then
rm -rf $PROJECT_PATH rm -rf $PROJECT_PATH
fi fi
# update the phonegap-android framework for the desired target
android update project --target $TARGET --path ./framework
# compile phonegap.js and phonegap.jar # compile phonegap.js and phonegap.jar
cd ./framework && ant jar && cd ../ cd ./framework && ant jar && cd ../
# create the project # create the project
android create project --target $TARGET --path $PROJECT_PATH --package $PACKAGE --activity $ACTIVITY android create project --target $TARGET --path $PROJECT_PATH --package $PACKAGE --activity $ACTIVITY
# copy in www # copy in all default project files (plugins.xml, manifest, www etc)
mkdir -p $PROJECT_PATH/assets && cp -r ./bin/templates/www $PROJECT_PATH/assets/www cp -r ./bin/templates/project $PROJECT_PATH
# copy in phonegap.js # copy in phonegap.js
cp ./framework/assets/www/phonegap-$VERSION.js $PROJECT_PATH/assets/www/phonegap-$VERSION.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 '__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" find "$ACTIVITY_PATH" | xargs grep '__ID__' -sl | xargs -L1 sed -i "" "s/__ID__/${PACKAGE}/g"
# copy in uses-permission elements find "$MANIFEST_PATH" | xargs grep '__ACTIVITY__' -sl | xargs -L1 sed -i "" "s/__ACTIVITY__/${ACTIVITY}/g"
sed '$d' < $PROJECT_PATH/AndroidManifest.xml > tmpFile ; mv tmpFile $PROJECT_PATH/AndroidManifest.xml find "$MANIFEST_PATH" | xargs grep '__PACKAGE__' -sl | xargs -L1 sed -i "" "s/__PACKAGE__/${PACKAGE}/g"
cat ./bin/templates/uses-permission-elements >> $PROJECT_PATH/AndroidManifest.xml
echo '</manifest>' >> $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
# leave the id for launching # leave the id for launching
touch $PROJECT_PATH/package-activity touch $PROJECT_PATH/package-activity
echo $PACKAGE/$PACKAGE.$ACTIVITY > $PROJECT_PATH/package-activity echo $PACKAGE/$PACKAGE.$ACTIVITY > $PROJECT_PATH/package-activity

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
package="__PACKAGE__" android:versionName="1.1" android:versionCode="5">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">
<activity android:name=".StandAlone" android:windowSoftInputMode="adjustPan"
android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="__ACTIVITY__" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="5" />
</manifest>

View File

@ -1,14 +0,0 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />