forked from sintaxi/phonegap
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
stevengill
committed
Oct 1, 2011
1 parent
de7a616
commit d1dad1f
Showing
594 changed files
with
188,154 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! /bin/sh | ||
# | ||
# create a phonegap/android project | ||
# | ||
# USAGE | ||
# ./create [path package activity] | ||
# | ||
|
||
# load up the config | ||
. ./.phonegap/config | ||
|
||
PACKAGE_AS_PATH=$(echo $PACKAGE | sed 's/\./\//g') | ||
ACTIVITY_PATH=./src/$PACKAGE_AS_PATH/$ACTIVITY.java | ||
MANIFEST_PATH=./AndroidManifest.xml | ||
|
||
# create the project | ||
android create project --target $TARGET --path . --package $PACKAGE --activity $ACTIVITY | ||
|
||
# copy all the phonegap scripts etc in there | ||
cp -R ./phonegap/templates/project/ . | ||
|
||
# copy in phonegap.js | ||
cp ./.phonegap/android/phonegap-$VERSION.js ./assets/www | ||
|
||
# copy in phonegap.jar | ||
cp ./.phonegap/android/phonegap-$VERSION.jar ./libs | ||
|
||
# copy in default activity | ||
cat ./phonegap/templates/Activity.java > $ACTIVITY_PATH | ||
|
||
# interpolate the acivity name and package | ||
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 "$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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#! /bin/sh | ||
|
||
. ./.phonegap/config | ||
|
||
# if there are no devices listed then emulate | ||
|
||
|
||
ant debug install | ||
adb shell am start -n $PACKAGE/$PACKAGE.$ACTIVITY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#! /bin/sh | ||
|
||
#Available Android Virtual Devices: | ||
# Name: default | ||
# Path: /Users/davejohnson/.android/avd/default.avd | ||
# Target: Android 2.2 (API level 8) | ||
# Skin: WVGA800 | ||
# Sdcard: 100M | ||
|
||
# get the name of the first virtual device or use command line arg or use "default" | ||
|
||
emulator -cpu-delay 0 -no-boot-anim -cache ./tmp/cache -avd default > /dev/null 2>&1 & # put the avd's chatty ass in the background |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /bin/sh | ||
|
||
adb logcat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package __ID__; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import com.phonegap.*; | ||
|
||
public class __ACTIVITY__ extends DroidGap | ||
{ | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) | ||
{ | ||
super.onCreate(savedInstanceState); | ||
super.loadUrl("file:///android_asset/www/index.html"); | ||
} | ||
} | ||
|
50 changes: 50 additions & 0 deletions
50
Android/Sample/phonegap/templates/project/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="__ACTIVITY__" 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="com.phonegap.DroidGap" android:label="@string/app_name" | ||
android:configChanges="orientation|keyboardHidden"> | ||
<intent-filter> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
<uses-sdk android:minSdkVersion="5" /> | ||
</manifest> |
38 changes: 38 additions & 0 deletions
38
Android/Sample/phonegap/templates/project/assets/www/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=320; user-scalable=no" /> | ||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | ||
<title>PhoneGap</title> | ||
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8"> | ||
<script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script> | ||
<script type="text/javascript" charset="utf-8" src="main.js"></script> | ||
|
||
</head> | ||
<body onload="init();" id="stage" class="theme"> | ||
<h1>Welcome to PhoneGap!</h1> | ||
<h2>this file is located at assets/www/index.html</h2> | ||
<div id="info"> | ||
<h4>Platform: <span id="platform"> </span>, Version: <span id="version"> </span></h4> | ||
<h4>UUID: <span id="uuid"> </span>, Name: <span id="name"> </span></h4> | ||
<h4>Width: <span id="width"> </span>, Height: <span id="height"> | ||
</span>, Color Depth: <span id="colorDepth"></span></h4> | ||
</div> | ||
<dl id="accel-data"> | ||
<dt>X:</dt><dd id="x"> </dd> | ||
<dt>Y:</dt><dd id="y"> </dd> | ||
<dt>Z:</dt><dd id="z"> </dd> | ||
</dl> | ||
<a href="#" class="btn large" onclick="toggleAccel();">Toggle Accelerometer</a> | ||
<a href="#" class="btn large" onclick="getLocation();">Get Location</a> | ||
<a href="tel:411" class="btn large">Call 411</a> | ||
<a href="#" class="btn large" onclick="beep();">Beep</a> | ||
<a href="#" class="btn large" onclick="vibrate();">Vibrate</a> | ||
<a href="#" class="btn large" onclick="show_pic();">Get a Picture</a> | ||
<a href="#" class="btn large" onclick="get_contacts();">Get Phone's Contacts</a> | ||
<a href="#" class="btn large" onclick="check_network();">Check Network</a> | ||
<div id="viewport" class="viewport" style="display: none;"> | ||
<img style="width:60px;height:60px" id="test_img" src="" /> | ||
</div> | ||
</body> | ||
</html> |
127 changes: 127 additions & 0 deletions
127
Android/Sample/phonegap/templates/project/assets/www/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
var deviceInfo = function() { | ||
document.getElementById("platform").innerHTML = device.platform; | ||
document.getElementById("version").innerHTML = device.version; | ||
document.getElementById("uuid").innerHTML = device.uuid; | ||
document.getElementById("name").innerHTML = device.name; | ||
document.getElementById("width").innerHTML = screen.width; | ||
document.getElementById("height").innerHTML = screen.height; | ||
document.getElementById("colorDepth").innerHTML = screen.colorDepth; | ||
}; | ||
|
||
var getLocation = function() { | ||
var suc = function(p) { | ||
alert(p.coords.latitude + " " + p.coords.longitude); | ||
}; | ||
var locFail = function() { | ||
}; | ||
navigator.geolocation.getCurrentPosition(suc, locFail); | ||
}; | ||
|
||
var beep = function() { | ||
navigator.notification.beep(2); | ||
}; | ||
|
||
var vibrate = function() { | ||
navigator.notification.vibrate(0); | ||
}; | ||
|
||
function roundNumber(num) { | ||
var dec = 3; | ||
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec); | ||
return result; | ||
} | ||
|
||
var accelerationWatch = null; | ||
|
||
function updateAcceleration(a) { | ||
document.getElementById('x').innerHTML = roundNumber(a.x); | ||
document.getElementById('y').innerHTML = roundNumber(a.y); | ||
document.getElementById('z').innerHTML = roundNumber(a.z); | ||
} | ||
|
||
var toggleAccel = function() { | ||
if (accelerationWatch !== null) { | ||
navigator.accelerometer.clearWatch(accelerationWatch); | ||
updateAcceleration({ | ||
x : "", | ||
y : "", | ||
z : "" | ||
}); | ||
accelerationWatch = null; | ||
} else { | ||
var options = {}; | ||
options.frequency = 1000; | ||
accelerationWatch = navigator.accelerometer.watchAcceleration( | ||
updateAcceleration, function(ex) { | ||
alert("accel fail (" + ex.name + ": " + ex.message + ")"); | ||
}, options); | ||
} | ||
}; | ||
|
||
var preventBehavior = function(e) { | ||
e.preventDefault(); | ||
}; | ||
|
||
function dump_pic(data) { | ||
var viewport = document.getElementById('viewport'); | ||
console.log(data); | ||
viewport.style.display = ""; | ||
viewport.style.position = "absolute"; | ||
viewport.style.top = "10px"; | ||
viewport.style.left = "10px"; | ||
document.getElementById("test_img").src = "data:image/jpeg;base64," + data; | ||
} | ||
|
||
function fail(msg) { | ||
alert(msg); | ||
} | ||
|
||
function show_pic() { | ||
navigator.camera.getPicture(dump_pic, fail, { | ||
quality : 50 | ||
}); | ||
} | ||
|
||
function close() { | ||
var viewport = document.getElementById('viewport'); | ||
viewport.style.position = "relative"; | ||
viewport.style.display = "none"; | ||
} | ||
|
||
function contacts_success(contacts) { | ||
alert(contacts.length | ||
+ ' contacts returned.' | ||
+ (contacts[2] && contacts[2].name ? (' Third contact is ' + contacts[2].name.formatted) | ||
: '')); | ||
} | ||
|
||
function get_contacts() { | ||
var obj = new ContactFindOptions(); | ||
obj.filter = ""; | ||
obj.multiple = true; | ||
navigator.contacts.find( | ||
[ "displayName", "name" ], contacts_success, | ||
fail, obj); | ||
} | ||
|
||
function check_network() { | ||
var networkState = navigator.network.connection.type; | ||
|
||
var states = {}; | ||
states[Connection.UNKNOWN] = 'Unknown connection'; | ||
states[Connection.ETHERNET] = 'Ethernet connection'; | ||
states[Connection.WIFI] = 'WiFi connection'; | ||
states[Connection.CELL_2G] = 'Cell 2G connection'; | ||
states[Connection.CELL_3G] = 'Cell 3G connection'; | ||
states[Connection.CELL_4G] = 'Cell 4G connection'; | ||
states[Connection.NONE] = 'No network connection'; | ||
|
||
confirm('Connection type:\n ' + states[networkState]); | ||
} | ||
|
||
function init() { | ||
// the next line makes it impossible to see Contacts on the HTC Evo since it | ||
// doesn't have a scroll button | ||
// document.addEventListener("touchmove", preventBehavior, false); | ||
document.addEventListener("deviceready", deviceInfo, true); | ||
} |
96 changes: 96 additions & 0 deletions
96
Android/Sample/phonegap/templates/project/assets/www/master.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
body { | ||
background:#222 none repeat scroll 0 0; | ||
color:#666; | ||
font-family:Helvetica; | ||
font-size:72%; | ||
line-height:1.5em; | ||
margin:0; | ||
border-top:1px solid #393939; | ||
} | ||
|
||
#info{ | ||
background:#ffa; | ||
border: 1px solid #ffd324; | ||
-webkit-border-radius: 5px; | ||
border-radius: 5px; | ||
clear:both; | ||
margin:15px 6px 0; | ||
width:295px; | ||
padding:4px 0px 2px 10px; | ||
} | ||
|
||
#info > h4{ | ||
font-size:.95em; | ||
margin:5px 0; | ||
} | ||
|
||
#stage.theme{ | ||
padding-top:3px; | ||
} | ||
|
||
/* Definition List */ | ||
#stage.theme > dl{ | ||
padding-top:10px; | ||
clear:both; | ||
margin:0; | ||
list-style-type:none; | ||
padding-left:10px; | ||
overflow:auto; | ||
} | ||
|
||
#stage.theme > dl > dt{ | ||
font-weight:bold; | ||
float:left; | ||
margin-left:5px; | ||
} | ||
|
||
#stage.theme > dl > dd{ | ||
width:45px; | ||
float:left; | ||
color:#a87; | ||
font-weight:bold; | ||
} | ||
|
||
/* Content Styling */ | ||
#stage.theme > h1, #stage.theme > h2, #stage.theme > p{ | ||
margin:1em 0 .5em 13px; | ||
} | ||
|
||
#stage.theme > h1{ | ||
color:#eee; | ||
font-size:1.6em; | ||
text-align:center; | ||
margin:0; | ||
margin-top:15px; | ||
padding:0; | ||
} | ||
|
||
#stage.theme > h2{ | ||
clear:both; | ||
margin:0; | ||
padding:3px; | ||
font-size:1em; | ||
text-align:center; | ||
} | ||
|
||
/* Stage Buttons */ | ||
#stage.theme a.btn{ | ||
border: 1px solid #555; | ||
-webkit-border-radius: 5px; | ||
border-radius: 5px; | ||
text-align:center; | ||
display:block; | ||
float:left; | ||
background:#444; | ||
width:150px; | ||
color:#9ab; | ||
font-size:1.1em; | ||
text-decoration:none; | ||
padding:1.2em 0; | ||
margin:3px 0px 3px 5px; | ||
} | ||
#stage.theme a.btn.large{ | ||
width:308px; | ||
padding:1.2em 0; | ||
} | ||
|
Oops, something went wrong.