forked from phonegap/phonegap
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proof of concept application as template, added acceleromter, and min…
…or tweaks all around
- Loading branch information
Ryan Willoughby
authored and
Joe Bowser
committed
Nov 4, 2009
1 parent
1b47542
commit 0f60329
Showing
8 changed files
with
256 additions
and
35 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,74 @@ | ||
/** | ||
* Asynchronously aquires the current acceleration. | ||
* @param {Function} successCallback The function to call when the acceleration | ||
* data is available | ||
* @param {Function} errorCallback The function to call when there is an error | ||
* getting the acceleration data. | ||
* @param {AccelerationOptions} options The options for getting the accelerometer data | ||
* such as timeout. | ||
*/ | ||
|
||
Accelerometer.prototype.getCurrentAcceleration = function(successCallback, errorCallback, options) { | ||
// If the acceleration is available then call success | ||
// If the acceleration is not available then call error | ||
|
||
if (!this.serviceObj) | ||
this.serviceObj = InitializeAccelerationServiceObject(); | ||
|
||
//get the sensor channel | ||
var SensorParams = { SearchCriterion : "AccelerometerAxis" }; | ||
var returnvalue = this.serviceObj.ISensor.FindSensorChannel(SensorParams); | ||
|
||
var error = returnvalue["ErrorCode"]; | ||
var errmsg = returnvalue["ErrorMessage"]; | ||
if( !(error == 0 || error == 1012) ) | ||
{ | ||
var ex = { name: "Unable to find Sensor Channel: " + error, message: errmsg }; | ||
errorCallback(ex); | ||
} | ||
var channelInfoMap = returnvalue["ReturnValue"][0]; | ||
var criteria = { ChannelInfoMap: channelInfoMap, ListeningType: "ChannelData" }; | ||
|
||
if (typeof(successCallback) != 'function') | ||
successCallback = function() {}; | ||
if (typeof(errorCallback) != 'function') | ||
errorCallback = function() {}; | ||
|
||
this.success_callback = successCallback; | ||
this.error_callback = errorCallback; | ||
|
||
//create a closure to persist this instance of Accelerometer into the RegisterForNofication callback | ||
var obj = this; | ||
|
||
this.serviceObj.ISensor.RegisterForNotification(criteria, function(transId, eventCode, result){ | ||
var criteria = { TransactionID: transId }; | ||
try { | ||
obj.serviceObj.ISensor.Cancel(criteria); | ||
|
||
var accel = new Acceleration(result.ReturnValue.XAxisData, result.ReturnValue.YAxisData, result.ReturnValue.ZAxisData); | ||
Accelerometer.lastAcceleration = accel; | ||
|
||
obj.success_callback(accel); | ||
|
||
} catch (ex) { | ||
obj.serviceObj.ISensor.Cancel(criteria); | ||
alert("accel listener - " + ex.name + ": " + ex.message); | ||
obj.error_callback(ex); | ||
} | ||
|
||
}); | ||
|
||
} | ||
|
||
//gets the Acceleration Service Object from WRT | ||
function InitializeAccelerationServiceObject() { | ||
var so; | ||
|
||
try { | ||
so = device.getServiceObject("Service.Sensor", "ISensor"); | ||
} catch (ex) { | ||
alert('Error: failed to load acceleration service: ' + ex.name + " " + ex.message); | ||
return null; | ||
} | ||
return so; | ||
} |
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 @@ | ||
/** | ||
* | ||
* @param {Function} successCallback | ||
* @param {Function} errorCallback | ||
* @param {Object} options | ||
*/ | ||
Camera.prototype.getPicture = function(successCallback, errorCallback, options) { | ||
|
||
} |
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
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,8 @@ | ||
/** | ||
* @author ryan | ||
* @description hide the main menu bar | ||
*/ | ||
|
||
PhoneGap.addConstructor(function() { | ||
menu.hideSoftkeys(); | ||
}); |
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
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,45 @@ | ||
body { | ||
width: 340px; | ||
height: 620px; | ||
font-family: Helvetica; | ||
margin: 0px; | ||
padding: 0px 10px; | ||
font-size: 16pt; | ||
} | ||
|
||
.header { | ||
width: 100%; | ||
text-align: center; | ||
margin: 20px 0px; | ||
font-size: 27pt; | ||
} | ||
|
||
.list { | ||
width: 100%; | ||
border: 1px solid black; | ||
} | ||
|
||
.list-item { | ||
padding: 8px 2px; | ||
} | ||
|
||
.list-item-small { | ||
font-size: 12pt; | ||
padding-top: 3px; | ||
float: right; | ||
} | ||
|
||
.contacts { | ||
width: 100%; | ||
height: 245px; | ||
overflow: auto; | ||
border: 1px solid black; | ||
} | ||
|
||
.nitobi-logo { | ||
position: absolute; | ||
bottom: 10px; | ||
right: 10px; | ||
height: 35px; | ||
width: 35px; | ||
} |