# HG changeset patch # User Eugene Ostroukhov # Date 1276627939 25200 # Node ID 5027709c9315d9e108dc818c6993d093a159b951 # Parent d1edab2715d49aac2903634d9acdc746d73c4c02 PhoneGap snippets and minor bugfix diff -r d1edab2715d4 -r 5027709c9315 org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Mon Jun 14 17:16:31 2010 -0700 +++ b/org.symbian.tools.wrttools/plugin.xml Tue Jun 15 11:52:19 2010 -0700 @@ -876,36 +876,6 @@ smallicon="icons/main16.gif" contenttypes="org.eclipse.wst.jsdt.core.jsSource"> - -function locationUpdated(transactionId, code, result) { - if (result.ErrorCode == 0) { - var longitude = result.ReturnValue.Longitude; // Longitude estimate in degrees. The value range is [+180, -180]. - var latitude = result.ReturnValue.Latitude; // Latitude estimate in degrees. The value range is [+90, -90]. - var altitude = result.ReturnValue.Altitude; // Elevation estimate in meters relative to the WGS 84 datum. - var satelliteNumView = result.ReturnValue.SatelliteNumView; // Number of satellites currently in view. - var satelliteNumViewUsed = result.ReturnValue.SatelliteNumViewUsed; // Number of satellites used to obtain the location fix. - var horizontalSpeed = result.ReturnValue.HorizontalSpeed; // Horizontal speed estimate in meters per second. This is the speed of the device at the time the location fix was obtained. - var horizontalSpeedError = result.ReturnValue.HorizontalSpeedError; // Horizontal speed error in meters per second. - var trueCourse = result.ReturnValue.TrueCourse; // Current direction of movement in degrees in relation to true north. - var trueCourseError = result.ReturnValue.TrueCourseError; // TrueCourse error in degrees. - var magneticHeading = result.ReturnValue.MagneticHeading; // Current direction of movement in degrees in relation to magnetic north. - var magneticHeadingError = result.ReturnValue.MagneticHeadingError; // MagneticHeading error in degrees. - var heading = result.ReturnValue.Heading; // Current instantaneous direction of movement in degrees in relation to true north. - var headingError = result.ReturnValue.HeadingError; // Heading error in degrees. - var magneticCourse = result.ReturnValue.MagneticCourse; // Current instantaneous direction of movement in degrees in relation to magnetic north. - var magneticCourseError = result.ReturnValue.MagneticCourseError; // MagneticCourse error in degrees - // TODO Location information was received - } else { - var errorCode = result.ErrorCode; - var errorMessage = result.ErrorMessage; - // TODO Failed to retrieve location information - } -} - - @@ -952,7 +922,7 @@ + label="Register orientation callback"> var sensors = device.getServiceObject("Service.Sensor", "ISensor"); var SensorParams = { @@ -978,6 +948,36 @@ + +function locationUpdated(transactionId, code, result) { + if (result.ErrorCode == 0) { + var longitude = result.ReturnValue.Longitude; // Longitude estimate in degrees. The value range is [+180, -180]. + var latitude = result.ReturnValue.Latitude; // Latitude estimate in degrees. The value range is [+90, -90]. + var altitude = result.ReturnValue.Altitude; // Elevation estimate in meters relative to the WGS 84 datum. + var satelliteNumView = result.ReturnValue.SatelliteNumView; // Number of satellites currently in view. + var satelliteNumViewUsed = result.ReturnValue.SatelliteNumViewUsed; // Number of satellites used to obtain the location fix. + var horizontalSpeed = result.ReturnValue.HorizontalSpeed; // Horizontal speed estimate in meters per second. This is the speed of the device at the time the location fix was obtained. + var horizontalSpeedError = result.ReturnValue.HorizontalSpeedError; // Horizontal speed error in meters per second. + var trueCourse = result.ReturnValue.TrueCourse; // Current direction of movement in degrees in relation to true north. + var trueCourseError = result.ReturnValue.TrueCourseError; // TrueCourse error in degrees. + var magneticHeading = result.ReturnValue.MagneticHeading; // Current direction of movement in degrees in relation to magnetic north. + var magneticHeadingError = result.ReturnValue.MagneticHeadingError; // MagneticHeading error in degrees. + var heading = result.ReturnValue.Heading; // Current instantaneous direction of movement in degrees in relation to true north. + var headingError = result.ReturnValue.HeadingError; // Heading error in degrees. + var magneticCourse = result.ReturnValue.MagneticCourse; // Current instantaneous direction of movement in degrees in relation to magnetic north. + var magneticCourseError = result.ReturnValue.MagneticCourseError; // MagneticCourse error in degrees + // TODO Location information was received + } else { + var errorCode = result.ErrorCode; + var errorMessage = result.ErrorMessage; + // TODO Failed to retrieve location information + } +} + + @@ -1002,5 +1002,78 @@ + + + +function updateAcceleration(accel) { + var x = accel.x; + var y = accel.y; + var z = accel.z; + + // TODO process the data +} + + + + +function displayContacts(contacts) { + for (var i=0; i < contacts.length; i++) { + var contact = contacts[i]; + var name = contact.name.formatted; + var phones = contact.name.phone; // Array of phone numbers + var name = contact.name.address; + + // TODO Insert your code here + } +} + + + + +function updateLocation(position) { + var pt = position.coords; + var latitude = pt.latitude; + var longitude = pt.longitude; + var altitude = pt.altitude; + var heading = pt.heading; + var speed = pt.speed; + + // TODO Insert your code here +} + + + + +function updateOrientation(orientation) { + switch (orientation) { + case DisplayOrientation.PORTRAIT: break; + case DisplayOrientation.REVERSE_PORTRAIT: break; + case DisplayOrientation.LANDSCAPE_LEFT_UP: break; + case DisplayOrientation.LANDSCAPE_RIGHT_UP: break; + case DisplayOrientation.FACE_UP: break; + case DisplayOrientation.FACE_DOWN: break; + } + + // TODO Insert your code here +} + + + diff -r d1edab2715d4 -r 5027709c9315 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WRTNavigatorContentProvider.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WRTNavigatorContentProvider.java Mon Jun 14 17:16:31 2010 -0700 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WRTNavigatorContentProvider.java Tue Jun 15 11:52:19 2010 -0700 @@ -122,7 +122,9 @@ protected void refreshViewer(final IResource resource) { viewer.getControl().getDisplay().asyncExec(new Runnable() { public void run() { - ((TreeViewer) viewer).refresh(resource); + if (!viewer.getControl().isDisposed()) { + ((TreeViewer) viewer).refresh(resource); + } } }); }