mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
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:
parent
1c064b0922
commit
8cf00fc788
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,3 +11,5 @@ framework/assets/www/.DS_Store
|
||||
framework/assets/www/phonegap-*.js
|
||||
example
|
||||
test
|
||||
tmp
|
||||
*.tmp
|
20
bin/create
20
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 '</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
|
||||
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
|
50
bin/templates/project/AndroidManifest.xml
Normal file
50
bin/templates/project/AndroidManifest.xml
Normal 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>
|
0
bin/templates/plugins.xml → bin/templates/project/res/xml/plugins.xml
Executable file → Normal file
0
bin/templates/plugins.xml → bin/templates/project/res/xml/plugins.xml
Executable file → Normal 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" />
|
Loading…
Reference in New Issue
Block a user