Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BlackBerry Samples for Java release 7.0.0.

An Open Source version of the samples as they were released
with the 7.0.0 Java Development Environment release.

The BlackBerry Samples for Java project is an Open Source
repository of samples that in the past were released through
the BlackBerry Developer Knowledge Base or within the
BlackBerry Java Tools.  The samples range in scope from Hello
World, to Advanced UI components and include both samples and
libraries that offer extended functionality.

Copyright (c) 2011 Research In Motion Limited

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
  • Loading branch information...
commit ec58ace3de4c3bccd293541837498c9e6a76e655 1 parent ea58453
@slegge slegge authored
Showing with 16,091 additions and 4,852 deletions.
  1. +3 −3 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/IconToolbarComponent.java
  2. +2 −2 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/TableComponent.java
  3. +3 −3 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/TextComponent.java
  4. +3 −3 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/ValueComponent.java
  5. +7 −6 com/rim/samples/device/attachmentdemo/FileExplorerScreen.java
  6. +139 −0 com/rim/samples/device/augmentedrealitydemo/ARDemoCameraScreen.java
  7. +72 −0 com/rim/samples/device/augmentedrealitydemo/AugmentedRealityDemo.java
  8. +55 −0 com/rim/samples/device/augmentedrealitydemo/AugmentedRealityDemo.jdp
  9. +210 −0 com/rim/samples/device/augmentedrealitydemo/Cube.java
  10. +233 −0 com/rim/samples/device/augmentedrealitydemo/DemoGLField.java
  11. BIN  com/rim/samples/device/augmentedrealitydemo/img/BlackBerry.png
  12. BIN  com/rim/samples/device/augmentedrealitydemo/img/augmentedrealitydemo_jde.png
  13. +198 −150 com/rim/samples/device/barcodescandemo/BarcodeScanDemo.java
  14. BIN  com/rim/samples/device/barcodescandemo/beep.wav
  15. +209 −0 com/rim/samples/device/blackberrybalancedemo/BlackBerryBalanceDemo.java
  16. +56 −0 com/rim/samples/device/blackberrybalancedemo/BlackBerryBalanceDemo.jdp
  17. +131 −121 ...ps/embeddedmapdemo/SavedLocationsScreen.java → blackberrybalancedemo/BlackBerryBalanceDemoScreen.java}
  18. +134 −0 com/rim/samples/device/blackberrybalancedemo/Memo.java
  19. +163 −0 com/rim/samples/device/blackberrybalancedemo/MemoScreen.java
  20. +82 −0 com/rim/samples/device/blackberrybalancedemo/MultiServiceListener.java
  21. +105 −0 com/rim/samples/device/blackberrybalancedemo/PersistentStoreListener.java
  22. BIN  com/rim/samples/device/blackberrybalancedemo/img/blackberrybalancedemo_jde.png
  23. +7 −2 com/rim/samples/device/blackberrymaildemo/ComposeScreen.java
  24. +15 −10 com/rim/samples/device/blackberrymaildemo/MessageScreen.java
  25. +17 −18 com/rim/samples/device/blackberrymaildemo/Util.java
  26. +2 −3 com/rim/samples/device/bluetooth/bluetoothjsr82demo/ClientScreen.java
  27. +21 −1 com/rim/samples/device/bluetooth/bluetoothjsr82demo/InfoScreen.java
  28. +5 −6 com/rim/samples/device/bluetooth/bluetoothjsr82demo/ServerScreen.java
  29. +17 −13 com/rim/samples/device/browser/browsercontentmanagerdemo/BrowserContentManagerDemo.java
  30. +15 −11 com/rim/samples/device/browser/browserfielddemo/BrowserFieldDemo.java
  31. +3 −3 com/rim/samples/device/browser/commonlib/SecondaryResourceFetchThread.java
  32. +2 −2 com/rim/samples/device/browser/commonlib/Utilities.java
  33. +522 −64 com/rim/samples/device/camerademo/CameraDemo.java
  34. +1 −2  com/rim/samples/device/camerademo/EncodingProperties.java
  35. +32 −40 com/rim/samples/device/camerademo/ImageScreen.java
  36. +10 −18 com/rim/samples/device/communicationapidemo/CommunicationController.java
  37. +21 −2 com/rim/samples/device/communicationapidemo/CommunicationControllerListener.java
  38. +0 −6 com/rim/samples/device/communicationapidemo/ResponseCallback.java
  39. +2 −2 com/rim/samples/device/communicationapidemo/ui/FullWidthButton.java
  40. +3 −5 com/rim/samples/device/communicationapidemo/view/AuthenticationScreen.java
  41. +1 −1  com/rim/samples/device/communicationapidemo/view/SendBlockScreen.java
  42. +2 −1  com/rim/samples/device/communicationapidemo/view/SendFireForgetScreen.java
  43. +0 −3  com/rim/samples/device/communicationapidemo/view/SendNonBlockAtomScreen.java
  44. +0 −5 com/rim/samples/device/communicationapidemo/view/SendNonBlockJsonScreen.java
  45. +0 −2  com/rim/samples/device/communicationapidemo/view/SendNonBlockRssScreen.java
  46. +0 −3  com/rim/samples/device/communicationapidemo/view/SendNonBlockSoapScreen.java
  47. +0 −2  com/rim/samples/device/communicationapidemo/view/SendNonBlockXmlScreen.java
  48. +0 −4 com/rim/samples/device/communicationapidemo/view/StreamDataScreen.java
  49. +21 −1 com/rim/samples/device/contactlinkingdemo/SampleLinkedContactInfoProvider.java
  50. +10 −1 com/rim/samples/device/embeddedmediademo/EmbeddedMediaDemo.java
  51. +6 −10 com/rim/samples/device/fileexplorerdemo/FileExplorerDemoScreen.java
  52. +6 −6 com/rim/samples/device/homescreendemo/HomeScreenDemo.java
  53. +3 −5 com/rim/samples/device/homescreendemo/HomeScreenDemoSecondaryScreen.java
  54. +45 −58 com/rim/samples/device/httpdemo/HTTPDemo.java
  55. +5 −5 com/rim/samples/device/httpdemo/WapOptionsScreen.java
  56. +105 −119 com/rim/samples/device/httppushdemo/HTTPPushDemo.java
  57. +10 −12 com/rim/samples/device/httppushdemo/readme.txt
  58. 0  com/rim/samples/device/{maps → location}/blackberrymapsdemo/BlackBerryMapsDemo.java
  59. 0  com/rim/samples/device/{maps → location}/blackberrymapsdemo/BlackBerryMapsDemo.jdp
  60. 0  com/rim/samples/device/{maps → location}/blackberrymapsdemo/InvokeContactScreen.java
  61. 0  com/rim/samples/device/{maps → location}/blackberrymapsdemo/InvokeDefaultScreen.java
  62. 0  com/rim/samples/device/{maps → location}/blackberrymapsdemo/InvokeLocationDocumentScreen.java
  63. 0  com/rim/samples/device/{maps → location}/blackberrymapsdemo/InvokeMapViewScreen.java
  64. 0  com/rim/samples/device/{maps → location}/blackberrymapsdemo/img/bbmapsdemo_jde.png
  65. +57 −0 com/rim/samples/device/location/dynamicmappabledemo/DynamicMappableDemo.java
  66. +54 −0 com/rim/samples/device/location/dynamicmappabledemo/DynamicMappableDemo.jdp
  67. +95 −0 com/rim/samples/device/location/dynamicmappabledemo/DynamicMappableScreen.java
  68. +114 −0 com/rim/samples/device/location/dynamicmappabledemo/UpdatableMappable.java
  69. +123 −0 com/rim/samples/device/location/dynamicmappabledemo/UpdateManager.java
  70. BIN  com/rim/samples/device/location/dynamicmappabledemo/img/dynamicmappabledemo_jde.png
  71. +221 −0 com/rim/samples/device/location/enhancedmapfielddemo/EnhancedMapFieldDemo.java
  72. 0  com/rim/samples/device/{maps → location}/enhancedmapfielddemo/EnhancedMapFieldDemo.jdp
  73. 0  com/rim/samples/device/{maps → location}/enhancedmapfielddemo/img/enhancedmapfielddemo_jde.png
  74. +129 −0 com/rim/samples/device/location/geocodedemo/GeocodeDemo.java
  75. +8 −9 com/rim/samples/device/{svg/svgscriptingdemo/SVGScriptingDemo.jdp → location/geocodedemo/GeocodeDemo.jdp}
  76. +112 −0 com/rim/samples/device/location/geocodedemo/GeocodeDemoScreen.java
  77. +360 −0 com/rim/samples/device/location/geocodedemo/GeocodeScreen.java
  78. +311 −0 com/rim/samples/device/location/geocodedemo/ReverseGeocodeScreen.java
  79. BIN  com/rim/samples/device/location/geocodedemo/img/geocodedemo_jde.png
  80. +239 −0 com/rim/samples/device/location/geofencedemo/GeofenceDemo.java
  81. +51 −0 com/rim/samples/device/location/geofencedemo/GeofenceDemo.jdp
  82. BIN  com/rim/samples/device/location/geofencedemo/img/geofencedemo_jde.png
  83. +2 −2 com/rim/samples/device/{gps → location}/gpsdemo/GPSDemo.java
  84. 0  com/rim/samples/device/{gps → location}/gpsdemo/GPSDemo.jdp
  85. +4 −4 com/rim/samples/device/{gps → location}/gpsdemo/PointScreen.java
  86. 0  com/rim/samples/device/{gps → location}/gpsdemo/img/gpsdemo_jde.png
  87. +1 −1  com/rim/samples/device/{gps → location}/gpsdemoadvanced/CoreGPSDiagnosticScreen.java
  88. +3 −3 com/rim/samples/device/{gps → location}/gpsdemoadvanced/ExtendedGPSDiagnosticScreen.java
  89. +1 −1  com/rim/samples/device/{gps → location}/gpsdemoadvanced/GPSDemoAdvanced.java
  90. 0  com/rim/samples/device/{gps → location}/gpsdemoadvanced/GPSDemoAdvanced.jdp
  91. 0  com/rim/samples/device/{gps → location}/gpsdemoadvanced/img/gpsdemoadvanced_jde.png
  92. 0  com/rim/samples/device/{gps → location}/gpsdemoadvanced/resource/help_core.txt
  93. 0  com/rim/samples/device/{gps → location}/gpsdemoadvanced/resource/help_extended.txt
  94. +54 −0 com/rim/samples/device/location/mapactiondemo/MapActionDemo.java
  95. +53 −0 com/rim/samples/device/location/mapactiondemo/MapActionDemo.jdp
  96. +209 −0 com/rim/samples/device/location/mapactiondemo/MapActionDemoScreen.java
  97. +125 −0 com/rim/samples/device/location/mapactiondemo/RestrictedMapAction.java
  98. BIN  com/rim/samples/device/location/mapactiondemo/img/mapactiondemo_jde.png
  99. 0  com/rim/samples/device/{maps → location}/mapfielddemo/DemoMapField.java
  100. 0  com/rim/samples/device/{maps → location}/mapfielddemo/MapFieldDemo.java
  101. 0  com/rim/samples/device/{maps → location}/mapfielddemo/MapFieldDemo.jdp
  102. 0  com/rim/samples/device/{maps → location}/mapfielddemo/MapFieldDemoMenuItem.java
  103. +1 −1  com/rim/samples/device/{maps → location}/mapfielddemo/MapFieldDemoScreen.java
  104. 0  com/rim/samples/device/{maps → location}/mapfielddemo/MapFieldDemoSite.java
  105. 0  com/rim/samples/device/{maps → location}/mapfielddemo/MapFieldDemoTokenizer.java
  106. 0  com/rim/samples/device/{maps → location}/mapfielddemo/img/bullseye.png
  107. 0  com/rim/samples/device/{maps → location}/mapfielddemo/img/mapfielddemo_jde.png
  108. 0  com/rim/samples/device/{maps → location}/mapfielddemo/sitedata/MapsData.txt
  109. 0  com/rim/samples/device/{maps → location}/mapfielddemo/sitedata/Readme.txt
  110. 0  com/rim/samples/device/{maps → location}/mapsmenuitemdemo/MapsMenuItemDemo.java
  111. 0  com/rim/samples/device/{maps → location}/mapsmenuitemdemo/MapsMenuItemDemo.jdp
  112. +380 −0 com/rim/samples/device/location/traveltimedemo/TravelTimeDemo.java
  113. 0  com/rim/samples/device/{ → location}/traveltimedemo/TravelTimeDemo.jdp
  114. 0  com/rim/samples/device/{ → location}/traveltimedemo/img/traveltimedemo_jde.png
  115. +87 −0 com/rim/samples/device/magnetometerdemo/MagnetometerDemo.java
  116. +52 −0 com/rim/samples/device/magnetometerdemo/MagnetometerDemo.jdp
  117. +486 −0 com/rim/samples/device/magnetometerdemo/MagnetometerDemoScreen.java
  118. BIN  com/rim/samples/device/magnetometerdemo/img/magnetometerdemo_jde.png
  119. +0 −410 com/rim/samples/device/maps/embeddedmapdemo/EmbeddedMapDemo.java
  120. +0 −58 com/rim/samples/device/maps/embeddedmapdemo/EmbeddedMapDemo.jdp
  121. +0 −300 com/rim/samples/device/maps/embeddedmapdemo/ExtendedMapField.java
  122. +0 −345 com/rim/samples/device/maps/embeddedmapdemo/LocatorScreen.java
  123. +0 −139 com/rim/samples/device/maps/embeddedmapdemo/LookupMatchesScreen.java
  124. +0 −106 com/rim/samples/device/maps/embeddedmapdemo/MapLocation.java
  125. BIN  com/rim/samples/device/maps/embeddedmapdemo/img/embeddedmapdemo_jde.png
  126. BIN  com/rim/samples/device/maps/embeddedmapdemo/img/marker.PNG
  127. BIN  com/rim/samples/device/maps/embeddedmapdemo/img/pointer.png
  128. +0 −139 com/rim/samples/device/maps/enhancedmapfielddemo/EnhancedMapFieldDemo.java
  129. +1 −1  com/rim/samples/device/mediakeysdemo/mediakeysdemomidlet/MediaKeysDemoMIDlet.java
  130. +1 −1  com/rim/samples/device/mediakeysdemo/mediakeysdemomidlet/MediaKeysMIDletConstants.java
  131. +3 −3 com/rim/samples/device/mediakeysdemo/mediaplayerdemo/mediaplayerlib/HelpScreen.java
  132. +8 −0 com/rim/samples/device/mediakeysdemo/mediaplayerdemo/mediaplayerlib/MediaPlayerActions.java
  133. +3 −6 com/rim/samples/device/mediakeysdemo/mediaplayerdemo/mediaplayerlib/PlayList.java
  134. +1 −1  com/rim/samples/device/memoapidemo/MemoMainScreen.java
  135. +1 −1  com/rim/samples/device/messagelistdemo/DemoMessage.java
  136. +0 −2  com/rim/samples/device/messagelistdemo/MessageListDemo.java
  137. +1 −1  com/rim/samples/device/messagelistdemo/MessageListDemoStore.java
  138. +71 −0 com/rim/samples/device/nativewindowmanagerdemo/NWMDemo.java
  139. +203 −0 com/rim/samples/device/nativewindowmanagerdemo/NWMVideoScreen.java
  140. BIN  com/rim/samples/device/nativewindowmanagerdemo/img/nativewindowmanagerdemo_jde.png
  141. BIN  com/rim/samples/device/nativewindowmanagerdemo/img/pause.png
  142. BIN  com/rim/samples/device/nativewindowmanagerdemo/img/play.png
  143. BIN  com/rim/samples/device/nativewindowmanagerdemo/media/BlackBerry.mp4
  144. +55 −0 com/rim/samples/device/nativewindowmanagerdemo/nativewindowmanagerdemo.jdp
  145. +18 −19 com/rim/samples/device/networkapidemo/TransportInfoScreen.java
  146. +17 −16 ...rim/samples/device/{svg/svgscriptingdemo/SVGScriptingDemo.java → nfcemulatordemo/NFCEmulatorDemo.java}
  147. +56 −0 com/rim/samples/device/nfcemulatordemo/NFCEmulatorDemo.jdp
  148. +274 −0 com/rim/samples/device/nfcemulatordemo/NFCEmulatorFieldChangeListener.java
  149. +69 −0 com/rim/samples/device/nfcemulatordemo/NFCEmulatorFieldDetector.java
  150. +224 −0 com/rim/samples/device/nfcemulatordemo/NFCEmulatorScreen.java
  151. +120 −0 com/rim/samples/device/nfcemulatordemo/VirtualISOTargetListener.java
  152. +77 −0 com/rim/samples/device/nfcemulatordemo/VirtualNDEFTagListener.java
  153. BIN  com/rim/samples/device/nfcemulatordemo/img/nfcemulatordemo_jde.png
  154. +150 −0 com/rim/samples/device/nfcreaderdemo/DemoFieldChangeListener.java
  155. +64 −0 com/rim/samples/device/nfcreaderdemo/DemoNDEFMessageListener.java
  156. +60 −0 com/rim/samples/device/nfcreaderdemo/NFCReaderDemo.java
  157. +55 −0 com/rim/samples/device/nfcreaderdemo/NFCReaderDemo.jdp
  158. +198 −0 com/rim/samples/device/nfcreaderdemo/NFCReaderScreen.java
  159. +331 −0 com/rim/samples/device/nfcreaderdemo/NFCReaderTargetDetector.java
  160. BIN  com/rim/samples/device/nfcreaderdemo/img/nfcreaderdemo_jde.png
  161. +1 −2  com/rim/samples/device/notificationsdemo/NotificationsEngineListenerImpl.java
  162. +216 −0 com/rim/samples/device/opengl11demo/Cube.java
  163. +15 −11 com/rim/samples/device/{opengldemo/OpenGLDemo.java → opengl11demo/OpenGL11Demo.java}
  164. +234 −0 com/rim/samples/device/opengl11demo/OpenGLDemoField.java
  165. BIN  com/rim/samples/device/opengl11demo/img/BlackBerry.png
  166. 0  com/rim/samples/device/{opengldemo/img/opengldemo_jde.png → opengl11demo/img/opengl11demo_jde.png}
  167. +6 −8 com/rim/samples/device/{opengldemo/OpenGLDemo.jdp → opengl11demo/opengl11demo.jdp}
  168. +225 −0 com/rim/samples/device/opengl20demo/Cube.java
  169. +75 −0 com/rim/samples/device/opengl20demo/OpenGL20Demo.java
  170. +410 −0 com/rim/samples/device/opengl20demo/OpenGLDemoField.java
  171. BIN  com/rim/samples/device/opengl20demo/img/BlackBerry.png
  172. BIN  com/rim/samples/device/opengl20demo/img/opengl20demo_jde.png
  173. +56 −0 com/rim/samples/device/opengl20demo/opengl20demo.jdp
  174. +24 −0 com/rim/samples/device/opengl20demo/shaders/TextureLight.fsh
  175. +24 −0 com/rim/samples/device/opengl20demo/shaders/TextureLight.vsh
  176. +0 −148 com/rim/samples/device/opengldemo/Cube.java
  177. +0 −158 com/rim/samples/device/opengldemo/CubeRenderer.java
  178. +0 −426 com/rim/samples/device/opengldemo/OpenGLScreen.java
  179. +0 −76 com/rim/samples/device/opengldemo/Renderer.java
  180. BIN  com/rim/samples/device/opengldemo/img/BlackBerry.png
  181. +67 −0 com/rim/samples/device/openglspritegamedemo/OpenGLSpriteGameDemo.jdp
  182. +1,303 −0 com/rim/samples/device/openglspritegamedemo/Sprite.java
  183. +85 −0 com/rim/samples/device/openglspritegamedemo/SpriteGame.java
  184. +435 −0 com/rim/samples/device/openglspritegamedemo/SpriteGameCharacter.java
  185. +551 −0 com/rim/samples/device/openglspritegamedemo/SpriteGameGLField.java
  186. +986 −0 com/rim/samples/device/openglspritegamedemo/SpriteGameLevel.java
  187. +78 −0 com/rim/samples/device/openglspritegamedemo/SpriteGameScreen.java
  188. +161 −0 com/rim/samples/device/openglspritegamedemo/SpriteGameSplashScreen.java
  189. BIN  com/rim/samples/device/openglspritegamedemo/res/img/RandOmazeLogo.png
  190. BIN  com/rim/samples/device/openglspritegamedemo/res/img/character.png
  191. BIN  com/rim/samples/device/openglspritegamedemo/res/img/level_block.png
  192. BIN  com/rim/samples/device/openglspritegamedemo/res/img/level_end.png
  193. BIN  com/rim/samples/device/openglspritegamedemo/res/img/lose.png
  194. BIN  com/rim/samples/device/openglspritegamedemo/res/img/obstacle_ball.png
  195. BIN  com/rim/samples/device/openglspritegamedemo/res/img/obstacle_spikewheel.png
  196. BIN  com/rim/samples/device/openglspritegamedemo/res/img/openglspritegamedemo_jde.png
  197. BIN  com/rim/samples/device/openglspritegamedemo/res/img/win.png
  198. +49 −0 com/rim/samples/device/openglspritegamedemo/res/level/levelone.xml
  199. +54 −0 com/rim/samples/device/openglspritegamedemo/res/level/leveltwo.xml
  200. +218 −0 com/rim/samples/device/openvgdemo/CreateImageVGField.java
  201. +57 −0 com/rim/samples/device/openvgdemo/OpenVGDemo.java
  202. +58 −0 com/rim/samples/device/openvgdemo/OpenVGDemo.jdp
  203. +103 −0 com/rim/samples/device/openvgdemo/OpenVGDemoScreen.java
  204. +172 −0 com/rim/samples/device/openvgdemo/ParsedPathVGField.java
  205. +74 −0 com/rim/samples/device/openvgdemo/Path.java
  206. +106 −0 com/rim/samples/device/openvgdemo/PathFileReader.java
  207. BIN  com/rim/samples/device/openvgdemo/res/img/icons.png
  208. BIN  com/rim/samples/device/openvgdemo/res/img/openvgdemo_jde.png
  209. +22 −0 com/rim/samples/device/openvgdemo/res/paths.txt
  210. +201 −0 com/rim/samples/device/optionsproviderdemo/FieldSet.java
  211. +126 −4 com/rim/samples/device/optionsproviderdemo/OptionsProviderDemo.java
  212. +9 −0 com/rim/samples/device/optionsproviderdemo/OptionsProviderDemo.jdp
  213. +20 −1 com/rim/samples/device/otabackuprestoredemo/OTAContactData.java
  214. +0 −32 com/rim/samples/device/otasyncdemo/readme.txt
  215. +7 −12 com/rim/samples/device/persistentstoredemo/Meeting.java
  216. +2 −0  com/rim/samples/device/persistentstoredemo/MeetingScreen.java
  217. +17 −29 com/rim/samples/device/persistentstoredemo/PersistentStoreDemo.java
  218. +4 −3 com/rim/samples/device/persistentstoredemo/PersistentStoreDemoScreen.java
  219. +32 −22 com/rim/samples/device/persistentstoredemo/PersistentStoreListener.java
  220. +9 −1 com/rim/samples/device/phone/phoneapidemo/PhoneApiDemo.java
  221. +4 −4 com/rim/samples/device/phone/phonelogsdemo/PhoneLogsDemo.java
  222. +1 −1  com/rim/samples/device/phone/phonemultilinedemo/PhoneMultiLineScreen.java
  223. +1 −2  com/rim/samples/device/rmsdemo/CDdb.java
  224. +1 −1  com/rim/samples/device/rmsdemo/RMSDemo.java
  225. +100 −66 com/rim/samples/device/sendmediademo/SendMediaDemo.java
  226. +75 −0 com/rim/samples/device/sendmenudemo/SendMenuDemo.java
  227. +52 −0 com/rim/samples/device/sendmenudemo/SendMenuDemo.jdp
  228. +326 −0 com/rim/samples/device/sendmenudemo/SendMenuDemoScreen.java
  229. BIN  com/rim/samples/device/sendmenudemo/img/sendmenudemo_jde.png
  230. +1 −1  com/rim/samples/device/socketdemo/SocketDemo.java
  231. +8 −2 com/rim/samples/device/sqlitedemo/DirectoryItem.java
  232. +6 −6 com/rim/samples/device/sqlitedemo/SQLManager.java
  233. +4 −8 com/rim/samples/device/sqlitedemo/SQLiteDemo.java
  234. +0 −2  com/rim/samples/device/svg/svgcldcdemo/SVGScreen.java
  235. +1 −1  com/rim/samples/device/svg/svgmapdemo/SVGMapManager.java
  236. +0 −129 com/rim/samples/device/svg/svgscriptingdemo/SVGScriptingDemoScreen.java
  237. BIN  com/rim/samples/device/svg/svgscriptingdemo/img/icon_jde.png
  238. BIN  com/rim/samples/device/svg/svgscriptingdemo/img/svgscriptingdemo_jde.png
  239. +0 −298 com/rim/samples/device/svg/svgscriptingdemo/sample.svg
  240. +42 −55 com/rim/samples/device/tiltdemo/TiltDemo.java
  241. +2 −2 com/rim/samples/device/touchdemo/TouchDemoScreen.java
  242. +0 −275 com/rim/samples/device/traveltimedemo/TravelTimeDemo.java
  243. +2 −2 com/rim/samples/device/udpdemo/UdpDemo.java
  244. +8 −4 com/rim/samples/device/ui/bitmapdemo/BitmapDemo.java
  245. +1 −1  com/rim/samples/device/ui/bitmapdemo/BitmapDemo.jdp
  246. +21 −1 com/rim/samples/device/ui/commandframeworkdemo/CommandFrameworkDemo.java
  247. +21 −1 com/rim/samples/device/ui/commandframeworkdemo/CommandFrameworkDemoRemoteApp.java
  248. +24 −4 com/rim/samples/device/ui/commandframeworkdemo/CommandFrameworkDemoScreen.java
  249. +21 −1 com/rim/samples/device/ui/commandframeworkdemo/ItemProvider.java
  250. +2 −2 com/rim/samples/device/ui/eyelidfielddemo/EyelidFieldDemoScreen.java
  251. +1 −1  com/rim/samples/device/ui/menudemo/MenuDemo.java
  252. +2 −2 com/rim/samples/device/ui/picturescrollfielddemo/PictureScrollFieldDemoScreen.java
  253. +21 −1 com/rim/samples/device/ui/picturescrollfielddemo/PinchScreen.java
  254. +21 −1 com/rim/samples/device/ui/progressindicatordemo/ActivityIndicatorScreen.java
  255. +21 −1 com/rim/samples/device/ui/progressindicatordemo/ProgressIndicatorScreen.java
  256. +3 −3 com/rim/samples/device/ui/screentransitionsdemo/ScreenTransitionsDemo.java
  257. +1 −1  com/rim/samples/device/ui/screentransitionsdemo/TransitionScreen.java
  258. +1 −1  com/rim/samples/device/ui/spinnerdemo/SpinnerDemoScreen.java
  259. +43 −3 com/rim/samples/device/ui/tableandlistdemo/RichListScreen.java
  260. +4 −5 com/rim/samples/device/ui/tableandlistdemo/TableScreen.java
  261. +3 −3 com/rim/samples/device/ui/tableandlistdemo/TreeScreen.java
  262. +22 −3 com/rim/samples/device/ui/uitoolkitdemo/AdjustmentScreen.java
  263. +21 −1 com/rim/samples/device/ui/uitoolkitdemo/TitleBarScreen.java
  264. +21 −1 com/rim/samples/device/ui/uitoolkitdemo/UiToolkitDemo.java
  265. +1 −1  com/rim/samples/device/ui/wireframelayoutdemo/WireFrameLayoutDemo.java
  266. +2 −2 com/rim/samples/device/ui/zoomscreendemo/ZoomScreenDemo.java
  267. +21 −1 com/rim/samples/device/unifiedsearchdemo/GraphicsHelper.java
  268. +0 −70 com/rim/samples/device/unifiedsearchdemo/PointOfInterest.java
  269. +0 −120 com/rim/samples/device/unifiedsearchdemo/PointOfInterestPublisher.java
  270. +0 −166 com/rim/samples/device/unifiedsearchdemo/PointOfInterestSearchable.java
  271. +0 −131 com/rim/samples/device/unifiedsearchdemo/SynchronizedQueue.java
  272. +32 −12 com/rim/samples/device/unifiedsearchdemo/UnifiedSearchDemo.java
  273. +4 −5 com/rim/samples/device/unifiedsearchdemo/UnifiedSearchDemo.jdp
  274. +91 −0 com/rim/samples/device/unifiedsearchdemo/UnifiedSearchDemoDataObject.java
  275. +81 −55 com/rim/samples/device/unifiedsearchdemo/{PointOfInterestEntity.java → UnifiedSearchDemoEntity.java}
  276. +52 −33 com/rim/samples/device/unifiedsearchdemo/UnifiedSearchDemoFileReader.java
  277. +296 −0 com/rim/samples/device/unifiedsearchdemo/UnifiedSearchDemoPublisher.java
  278. +83 −61 com/rim/samples/device/unifiedsearchdemo/UnifiedSearchDemoPublisherScreen.java
  279. +60 −21 com/rim/samples/device/unifiedsearchdemo/UnifiedSearchDemoSearchScreen.java
  280. +0 −6 com/rim/samples/device/unifiedsearchdemo/data/POIs.txt
  281. +7 −0 com/rim/samples/device/unifiedsearchdemo/data/data.txt
  282. +1 −1  com/rim/samples/device/videorecordingdemo/VideoRecordingDemo.java
  283. +3 −6 com/rim/samples/device/videorecordingdemo/VideoRecordingScreen.java
  284. +5 −9 com/rim/samples/server/httppushdemo/HTTPPushDemo.java
  285. +44 −20 samples.jdw
View
6 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/IconToolbarComponent.java
@@ -197,7 +197,7 @@ protected void onFocus(final int direction) {
}
/**
- * @see Field#onUnFocus()
+ * @see Field#onUnfocus()
*/
protected void onUnfocus() {
super.onUnfocus();
@@ -215,7 +215,7 @@ protected void onUnfocus() {
}
/**
- * @see Field#getAccesssibleContext()
+ * @see Field#getAccessibleContext()
*/
public AccessibleContext getAccessibleContext() {
return this;
@@ -298,7 +298,7 @@ public boolean isAccessibleStateSet(final int state) {
}
/**
- * @see AccessibleContext#getAccessibleChildSelected(int)
+ * @see AccessibleContext#isAccessibleChildSelected(int)
*/
public boolean isAccessibleChildSelected(final int index) {
// Check whether child icon at the specified index is selected
View
4 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/TableComponent.java
@@ -87,7 +87,7 @@ public TableComponent(final int columnCount, final int rowCount) {
}
/**
- * @see Manager#getAccesssibleContext()
+ * @see Manager#getAccessibleContext()
*/
public AccessibleContext getAccessibleContext() {
return this;
@@ -386,7 +386,7 @@ public int getAccessibleStateSet() {
}
/**
- * @see AccessibleContext#isAccessibleStateSet()
+ * @see AccessibleContext#isAccessibleStateSet(int)
*/
public boolean isAccessibleStateSet(final int state) {
return (state & getAccessibleStateSet()) != 0;
View
6 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/TextComponent.java
@@ -75,7 +75,7 @@ public TextComponent(final String text) {
// *********************** Field implementation ****************************
/**
- * @see Field#getAccesssibleContext()
+ * @see Field#getAccessibleContext()
*/
public AccessibleContext getAccessibleContext() {
return this;
@@ -96,7 +96,7 @@ public int getPreferredHeight() {
}
/**
- * @see Field#layout(width, height)
+ * @see Field#layout(int, int)
*/
protected void layout(final int width, final int height) {
// Split text into lines based on the given width
@@ -279,7 +279,7 @@ public AccessibleValue getAccessibleValue() {
}
/**
- * @see AccessibleContext#getAccessibleChildSelected(int)
+ * @see AccessibleContext#isAccessibleChildSelected(int)
*/
public boolean isAccessibleChildSelected(final int index) {
// Text field doesn't have any children
View
6 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/ValueComponent.java
@@ -75,7 +75,7 @@ public ValueComponent(final int min, final int current, final int max) {
// ********************Field implementation ********************************
/**
- * @see Field#getAccesssibleContext()
+ * @see Field#getAccessibleContext()
*/
public AccessibleContext getAccessibleContext() {
return this;
@@ -169,7 +169,7 @@ protected void onFocus(final int direction) {
}
/**
- * @see Field#onUnFocus()
+ * @see Field#onUnfocus()
*/
protected void onUnfocus() {
super.onUnfocus();
@@ -233,7 +233,7 @@ public boolean isAccessibleStateSet(final int state) {
}
/**
- * @see AccessibleContext#getAccessibleChildAt(int
+ * @see AccessibleContext#getAccessibleChildAt(int)
*/
public AccessibleContext getAccessibleChildAt(final int index) {
// No children in the value component
View
13 com/rim/samples/device/attachmentdemo/FileExplorerScreen.java
@@ -131,7 +131,7 @@ public FileExplorerScreen(final UiApplication app) {
_view.setDataTemplate(dataTemplate);
dataTemplate.useFixedHeight(true);
- // Add the file to the screen
+ // Add the TableView to the screen
add(_view);
readRoots(ROOT);
@@ -218,10 +218,11 @@ private void readRoots(final String root) {
// Reset the table contents
_model.removeAllRows();
- FileConnection fc = null;
Enumeration rootEnum = null;
if (root != null) {
+ FileConnection fc = null;
+
// Open the file system and get the list of directories/files
try {
fc = (FileConnection) Connector.open(root);
@@ -276,8 +277,8 @@ private void readSubroots(final String file) {
new FileHolder(file, fc.isDirectory());
_model.addRow(fileholder);
} catch (final IOException e) {
- AttachmentDemo
- .errorDialog("Connector.open() threw " + e.toString());
+ System.out.println("Connector.open(" + file + ") threw "
+ + e.toString());
} finally {
if (fc != null) {
// Everything is read. Close the connection.
@@ -375,7 +376,7 @@ protected boolean doAddRow(final Object row) {
}
/**
- * @see net.rim.device.api.ui.component.table.TableModelAdapter#doRemoveRowAt()
+ * @see net.rim.device.api.ui.component.table.TableModelAdapter#doRemoveRowAt(int)
*/
protected boolean doRemoveRowAt(final int index) {
_elements.removeElementAt(index);
@@ -390,7 +391,7 @@ protected Object doGetRow(final int index) {
}
/**
- * @see net.rim.device.api.ui.component.table.TableModelAdapter#removeAllRows()
+ * Removes all rows by repeatedly invoking {@link #removeRowAt}
*/
public void removeAllRows() {
while (getNumberOfRows() > 0) {
View
139 com/rim/samples/device/augmentedrealitydemo/ARDemoCameraScreen.java
@@ -0,0 +1,139 @@
+/*
+ * ARDemoCameraScreen.java
+ *
+ * Copyright © 1998-2011 Research In Motion Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Note: For the sake of simplicity, this sample application may not leverage
+ * resource bundles and resource strings. However, it is STRONGLY recommended
+ * that application developers make use of the localization features available
+ * within the BlackBerry development platform to ensure a seamless application
+ * experience across a variety of languages and geographies. For more information
+ * on localizing your application, please refer to the BlackBerry Java Development
+ * Environment Development Guide associated with this release.
+ */
+
+package com.rim.samples.device.augmentedrealitydemo;
+
+import javax.microedition.media.Player;
+import javax.microedition.media.control.GUIControl;
+import javax.microedition.media.control.VideoControl;
+
+import net.rim.device.api.system.Display;
+import net.rim.device.api.ui.Field;
+import net.rim.device.api.ui.UiApplication;
+import net.rim.device.api.ui.component.Dialog;
+import net.rim.device.api.ui.component.RichTextField;
+import net.rim.device.api.ui.container.ComponentCanvas;
+import net.rim.device.api.ui.container.MainScreen;
+
+/**
+ * MainScreen subclass for the Augmented Reality Demo application. This screen
+ * positions a rotating 3D cube on top of the camera view finder. The cube
+ * changes its axis of rotation when the orientation of the device changes.
+ */
+public final class ARDemoCameraScreen extends MainScreen {
+ private Field _cameraField;
+ private Player _player;
+ private DemoGLField _glField;
+ private static final int GL_FIELD_HEIGHT = Display.getHeight() / 3;
+ private static final int GL_FIELD_WIDTH = GL_FIELD_HEIGHT;
+ private static final int GL_FRAME_RATE = 60;
+
+ /**
+ * Creates a new ARDemoCameraScreen object
+ */
+ public ARDemoCameraScreen() {
+ // Set the title of the screen
+ setTitle("Augmented Reality Demo");
+
+ // Initialize the camera object and camera field
+ initializeCamera();
+
+ // If the camera field was constructed successfully, create the UI
+ if (_cameraField != null) {
+ // Add the camera field to a new ComponentCanvas
+ final ComponentCanvas compCanvas =
+ new ComponentCanvas(Display.getWidth(), Display.getHeight());
+ compCanvas.add(_cameraField, 0, 0);
+
+ // Initialize GLField
+ _glField = new DemoGLField(GL_FIELD_WIDTH, GL_FIELD_HEIGHT);
+ _glField.setTargetFrameRate(GL_FRAME_RATE);
+
+ // Add the GLField to the canvas
+ compCanvas.add(_glField, 100, 100);
+
+ // Add the ComponentCanvas to the screen
+ add(compCanvas);
+ } else {
+ add(new RichTextField("Error connecting to camera"));
+ }
+ }
+
+ /**
+ * @see net.rim.device.api.ui.Screen#close()
+ */
+ public void close() {
+ if (_player != null) {
+ try {
+ _player.close();
+ } catch (final Exception e) {
+ }
+ }
+
+ _glField.cleanUp();
+
+ super.close();
+ }
+
+ /**
+ * Initializes the Player, VideoControl and camera field
+ */
+ private void initializeCamera() {
+ try {
+ // Create a player for the camera view finder
+ _player =
+ javax.microedition.media.Manager
+ .createPlayer("capture://video");
+
+ // Set the player to the REALIZED state
+ _player.realize();
+
+ // Get the video control
+ final VideoControl videoControl =
+ (VideoControl) _player.getControl("VideoControl");
+
+ if (videoControl != null) {
+ // Create the video field as a GUI primitive
+ _cameraField =
+ (Field) videoControl.initDisplayMode(
+ GUIControl.USE_GUI_PRIMITIVE,
+ "net.rim.device.api.ui.Field");
+ videoControl.setDisplayFullScreen(true);
+ videoControl.setVisible(true);
+ }
+
+ // Set the player to the STARTED state
+ _player.start();
+ } catch (final Exception e) {
+ UiApplication.getUiApplication().invokeLater(new Runnable() {
+ public void run() {
+ Dialog.alert("ERROR " + e.getClass() + ": "
+ + e.getMessage());
+ }
+ });
+ }
+ }
+}
View
72 com/rim/samples/device/augmentedrealitydemo/AugmentedRealityDemo.java
@@ -0,0 +1,72 @@
+/*
+ * AugmentedRealityDemo.java
+ *
+ * Copyright © 1998-2011 Research In Motion Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Note: For the sake of simplicity, this sample application may not leverage
+ * resource bundles and resource strings. However, it is STRONGLY recommended
+ * that application developers make use of the localization features available
+ * within the BlackBerry development platform to ensure a seamless application
+ * experience across a variety of languages and geographies. For more information
+ * on localizing your application, please refer to the BlackBerry Java Development
+ * Environment Development Guide associated with this release.
+ */
+
+package com.rim.samples.device.augmentedrealitydemo;
+
+import net.rim.device.api.opengles.GLUtils;
+import net.rim.device.api.ui.UiApplication;
+import net.rim.device.api.ui.component.Dialog;
+
+/**
+ * This application shows an example of overlaying a graphical object on a
+ * surface backed field to create an augmented reality experience. The
+ * application displays a spinning 3D cube object on top of the camera view
+ * finder. The cube changes its axis of rotation when the orientation of the
+ * device changes.
+ */
+public final class AugmentedRealityDemo extends UiApplication {
+
+ /**
+ * Entry point for application
+ *
+ * @param args
+ * Command line arguments (not used)
+ */
+ public static void main(final String[] args) {
+ // Create a new instance of the application and make the currently
+ // running thread the application's event dispatch thread.
+ final AugmentedRealityDemo app = new AugmentedRealityDemo();
+ app.enterEventDispatcher();
+ }
+
+ /**
+ * Creates a new AugmentedRealityDemo object
+ */
+ public AugmentedRealityDemo() {
+ // Check whether OpenGL is supported on the current BlackBerry
+ // Smartphone
+ if (GLUtils.isSupported()) {
+ pushScreen(new ARDemoCameraScreen());
+ } else {
+ UiApplication.getUiApplication().invokeLater(new Runnable() {
+ public void run() {
+ Dialog.alert("This device does not support OpenGL, exiting Augmented Reality Demo application...");
+ System.exit(0);
+ }
+ });
+ }
+ }
+}
View
55 com/rim/samples/device/augmentedrealitydemo/AugmentedRealityDemo.jdp
@@ -0,0 +1,55 @@
+## RIM Java Development Environment
+# RIM Project file
+#
+# This file is generated and managed by BlackBerry developer tools.
+# It SHOULD NOT BE modified manually.
+#
+AddOn=0
+AlwaysBuild=0
+[AlxImports
+]
+AutoRestart=0
+[ClassProtection
+]
+[CustomBuildFiles
+]
+[CustomBuildRules
+]
+[DefFiles
+]
+[DependsOn
+]
+ExcludeFromBuildAll=0
+Exported=0
+[Files
+ARDemoCameraScreen.java
+AugmentedRealityDemo.java
+Cube.java
+DemoGLField.java
+img\augmentedrealitydemo_jde.png
+img\BlackBerry.png
+]
+HaveAlxImports=0
+HaveDefs=0
+HaveImports=0
+[Icons
+img\augmentedrealitydemo_jde.png
+]
+[ImplicitRules
+]
+[Imports
+]
+Listing=0
+Options=-quiet
+OutputFileName=AugmentedRealityDemo
+[PackageProtection
+]
+RibbonPosition=0
+[RolloverIcons
+]
+RunOnStartup=0
+SkipCompile=0
+StartupTier=7
+SystemModule=0
+Title=Augmented Reality Demo
+Type=0
View
210 com/rim/samples/device/augmentedrealitydemo/Cube.java
@@ -0,0 +1,210 @@
+/*
+ * Cube.java
+ *
+ * Copyright © 1998-2011 Research In Motion Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Note: For the sake of simplicity, this sample application may not leverage
+ * resource bundles and resource strings. However, it is STRONGLY recommended
+ * that application developers make use of the localization features available
+ * within the BlackBerry development platform to ensure a seamless application
+ * experience across a variety of languages and geographies. For more information
+ * on localizing your application, please refer to the BlackBerry Java Development
+ * Environment Development Guide associated with this release.
+ */
+
+package com.rim.samples.device.augmentedrealitydemo;
+
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.ShortBuffer;
+
+import javax.microedition.khronos.opengles.GL;
+import javax.microedition.khronos.opengles.GL10;
+import javax.microedition.khronos.opengles.GL11;
+
+/**
+ * A class representing a 3D cube
+ */
+public final class Cube {
+
+ private static final float[] VERTICES = { -0.5f, 0.5f, 0.5f, -0.5f, -0.5f,
+ 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f,
+ -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f,
+ -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f,
+ 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f,
+ 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f,
+ -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f,
+ -0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f,
+ 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f,
+ 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f,
+ 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, 0.5f,
+ -0.5f, -0.5f };
+
+ private static final float[] TEXCOORDS = { 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1,
+ 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0,
+ 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1,
+ 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, };
+
+ private static final float[] NORMALS = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
+ 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
+ 1, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0,
+ -1, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0,
+ 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1,
+ 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0 };
+
+ private static final short[] INDICES = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+ 28, 29, 30, 31, 32, 33, 34, 35 };
+
+ private int _buffers[];
+ private final float _vertices[];
+ private final float _normals[];
+ private final float _texcoords[];
+ private final short _indices[];
+ private final int _verticesSize;
+ private final int _normalsSize;
+ private final int _texcoordsSize;
+ private final int _indicesSize;
+ private int _vertexAttribIndex = -1;
+ private int _normalAttribIndex = -1;
+ private int _texcoordAttribIndex = -1;
+
+ /**
+ * Creates a new Cube object
+ *
+ * @param g
+ * GL object used for drawing
+ */
+ public Cube(final GL g) {
+ _vertices = VERTICES;
+ _normals = NORMALS;
+ _texcoords = TEXCOORDS;
+ _indices = INDICES;
+ _verticesSize = VERTICES.length * 4;
+ _normalsSize = NORMALS.length * 4;
+ _texcoordsSize = TEXCOORDS.length * 4;
+ _indicesSize = INDICES.length * 2;
+
+ init(g);
+ }
+
+ /**
+ * Initializes the cube
+ *
+ * @param g
+ * GL object used for drawing
+ */
+ void init(final GL g) {
+ final FloatBuffer vertices =
+ ByteBuffer.allocateDirect(
+ _verticesSize + _normalsSize + _texcoordsSize)
+ .asFloatBuffer();
+ vertices.put(_vertices);
+
+ if (_normalsSize > 0) {
+ vertices.put(_normals);
+ }
+
+ if (_texcoordsSize > 0) {
+ vertices.put(_texcoords);
+ }
+
+ vertices.rewind();
+ final ShortBuffer indices =
+ ByteBuffer.allocateDirect(_indicesSize).asShortBuffer();
+ indices.put(_indices);
+ indices.rewind();
+
+ _buffers = new int[2];
+
+ final GL11 gl = (GL11) g;
+ gl.glGenBuffers(2, _buffers, 0);
+ gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, _buffers[0]);
+ gl.glBufferData(GL11.GL_ARRAY_BUFFER, _verticesSize + _normalsSize
+ + _texcoordsSize, vertices, GL11.GL_STATIC_DRAW);
+ gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, _buffers[1]);
+ gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, _indicesSize, indices,
+ GL11.GL_STATIC_DRAW);
+ gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
+ gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);
+ }
+
+ /**
+ * Renders the cube
+ *
+ * @param g
+ * GL object used for drawing
+ */
+ public void render(final GL g) {
+ final GL11 gl = (GL11) g;
+ gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, _buffers[0]);
+ gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, _buffers[1]);
+
+ if (_vertexAttribIndex != -1) {
+ gl.glVertexPointer(3, GL10.GL_FLOAT, 0, 0);
+ gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
+ }
+
+ if (_normalAttribIndex != -1 && _normalsSize > 0) {
+ gl.glNormalPointer(GL10.GL_FLOAT, 0, _verticesSize);
+ gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
+ }
+
+ if (_texcoordAttribIndex != -1 && _texcoordsSize > 0) {
+ gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, _verticesSize
+ + _normalsSize);
+ gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
+ }
+
+ gl.glDrawElements(GL10.GL_TRIANGLES, _indicesSize / 2,
+ GL10.GL_UNSIGNED_SHORT, 0);
+
+ if (_vertexAttribIndex != -1) {
+ gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
+ }
+
+ if (_normalAttribIndex != -1 && _normalsSize > 0) {
+ gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
+ }
+
+ if (_texcoordAttribIndex != -1 && _texcoordsSize > 0) {
+ gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
+ }
+
+ gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
+ gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);
+ }
+
+ /**
+ * Enables vertex attribute
+ */
+ public void enableVertexAttrib() {
+ _vertexAttribIndex = 1;
+ }
+
+ /**
+ * Enables normal attribute
+ */
+ public void enableNormalAttrib() {
+ _normalAttribIndex = 1;
+ }
+
+ /**
+ * Enables texcoord attribute
+ */
+ public void enableTexcoordAttrib() {
+ _texcoordAttribIndex = 1;
+ }
+}
View
233 com/rim/samples/device/augmentedrealitydemo/DemoGLField.java
@@ -0,0 +1,233 @@
+/*
+ * DemoGLField.java
+ *
+ * Copyright © 1998-2011 Research In Motion Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Note: For the sake of simplicity, this sample application may not leverage
+ * resource bundles and resource strings. However, it is STRONGLY recommended
+ * that application developers make use of the localization features available
+ * within the BlackBerry development platform to ensure a seamless application
+ * experience across a variety of languages and geographies. For more information
+ * on localizing your application, please refer to the BlackBerry Java Development
+ * Environment Development Guide associated with this release.
+ */
+
+package com.rim.samples.device.augmentedrealitydemo;
+
+import javax.microedition.khronos.opengles.GL;
+import javax.microedition.khronos.opengles.GL10;
+import javax.microedition.khronos.opengles.GL11;
+
+import net.rim.device.api.math.Matrix4f;
+import net.rim.device.api.math.Vector3f;
+import net.rim.device.api.opengles.GLField;
+import net.rim.device.api.opengles.GLUtils;
+import net.rim.device.api.system.AccelerometerData;
+import net.rim.device.api.system.AccelerometerListener;
+import net.rim.device.api.system.AccelerometerSensor;
+import net.rim.device.api.system.AccelerometerSensor.Channel;
+import net.rim.device.api.system.Application;
+import net.rim.device.api.system.Bitmap;
+
+/**
+ * A GLField implementation which renders a Cube object and changes the rotation
+ * axis based on accelerometer data.
+ */
+class DemoGLField extends GLField implements AccelerometerListener {
+ // Holds the number of radians to rotate per frame
+ private static final float RADIANS_PER_FRAME = (float) Math.toRadians(2.0f);
+
+ // Accelerometer orientation data channel
+ private Channel _orientChannel;
+
+ // Holds the screen's aspect ratio
+ private final float _aspect;
+
+ // Holds the transformations for the boxes
+ private Matrix4f _transform;
+
+ // Holds the axis of rotation
+ private final Vector3f _rotationAxis = new Vector3f(0, 1, 0);
+
+ // Holds the cube to be rendered
+ private Cube _cube;
+
+ private final int _width;
+ private final int _height;
+
+ /**
+ * Creates a new DemoGLField object
+ *
+ * @param width
+ * Width for the field
+ * @param height
+ * Height of the field
+ */
+ DemoGLField(final int width, final int height) {
+ super(GLField.VERSION_1_1);
+
+ _width = width;
+ _height = height;
+ _aspect = (float) width / (float) height;
+
+ if (AccelerometerSensor.isSupported()) {
+ // Initialize Accelerometer data channel and listener
+ _orientChannel =
+ AccelerometerSensor.openOrientationDataChannel(Application
+ .getApplication());
+ _orientChannel.addAccelerometerListener(this);
+ }
+ }
+
+ /**
+ * @see net.rim.device.api.ui.Field#layout(int, int)
+ */
+ protected void layout(final int width, final int height) {
+ setExtent(_width, _height);
+ }
+
+ /**
+ * @see net.rim.device.api.opengles.GLField#initialize(GL)
+ */
+ public void initialize(final GL renderer) {
+ final GL11 gl = (GL11) renderer;
+
+ _transform = new Matrix4f();
+ _transform.translate(0, 0, -4.0f);
+ _transform.scale(1.5f);
+
+ // Create the cube for "instanced" rendering
+ _cube = new Cube(gl);
+
+ gl.glEnable(GL10.GL_TEXTURE_2D);
+
+ // Load the texture bitmap
+ final Bitmap bitmap = Bitmap.getBitmapResource("BlackBerry.png");
+ if (bitmap != null) {
+ final int[] textureIds = new int[1];
+ gl.glGenTextures(1, textureIds, 0);
+ final int _texture = textureIds[0];
+ gl.glBindTexture(GL10.GL_TEXTURE_2D, _texture);
+ GLUtils.glTexImage2D(gl, 0, GL10.GL_RGB,
+ GL10.GL_UNSIGNED_SHORT_5_6_5, bitmap, null);
+ gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
+ GL10.GL_LINEAR);
+ gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,
+ GL10.GL_LINEAR);
+ gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
+ GL10.GL_CLAMP_TO_EDGE);
+ gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
+ GL10.GL_CLAMP_TO_EDGE);
+ }
+
+ // Setup GL state
+ gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
+ gl.glDisable(GL10.GL_DITHER);
+ gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
+ gl.glEnable(GL10.GL_CULL_FACE);
+ gl.glShadeModel(GL10.GL_SMOOTH);
+ gl.glEnable(GL10.GL_DEPTH_TEST);
+
+ initializeLights(gl);
+ }
+
+ /**
+ * Defines the lighting for the cube
+ *
+ * @param gl
+ * The GL11 object used for drawing
+ */
+ private void initializeLights(final GL11 gl) {
+ // Set the ambient color for the entire scene
+ final float[] ambientColor = { 0.2f, 0.2f, 0.2f, 1.0f };
+ gl.glLightModelfv(GL10.GL_LIGHT_MODEL_AMBIENT, ambientColor, 0);
+
+ // Set up the position and color for light 0
+ final float[] position = { 5.0f, -2.0f, 20.0f, 0.0f };
+ final float[] color = { 0.75f, 0.75f, 0.75f, 1.0f };
+ gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, position, 0);
+ gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, color, 0);
+ gl.glEnable(GL10.GL_LIGHT0);
+
+ gl.glEnable(GL10.GL_LIGHTING);
+ }
+
+ /**
+ * @see AccelerometerListener#onData(AccelerometerData)
+ */
+ public void onData(final AccelerometerData accData) {
+ // Adjust the rotation of the cube based on current orientation
+ switch (accData.getOrientation()) {
+ case AccelerometerSensor.ORIENTATION_TOP_UP:
+ _rotationAxis.set(0.0f, 1.0f, 0.0f);
+ break;
+ case AccelerometerSensor.ORIENTATION_BOTTOM_UP:
+ _rotationAxis.set(0.0f, 1.0f, 0.0f);
+ break;
+ case AccelerometerSensor.ORIENTATION_FRONT_UP:
+ _rotationAxis.set(0.0f, 0.0f, 1.0f);
+ break;
+ case AccelerometerSensor.ORIENTATION_BACK_UP:
+ _rotationAxis.set(0.0f, 0.0f, 1.0f);
+ break;
+ case AccelerometerSensor.ORIENTATION_LEFT_UP:
+ _rotationAxis.set(1.0f, 0.0f, 0.0f);
+ break;
+ case AccelerometerSensor.ORIENTATION_RIGHT_UP:
+ _rotationAxis.set(1.0f, 0.0f, 0.0f);
+ break;
+ }
+ }
+
+ /**
+ * @see net.rim.device.api.opengles.GLField#update()
+ */
+ public void update() {
+ _rotationAxis.normalize();
+ _transform.rotate(_rotationAxis, RADIANS_PER_FRAME);
+ }
+
+ /**
+ * @see net.rim.device.api.opengles.GLField#render(GL)
+ */
+ public void render(final GL renderer) {
+ final GL11 gl = (GL11) renderer;
+
+ gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
+
+ // Set up the perspective projection
+ gl.glMatrixMode(GL10.GL_PROJECTION);
+ gl.glLoadIdentity();
+ GLUtils.gluPerspective(gl, 45.0f, _aspect, 0.15f, 1000.0f);
+
+ // Set up the local modelview transform and render it
+ gl.glMatrixMode(GL10.GL_MODELVIEW);
+
+ gl.glLoadMatrixf(_transform.getArray(), 0);
+ _cube.enableVertexAttrib();
+ _cube.enableNormalAttrib();
+ _cube.enableTexcoordAttrib();
+ _cube.render(gl);
+ }
+
+ /**
+ * Closes the Accelerometer's data channel
+ */
+ public void cleanUp() {
+ if (_orientChannel != null) {
+ _orientChannel.close();
+ }
+ }
+}
View
BIN  com/rim/samples/device/augmentedrealitydemo/img/BlackBerry.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  com/rim/samples/device/augmentedrealitydemo/img/augmentedrealitydemo_jde.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
348 com/rim/samples/device/barcodescandemo/BarcodeScanDemo.java
@@ -29,40 +29,40 @@
import java.util.Hashtable;
import java.util.Vector;
-import javax.microedition.media.MediaException;
-
+import net.rim.device.api.amms.control.camera.ImageDecoder;
+import net.rim.device.api.amms.control.camera.ImageDecoderListener;
+import net.rim.device.api.amms.control.camera.ImageScanner;
import net.rim.device.api.barcodelib.BarcodeDecoder;
-import net.rim.device.api.barcodelib.BarcodeDecoderListener;
-import net.rim.device.api.barcodelib.BarcodeScanner;
-import net.rim.device.api.system.Alert;
-import net.rim.device.api.system.Characters;
+import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
+import net.rim.device.api.ui.TransitionContext;
+import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiApplication;
+import net.rim.device.api.ui.UiEngineInstance;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.DecodeHintType;
+import com.google.zxing.Result;
/*
* This application demonstrates the use of the Barcode API. It
* presents a simple interface for accessing and displaying a window
- * in which the user can center a QR (Quick Response) Code. When a
- * code is scanned, the application will return to the original
- * screen and display the code's embedded data.
+ * in which the user can center a bar code. When a code is scanned,
+ * the application will display the code's type and embedded data.
*/
public final class BarcodeScanDemo extends UiApplication {
+
/**
- * Entry point for application
+ * Entry point for the application
*
* @param args
- * Command-line arguments (not used)
+ * Command-line argument (not used)
*/
public static void main(final String[] args) {
- // Create a new instance of the application and make the currently
- // running thread the application's event dispatch thread.
new BarcodeScanDemo().enterEventDispatcher();
}
@@ -70,179 +70,227 @@ public static void main(final String[] args) {
* Creates a new BarcodeScanDemo object
*/
public BarcodeScanDemo() {
- pushScreen(new BarcodeScanDemoScreen());
+ pushScreen(new ScanScreen());
}
}
/**
* A UI screen to display the camera display and buttons
*/
-final class BarcodeScanDemoScreen extends MainScreen {
- private ViewFinderScreen _viewFinderScreen;
- private final LabelField _scannedText;
+final class ScanScreen extends MainScreen {
+ private ImageScanner _scanner;
+ private MainScreen _vfScreen;
+ private ButtonField _QRButton;
+ private ButtonField _UPCButton;
+ private ButtonField _dataMatrixButton;
+ private ButtonField _code128Button;
/**
- * Creates a new BarcodeScanDemoScreen object
+ * Creates a new ScanScreen object
*/
- public BarcodeScanDemoScreen() {
+ public ScanScreen() {
// Set the title of the screen
setTitle("Barcode Scan Demo");
+ buildUi();
+ }
+
+ /**
+ * Builds the user interface. Adds buttons and registers MyFieldListeners
+ * for each.
+ */
+ private void buildUi() {
- // Create a button which will launch a viewfinder screen
- final ButtonField buttonField =
- new ButtonField("Scan QR Barcode", ButtonField.CONSUME_CLICK
+ _QRButton =
+ new MyButtonField("Scan QR", ButtonField.CONSUME_CLICK
| ButtonField.NEVER_DIRTY | Field.FIELD_HCENTER
| Field.FIELD_VCENTER);
- buttonField.setChangeListener(new FieldChangeListener() {
- public void fieldChanged(final Field field, final int context) {
- // If no screen exists, create one before displaying
- if (_viewFinderScreen == null) {
- _viewFinderScreen = new ViewFinderScreen();
- }
-
- // Push view finder screen onto the display stack
- UiApplication.getUiApplication().pushScreen(_viewFinderScreen);
-
- // Begin the scanning process
- _viewFinderScreen.startScan();
- }
- });
+ _QRButton.setChangeListener(new MyFieldListener());
- buttonField.setPadding(2, 2, 2, 2);
- add(buttonField);
+ _dataMatrixButton =
+ new MyButtonField("Scan DataMatrix", ButtonField.CONSUME_CLICK
+ | ButtonField.NEVER_DIRTY | Field.FIELD_HCENTER
+ | Field.FIELD_VCENTER);
+ _dataMatrixButton.setChangeListener(new MyFieldListener());
- _scannedText = new LabelField();
- _scannedText.setPadding(5, 5, 5, 5);
- add(_scannedText);
+ _UPCButton =
+ new MyButtonField("Scan UPC", ButtonField.CONSUME_CLICK
+ | ButtonField.NEVER_DIRTY | Field.FIELD_HCENTER
+ | Field.FIELD_VCENTER);
+ _UPCButton.setChangeListener(new MyFieldListener());
+
+ _code128Button =
+ new MyButtonField("Scan Code 128", ButtonField.CONSUME_CLICK
+ | ButtonField.NEVER_DIRTY | Field.FIELD_HCENTER
+ | Field.FIELD_VCENTER);
+ _code128Button.setChangeListener(new MyFieldListener());
+
+ add(_QRButton);
+ add(_dataMatrixButton);
+ add(_UPCButton);
+ add(_code128Button);
}
/**
- * A MainScreen subclass to display a view finder which presents camera
- * input to the user and uses a BarcodeScanner to periodically check for the
- * presence of a QR code.
+ * Allows for larger than normal ButtonFields
*/
- private final class ViewFinderScreen extends MainScreen {
- private BarcodeScanner _scanner;
- private final short _frequency = 1046;
- private final short _duration = 200;
- private final int _volume = 100;
-
- /**
- * Creates a new ViewFinderScreen object
- */
- public ViewFinderScreen() {
- // Initialize Hashtable used to inform the scanner how to
- // recognize the QR code format.
- final Hashtable hints = new Hashtable();
- final Vector formats = new Vector(1);
- formats.addElement(BarcodeFormat.QR_CODE);
- hints.put(DecodeHintType.POSSIBLE_FORMATS, formats);
-
- // Initialize the BarcodeDecoder
- final BarcodeDecoder decoder = new BarcodeDecoder(hints);
-
- // Create a custom instance of a BarcodeDecoderListener to pop the
- // screen and display results when a QR code is recognized.
- final BarcodeDecoderListener decoderListener =
- new BarcodeDecoderListener() {
- /**
- * @see BarcodeDecoderListener#barcodeDecoded(String)
- */
- public void barcodeDecoded(final String rawText) {
- displayMessage(rawText);
- beep();
- }
- };
-
- try {
- // Initialize the BarcodeScanner object and add the associated
- // view finder.
- _scanner = new BarcodeScanner(decoder, decoderListener);
- _scanner.getVideoControl().setDisplayFullScreen(true);
- add(_scanner.getViewfinder());
-
- } catch (final Exception e) {
- displayMessage("Error: " + e.getMessage());
- }
+ private class MyButtonField extends ButtonField {
+ public MyButtonField(final String label, final long style) {
+ super(label, style);
}
/**
- * Informs the BarcodeScanner that it should begin scanning for QR Codes
+ * Retreives the buttons perferred width (60% of Display.getWidth())
+ *
+ * @return The preferred width of the button
*/
- public void startScan() {
- try {
- _scanner.startScan();
- } catch (final MediaException me) {
- displayMessage("Error: " + me.getMessage());
- }
+ public int getPreferredWidth() {
+ return (int) (Display.getWidth() * 0.60);
}
+ }
- /**
- * @see net.rim.device.api.ui.Screen#keyChar()
- */
- protected boolean keyChar(final char key, final int status,
- final int time) {
- if (key == Characters.ESCAPE) {
- // Manually stop the scanning process and pop the screen
- try {
- _scanner.stopScan();
- UiApplication.getUiApplication().popScreen(
- ViewFinderScreen.this);
- } catch (final MediaException me) {
- displayMessage("Error: " + me.getMessage());
- }
- }
+ /**
+ * @see net.rim.device.api.ui.container.MainScreen#onSavePrompt()
+ */
+ protected boolean onSavePrompt() {
+ // Prevent the save dialog from being displayed
+ return true;
+ }
- return super.keyChar(key, status, time);
- }
+ /**
+ * Displays the decoded barcode text and the type of barcode that was just
+ * scanned.
+ *
+ * @param result
+ * The results from scanning a barcode
+ */
+ public void inform(final Result result) {
+ // Close the viewfinder first
+ UiApplication.getUiApplication().popScreen(_vfScreen);
- /**
- * @see net.rim.device.api.ui.Screen#close()
- */
- public void close() {
- try {
- _scanner.stopScan();
- } catch (final MediaException me) {
- displayMessage("Error: " + me.getMessage());
+ final MainScreen resultsScreen = new MainScreen();
+
+ final LabelField text =
+ new LabelField("Barcode Text: " + result.getText());
+ text.setPadding(4, 4, 4, 4);
+
+ final LabelField type =
+ new LabelField("Barcode Type: "
+ + result.getBarcodeFormat().toString());
+ type.setPadding(4, 4, 4, 4);
+
+ final TransitionContext context =
+ new TransitionContext(TransitionContext.TRANSITION_SLIDE);
+ context.setIntAttribute(TransitionContext.ATTR_DIRECTION,
+ TransitionContext.KIND_OUT);
+
+ Ui.getUiEngineInstance().setTransition(null, resultsScreen,
+ UiEngineInstance.TRIGGER_PUSH, context);
+
+ resultsScreen.add(text);
+ resultsScreen.add(type);
+
+ UiApplication.getUiApplication().pushScreen(resultsScreen);
+ }
+
+ /**
+ * Initializes the camara to begin scanning the barcode
+ *
+ * @param decoder
+ * The decoder that is going to be used to decode the barcode
+ * @param listener
+ * The listner that is going to be used to tell when the barcode
+ * is scanned
+ * @return An initialized Viewfinder screen to be displayed
+ */
+ private Field initializeCamera(final ImageDecoder decoder,
+ final ImageDecoderListener listener) {
+ try {
+ // Check if the ImageScanner has already been initialized. If it
+ // has,
+ // make sure to close its player, so that a new one can be created.
+ if (_scanner != null) {
+ _scanner.getPlayer().close();
}
- super.close();
+ _scanner = new ImageScanner(decoder, listener);
+ _scanner.getVideoControl().setDisplayFullScreen(true);
+ _scanner.startScan();
+ return _scanner.getViewfinder();
+ } catch (final Exception e) {
}
+ return null;
+ }
+
+ /**
+ * Handles field change events
+ */
+ private class MyFieldListener implements FieldChangeListener {
+
+ final ImageDecoderListener _imageDecoderListener =
+ new ImageDecoderListener() {
+
+ /**
+ * @see net.rim.device.api.amms.control.camera.ImageDecoderListener#imageDecoded(Object)
+ */
+ public void imageDecoded(final Object decoded) {
+ UiApplication.getUiApplication().invokeLater(
+ new Runnable() {
+ public void run() {
+ inform((Result) decoded);
+ }
+ });
+ }
+ };
/**
- * Pops the ViewFinderScreen and displays text on the main screen
+ * Listens for when a button is pressed
*
- * @param text
- * Text to display on the screen
+ * @see net.rim.device.api.ui.FieldChangeListener#fieldChanged(Field,
+ * int)
*/
- private void displayMessage(final String text) {
- UiApplication.getUiApplication().invokeLater(new Runnable() {
- public void run() {
- _scannedText.setText(text);
- UiApplication.getUiApplication().popScreen(
- ViewFinderScreen.this);
- }
- });
- }
+ public void fieldChanged(final Field field, final int context) {
+ final Vector formats = new Vector();
- /**
- * Beeps to notify the user that a scan was successful
- */
- private void beep() {
- UiApplication.getUiApplication().invokeLater(new Runnable() {
- public void run() {
- Alert.startAudio(new short[] { _frequency, _duration },
- _volume);
- }
- });
- }
- }
+ // Find what button was pressed and add its format(s) to the vector
+ if (field == _QRButton) {
+ System.out.println("QR button");
+ formats.addElement(BarcodeFormat.QR_CODE);
+ } else if (field == _dataMatrixButton) {
+ formats.addElement(BarcodeFormat.DATAMATRIX);
+ } else if (field == _UPCButton) {
+ formats.addElement(BarcodeFormat.UPC_A);
+ formats.addElement(BarcodeFormat.UPC_E);
+ formats.addElement(BarcodeFormat.EAN_13);
+ formats.addElement(BarcodeFormat.EAN_8);
+ } else if (field == _code128Button) {
+ formats.addElement(BarcodeFormat.CODE_128);
+ }
- /**
- * @see net.rim.device.api.ui.container.MainScreen#onSavePrompt()
- */
- protected boolean onSavePrompt() {
- // Suppress the save dialog
- return true;
+ // Allows for the decoder to look for a specific type of barcode.
+ // Can increase the decoders speed or accuracy.
+ final Hashtable hints = new Hashtable();
+ hints.put(DecodeHintType.POSSIBLE_FORMATS, formats);
+
+ // Uncomment the following line of java code if you wish to
+ // "try harder",
+ // but expect that as a result the decoding time for each image
+ // processed
+ // may take upwards of 20 times as long. It is recommended that this
+ // setting
+ // not be used in most cases.
+ // hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
+
+ // Initialize the camera object and video field
+ final Field cameraField =
+ initializeCamera(new BarcodeDecoder(hints),
+ _imageDecoderListener);
+
+ // If the field was constructed successfully, create the UI
+ if (cameraField != null) {
+ _vfScreen = new MainScreen();
+ _vfScreen.add(cameraField);
+ UiApplication.getUiApplication().pushScreen(_vfScreen);
+ }
+ }
}
}
View
BIN  com/rim/samples/device/barcodescandemo/beep.wav
Binary file not shown
View
209 com/rim/samples/device/blackberrybalancedemo/BlackBerryBalanceDemo.java
@@ -0,0 +1,209 @@
+/*
+ * PersistentStoreDemo.java
+ *
+ * Copyright © 1998-2011 Research In Motion Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Note: For the sake of simplicity, this sample application may not leverage
+ * resource bundles and resource strings. However, it is STRONGLY recommended
+ * that application developers make use of the localization features available
+ * within the BlackBerry development platform to ensure a seamless application
+ * experience across a variety of languages and geographies. For more information
+ * on localizing your application, please refer to the BlackBerry Java Development
+ * Environment Development Guide associated with this release.
+ */
+
+package com.rim.samples.device.blackberrybalancedemo;
+
+import java.util.Vector;
+
+import net.rim.device.api.system.MultiServicePlatformConstants;
+import net.rim.device.api.system.MultiServicePlatformManager;
+import net.rim.device.api.system.PersistentObject;
+import net.rim.device.api.system.PersistentStore;
+import net.rim.device.api.system.ServiceMode;
+import net.rim.device.api.ui.Screen;
+import net.rim.device.api.ui.UiApplication;
+import net.rim.device.api.ui.component.Dialog;
+
+/**
+ * A sample application to demonstrate the BlackBerry Balance service. This
+ * project is a simple GUI memo application in which memos are created and saved
+ * in persistent store. Memos encapsulate a service mode property which is set
+ * when the multi service framework suggests a relevant service mode for this
+ * application to operate in. The application registers a
+ * MultiServicePlatformListener with the framework so as to be notified when
+ * controlled data should be wiped from the device.
+ */
+public final class BlackBerryBalanceDemo extends UiApplication {
+ private static Vector _memos;
+ private static PersistentObject _store;
+ private static BlackBerryBalanceDemoScreen _screen;
+
+ // com.rim.samples.device.blackberrybalancedemo = 0x58202aef09586a38L
+ static final long BLACKBERRY_BALANCE_DEMO_ID = 0x58202aef09586a38L;
+
+ /**
+ * Entry point for application
+ *
+ * @param args
+ * Command-line arguments (not used)
+ */
+ public static void main(final String[] args) {
+ final BlackBerryBalanceDemo app = new BlackBerryBalanceDemo();
+ app.enterEventDispatcher();
+ }
+
+ /**
+ * Creates a new PersistentStoreDemo object
+ */
+ public BlackBerryBalanceDemo() {
+ MultiServicePlatformManager.addListener(new MultiServiceListener(),
+ MultiServicePlatformConstants.LOW_PRIORITY);
+
+ // Retrieve the persistent object for this application
+ _store =
+ PersistentStore.getPersistentObject(BLACKBERRY_BALANCE_DEMO_ID);
+
+ // Synchronize on the PersistentObject so that no other object can
+ // acquire the lock before we finish our commit operation.
+ synchronized (_store) {
+ // If the PersistentObject is empty, initialize it
+ if (_store.getContents() == null) {
+ _store.setContents(new Vector());
+ }
+ }
+
+ // Retrieve the saved Memo objects from the persistent store
+ _memos = (Vector) _store.getContents();
+
+ // Push the main screen onto the display stack
+ _screen = new BlackBerryBalanceDemoScreen(_memos);
+ pushScreen(_screen);
+ }
+
+ /**
+ * Saves new or updated memo
+ *
+ * @param memo
+ * The memo to be saved
+ * @param index
+ * The memo's position in the collection. A value of -1
+ * represents a new meeting.
+ */
+ public void saveMemo(final Memo memo, final int index) {
+ if (index >= 0) {
+ _screen.getModel().removeRowAt(index);
+ _screen.getModel().insertRowAt(index, memo);
+ } else {
+ _screen.getModel().addRow(memo);
+ }
+ }
+
+ /**
+ * Returns collection of Memo objects
+ *
+ * @return A vector of Memo objects
+ */
+ public Vector getMemos() {
+ return _memos;
+ }
+
+ /**
+ * Commits the updated vector of Memo objects to the persistent store.
+ */
+ public void persist() {
+ // Synchronize on the PersistentObject so that no other object can
+ // acquire the lock before the commit operation is finished.
+ synchronized (_store) {
+ _store.setContents(_memos);
+ PersistentObject.commit(_store);
+ }
+ }
+
+ /**
+ * @see net.rim.device.api.system.Application#suggestServiceMode(ServiceMode)
+ */
+ public boolean suggestServiceMode(final ServiceMode serviceMode) {
+ // This particular application is only concerned with protecting data
+ // that is flagged as corporate. Other implementations may want to
+ // make a further distinction between personal/undecided data.
+ if (!MultiServicePlatformManager.isCorporateServiceUid(serviceMode
+ .getServiceUid())) {
+ final Screen activeScreen = getActiveScreen();
+
+ if (activeScreen instanceof MemoScreen) {
+ return activeScreen.suggestServiceMode(serviceMode);
+ }
+ }
+
+ return super.suggestServiceMode(serviceMode);
+ }
+
+ /**
+ * @see net.rim.device.api.system.Application#getServiceMode()
+ */
+ public ServiceMode getServiceMode() {
+ final Screen activeScreen = getActiveScreen();
+
+ if (activeScreen instanceof MemoScreen) {
+ return activeScreen.getServiceMode();
+ }
+
+ return super.getServiceMode();
+ }
+
+ /**
+ * Called by the MultiServiceListener class when this application needs to
+ * discard any controlled data. For testing purposes this method could be
+ * called explicitly by the application. For a real world testing scenario
+ * the running Blackberry device would be activated against a BES server and
+ * a command to delete organization data would be issued by the BES
+ * administrator.
+ */
+ public void onWipe(final String serviceUid, final long dataType) {
+ final int size = _memos.size();
+ for (int i = size - 1; i >= 0; --i) {
+ final Memo memo = (Memo) _memos.elementAt(i);
+ if (serviceUid.equals(memo.getMode())) {
+ _screen.getModel().removeRowAt(i);
+ }
+ }
+
+ final Screen activeScreen = getActiveScreen();
+
+ if (activeScreen instanceof MemoScreen) {
+ final Memo activeMemo = ((MemoScreen) activeScreen).getMemo();
+ final int index = ((MemoScreen) activeScreen).getMemoIndex();
+
+ if (index == -1 || !activeMemo.getMode().equals(serviceUid)) {
+ // New memo with no wipable data, OK to save it.
+ activeScreen.onClose();
+ } else {
+ final Dialog dialog =
+ new Dialog(
+ Dialog.D_OK,
+ "Application has been instructed to wipe corporate data."
+ + " This memo will be deleted and this screen closed.",
+ 0, null, 0);
+ dialog.doModal();
+ this.popScreen(activeScreen);
+ }
+ }
+
+ persist();
+
+ MultiServicePlatformManager.removeListener(new MultiServiceListener());
+ }
+}
View
56 com/rim/samples/device/blackberrybalancedemo/BlackBerryBalanceDemo.jdp
@@ -0,0 +1,56 @@
+## RIM Java Development Environment
+# RIM Project file
+#
+# This file is generated and managed by BlackBerry developer tools.
+# It SHOULD NOT BE modified manually.
+#
+AddOn=0
+AlwaysBuild=0
+[AlxImports
+]
+AutoRestart=0
+[ClassProtection
+]
+[CustomBuildFiles
+]
+[CustomBuildRules
+]
+[DefFiles
+]
+[DependsOn
+]
+ExcludeFromBuildAll=0
+Exported=0
+[Files
+BlackBerryBalanceDemo.java
+BlackBerryBalanceDemoScreen.java
+img\blackberrybalancedemo_jde.png
+Memo.java
+MemoScreen.java
+MultiServiceListener.java
+PersistentStoreListener.java
+]
+HaveAlxImports=0
+HaveDefs=0
+HaveImports=0
+[Icons
+img\blackberrybalancedemo_jde.png
+]
+[ImplicitRules
+]
+[Imports
+]
+Listing=0
+Options=-quiet
+OutputFileName=BlackBerryBalanceDemo
+[PackageProtection
+]
+RibbonPosition=0
+[RolloverIcons
+]
+RunOnStartup=0
+SkipCompile=0
+StartupTier=7
+SystemModule=0
+Title=BlackBerry Balance Demo
+Type=0
View
252 ...ce/maps/embeddedmapdemo/SavedLocationsScreen.java → ...berrybalancedemo/BlackBerryBalanceDemoScreen.java
@@ -1,5 +1,5 @@
-/**
- * SavedLocationsScreen.java
+/*
+ * BlackBerryBalanceDemoScreen.java
*
* Copyright © 1998-2011 Research In Motion Limited
*
@@ -24,7 +24,7 @@
* Environment Development Guide associated with this release.
*/
-package com.rim.samples.device.embeddedmapdemo;
+package com.rim.samples.device.blackberrybalancedemo;
import java.util.Vector;
@@ -33,16 +33,19 @@
import net.rim.device.api.command.ReadOnlyCommandMetadata;
import net.rim.device.api.system.Characters;
import net.rim.device.api.system.Display;
+import net.rim.device.api.system.MultiServicePlatformManager;
import net.rim.device.api.ui.Color;
-import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.MenuItem;
-import net.rim.device.api.ui.Screen;
+import net.rim.device.api.ui.TouchEvent;
+import net.rim.device.api.ui.TouchGesture;
+import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.Menu;
+import net.rim.device.api.ui.component.table.AbstractTableModel;
import net.rim.device.api.ui.component.table.DataTemplate;
import net.rim.device.api.ui.component.table.TableController;
import net.rim.device.api.ui.component.table.TableModelAdapter;
@@ -54,96 +57,82 @@
import net.rim.device.api.util.StringProvider;
/**
- * A screen to display the saved locations by name. It allows the user to select
- * a saved location for quick navigation on the map.
+ * This screen displays a list of Memos
*/
-public final class SavedLocationsScreen extends MainScreen {
- private Vector _mapLocations;
- private EmbeddedMapDemo.EmbeddedMapDemoScreen _mainScreen;
- private LocationTableModelAdapter _model;
+public final class BlackBerryBalanceDemoScreen extends MainScreen {
+ private BlackBerryBalanceDemo _uiApp;
+ private Vector _memos;
+ private AbstractTableModel _model;
private TableView _view;
+ private MenuItem _deleteItem;
/**
- * Constructs a new SavedLocationsScreen object
+ * Creates a new PersistentStoreDemoScreen object
*
- * @param mapLocations
- * The list of saved locations
- * @param mainScreen
- * The screen containing the map to display the selected location
- * on
+ * @param memos
+ * A vector of persistable memo objects
*/
- public SavedLocationsScreen(final Vector mapLocations,
- final EmbeddedMapDemo.EmbeddedMapDemoScreen mainScreen) {
+ public BlackBerryBalanceDemoScreen(final Vector memos) {
super(Manager.NO_VERTICAL_SCROLL);
- setTitle("Select a location to display");
+ _uiApp = (BlackBerryBalanceDemo) UiApplication.getUiApplication();
+ _memos = memos;
- _mapLocations = mapLocations;
- _mainScreen = mainScreen;
+ // Initialize UI components
+ setTitle("BlackBerry Balance Demo");
- _model = new LocationTableModelAdapter();
+ // Create an adapter to display memos list in a table
+ _model = new MemoTableModelAdapter();
+ // Create the view and controller
_view = new TableView(_model);
final TableController controller = new TableController(_model, _view);
controller.setFocusPolicy(TableController.ROW_FOCUS);
_view.setController(controller);
- // Set command on touch screen/trackpad action
- controller.setCommand(new CommandHandler() {
- /**
- * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
- * Object)
- */
- public void execute(final ReadOnlyCommandMetadata metadata,
- final Object context) {
- displayAction();
- }
-
- }, null, null);
-
- // Set the highlight style for the view
_view.setDataTemplateFocus(BackgroundFactory
.createLinearGradientBackground(Color.LIGHTBLUE,
Color.LIGHTBLUE, Color.BLUE, Color.BLUE));
-
- // Create a data template that will format the model data as an array of
- // LabelFields
final DataTemplate dataTemplate = new DataTemplate(_view, 1, 1) {
public Field[] getDataFields(final int modelRowIndex) {
- final MapLocation mapLocation =
- (MapLocation) _mapLocations.elementAt(modelRowIndex);
+ final String text =
+ ((Memo) _model.getRow(modelRowIndex))
+ .getField(Memo.MEMO_NAME);
final Field[] fields =
- { new LabelField(mapLocation.toString(),
- Field.NON_FOCUSABLE | DrawStyle.ELLIPSIS) };
+ { new LabelField(text, Field.NON_FOCUSABLE) };
+
return fields;
}
};
-
- // Define the regions of the data template and column/row size
dataTemplate.createRegion(new XYRect(0, 0, 1, 1));
dataTemplate.setColumnProperties(0, new TemplateColumnProperties(
Display.getWidth()));
- dataTemplate.setRowProperties(0, new TemplateRowProperties(24));
-
+ dataTemplate.setRowProperties(0, new TemplateRowProperties(32));
_view.setDataTemplate(dataTemplate);
dataTemplate.useFixedHeight(true);
- // Add the file to the screen
add(_view);
- _displayItem = new MenuItem(new StringProvider("Display"), 0x230010, 0);
- _displayItem.setCommand(new Command(new CommandHandler() {
+ // Menu item to create a new memo
+ final MenuItem newMemoItem =
+ new MenuItem(new StringProvider("New memo"), 0x230010, 0);
+ newMemoItem.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
- displayAction();
+ // New memos are in UNDECIDED mode by default
+ final Memo memo =
+ new Memo(MultiServicePlatformManager
+ .getDefaultUndecidedServiceUid());
+
+ _uiApp.pushScreen(new MemoScreen(memo, -1));
}
}));
- _deleteItem = new MenuItem(new StringProvider("Delete"), 0x230020, 1);
+ _deleteItem = new MenuItem(new StringProvider("Delete"), 0x230040, 3);
_deleteItem.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
@@ -151,101 +140,110 @@ public void execute(final ReadOnlyCommandMetadata metadata,
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
- final MapLocation mapLocation =
- (MapLocation) _model.getRow(_view
- .getRowNumberWithFocus());
+ // Retrieve the highlighted memo object and remove it from the
+ // vector, then update the list field to reflect the change.
+ final int i = _view.getRowNumberWithFocus();
+ final String memoName =
+ ((Memo) _uiApp.getMemos().elementAt(i))
+ .getField(Memo.MEMO_NAME);
final int result =
- Dialog.ask(Dialog.DELETE, "Delete "
- + mapLocation.toString() + "?");
+ Dialog.ask(Dialog.DELETE, "Delete " + memoName + "?");
if (result == Dialog.YES) {
- _model.removeRowAt(_view.getRowNumberWithFocus());
- _mainScreen.clearEditFields();
+ _model.removeRowAt(i);
}
}
}));
- _deleteAllItem =
- new MenuItem(new StringProvider("Delete All"), 0x230030, 10);
- _deleteAllItem.setCommand(new Command(new CommandHandler() {
- /**
- * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
- * Object)
- */
- public void execute(final ReadOnlyCommandMetadata metadata,
- final Object context) {
- final int result = Dialog.ask(Dialog.DELETE, "Are you sure?");
- if (result == Dialog.YES) {
- _model.removeAllRows();
- _mainScreen.clearEditFields();
- close();
- }
- }
- }));
+ addMenuItem(newMemoItem);
}
/**
- * Displays the currently selected location on the map. Will close this
- * screen.
+ * Returns a reference to the table model
+ *
+ * @return The table model
*/
- private void displayAction() {
- _mainScreen.displayLocation((MapLocation) _model.getRow(_view
- .getRowNumberWithFocus()));
- close();
+ public AbstractTableModel getModel() {
+ return _model;
}
/**
- * @see Screen#keyChar(char, int, int)
+ * Pushes a MemoScreen to display the selected memo
*/
- public boolean keyChar(final char c, final int status, final int time) {
- switch (c) {
-