equal
deleted
inserted
replaced
942 SearchCriterion : "Orientation" |
942 SearchCriterion : "Orientation" |
943 }; |
943 }; |
944 var result = sensors.ISensor.FindSensorChannel(SensorParams); |
944 var result = sensors.ISensor.FindSensorChannel(SensorParams); |
945 |
945 |
946 if (result.ErrorCode == 0) { |
946 if (result.ErrorCode == 0) { |
|
947 // TODO Function named "orientationCallback" will be called when device orientation changes. This function should be created. |
947 var result2 = sensors.ISensor.RegisterForNotification({ ChannelInfoMap : result.ReturnValue[0], ListeningType : "ChannelData" }, orientationCallback); |
948 var result2 = sensors.ISensor.RegisterForNotification({ ChannelInfoMap : result.ReturnValue[0], ListeningType : "ChannelData" }, orientationCallback); |
948 if (result.ErrorCode == 0) { |
949 if (result.ErrorCode == 0) { |
949 var transactionId = result.TransactionID; |
950 var transactionId = result.TransactionID; |
950 // TODO Use this transaction ID to cancel notifications when watching orientation is no longer needed |
951 // TODO Use this transaction ID to cancel notifications when watching orientation is no longer needed |
951 } else { |
952 } else { |
963 <item |
964 <item |
964 description="This function can be used as a callback in GetLocation and Trace calls to location service." |
965 description="This function can be used as a callback in GetLocation and Trace calls to location service." |
965 id="org.symbian.tools.wrttools.location" |
966 id="org.symbian.tools.wrttools.location" |
966 label="Location callback"> |
967 label="Location callback"> |
967 <content> |
968 <content> |
|
969 // This function can be passed as a callback to locationService.ILocation |
|
970 // GetLocation or Trace method |
968 function locationUpdated(transactionId, code, result) { |
971 function locationUpdated(transactionId, code, result) { |
969 if (result.ErrorCode == 0) { |
972 if (result.ErrorCode == 0) { |
970 var longitude = result.ReturnValue.Longitude; // Longitude estimate in degrees. The value range is [+180, -180]. |
973 var longitude = result.ReturnValue.Longitude; // Longitude estimate in degrees. The value range is [+180, -180]. |
971 var latitude = result.ReturnValue.Latitude; // Latitude estimate in degrees. The value range is [+90, -90]. |
974 var latitude = result.ReturnValue.Latitude; // Latitude estimate in degrees. The value range is [+90, -90]. |
972 var altitude = result.ReturnValue.Altitude; // Elevation estimate in meters relative to the WGS 84 datum. |
975 var altitude = result.ReturnValue.Altitude; // Elevation estimate in meters relative to the WGS 84 datum. |
993 <item |
996 <item |
994 description="Function that processes notifications from the orientation sensor" |
997 description="Function that processes notifications from the orientation sensor" |
995 id="org.symbian.tools.wrttools.contacts" |
998 id="org.symbian.tools.wrttools.contacts" |
996 label="Orientation callback"> |
999 label="Orientation callback"> |
997 <content> |
1000 <content> |
|
1001 // This function can be passed as callback to locationService.ILocation.GetLocation |
|
1002 // or locationService.ILocation.Trace method |
998 function orientationCallback(transactionId, code, result) { |
1003 function orientationCallback(transactionId, code, result) { |
999 if (result.ErrorCode == 0) { |
1004 if (result.ErrorCode == 0) { |
1000 var orientation = result.ReturnValue.DeviceOrientation; |
1005 var orientation = result.ReturnValue.DeviceOrientation; |
1001 // TODO Possible values: |
1006 // TODO Possible values: |
1002 // "Undefined" |
1007 // "Undefined" |
1023 <item |
1028 <item |
1024 description="Accepts accerelometer data" |
1029 description="Accepts accerelometer data" |
1025 id="org.symbian.tools.wrttools.phonegap.accererometer" |
1030 id="org.symbian.tools.wrttools.phonegap.accererometer" |
1026 label="Accelerometer callback"> |
1031 label="Accelerometer callback"> |
1027 <content> |
1032 <content> |
|
1033 // This callback can be passed as a successCallback argument to |
|
1034 // navigator.accelerometer getCurrentAcceleration and watchAcceleration methods |
1028 function updateAcceleration(accel) { |
1035 function updateAcceleration(accel) { |
1029 var x = accel.x; |
1036 var x = accel.x; |
1030 var y = accel.y; |
1037 var y = accel.y; |
1031 var z = accel.z; |
1038 var z = accel.z; |
1032 |
1039 |
1037 <item |
1044 <item |
1038 description="Accepts contacts data" |
1045 description="Accepts contacts data" |
1039 id="org.symbian.tools.wrttools.phonegap.contacts" |
1046 id="org.symbian.tools.wrttools.phonegap.contacts" |
1040 label="Contacts callback"> |
1047 label="Contacts callback"> |
1041 <content> |
1048 <content> |
|
1049 // This method can be passed as a successCallback argument to |
|
1050 // navigator.contacts.find method |
1042 function displayContacts(contacts) { |
1051 function displayContacts(contacts) { |
1043 for (var i=0; i < contacts.length; i++) { |
1052 for (var i=0; i < contacts.length; i++) { |
1044 var contact = contacts[i]; |
1053 var contact = contacts[i]; |
1045 var name = contact.name.formatted; |
1054 var name = contact.name.formatted; |
1046 var phones = contact.name.phone; // Array of phone numbers |
1055 var phones = contact.name.phone; // Array of phone numbers |
1054 <item |
1063 <item |
1055 description="Accepts location data" |
1064 description="Accepts location data" |
1056 id="org.symbian.tools.wrttools.phonegap.location" |
1065 id="org.symbian.tools.wrttools.phonegap.location" |
1057 label="Location callback"> |
1066 label="Location callback"> |
1058 <content> |
1067 <content> |
|
1068 // This method can be passed as a successCallback argument to |
|
1069 // navigator.geolocation getCurrentPosition or watchPosition methods |
1059 function updateLocation(position) { |
1070 function updateLocation(position) { |
1060 var pt = position.coords; |
1071 var pt = position.coords; |
1061 var latitude = pt.latitude; |
1072 var latitude = pt.latitude; |
1062 var longitude = pt.longitude; |
1073 var longitude = pt.longitude; |
1063 var altitude = pt.altitude; |
1074 var altitude = pt.altitude; |
1071 <item |
1082 <item |
1072 description="Accepts orientation data" |
1083 description="Accepts orientation data" |
1073 id="org.symbian.tools.wrttools.phonegap.orientation" |
1084 id="org.symbian.tools.wrttools.phonegap.orientation" |
1074 label="Orientation callback"> |
1085 label="Orientation callback"> |
1075 <content> |
1086 <content> |
|
1087 // This method can be passed as a successCallback argument to |
|
1088 // navigator.orientation getCurrentOrientation or watchOrientation methods |
1076 function updateOrientation(orientation) { |
1089 function updateOrientation(orientation) { |
1077 switch (orientation) { |
1090 switch (orientation) { |
1078 case DisplayOrientation.PORTRAIT: break; |
1091 case DisplayOrientation.PORTRAIT: break; |
1079 case DisplayOrientation.REVERSE_PORTRAIT: break; |
1092 case DisplayOrientation.REVERSE_PORTRAIT: break; |
1080 case DisplayOrientation.LANDSCAPE_LEFT_UP: break; |
1093 case DisplayOrientation.LANDSCAPE_LEFT_UP: break; |