mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-04 00:13:20 +08:00
Merging current Nitobi repo code with the Video Code
This commit is contained in:
commit
6365d4fbd6
@ -1 +0,0 @@
|
|||||||
This file is used to ensure this subdirectory is created.
|
|
Binary file not shown.
@ -10,14 +10,14 @@
|
|||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
|
||||||
var deviceInfo = function(){
|
var deviceInfo = function(){
|
||||||
document.getElementById("platform").innerHTML = Device.platform;
|
document.getElementById("platform").innerHTML = device.platform;
|
||||||
document.getElementById("version").innerHTML = Device.version;
|
document.getElementById("version").innerHTML = device.version;
|
||||||
document.getElementById("uuid").innerHTML = Device.uuid;
|
document.getElementById("uuid").innerHTML = device.uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
var getLocation = function() {
|
var getLocation = function() {
|
||||||
var suc = function(p){
|
var suc = function(p){
|
||||||
alert(p.latitude + " " + p.longitude);
|
alert(p.coords.latitude + " " + p.coords.longitude);
|
||||||
};
|
};
|
||||||
var fail = function(){};
|
var fail = function(){};
|
||||||
navigator.geolocation.getCurrentPosition(suc,fail);
|
navigator.geolocation.getCurrentPosition(suc,fail);
|
||||||
|
@ -93,3 +93,7 @@
|
|||||||
width:308px;
|
width:308px;
|
||||||
padding:1.2em 0;
|
padding:1.2em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#viewport {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
@ -308,11 +308,21 @@ function Device() {
|
|||||||
this.gap = null;
|
this.gap = null;
|
||||||
this.uuid = null;
|
this.uuid = null;
|
||||||
try {
|
try {
|
||||||
|
<<<<<<< HEAD:android/assets/www/phonegap.js
|
||||||
if (window['DroidGap'] != undefined && window.DroidGap.exists()) {
|
if (window['DroidGap'] != undefined && window.DroidGap.exists()) {
|
||||||
this.available = true;
|
this.available = true;
|
||||||
this.isAndroid = true;
|
this.isAndroid = true;
|
||||||
this.uuid = window.DroidGap.getUuid();
|
this.uuid = window.DroidGap.getUuid();
|
||||||
this.gapVersion = window.DroidGap.getVersion();
|
this.gapVersion = window.DroidGap.getVersion();
|
||||||
|
=======
|
||||||
|
if (window.DroidGap) {
|
||||||
|
this.available = true;
|
||||||
|
this.uuid = window.DroidGap.getUuid();
|
||||||
|
this.version = window.DroidGap.getOSVersion();
|
||||||
|
this.gapVersion = window.DroidGap.getVersion();
|
||||||
|
this.platform = window.DroidGap.getPlatform();
|
||||||
|
this.name = window.DroidGap.getProductName();
|
||||||
|
>>>>>>> 4c08b34a81e55a3146e67a8ad2282b7082b640e0:android/assets/www/phonegap.js
|
||||||
} else {
|
} else {
|
||||||
this.platform = DeviceInfo.platform;
|
this.platform = DeviceInfo.platform;
|
||||||
this.version = DeviceInfo.version;
|
this.version = DeviceInfo.version;
|
||||||
@ -508,9 +518,12 @@ function Media(src) {
|
|||||||
this.src = src;
|
this.src = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD:android/assets/www/phonegap.js
|
||||||
Media.prototype.record = function() {
|
Media.prototype.record = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> 4c08b34a81e55a3146e67a8ad2282b7082b640e0:android/assets/www/phonegap.js
|
||||||
Media.prototype.play = function() {
|
Media.prototype.play = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,6 +690,7 @@ PhoneGap.addConstructor(function() {
|
|||||||
* @param {Object} vel
|
* @param {Object} vel
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
|
<<<<<<< HEAD:android/assets/www/phonegap.js
|
||||||
function Position(lat, lng, acc, alt, altacc, head, vel) {
|
function Position(lat, lng, acc, alt, altacc, head, vel) {
|
||||||
/**
|
/**
|
||||||
* The latitude of the position.
|
* The latitude of the position.
|
||||||
@ -910,8 +924,215 @@ var Device = {
|
|||||||
{
|
{
|
||||||
DroidGap.beep();
|
DroidGap.beep();
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
function Position(coords, timestamp) {
|
||||||
|
this.coords = coords;
|
||||||
|
this.timestamp = new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Coordinates(lat, lng, alt, acc, head, vel) {
|
||||||
|
/**
|
||||||
|
* The latitude of the position.
|
||||||
|
*/
|
||||||
|
this.latitude = lat;
|
||||||
|
/**
|
||||||
|
* The longitude of the position,
|
||||||
|
*/
|
||||||
|
this.longitude = lng;
|
||||||
|
/**
|
||||||
|
* The accuracy of the position.
|
||||||
|
*/
|
||||||
|
this.accuracy = acc;
|
||||||
|
/**
|
||||||
|
* The altitude of the position.
|
||||||
|
*/
|
||||||
|
this.altitude = alt;
|
||||||
|
/**
|
||||||
|
* The direction the device is moving at the position.
|
||||||
|
*/
|
||||||
|
this.heading = head;
|
||||||
|
/**
|
||||||
|
* The velocity with which the device is moving at the position.
|
||||||
|
*/
|
||||||
|
this.speed = vel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class specifies the options for requesting position data.
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function PositionOptions() {
|
||||||
|
/**
|
||||||
|
* Specifies the desired position accuracy.
|
||||||
|
*/
|
||||||
|
this.enableHighAccuracy = true;
|
||||||
|
/**
|
||||||
|
* The timeout after which if position data cannot be obtained the errorCallback
|
||||||
|
* is called.
|
||||||
|
*/
|
||||||
|
this.timeout = 10000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains information about any GSP errors.
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function PositionError() {
|
||||||
|
this.code = null;
|
||||||
|
this.message = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
PositionError.UNKNOWN_ERROR = 0;
|
||||||
|
PositionError.PERMISSION_DENIED = 1;
|
||||||
|
PositionError.POSITION_UNAVAILABLE = 2;
|
||||||
|
PositionError.TIMEOUT = 3;
|
||||||
|
/**
|
||||||
|
* This class provides access to the device SMS functionality.
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function Sms() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an SMS message.
|
||||||
|
* @param {Integer} number The phone number to send the message to.
|
||||||
|
* @param {String} message The contents of the SMS message to send.
|
||||||
|
* @param {Function} successCallback The function to call when the SMS message is sent.
|
||||||
|
* @param {Function} errorCallback The function to call when there is an error sending the SMS message.
|
||||||
|
* @param {PositionOptions} options The options for accessing the GPS location such as timeout and accuracy.
|
||||||
|
*/
|
||||||
|
Sms.prototype.send = function(number, message, successCallback, errorCallback, options) {
|
||||||
|
|
||||||
|
>>>>>>> 4c08b34a81e55a3146e67a8ad2282b7082b640e0:android/assets/www/phonegap.js
|
||||||
|
}
|
||||||
|
|
||||||
|
PhoneGap.addConstructor(function() {
|
||||||
|
if (typeof navigator.sms == "undefined") navigator.sms = new Sms();
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* This class provides access to the telephony features of the device.
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function Telephony() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the specifed number.
|
||||||
|
* @param {Integer} number The number to be called.
|
||||||
|
*/
|
||||||
|
Telephony.prototype.call = function(number) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PhoneGap.addConstructor(function() {
|
||||||
|
if (typeof navigator.telephony == "undefined") navigator.telephony = new Telephony();
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* This class exposes mobile phone interface controls to JavaScript, such as
|
||||||
|
* native tab and tool bars, etc.
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function UIControls() {
|
||||||
|
this.tabBarTag = 0;
|
||||||
|
this.tabBarCallbacks = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a native tab bar that can have tab buttons added to it which can respond to events.
|
||||||
|
*/
|
||||||
|
UIControls.prototype.createTabBar = function() {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a tab bar. The tab bar has to be created first.
|
||||||
|
* @param {Object} [options] Options indicating how the tab bar should be shown:
|
||||||
|
* - \c height integer indicating the height of the tab bar (default: \c 49)
|
||||||
|
* - \c position specifies whether the tab bar will be placed at the \c top or \c bottom of the screen (default: \c bottom)
|
||||||
|
*/
|
||||||
|
UIControls.prototype.showTabBar = function(options) {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide a tab bar. The tab bar has to be created first.
|
||||||
|
*/
|
||||||
|
UIControls.prototype.hideTabBar = function(animate) {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new tab bar item for use on a previously created tab bar. Use ::showTabBarItems to show the new item on the tab bar.
|
||||||
|
*
|
||||||
|
* If the supplied image name is one of the labels listed below, then this method will construct a tab button
|
||||||
|
* using the standard system buttons. Note that if you use one of the system images, that the \c title you supply will be ignored.
|
||||||
|
*
|
||||||
|
* <b>Tab Buttons</b>
|
||||||
|
* - tabButton:More
|
||||||
|
* - tabButton:Favorites
|
||||||
|
* - tabButton:Featured
|
||||||
|
* - tabButton:TopRated
|
||||||
|
* - tabButton:Recents
|
||||||
|
* - tabButton:Contacts
|
||||||
|
* - tabButton:History
|
||||||
|
* - tabButton:Bookmarks
|
||||||
|
* - tabButton:Search
|
||||||
|
* - tabButton:Downloads
|
||||||
|
* - tabButton:MostRecent
|
||||||
|
* - tabButton:MostViewed
|
||||||
|
* @param {String} name internal name to refer to this tab by
|
||||||
|
* @param {String} [title] title text to show on the tab, or null if no text should be shown
|
||||||
|
* @param {String} [image] image filename or internal identifier to show, or null if now image should be shown
|
||||||
|
* @param {Object} [options] Options for customizing the individual tab item
|
||||||
|
* - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden
|
||||||
|
*/
|
||||||
|
UIControls.prototype.createTabBarItem = function(name, label, image, options) {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing tab bar item to change its badge value.
|
||||||
|
* @param {String} name internal name used to represent this item when it was created
|
||||||
|
* @param {Object} options Options for customizing the individual tab item
|
||||||
|
* - \c badge value to display in the optional circular badge on the item; if null or unspecified, the badge will be hidden
|
||||||
|
*/
|
||||||
|
UIControls.prototype.updateTabBarItem = function(name, options) {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show previously created items on the tab bar
|
||||||
|
* @param {String} arguments... the item names to be shown
|
||||||
|
* @param {Object} [options] dictionary of options, notable options including:
|
||||||
|
* - \c animate indicates that the items should animate onto the tab bar
|
||||||
|
* @see createTabBarItem
|
||||||
|
* @see createTabBar
|
||||||
|
*/
|
||||||
|
UIControls.prototype.showTabBarItems = function(tabs, options) {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manually select an individual tab bar item, or nil for deselecting a currently selected tab bar item.
|
||||||
|
* @param {String} tabName the name of the tab to select, or null if all tabs should be deselected
|
||||||
|
* @see createTabBarItem
|
||||||
|
* @see showTabBarItems
|
||||||
|
*/
|
||||||
|
UIControls.prototype.selectTabBarItem = function(tab) {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when a tab bar item has been selected.
|
||||||
|
* @param {Number} tag the tag number for the item that has been selected
|
||||||
|
*/
|
||||||
|
UIControls.prototype.tabBarItemSelected = function(tag) {
|
||||||
|
if (typeof(this.tabBarCallbacks[tag]) == 'function')
|
||||||
|
this.tabBarCallbacks[tag]();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a toolbar.
|
||||||
|
*/
|
||||||
|
UIControls.prototype.createToolBar = function() {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when a tab bar item has been selected.
|
||||||
|
* @param {String} title the title to set within the toolbar
|
||||||
|
*/
|
||||||
|
UIControls.prototype.setToolBarTitle = function(title) {};
|
||||||
|
|
||||||
|
PhoneGap.addConstructor(function() {
|
||||||
|
window.uicontrols = new UIControls();
|
||||||
|
});
|
||||||
/*
|
/*
|
||||||
* Since we can't guarantee that we will have the most recent, we just try our best!
|
* Since we can't guarantee that we will have the most recent, we just try our best!
|
||||||
*
|
*
|
||||||
@ -920,14 +1141,22 @@ var Device = {
|
|||||||
|
|
||||||
Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallback, options)
|
Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallback, options)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD:android/assets/www/phonegap.js
|
||||||
var position = Geo.getCurrentPosition();
|
var position = Geo.getCurrentPosition();
|
||||||
|
=======
|
||||||
|
var position = Geo.getCurrentLocation();
|
||||||
|
>>>>>>> 4c08b34a81e55a3146e67a8ad2282b7082b640e0:android/assets/www/phonegap.js
|
||||||
this.global_success = successCallback;
|
this.global_success = successCallback;
|
||||||
this.fail = errorCallback;
|
this.fail = errorCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Run the global callback
|
// Run the global callback
|
||||||
|
<<<<<<< HEAD:android/assets/www/phonegap.js
|
||||||
Geolocation.prototype.gotCurrentPosition = function(lat, lng)
|
Geolocation.prototype.gotCurrentPosition = function(lat, lng)
|
||||||
|
=======
|
||||||
|
Geolocation.prototype.gotCurrentPosition = function(lat, lng, alt, altacc, head, vel, stamp)
|
||||||
|
>>>>>>> 4c08b34a81e55a3146e67a8ad2282b7082b640e0:android/assets/www/phonegap.js
|
||||||
{
|
{
|
||||||
if (lat == 0 || lng == 0)
|
if (lat == 0 || lng == 0)
|
||||||
{
|
{
|
||||||
@ -935,12 +1164,17 @@ Geolocation.prototype.gotCurrentPosition = function(lat, lng)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD:android/assets/www/phonegap.js
|
||||||
var p = { "lat" : lat, "lng": lng };
|
var p = { "lat" : lat, "lng": lng };
|
||||||
this.global_success(p);
|
this.global_success(p);
|
||||||
|
=======
|
||||||
|
coords = new Coordinates(lat, lng, alt, altacc, head, vel);
|
||||||
|
loc = new Position(coords, stamp);
|
||||||
|
this.global_success(loc);
|
||||||
|
>>>>>>> 4c08b34a81e55a3146e67a8ad2282b7082b640e0:android/assets/www/phonegap.js
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This turns on the GeoLocator class, which has two listeners.
|
* This turns on the GeoLocator class, which has two listeners.
|
||||||
* The listeners have their own timeouts, and run independently of this process
|
* The listeners have their own timeouts, and run independently of this process
|
||||||
@ -966,9 +1200,15 @@ Geolocation.prototype.watchPosition = function(successCallback, errorCallback, o
|
|||||||
* Retrieve and stop this listener from listening to the GPS
|
* Retrieve and stop this listener from listening to the GPS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
<<<<<<< HEAD:android/assets/www/phonegap.js
|
||||||
Geolocation.prototype.success(key, lat, lng)
|
Geolocation.prototype.success(key, lat, lng)
|
||||||
|
=======
|
||||||
|
Geolocation.prototype.success = function(key, lat, lng, alt, altacc, head, vel, stamp)
|
||||||
|
>>>>>>> 4c08b34a81e55a3146e67a8ad2282b7082b640e0:android/assets/www/phonegap.js
|
||||||
{
|
{
|
||||||
this.listeners[key].success(lat,lng);
|
var coords = new Coordinates(lat, lng, alt, altacc, head, vel);
|
||||||
|
var loc = new Position(coords, stamp);
|
||||||
|
this.listeners[key].success(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
Geolocation.prototype.fail(key)
|
Geolocation.prototype.fail(key)
|
||||||
@ -981,6 +1221,7 @@ Geolocation.prototype.clearWatch = function(watchId)
|
|||||||
Geo.stop(watchId);
|
Geo.stop(watchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD:android/assets/www/phonegap.js
|
||||||
|
|
||||||
Notification.prototype.vibrate = function(mills)
|
Notification.prototype.vibrate = function(mills)
|
||||||
{
|
{
|
||||||
@ -997,3 +1238,98 @@ Notification.prototype.beep = function(count, volume)
|
|||||||
{
|
{
|
||||||
Device.notify();
|
Device.notify();
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
|
||||||
|
Notification.prototype.vibrate = function(mills)
|
||||||
|
{
|
||||||
|
DroidGap.vibrate(mills);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On the Android, we don't beep, we notify you with your
|
||||||
|
* notification! We shouldn't keep hammering on this, and should
|
||||||
|
* review what we want beep to do.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Notification.prototype.beep = function(count, volume)
|
||||||
|
{
|
||||||
|
DroidGap.beep(count);
|
||||||
|
}
|
||||||
|
// Need to define these for android
|
||||||
|
_accel = {}
|
||||||
|
_accel.x = 0;
|
||||||
|
_accel.y = 0;
|
||||||
|
_accel.z = 0;
|
||||||
|
|
||||||
|
function gotAccel(x, y, z)
|
||||||
|
{
|
||||||
|
_accel.x = x;
|
||||||
|
_accel.y = y;
|
||||||
|
_accel.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides access to device accelerometer data.
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function Accelerometer() {
|
||||||
|
/**
|
||||||
|
* The last known acceleration.
|
||||||
|
*/
|
||||||
|
this.lastAcceleration = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
|
||||||
|
// Created for iPhone, Iphone passes back _accel obj litteral
|
||||||
|
if (typeof successCallback == "function") {
|
||||||
|
var accel = new Acceleration(_accel.x,_accel.y,_accel.z);
|
||||||
|
Accelerometer.lastAcceleration = accel;
|
||||||
|
successCallback(accel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asynchronously aquires the acceleration repeatedly at a given interval.
|
||||||
|
* @param {Function} successCallback The function to call each time 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.watchAcceleration = function(successCallback, errorCallback, options) {
|
||||||
|
// TODO: add the interval id to a list so we can clear all watches
|
||||||
|
var frequency = (options != undefined)? options.frequency : 10000;
|
||||||
|
|
||||||
|
Accel.start(frequency);
|
||||||
|
return setInterval(function() {
|
||||||
|
navigator.accelerometer.getCurrentAcceleration(successCallback, errorCallback, options);
|
||||||
|
}, frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the specified accelerometer watch.
|
||||||
|
* @param {String} watchId The ID of the watch returned from #watchAcceleration.
|
||||||
|
*/
|
||||||
|
Accelerometer.prototype.clearWatch = function(watchId) {
|
||||||
|
Accel.stop();
|
||||||
|
clearInterval(watchId);
|
||||||
|
}
|
||||||
|
|
||||||
|
PhoneGap.addConstructor(function() {
|
||||||
|
if (typeof navigator.accelerometer == "undefined") navigator.accelerometer = new Accelerometer();
|
||||||
|
});
|
||||||
|
>>>>>>> 4c08b34a81e55a3146e67a8ad2282b7082b640e0:android/assets/www/phonegap.js
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">PhoneGap</string>
|
<string name="app_name">PhoneGap</string>
|
||||||
<string name="url">file:///android_asset/www/index.html</string>
|
<string name="url">file:///android_asset/www/index.html</string>
|
||||||
<string name="go">Snap</string>
|
<string name="go">Snap</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -12,6 +12,10 @@ public class AccelListener implements SensorListener{
|
|||||||
|
|
||||||
WebView mAppView;
|
WebView mAppView;
|
||||||
Context mCtx;
|
Context mCtx;
|
||||||
|
String mKey;
|
||||||
|
int mTime = 10000;
|
||||||
|
boolean started = false;
|
||||||
|
|
||||||
private SensorManager sensorManager;
|
private SensorManager sensorManager;
|
||||||
|
|
||||||
private long lastUpdate = -1;
|
private long lastUpdate = -1;
|
||||||
@ -23,16 +27,21 @@ public class AccelListener implements SensorListener{
|
|||||||
sensorManager = (SensorManager) mCtx.getSystemService(Context.SENSOR_SERVICE);
|
sensorManager = (SensorManager) mCtx.getSystemService(Context.SENSOR_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start()
|
public void start(int time)
|
||||||
{
|
{
|
||||||
sensorManager.registerListener(this,
|
mTime = time;
|
||||||
|
if (!started)
|
||||||
|
{
|
||||||
|
sensorManager.registerListener(this,
|
||||||
SensorManager.SENSOR_ACCELEROMETER,
|
SensorManager.SENSOR_ACCELEROMETER,
|
||||||
SensorManager.SENSOR_DELAY_GAME);
|
SensorManager.SENSOR_DELAY_GAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop()
|
public void stop()
|
||||||
{
|
{
|
||||||
sensorManager.unregisterListener(this);
|
if(started)
|
||||||
|
sensorManager.unregisterListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAccuracyChanged(int sensor, int accuracy) {
|
public void onAccuracyChanged(int sensor, int accuracy) {
|
||||||
@ -43,7 +52,7 @@ public class AccelListener implements SensorListener{
|
|||||||
if (sensor != SensorManager.SENSOR_ACCELEROMETER || values.length < 3)
|
if (sensor != SensorManager.SENSOR_ACCELEROMETER || values.length < 3)
|
||||||
return;
|
return;
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = System.currentTimeMillis();
|
||||||
if (lastUpdate == -1 || (curTime - lastUpdate) > 1000) {
|
if (lastUpdate == -1 || (curTime - lastUpdate) > mTime) {
|
||||||
|
|
||||||
lastUpdate = curTime;
|
lastUpdate = curTime;
|
||||||
|
|
||||||
|
@ -93,6 +93,7 @@ public class DroidGap extends Activity {
|
|||||||
|
|
||||||
private void bindBrowser(WebView appView)
|
private void bindBrowser(WebView appView)
|
||||||
{
|
{
|
||||||
|
|
||||||
gap = new PhoneGap(this, appView);
|
gap = new PhoneGap(this, appView);
|
||||||
geo = new GeoBroker(appView, this);
|
geo = new GeoBroker(appView, this);
|
||||||
accel = new AccelListener(this, appView);
|
accel = new AccelListener(this, appView);
|
||||||
|
@ -30,13 +30,20 @@ public class GeoListener {
|
|||||||
/*
|
/*
|
||||||
* We only need to figure out what we do when we succeed!
|
* We only need to figure out what we do when we succeed!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
String params;
|
||||||
|
/*
|
||||||
|
* Build the giant string to send back to Javascript!
|
||||||
|
*/
|
||||||
|
params = loc.getLatitude() + "," + loc.getLongitude() + ", " + loc.getAltitude() + "," + loc.getAccuracy() + "," + loc.getBearing();
|
||||||
|
params += "," + loc.getSpeed() + "," + loc.getTime();
|
||||||
if(id != "global")
|
if(id != "global")
|
||||||
{
|
{
|
||||||
mAppView.loadUrl("javascript:Geolocation.success(" + id + ", " + loc.getLatitude() + ", " + loc.getLongitude() + ")");
|
mAppView.loadUrl("javascript:navigator.geolocation.success(" + id + "," + params + ")");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mAppView.loadUrl("javascript:Geolocation.gotCurrentPosition(" + loc.getLatitude() + ", " + loc.getLongitude() + ")");
|
mAppView.loadUrl("javascript:navigator.geolocation.gotCurrentPosition(" + params + ")");
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,7 +51,13 @@ public class GeoListener {
|
|||||||
void fail()
|
void fail()
|
||||||
{
|
{
|
||||||
// Do we need to know why? How would we handle this?
|
// Do we need to know why? How would we handle this?
|
||||||
mAppView.loadUrl("javascript:GeoLocation.fail(" + id + ")");
|
if (id != "global") {
|
||||||
|
mAppView.loadUrl("javascript:navigator.geolocation.fail(" + id + ")");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mAppView.loadUrl("javascript:navigator.geolocation.fail()");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This stops the listener
|
// This stops the listener
|
||||||
|
@ -54,6 +54,7 @@ public class GpsListener implements LocationListener {
|
|||||||
public void onProviderDisabled(String provider) {
|
public void onProviderDisabled(String provider) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
Log.d(LOG_TAG, "The provider " + provider + " is disabled");
|
Log.d(LOG_TAG, "The provider " + provider + " is disabled");
|
||||||
|
owner.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onProviderEnabled(String provider) {
|
public void onProviderEnabled(String provider) {
|
||||||
@ -68,6 +69,7 @@ public class GpsListener implements LocationListener {
|
|||||||
if(status == 0)
|
if(status == 0)
|
||||||
{
|
{
|
||||||
Log.d(LOG_TAG, provider + " is OUT OF SERVICE");
|
Log.d(LOG_TAG, provider + " is OUT OF SERVICE");
|
||||||
|
owner.fail();
|
||||||
}
|
}
|
||||||
else if(status == 1)
|
else if(status == 1)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,10 @@ public class PhoneGap{
|
|||||||
RingtoneManager beeper = new RingtoneManager(mCtx);
|
RingtoneManager beeper = new RingtoneManager(mCtx);
|
||||||
Uri ringtone = beeper.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
Uri ringtone = beeper.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
||||||
Ringtone notification = beeper.getRingtone(mCtx, ringtone);
|
Ringtone notification = beeper.getRingtone(mCtx, ringtone);
|
||||||
notification.play();
|
for (long i = 0; i < pattern; ++i)
|
||||||
|
{
|
||||||
|
notification.play();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void vibrate(long pattern){
|
public void vibrate(long pattern){
|
||||||
|
Loading…
Reference in New Issue
Block a user