Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BlackBerry Samples for Java release 6.0.0.

An Open Source version of the samples as they were released
with the 6.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.
commit ea584537f125a95e27000dfca596344ea11301cd 1 parent b3db4c1
@slegge slegge authored
Showing with 16,587 additions and 5,536 deletions.
  1. +89 −50 com/rim/samples/device/accelerometerdemo/AccelerometerDemo.java
  2. +6 −2 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/CustomComponentsDemo.java
  3. +2 −1  com/rim/samples/device/accessibilitydemo/customcomponentsdemo/CustomComponentsDemo.jdp
  4. +11 −2 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/IconToolbarComponent.java
  5. +8 −1 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/TableComponent.java
  6. +2 −1  com/rim/samples/device/accessibilitydemo/screenreaderdemo/ScreenReaderDemo.jdp
  7. +1 −1  com/rim/samples/device/accessibilitydemo/screenreaderdemo/Util.java
  8. +34 −36 com/rim/samples/device/activetextfieldsdemo/ActiveTextFieldsDemo.java
  9. +10 −2 com/rim/samples/device/activetextfieldsdemo/ActiveTextFieldsDemo_autostartup.jdp
  10. +8 −8 com/rim/samples/device/applicationpermissionsdemo/ApplicationPermissionsDemo.java
  11. +3 −3 com/rim/samples/device/attachmentdemo/AttachmentDemo.jdp
  12. +57 −29 com/rim/samples/device/attachmentdemo/AttachmentDemoScreen.java
  13. +0 −143 com/rim/samples/device/attachmentdemo/FileExplorerListField.java
  14. +165 −27 com/rim/samples/device/attachmentdemo/FileExplorerScreen.java
  15. +6 −2 com/rim/samples/device/attachmentdemo/FileUploadDialog.java
  16. BIN  com/rim/samples/device/attachmentdemo/img/attachmentdemo_jde.png
  17. BIN  com/rim/samples/device/attachmentdemo/img/icon_jde.png
  18. +248 −0 com/rim/samples/device/barcodescandemo/BarcodeScanDemo.java
  19. +53 −0 com/rim/samples/device/barcodescandemo/BarcodeScanDemo.jdp
  20. BIN  com/rim/samples/device/barcodescandemo/beep.wav
  21. BIN  com/rim/samples/device/barcodescandemo/img/barcodescandemo_jde.png
  22. +14 −12 com/rim/samples/device/blackberrymaildemo/BlackBerryMailDemo.java
  23. +4 −3 com/rim/samples/device/blackberrymaildemo/BlackBerryMailDemo.jdp
  24. +85 −46 com/rim/samples/device/blackberrymaildemo/BlackBerryMailDemoScreen.java
  25. +100 −78 com/rim/samples/device/blackberrymaildemo/ComposeScreen.java
  26. +14 −3 com/rim/samples/device/blackberrymaildemo/FoldersViewScreen.java
  27. +36 −16 com/rim/samples/device/blackberrymaildemo/MessagesViewScreen.java
  28. BIN  com/rim/samples/device/blackberrymaildemo/img/blackberrymaildemo_jde.png
  29. BIN  com/rim/samples/device/blackberrymaildemo/img/icon_jde.png
  30. +0 −138 com/rim/samples/device/blackberrymapsdemo/BlackBerryMapsDemo.java
  31. +0 −116 com/rim/samples/device/blackberrymapsdemo/InvokeContactScreen.java
  32. +0 −90 com/rim/samples/device/blackberrymapsdemo/InvokeLocationDocumentScreen.java
  33. +40 −31 com/rim/samples/device/{ → bluetooth}/bluetoothdemo/AppScreen.java
  34. 0  com/rim/samples/device/{ → bluetooth}/bluetoothdemo/BluetoothDemo.java
  35. 0  com/rim/samples/device/{ → bluetooth}/bluetoothdemo/BluetoothDemo.jdp
  36. +151 −131 com/rim/samples/device/{ → bluetooth}/bluetoothdemo/SPPScreen.java
  37. 0  com/rim/samples/device/{ → bluetooth}/bluetoothdemo/img/bluetooth_jde.png
  38. 0  com/rim/samples/device/{ → bluetooth}/bluetoothdemo/readme.txt
  39. +154 −0 com/rim/samples/device/bluetooth/bluetoothjsr82demo/BluetoothJSR82Demo.java
  40. +56 −0 com/rim/samples/device/bluetooth/bluetoothjsr82demo/BluetoothJSR82Demo.jdp
  41. +467 −0 com/rim/samples/device/bluetooth/bluetoothjsr82demo/ClientScreen.java
  42. +131 −0 com/rim/samples/device/bluetooth/bluetoothjsr82demo/InfoScreen.java
  43. +332 −0 com/rim/samples/device/bluetooth/bluetoothjsr82demo/ServerScreen.java
  44. BIN  com/rim/samples/device/bluetooth/bluetoothjsr82demo/img/bluetoothJSR82demo_jde.png
  45. +19 −4 com/rim/samples/device/{ → bluetooth}/bluetoothserialportdemo/BluetoothSerialPortDemo.java
  46. 0  com/rim/samples/device/{ → bluetooth}/bluetoothserialportdemo/BluetoothSerialPortDemo.jdp
  47. 0  com/rim/samples/device/{ → bluetooth}/bluetoothserialportdemo/img/serialportdemo_jde.png
  48. +5 −3 com/rim/samples/device/browser/browsercontentmanagerdemo/BrowserContentManagerDemo.java
  49. +18 −11 com/rim/samples/device/{ → browser}/browserfield2demo/BrowserField2Demo.java
  50. +4 −3 ...les/device/{browserfield2demo/browserfield2demo.jdp → browser/browserfield2demo/BrowserField2Demo.jdp}
  51. +37 −26 com/rim/samples/device/{ → browser}/browserfield2demo/BrowserFieldScreen.java
  52. BIN  com/rim/samples/device/browser/browserfield2demo/img/browserfield2demo_jde.png
  53. 0  com/rim/samples/device/{ → browser}/browserfield2demo/index.html
  54. 0  com/rim/samples/device/{ → browser}/browserfield2demo/js/jquery.js
  55. 0  com/rim/samples/device/{ → browser}/browserfield2demo/js/script.js
  56. +7 −4 com/rim/samples/device/browser/browserfielddemo/BrowserFieldDemo.java
  57. +2 −0  com/rim/samples/device/browser/browserfielddemo/BrowserFieldDemo.jdp
  58. +2 −2 com/rim/samples/device/browser/browserplugin/BrowserPlugin.java
  59. +1 −1  com/rim/samples/device/browser/browserplugin/LoaderApp.java
  60. +1 −1  com/rim/samples/device/browser/commonlib/SecondaryResourceFetchThread.java
  61. +1 −1  com/rim/samples/device/browser/commonlib/Utilities.java
  62. BIN  com/rim/samples/device/browserfield2demo/img/icon_jde.png
  63. +3 −1 com/rim/samples/device/bufferedplaybackdemo/BufferedPlayback.java
  64. +3 −1 com/rim/samples/device/bufferedplaybackdemo/bufferedplaybackdemo.jdp
  65. +103 −24 com/rim/samples/device/camerademo/CameraDemo.java
  66. +2 −1  com/rim/samples/device/camerademo/CameraDemo.jdp
  67. +1 −22 com/rim/samples/device/camerademo/EncodingProperties.java
  68. +88 −127 com/rim/samples/device/camerademo/ImageScreen.java
  69. +240 −176 com/rim/samples/device/chapidemo/ChapiDemo.java
  70. +4 −1 com/rim/samples/device/chapidemo/ChapiDemo.jdp
  71. +3 −1 com/rim/samples/device/chapidemo/ChapiDemo_Autostartup.jdp
  72. +0 −1  com/rim/samples/device/chapidemo/Data/rim.csv
  73. +161 −0 com/rim/samples/device/chapidemo/DemoContentHandler.java
  74. +46 −0 com/rim/samples/device/chapidemo/DemoContentHandler2.java
  75. +19 −30 ...les/device/{networkapidemo/FixedWidthLabelField.java → communicationapidemo/CommunicationAPIDemo.java}
  76. +78 −0 com/rim/samples/device/communicationapidemo/CommunicationAPIDemo.jdp
  77. +58 −0 com/rim/samples/device/communicationapidemo/CommunicationAPILocalHelper.jdp
  78. +1,102 −0 com/rim/samples/device/communicationapidemo/CommunicationController.java
  79. +15 −0 com/rim/samples/device/communicationapidemo/CommunicationControllerListener.java
  80. +79 −0 com/rim/samples/device/communicationapidemo/ResponseCallback.java
  81. +14 −0 com/rim/samples/device/communicationapidemo/config/config.xml
  82. BIN  com/rim/samples/device/communicationapidemo/img/communicationapidemo_jde.png
  83. +110 −0 com/rim/samples/device/communicationapidemo/local/CommunicationController.java
  84. +15 −21 ...rim/samples/device/{networkapidemo/FullWidthButton.java → communicationapidemo/local/LocalHelper.java}
  85. +91 −0 com/rim/samples/device/communicationapidemo/local/MenuMainScreen.java
  86. +140 −0 com/rim/samples/device/communicationapidemo/local/SendFireForgetScreen.java
  87. +133 −0 com/rim/samples/device/communicationapidemo/readme.txt
  88. +69 −0 com/rim/samples/device/communicationapidemo/ui/FullWidthButton.java
  89. +114 −0 com/rim/samples/device/communicationapidemo/util/Utils.java
  90. +154 −0 com/rim/samples/device/communicationapidemo/view/AuthenticationScreen.java
  91. +171 −0 com/rim/samples/device/communicationapidemo/view/MenuMainScreen.java
  92. +182 −0 com/rim/samples/device/communicationapidemo/view/MenuManager.java
  93. +129 −0 com/rim/samples/device/communicationapidemo/view/MenuReceiveScreen.java
  94. +116 −0 com/rim/samples/device/communicationapidemo/view/MenuSendNonBlockScreen.java
  95. +130 −0 com/rim/samples/device/communicationapidemo/view/MenuSendScreen.java
  96. +148 −0 com/rim/samples/device/communicationapidemo/view/MessageCancellationScreen.java
  97. +118 −0 com/rim/samples/device/communicationapidemo/view/ReceiveBPSScreen.java
  98. +184 −0 com/rim/samples/device/communicationapidemo/view/ReceiveIPCScreen.java
  99. +183 −0 com/rim/samples/device/communicationapidemo/view/ReceivePushScreen.java
  100. +147 −0 com/rim/samples/device/communicationapidemo/view/SendBlockScreen.java
  101. +138 −0 com/rim/samples/device/communicationapidemo/view/SendFireForgetScreen.java
  102. +203 −0 com/rim/samples/device/communicationapidemo/view/SendNonBlockAtomScreen.java
  103. +261 −0 com/rim/samples/device/communicationapidemo/view/SendNonBlockJsonScreen.java
  104. +202 −0 com/rim/samples/device/communicationapidemo/view/SendNonBlockRssScreen.java
  105. +215 −0 com/rim/samples/device/communicationapidemo/view/SendNonBlockSoapScreen.java
  106. +190 −0 com/rim/samples/device/communicationapidemo/view/SendNonBlockXmlScreen.java
  107. +144 −0 com/rim/samples/device/communicationapidemo/view/StreamDataScreen.java
  108. +32 −18 com/rim/samples/device/contactlinkingdemo/ContactLinkingDemo.java
  109. +7 −4 com/rim/samples/device/contactlinkingdemo/ContactLinkingDemo.jdp
  110. +2 −1  com/rim/samples/device/contactlinkingdemo/ContactLinkingDemo_autostartup.jdp
  111. +198 −142 com/rim/samples/device/contactlinkingdemo/ContactListScreen.java
  112. +0 −66 com/rim/samples/device/contactlinkingdemo/SampleAddressBookFieldFactory.java
  113. +85 −0 com/rim/samples/device/contactlinkingdemo/SampleLinkedContactInfoProvider.java
  114. +5 −2 com/rim/samples/device/contactlinkingdemo/SampleMenuItem.java
  115. BIN  com/rim/samples/device/contactlinkingdemo/img/contactlinkingdemo_jde.png
  116. BIN  com/rim/samples/device/contactlinkingdemo/img/icon_jde.png
  117. BIN  com/rim/samples/device/contactlinkingdemo/img/logo_black.jpg
  118. BIN  com/rim/samples/device/contactlinkingdemo/img/logo_blue.jpg
  119. +16 −5 com/rim/samples/device/cryptodemo/CryptoDemo.java
  120. +0 −185 com/rim/samples/device/embeddedmapdemo/LookupMatchesScreen.java
  121. +0 −236 com/rim/samples/device/embeddedmapdemo/SavedLocationsScreen.java
  122. +33 −46 com/rim/samples/device/embeddedmediademo/EmbeddedMediaDemo.java
  123. +9 −1 com/rim/samples/device/fileexplorerdemo/FileExplorerDemo.jdp
  124. +0 −154 com/rim/samples/device/fileexplorerdemo/FileExplorerDemoListFieldImpl.java
  125. +182 −81 com/rim/samples/device/fileexplorerdemo/FileExplorerDemoScreen.java
  126. +491 −0 com/rim/samples/device/gps/gpsdemo/GPSDemo.java
  127. +8 −9 com/rim/samples/device/{otasyncdemo/OTASyncDemo.jdp → gps/gpsdemo/GPSDemo.jdp}
  128. +299 −0 com/rim/samples/device/gps/gpsdemo/PointScreen.java
  129. 0  com/rim/samples/device/{ → gps}/gpsdemo/img/gpsdemo_jde.png
  130. +1,432 −0 com/rim/samples/device/gps/gpsdemoadvanced/CoreGPSDiagnosticScreen.java
  131. +1,620 −0 com/rim/samples/device/gps/gpsdemoadvanced/ExtendedGPSDiagnosticScreen.java
  132. +98 −0 com/rim/samples/device/gps/gpsdemoadvanced/GPSDemoAdvanced.java
  133. +57 −0 com/rim/samples/device/gps/gpsdemoadvanced/GPSDemoAdvanced.jdp
  134. BIN  com/rim/samples/device/gps/gpsdemoadvanced/img/gpsdemoadvanced_jde.png
  135. +49 −0 com/rim/samples/device/gps/gpsdemoadvanced/resource/help_core.txt
  136. +68 −0 com/rim/samples/device/gps/gpsdemoadvanced/resource/help_extended.txt
  137. +0 −741 com/rim/samples/device/gpsdemo/GPSDemo.java
  138. +0 −50 com/rim/samples/device/gpsdemo/GPSDemo.jdp
  139. +0 −231 com/rim/samples/device/gpsdemo/PointScreen.java
  140. +48 −0 com/rim/samples/device/homescreendemo/HomeScreenAlternateEntryPoint.jdp
  141. +448 −0 com/rim/samples/device/homescreendemo/HomeScreenDemo.java
  142. +54 −0 com/rim/samples/device/homescreendemo/HomeScreenDemo.jdp
  143. +260 −0 com/rim/samples/device/homescreendemo/HomeScreenDemoSecondaryScreen.java
  144. BIN  com/rim/samples/device/homescreendemo/img/homescreendemo_jde.png
  145. BIN  com/rim/samples/device/homescreendemo/img/logo_black.jpg
  146. BIN  com/rim/samples/device/homescreendemo/img/logo_blue.jpg
  147. +102 −58 com/rim/samples/device/httpdemo/HTTPDemo.java
  148. +26 −14 com/rim/samples/device/httpdemo/WapOptionsScreen.java
  149. +2 −1  com/rim/samples/device/httpfilterdemo/HTTPFilterDemo.jdp
  150. +1 −1  com/rim/samples/device/httpfilterdemo/precanned/Protocol.java
  151. +2 −2 com/rim/samples/device/httppushdemo/HTTPPushDemo.java
  152. +1 −1  com/rim/samples/device/keywordfilterdemo/CountryList.java
  153. +3 −1 com/rim/samples/device/keywordfilterdemo/KeywordFilterDemo.java
  154. +50 −46 com/rim/samples/device/keywordfilterdemo/KeywordFilterDemoScreen.java
  155. +28 −16 com/rim/samples/device/localizationdemo/LocalizationDemo.java
  156. +10 −2 com/rim/samples/device/localizationdemo/LocalizationDemo.jdp
  157. +159 −0 com/rim/samples/device/maps/blackberrymapsdemo/BlackBerryMapsDemo.java
  158. 0  com/rim/samples/device/{ → maps}/blackberrymapsdemo/BlackBerryMapsDemo.jdp
  159. +127 −0 com/rim/samples/device/maps/blackberrymapsdemo/InvokeContactScreen.java
  160. +28 −16 com/rim/samples/device/{ → maps}/blackberrymapsdemo/InvokeDefaultScreen.java
  161. +107 −0 com/rim/samples/device/maps/blackberrymapsdemo/InvokeLocationDocumentScreen.java
  162. +30 −19 com/rim/samples/device/{ → maps}/blackberrymapsdemo/InvokeMapViewScreen.java
  163. 0  com/rim/samples/device/{ → maps}/blackberrymapsdemo/img/bbmapsdemo_jde.png
  164. +87 −71 com/rim/samples/device/{ → maps}/embeddedmapdemo/EmbeddedMapDemo.java
  165. 0  com/rim/samples/device/{ → maps}/embeddedmapdemo/EmbeddedMapDemo.jdp
  166. +5 −6 com/rim/samples/device/{ → maps}/embeddedmapdemo/ExtendedMapField.java
  167. +45 −25 com/rim/samples/device/{ → maps}/embeddedmapdemo/LocatorScreen.java
  168. +139 −0 com/rim/samples/device/maps/embeddedmapdemo/LookupMatchesScreen.java
  169. 0  com/rim/samples/device/{ → maps}/embeddedmapdemo/MapLocation.java
  170. +282 −0 com/rim/samples/device/maps/embeddedmapdemo/SavedLocationsScreen.java
  171. 0  com/rim/samples/device/{ → maps}/embeddedmapdemo/img/embeddedmapdemo_jde.png
  172. 0  com/rim/samples/device/{ → maps}/embeddedmapdemo/img/marker.PNG
  173. 0  com/rim/samples/device/{ → maps}/embeddedmapdemo/img/pointer.png
  174. +139 −0 com/rim/samples/device/maps/enhancedmapfielddemo/EnhancedMapFieldDemo.java
  175. +51 −0 com/rim/samples/device/maps/enhancedmapfielddemo/EnhancedMapFieldDemo.jdp
  176. BIN  com/rim/samples/device/maps/enhancedmapfielddemo/img/enhancedmapfielddemo_jde.png
  177. +1 −1  com/rim/samples/device/{ → maps}/mapfielddemo/DemoMapField.java
  178. +3 −1 com/rim/samples/device/{ → maps}/mapfielddemo/MapFieldDemo.java
  179. 0  com/rim/samples/device/{ → maps}/mapfielddemo/MapFieldDemo.jdp
  180. +2 −1  com/rim/samples/device/{ → maps}/mapfielddemo/MapFieldDemoMenuItem.java
  181. +25 −12 com/rim/samples/device/{ → maps}/mapfielddemo/MapFieldDemoScreen.java
  182. 0  com/rim/samples/device/{ → maps}/mapfielddemo/MapFieldDemoSite.java
  183. 0  com/rim/samples/device/{ → maps}/mapfielddemo/MapFieldDemoTokenizer.java
  184. 0  com/rim/samples/device/{ → maps}/mapfielddemo/img/bullseye.png
  185. 0  com/rim/samples/device/{ → maps}/mapfielddemo/img/mapfielddemo_jde.png
  186. 0  com/rim/samples/device/{ → maps}/mapfielddemo/sitedata/MapsData.txt
  187. 0  com/rim/samples/device/{ → maps}/mapfielddemo/sitedata/Readme.txt
  188. +51 −40 com/rim/samples/device/{ → maps}/mapsmenuitemdemo/MapsMenuItemDemo.java
  189. 0  com/rim/samples/device/{ → maps}/mapsmenuitemdemo/MapsMenuItemDemo.jdp
  190. +0 −39 com/rim/samples/device/mapsmenuitemdemo/MapsMenuItemDemo_autostartup.jdp
  191. +0 −273 com/rim/samples/device/mediaenginedemo/MediaEngineDemo.java
  192. +0 −118 com/rim/samples/device/mediaenginedemo/MediaListenerImpl.java
  193. BIN  com/rim/samples/device/mediaenginedemo/img/mediaengine_jde.png
  194. BIN  com/rim/samples/device/mediaenginedemo/planets.pme
  195. +0 −102 com/rim/samples/device/mediaenginedemo/planets.svg
  196. BIN  com/rim/samples/device/mediaenginedemo/runner.pme
  197. +0 −129 com/rim/samples/device/mediaenginedemo/runner.svg
  198. +2 −2 com/rim/samples/device/mediakeysdemo/mediakeysdemomidlet/MediaKeysDemoMIDlet.java
  199. +19 −14 com/rim/samples/device/mediakeysdemo/mediaplayerdemo/mediaplayerlib/MediaPlayerDemoScreen.java
  200. +1 −1  com/rim/samples/device/mediakeysdemo/mediaplayerdemo/mediaplayerlib/PlayList.java
  201. +26 −26 com/rim/samples/device/memoapidemo/EditMemoScreen.java
  202. +10 −2 com/rim/samples/device/memoapidemo/MemoAPIDemo_autostartup.jdp
  203. +239 −241 com/rim/samples/device/memoapidemo/MemoMainScreen.java
  204. +28 −40 com/rim/samples/device/memoapidemo/ViewMemoScreen.java
  205. +159 −133 com/rim/samples/device/memorydemo/MemoryDemoMainScreen.java
  206. +33 −13 com/rim/samples/device/memorydemo/MemoryDemoOrderScreen.java
  207. +4 −2 com/rim/samples/device/memorydemo/OrderList.java
  208. +20 −15 com/rim/samples/device/messagelistdemo/CommunicationSimulatorThread.java
  209. +20 −34 com/rim/samples/device/messagelistdemo/DemoMessage.java
  210. +2 −2 com/rim/samples/device/messagelistdemo/DemoMessageScreen.java
  211. +224 −120 com/rim/samples/device/messagelistdemo/MessageListDemo.java
  212. +9 −0 com/rim/samples/device/messagelistdemo/MessageListDemo.jdp
  213. +173 −94 com/rim/samples/device/messagelistdemo/MessageListDemoDaemon.java
  214. +24 −20 com/rim/samples/device/messagelistdemo/MessageListDemoStore.java
  215. +10 −2 com/rim/samples/device/messagelistdemo/MessageListDemo_autostartup.jdp
  216. BIN  com/rim/samples/device/messagelistdemo/img/sm_add_message.png
  217. BIN  com/rim/samples/device/messagelistdemo/img/sm_add_messages_bulk.png
  218. BIN  com/rim/samples/device/messagelistdemo/img/sm_mark_opened.png
  219. BIN  com/rim/samples/device/messagelistdemo/img/sm_mark_unopened.png
  220. BIN  com/rim/samples/device/messagelistdemo/img/sm_open.png
  221. BIN  com/rim/samples/device/messagelistdemo/img/sm_open_messages_app.png
  222. BIN  com/rim/samples/device/messagelistdemo/img/sm_reply.png
  223. BIN  com/rim/samples/device/messagelistdemo/img/sm_start_auto.png
  224. BIN  com/rim/samples/device/messagelistdemo/img/sm_stop_auto.png
  225. +21 −17 com/rim/samples/device/mmsdemo/MMSDemo.java
  226. +3 −2 com/rim/samples/device/mmsdemo/MMSDemo.jdp
  227. +133 −108 com/rim/samples/device/mmsdemo/MMSDemoSendScreen.java
  228. BIN  com/rim/samples/device/mmsdemo/img/icon_jde.png
  229. BIN  com/rim/samples/device/mmsdemo/img/mmsdemo_jde.png
  230. +49 −56 com/rim/samples/device/networkapidemo/ConnectionDetailsScreen.java
  231. +87 −106 com/rim/samples/device/networkapidemo/ConnectionTestsScreen.java
  232. +33 −31 com/rim/samples/device/networkapidemo/NetworkAPIDemo.java
  233. +4 −4 com/rim/samples/device/networkapidemo/NetworkAPIDemo.jdp
  234. +157 −50 com/rim/samples/device/networkapidemo/TransportInfoScreen.java
Sorry, we could not display the entire diff because too many files (506) changed.
View
139 com/rim/samples/device/accelerometerdemo/AccelerometerDemo.java
@@ -28,6 +28,9 @@
import java.util.Random;
+import net.rim.device.api.command.Command;
+import net.rim.device.api.command.CommandHandler;
+import net.rim.device.api.command.ReadOnlyCommandMetadata;
import net.rim.device.api.system.AccelerometerSensor;
import net.rim.device.api.system.AccelerometerSensor.Channel;
import net.rim.device.api.system.Bitmap;
@@ -39,7 +42,9 @@
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
+import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.container.MainScreen;
+import net.rim.device.api.util.StringProvider;
/**
* This sample demonstrates the Accelerometer API. The DrawThread opens the
@@ -75,8 +80,11 @@
private int _tick = 0;
+ private MenuItem _startMenuItem;
+ private MenuItem _stopMenuItem;
+
/**
- * Entry point for application.
+ * Entry point for application
*
* @param args
* Command line arguments (not used)
@@ -88,13 +96,51 @@ public static void main(final String[] args) {
app.enterEventDispatcher();
}
- // Constructor
+ /**
+ * Creates a new AccelerometerDemo object
+ */
public AccelerometerDemo() {
if (AccelerometerSensor.isSupported()) {
- // Initialize UI
+
+ // Menu item to start the ball moving
+ _startMenuItem =
+ new MenuItem(new StringProvider("Start"), 0x230010, 0);
+ _startMenuItem.setCommand(new Command(new CommandHandler() {
+ /**
+ * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
+ * Object)
+ */
+ public void execute(final ReadOnlyCommandMetadata metadata,
+ final Object context) {
+ if (_thread == null) {
+ // Start drawing
+ _thread = new DrawThread();
+ _thread.start();
+ }
+ }
+ }));
+
+ // Menu item to stop the ball moving
+ _stopMenuItem =
+ new MenuItem(new StringProvider("Stop"), 0x230010, 0);
+ _stopMenuItem.setCommand(new Command(new CommandHandler() {
+ /**
+ * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
+ * Object)
+ */
+ public void execute(final ReadOnlyCommandMetadata metadata,
+ final Object context) {
+ if (_thread != null) {
+ synchronized (_thread) {
+ _thread._running = false;
+ _thread.notifyAll();
+ _thread = null;
+ }
+ }
+ }
+ }));
+
_screen = new AccelerometerDemoScreen();
- _screen.addMenuItem(_startMenuItem);
- _screen.addMenuItem(_stopMenuItem);
pushScreen(_screen);
_ball = Bitmap.getBitmapResource("img/ball.png");
@@ -105,7 +151,7 @@ public AccelerometerDemo() {
_ballHeight = _ball.getHeight();
}
- // Prevent UI from rotating our screen.
+ // Prevent UI from rotating the screen
Ui.getUiEngineInstance().setAcceptableDirections(
DEFAULT_ORIENTATION);
} else {
@@ -119,7 +165,7 @@ public void run() {
}
/**
- * Calculates ball position.
+ * Calculates ball position
*
* @param xAcc
* x axis acceleration
@@ -127,15 +173,15 @@ public void run() {
* y axis acceleration
*/
private void applyForce(final int xAcc, final int yAcc) {
- // Calculate new speed.
+ // Calculate new speed
_xSpeed += xAcc * G_NORM;
_ySpeed += yAcc * G_NORM;
- // Apply table friction.
+ // Apply table friction
_xSpeed *= TABLE_FRICTION;
_ySpeed *= TABLE_FRICTION;
- // Move the ball.
+ // Move the ball
_x += _xSpeed;
_y += _ySpeed;
@@ -163,7 +209,7 @@ private void applyForce(final int xAcc, final int yAcc) {
}
/**
- * A thread class to handle screen updates.
+ * A thread class to handle screen updates
*/
private class DrawThread extends Thread {
private boolean _running;
@@ -171,16 +217,16 @@ private void applyForce(final int xAcc, final int yAcc) {
public void run() {
_running = true;
- // Start querying the accelerometer sensor.
+ // Start querying the accelerometer sensor
openAccelerometerConnection();
while (_running) {
_tick++;
- // Get current acceleration.
+ // Get current acceleration
readAcceleration();
- // Apply force to the ball.
+ // Apply force to the ball
applyForce(-_xyz[0], _xyz[1]);
try {
@@ -203,13 +249,22 @@ public void run() {
_screen.invalidate();
}
- // Stop querying the sensor to save battery charge.
+ // Stop querying the sensor to save battery charge
closeAccelerometerConnection();
}
+
+ /**
+ * Returns running state of thread
+ *
+ * @return True if this thread is running, otherwise false
+ */
+ public boolean isRunning() {
+ return _running;
+ }
}
/**
- * Opens the data channel.
+ * Opens the data channel
*/
private void openAccelerometerConnection() {
if (DeviceInfo.isSimulator()) {
@@ -223,23 +278,23 @@ private void openAccelerometerConnection() {
}
/**
- * Gets the latest acceleromenter data.
+ * Gets the latest acceleromenter data
*/
private void readAcceleration() {
if (_simulated) {
- // Running in a simulator, simulate random.
+ // Running in a simulator, simulate random
if (_tick % 10 == 0) {
_xyz[0] = (short) (_r.nextInt(400) - 200);
_xyz[1] = (short) (_r.nextInt(400) - 200);
}
} else {
- // Real device, call the API for samples.
+ // Real device, call the API for samples
_accChannel.getLastAccelerationData(_xyz);
}
}
/**
- * Closes the data channel.
+ * Closes the data channel
*/
private void closeAccelerometerConnection() {
if (_accChannel != null) {
@@ -249,36 +304,7 @@ private void closeAccelerometerConnection() {
}
/**
- * Menu item to start the ball moving.
- */
- private final MenuItem _startMenuItem = new MenuItem("Start", 0, 0) {
- public void run() {
- if (_thread == null) {
- // Start drawing
- _thread = new DrawThread();
- _thread.start();
- }
-
- }
- };
-
- /**
- * Menu item to stop the ball moving.
- */
- private final MenuItem _stopMenuItem = new MenuItem("Stop", 0, 0) {
- public void run() {
- if (_thread != null) {
- synchronized (_thread) {
- _thread._running = false;
- _thread.notifyAll();
- _thread = null;
- }
- }
- }
- };
-
- /**
- * A screen on which to display the ball.
+ * A screen on which to display the ball
*/
private class AccelerometerDemoScreen extends MainScreen {
/**
@@ -292,6 +318,19 @@ protected void paint(final Graphics graphics) {
}
/**
+ * @see MainScreen#makeMenu(Menu, int)
+ */
+ protected void makeMenu(final Menu menu, final int instance) {
+ if (_thread == null || !_thread.isRunning()) {
+ menu.add(_startMenuItem);
+ } else {
+ menu.add(_stopMenuItem);
+ }
+
+ super.makeMenu(menu, instance);
+ }
+
+ /**
* @see Screen#onClose()
*/
public boolean onClose() {
View
8 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/CustomComponentsDemo.java
@@ -59,7 +59,9 @@ public static void main(final String[] args) {
new CustomComponentsDemo().enterEventDispatcher();
}
- // Constructor
+ /**
+ * Creates a new CustomComponentsDemo object
+ */
public CustomComponentsDemo() {
try {
// Only one listener can be registered
@@ -91,7 +93,9 @@ public void run() {
private final TextComponent _textComponent;
private final ValueComponent _valueComponent;
- // Constructor
+ /**
+ * Creates a new CustomComponentsDemoScreen object
+ */
private CustomComponentsDemoScreen() {
setTitle("Accessibility Demo");
View
3  com/rim/samples/device/accessibilitydemo/customcomponentsdemo/CustomComponentsDemo.jdp
@@ -46,13 +46,14 @@ img\accessibilitydemo_jde.png
]
Listing=0
Options=-quiet
-OutputFileName=accessibilitydemo
+OutputFileName=CustomComponentsDemo
[PackageProtection
]
RibbonPosition=0
[RolloverIcons
]
RunOnStartup=0
+SkipCompile=0
StartupTier=7
SystemModule=0
Title=Accessibility Demo
View
13 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/IconToolbarComponent.java
@@ -53,7 +53,9 @@
private int _iconHeight;
private int _state;
- // Constructor
+ /**
+ * Creates a new IconToolbarComponent object
+ */
public IconToolbarComponent() {
super(Field.FOCUSABLE);
@@ -337,7 +339,14 @@ public AccessibleValue getAccessibleValue() {
private final Bitmap _image;
private int _state;
- // Constructor
+ /**
+ * Creates a new Icon object
+ *
+ * @param label
+ * Label for the icon
+ * @param image
+ * Bitmap image for the icon
+ */
public Icon(final String label, final Bitmap image) {
_label = label;
_image = image;
View
9 com/rim/samples/device/accessibilitydemo/customcomponentsdemo/TableComponent.java
@@ -176,7 +176,14 @@ public boolean isAccessibleSelected(final int r, final int c) {
private final boolean _selected; // True if the label is selected -
// applicable for table cells only
- // Constructor
+ /**
+ * Creates a new AccessibleLabel object
+ *
+ * @param label
+ * Text to display on the label
+ * @param selected
+ * True if the label is selected, otherwise false
+ */
private AccessibleLabel(final String label, final boolean selected) {
_label = label;
_selected = selected;
View
3  com/rim/samples/device/accessibilitydemo/screenreaderdemo/ScreenReaderDemo.jdp
@@ -38,13 +38,14 @@ HaveImports=0
]
Listing=0
Options=-quiet
-OutputFileName=screenreaderdemo
+OutputFileName=ScreenReaderDemo
[PackageProtection
]
RibbonPosition=0
[RolloverIcons
]
RunOnStartup=0
+SkipCompile=0
StartupTier=7
SystemModule=0
Type=2
View
2  com/rim/samples/device/accessibilitydemo/screenreaderdemo/Util.java
@@ -91,7 +91,7 @@ public static void speak(final String text) {
*
* @param stateSet
* Flag containing bits representing supported orientation(s)
- * @return <description>
+ * @return String to indicate supported orientation
*/
public static String getOrientation(final int stateSet) {
final boolean horizontal = (stateSet & AccessibleState.HORIZONTAL) != 0;
View
70 com/rim/samples/device/activetextfieldsdemo/ActiveTextFieldsDemo.java
@@ -49,8 +49,8 @@
public final class ActiveTextFieldsDemo extends UiApplication {
private static ApplicationMenuItem[] _menuItems =
new ApplicationMenuItem[2];
- private RichTextField _trackingNumber;
- private RichTextField _statusLocation;
+ private static RichTextField _trackingNumber;
+ private static RichTextField _statusLocation;
/**
* Entry point for application
@@ -146,7 +146,8 @@ public ActiveTextFieldsDemo(final boolean isDemoApp) {
// real world situation the application would send the highlighted
// transaction number back to a server and retrieve the status and location
// information.
- private static ApplicationMenuItem statusItem = new ApplicationMenuItem(0) {
+ private static ApplicationMenuItem statusItem = new ApplicationMenuItem(
+ 0x230010) {
/**
* Sets the label and text in the display fields of the handler screen
@@ -156,11 +157,9 @@ public ActiveTextFieldsDemo(final boolean isDemoApp) {
* displayed
*/
public Object run(final Object context) {
- final ActiveTextFieldsDemo app =
- (ActiveTextFieldsDemo) UiApplication.getUiApplication();
- app._trackingNumber.setLabel("Status for tracking No: ");
- app._trackingNumber.setText(context.toString());
- app._statusLocation.setText("< In Progress >");
+ _trackingNumber.setLabel("Status for tracking No: ");
+ _trackingNumber.setText(context.toString());
+ _statusLocation.setText("< In Progress >");
return null;
}
@@ -169,38 +168,36 @@ public String toString() {
}
};
- private static ApplicationMenuItem locationItem =
- new ApplicationMenuItem(1) {
- /**
- * Sets the label and text in the display fields of the handler
- * screen
- *
- * @param context
- * The String representation of the context object is
- * displayed
- */
- public Object run(final Object context) {
- final ActiveTextFieldsDemo app =
- (ActiveTextFieldsDemo) UiApplication
- .getUiApplication();
- app._trackingNumber.setLabel("Location for tracking No: ");
- app._trackingNumber.setText(context.toString());
- app._statusLocation.setText("< 39.3° N 76.6° W >");
- return null;
- }
-
- public String toString() {
- return "Location";
- }
- };
+ private static ApplicationMenuItem locationItem = new ApplicationMenuItem(
+ 0x230020) {
+ /**
+ * Sets the label and text in the display fields of the handler screen
+ *
+ * @param context
+ * The String representation of the context object is
+ * displayed
+ */
+ public Object run(final Object context) {
+ _trackingNumber.setLabel("Location for tracking No: ");
+ _trackingNumber.setText(context.toString());
+ _statusLocation.setText("< 39.3° N 76.6° W >");
+ return null;
+ }
+
+ public String toString() {
+ return "Location";
+ }
+ };
/**
* The screen that is displayed when one of our application menu items is
* invoked.
*/
- private final class HandlerScreen extends MainScreen {
+ private static final class HandlerScreen extends MainScreen {
- // Constructor
+ /**
+ * Creates a new HandlerScreen object
+ */
private HandlerScreen() {
// Set the screen title
setTitle("Active Text Fields Handler");
@@ -218,8 +215,9 @@ private HandlerScreen() {
* The screen for the demo version of this application
*/
final class ActiveTextFieldsScreen extends MainScreen {
-
- // Constructor
+ /**
+ * Creates a new ActiveTextFieldsScreen object
+ */
ActiveTextFieldsScreen() {
// Set the screen title
setTitle("Active Text Fields Demo");
View
12 com/rim/samples/device/activetextfieldsdemo/ActiveTextFieldsDemo_autostartup.jdp
@@ -1,5 +1,9 @@
## 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
@@ -17,6 +21,7 @@ AutoRestart=0
]
EntryFor=ActiveTextFieldsDemo
ExcludeFromBuildAll=0
+Exported=0
HaveAlxImports=0
HaveDefs=0
HaveImports=0
@@ -28,12 +33,15 @@ HaveImports=0
]
Listing=0
MidletClass=autostartup
-Options=-quiet
-OutputFileName=activetextfields_autostartup
+Options=-quiet
+OutputFileName=ActiveTextFieldsDemo_autostartup
[PackageProtection
]
RibbonPosition=0
+[RolloverIcons
+]
RunOnStartup=1
+SkipCompile=0
StartupTier=7
SystemModule=1
Type=3
View
16 com/rim/samples/device/applicationpermissionsdemo/ApplicationPermissionsDemo.java
@@ -174,29 +174,29 @@ private void showTestScreen() {
if (_eventInjectorButton == null) {
_eventInjectorButton =
- new ButtonField("Event Injector", ButtonField.CONSUME_CLICK
- | ButtonField.NEVER_DIRTY);
+ new ButtonField("Event Injector", ButtonField.NEVER_DIRTY
+ | ButtonField.CONSUME_CLICK);
_eventInjectorButton.setChangeListener(this);
}
if (_phoneButton == null) {
_phoneButton =
- new ButtonField("Phone", ButtonField.CONSUME_CLICK
- | ButtonField.NEVER_DIRTY);
+ new ButtonField("Phone", ButtonField.NEVER_DIRTY
+ | ButtonField.CONSUME_CLICK);
_phoneButton.setChangeListener(this);
}
if (_deviceSettingsButton == null) {
_deviceSettingsButton =
- new ButtonField("Device Settings",
- ButtonField.CONSUME_CLICK | ButtonField.NEVER_DIRTY);
+ new ButtonField("Device Settings", ButtonField.NEVER_DIRTY
+ | ButtonField.CONSUME_CLICK);
_deviceSettingsButton.setChangeListener(this);
}
if (_emailButton == null) {
_emailButton =
- new ButtonField("Email", ButtonField.CONSUME_CLICK
- | ButtonField.NEVER_DIRTY);
+ new ButtonField("Email", ButtonField.NEVER_DIRTY
+ | ButtonField.CONSUME_CLICK);
_emailButton.setChangeListener(this);
}
View
6 com/rim/samples/device/attachmentdemo/AttachmentDemo.jdp
@@ -28,18 +28,17 @@ AttachmentDemoScreen.java
attachments\logo.png
attachments\test.abc
attachments\test_doc.doc
-FileExplorerListField.java
FileExplorerScreen.java
FileHolder.java
FileUploadAction.java
FileUploadDialog.java
-img\icon_jde.png
+img\attachmentdemo_jde.png
]
HaveAlxImports=0
HaveDefs=0
HaveImports=0
[Icons
-img\icon_jde.png
+img\attachmentdemo_jde.png
]
[ImplicitRules
]
@@ -55,6 +54,7 @@ RibbonPosition=0
[RolloverIcons
]
RunOnStartup=0
+SkipCompile=0
StartupTier=7
SystemModule=0
Title=Attachment Demo
View
86 com/rim/samples/device/attachmentdemo/AttachmentDemoScreen.java
@@ -28,12 +28,19 @@
import java.io.IOException;
+import javax.microedition.io.Connector;
+import javax.microedition.io.file.FileConnection;
+
+import net.rim.device.api.command.Command;
+import net.rim.device.api.command.CommandHandler;
+import net.rim.device.api.command.ReadOnlyCommandMetadata;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
+import net.rim.device.api.util.StringProvider;
/**
* The main screen class for the Attachment Demo sample application
@@ -60,8 +67,56 @@ public AttachmentDemoScreen(final UiApplication app) {
"Open the menu to download or upload attachments",
Field.NON_FOCUSABLE);
add(_statusField);
- addMenuItem(_downloadItem);
- addMenuItem(_uploadItem);
+ final MenuItem downloadItem =
+ new MenuItem(new StringProvider("Download Attachments"),
+ 0x230010, 0);
+ downloadItem.setCommand(new Command(new CommandHandler() {
+ /**
+ * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
+ * Object)
+ */
+ public void execute(final ReadOnlyCommandMetadata metadata,
+ final Object context) {
+ _statusField.setText("");
+ if (_action.getMessages()) {
+ try {
+ _action.download(Dialog.ask(Dialog.D_YES_NO,
+ "Download only png and msword attachments?") == Dialog.NO);
+ } catch (final IOException ex) {
+ AttachmentDemo
+ .errorDialog("DownloadManager.download() threw "
+ + ex.toString());
+ }
+ } else {
+ displayStatus("Mailbox is empty.");
+ }
+ }
+ }));
+ final MenuItem uploadItem =
+ new MenuItem(new StringProvider("Send Attachment"), 0x230020, 1);
+ uploadItem.setCommand(new Command(new CommandHandler() {
+ /**
+ * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
+ * Object)
+ */
+ public void execute(final ReadOnlyCommandMetadata metadata,
+ final Object context) {
+ _statusField
+ .setText("Open the menu to download or upload attachments");
+
+ // Check if SD card is inserted
+ try {
+ final FileConnection fc =
+ (FileConnection) Connector.open("file:///SDCard/");
+ fc.close();
+ _app.pushScreen(new FileExplorerScreen(_app));
+ } catch (final IOException e) {
+ Dialog.inform("Please insert an SD card to upload items.");
+ }
+ }
+ }));
+ addMenuItem(downloadItem);
+ addMenuItem(uploadItem);
}
/**
@@ -77,31 +132,4 @@ public void run() {
}
});
}
-
- // Menu items --------------------------------------------------------------
- MenuItem _downloadItem = new MenuItem("Download Attachments", 110, 10) {
- public void run() {
- _statusField.setText("");
- if (_action.getMessages()) {
- try {
- _action.download(Dialog.ask(Dialog.D_YES_NO,
- "Download only png and msword attachments?") == Dialog.NO);
- } catch (final IOException ex) {
- AttachmentDemo
- .errorDialog("DownloadManager.download() threw "
- + ex.toString());
- }
- } else {
- displayStatus("Mailbox is empty.");
- }
- }
- };
-
- MenuItem _uploadItem = new MenuItem("Send Attachment", 110, 10) {
- public void run() {
- _statusField
- .setText("Open the menu to download or upload attachments");
- _app.pushScreen(new FileExplorerScreen(_app));
- }
- };
}
View
143 com/rim/samples/device/attachmentdemo/FileExplorerListField.java
@@ -1,143 +0,0 @@
-/*
- * FileExplorerListField.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.attachmentdemo;
-
-import java.util.Vector;
-
-import net.rim.device.api.system.Characters;
-import net.rim.device.api.system.Display;
-import net.rim.device.api.ui.Graphics;
-import net.rim.device.api.ui.Manager;
-import net.rim.device.api.ui.component.ListField;
-import net.rim.device.api.ui.component.ListFieldCallback;
-
-/**
- * A ListField class to display file holder information
- */
-public class FileExplorerListField extends ListField implements
- ListFieldCallback {
- private final Vector _elements = new Vector();
-
- /**
- * Creates a new FileExplorerListField object
- */
- public FileExplorerListField() {
- setCallback(this);
- }
-
- /**
- * Adds a given element to this list field
- *
- * @param element
- * The element to be added
- */
- void add(final Object element) {
- _elements.addElement(element);
- setSize(getSize());
- }
-
- /**
- * @see ListField#keyChar(char, int, int)
- */
- public boolean keyChar(final char key, final int status, final int time) {
- // Allow space bar to page down
- if (getSize() > 0 && key == Characters.SPACE) {
- getScreen().scroll(Manager.DOWNWARD);
- return true;
- }
-
- return super.keyChar(key, status, time);
- }
-
- /**
- * @see ListField#getSize()
- */
- public int getSize() {
- return _elements != null ? _elements.size() : 0;
- }
-
- /**
- * Removes all elements from this list field
- */
- void removeAll() {
- _elements.removeAllElements();
- setSize(0);
- }
-
- // ListFieldCallback implementation ----------------------------------------
-
- /**
- * @see ListFieldCallback#drawListRow(ListField, Graphics, int, int, int)
- */
- public void drawListRow(final ListField listField, final Graphics graphics,
- final int index, final int y, final int width) {
- if (index < getSize()) {
- final FileHolder fileholder =
- (FileHolder) _elements.elementAt(index);
-
- String text;
-
- if (fileholder.isDirectory()) {
- int pathIndex = fileholder.getPath().lastIndexOf('/');
- pathIndex =
- fileholder.getPath().substring(0, pathIndex)
- .lastIndexOf('/');
- text = fileholder.getPath().substring(pathIndex + 1);
- } else {
- text = fileholder.getFileName();
- }
-
- graphics.drawText(text, 0, y);
- }
- }
-
- /**
- * @see ListFieldCallback#get(ListField, int)
- */
- public Object get(final ListField listField, final int index) {
- if (index >= 0 && index < getSize()) {
- return _elements.elementAt(index);
- }
-
- return null;
- }
-
- /**
- * @see ListFieldCallback#getPreferredWidth(ListField)
- */
- public int getPreferredWidth(final ListField listField) {
- return Display.getWidth();
- }
-
- /**
- * @see ListFieldCallback#indexOfList(ListField, String, int)
- */
- public int indexOfList(final ListField listField, final String prefix,
- final int start) {
- return listField.indexOfList(prefix, start);
- }
-}
View
192 com/rim/samples/device/attachmentdemo/FileExplorerScreen.java
@@ -28,27 +28,49 @@
import java.io.IOException;
import java.util.Enumeration;
+import java.util.Vector;
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import javax.microedition.io.file.FileSystemRegistry;
+import net.rim.device.api.command.Command;
+import net.rim.device.api.command.CommandHandler;
+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.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.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.DataTemplate;
+import net.rim.device.api.ui.component.table.TableController;
+import net.rim.device.api.ui.component.table.TableModelAdapter;
+import net.rim.device.api.ui.component.table.TableView;
+import net.rim.device.api.ui.component.table.TemplateColumnProperties;
+import net.rim.device.api.ui.component.table.TemplateRowProperties;
import net.rim.device.api.ui.container.MainScreen;
+import net.rim.device.api.ui.decor.BackgroundFactory;
+import net.rim.device.api.util.StringProvider;
/**
- * A MainScreen class to show the listing of all directories/files
+ * Shows the listing of all directories/files
*/
public class FileExplorerScreen extends MainScreen {
- private static String ROOT = "file:///SDCard/";
+ private static final String ROOT = "file:///SDCard/";
+ private final Vector _elements = new Vector();
- private final FileExplorerListField _list;
+ private FileExplorerTableModelAdapter _model;
+ private TableView _view;
private String _parentRoot;
- private final UiApplication _app;
+ private UiApplication _app;
/**
* Constructs a new FileExplorerScreen object
@@ -57,13 +79,86 @@
* Reference to the UiApplication instance
*/
public FileExplorerScreen(final UiApplication app) {
+ super(Manager.NO_VERTICAL_SCROLL);
+
_app = app;
- // Instantiate and add ListField
- _list = new FileExplorerListField();
- add(_list);
+ _model = new FileExplorerTableModelAdapter();
+
+ _view = new TableView(_model);
+ final TableController controller = new TableController(_model, _view);
+ controller.setFocusPolicy(TableController.ROW_FOCUS);
+ _view.setController(controller);
+
+ // 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 FileHolder fileholder =
+ (FileHolder) _model.getRow(modelRowIndex);
+
+ String text;
+
+ if (fileholder.isDirectory()) {
+ int pathIndex = fileholder.getPath().lastIndexOf('/');
+ pathIndex =
+ fileholder.getPath().substring(0, pathIndex)
+ .lastIndexOf('/');
+ text = fileholder.getPath().substring(pathIndex + 1);
+ } else {
+ text = fileholder.getFileName();
+ }
+
+ final Field[] fields =
+ { new LabelField(text, DrawStyle.ELLIPSIS
+ | 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));
+
+ _view.setDataTemplate(dataTemplate);
+ dataTemplate.useFixedHeight(true);
+
+ // Add the file to the screen
+ add(_view);
readRoots(ROOT);
+
+ _selectItem = new MenuItem(new StringProvider("Select"), 0x230010, 0);
+ _selectItem.setCommand(new Command(new CommandHandler() {
+ /**
+ * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
+ * Object)
+ */
+ public void execute(final ReadOnlyCommandMetadata metadata,
+ final Object context) {
+ selectAction();
+ }
+ }));
+
+ _backItem = new MenuItem(new StringProvider("Go Back"), 0x230020, 1);
+ _backItem.setCommand(new Command(new CommandHandler() {
+ /**
+ * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
+ * Object)
+ */
+ public void execute(final ReadOnlyCommandMetadata metadata,
+ final Object context) {
+ goBack();
+ }
+ }));
}
/**
@@ -73,14 +168,12 @@ public boolean keyChar(final char c, final int status, final int time) {
// Enter key will take action on directory/file. Escape key will go up
// one directory or close screen if at top level.
switch (c) {
- case Characters.ENTER:
- selectAction();
- return true;
case Characters.ESCAPE:
if (goBack()) {
return true;
}
}
+
return super.keyChar(c, status, time);
}
@@ -96,6 +189,7 @@ public void makeMenu(final Menu menu, final int instance) {
menu.add(_backItem);
}
}
+
super.makeMenu(menu, instance);
}
@@ -107,7 +201,8 @@ protected boolean invokeAction(final int action) {
selectAction();
return true;
}
- return false;
+
+ return super.invokeAction(action);
}
/**
@@ -120,8 +215,8 @@ private void readRoots(final String root) {
_parentRoot = root;
setTitle(root);
- // Reset the list field
- _list.removeAll();
+ // Reset the table contents
+ _model.removeAllRows();
FileConnection fc = null;
Enumeration rootEnum = null;
@@ -131,7 +226,7 @@ private void readRoots(final String root) {
try {
fc = (FileConnection) Connector.open(root);
rootEnum = fc.list();
- } catch (final Exception e) {
+ } catch (final IOException e) {
AttachmentDemo.errorDialog(e.toString());
return;
} finally {
@@ -179,13 +274,13 @@ private void readSubroots(final String file) {
// connection is not left open
final FileHolder fileholder =
new FileHolder(file, fc.isDirectory());
- _list.add(fileholder);
+ _model.addRow(fileholder);
} catch (final IOException e) {
AttachmentDemo
.errorDialog("Connector.open() threw " + e.toString());
} finally {
if (fc != null) {
- // Everything is read, make sure to close the connection
+ // Everything is read. Close the connection.
try {
fc.close();
fc = null;
@@ -200,7 +295,7 @@ private void readSubroots(final String file) {
*/
private void selectAction() {
final FileHolder fileholder =
- (FileHolder) _list.get(_list, _list.getSelectedIndex());
+ (FileHolder) _model.getRow(_view.getRowNumberWithFocus());
if (fileholder != null) {
// If the FileHolder represents a directory, then show what's
@@ -254,20 +349,63 @@ public void run() {
}
/**
- * Menu item for displaying information on a selected file
+ * Adapter for displaying file explorer entries in table format
*/
- private final MenuItem _selectItem = new MenuItem("Select", 500, 500) {
- public void run() {
- selectAction();
+ private class FileExplorerTableModelAdapter extends TableModelAdapter {
+ /**
+ * @see net.rim.device.api.ui.component.table.TableModelAdapter#getNumberOfRows()
+ */
+ public int getNumberOfRows() {
+ return _elements.size();
}
- };
+
+ /**
+ * @see net.rim.device.api.ui.component.table.TableModelAdapter#getNumberOfColumns()
+ */
+ public int getNumberOfColumns() {
+ return 1;
+ }
+
+ /**
+ * @see net.rim.device.api.ui.component.table.TableModelAdapter#doAddRow(Object)
+ */
+ protected boolean doAddRow(final Object row) {
+ _elements.addElement(row);
+ return true;
+ }
+
+ /**
+ * @see net.rim.device.api.ui.component.table.TableModelAdapter#doRemoveRowAt()
+ */
+ protected boolean doRemoveRowAt(final int index) {
+ _elements.removeElementAt(index);
+ return true;
+ }
+
+ /**
+ * @see net.rim.device.api.ui.component.table.TableModelAdapter#doGetRow(int)
+ */
+ protected Object doGetRow(final int index) {
+ return _elements.elementAt(index);
+ }
+
+ /**
+ * @see net.rim.device.api.ui.component.table.TableModelAdapter#removeAllRows()
+ */
+ public void removeAllRows() {
+ while (getNumberOfRows() > 0) {
+ removeRowAt(0);
+ }
+ }
+ }
+
+ /**
+ * Menu item for displaying information on a selected file
+ */
+ private MenuItem _selectItem;
/**
* Menu item for going back one directory in the directory hierarchy
*/
- private final MenuItem _backItem = new MenuItem("Go Back", 500, 500) {
- public void run() {
- goBack();
- }
- };
+ private MenuItem _backItem;
}
View
8 com/rim/samples/device/attachmentdemo/FileUploadDialog.java
@@ -73,9 +73,13 @@ public FileUploadDialog(final FileHolder fileHolder,
_emailEdit = new BasicEditField("Recipient Email: ", "");
add(_emailEdit);
- _okButton = new ButtonField("OK", Field.FIELD_HCENTER);
+ _okButton =
+ new ButtonField("OK", Field.FIELD_HCENTER
+ | ButtonField.CONSUME_CLICK);
_okButton.setChangeListener(this);
- _cancelButton = new ButtonField("Cancel", Field.FIELD_HCENTER);
+ _cancelButton =
+ new ButtonField("Cancel", Field.FIELD_HCENTER
+ | ButtonField.CONSUME_CLICK);
_cancelButton.setChangeListener(this);
final HorizontalFieldManager hfm =
View
BIN  com/rim/samples/device/attachmentdemo/img/attachmentdemo_jde.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/attachmentdemo/img/icon_jde.png
Deleted file not rendered
View
248 com/rim/samples/device/barcodescandemo/BarcodeScanDemo.java
@@ -0,0 +1,248 @@
+/*
+ * BarcodeScanDemo.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.barcodescandemo;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+import javax.microedition.media.MediaException;
+
+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.ui.Field;
+import net.rim.device.api.ui.FieldChangeListener;
+import net.rim.device.api.ui.UiApplication;
+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;
+
+/*
+ * 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.
+ */
+public final class BarcodeScanDemo 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.
+ new BarcodeScanDemo().enterEventDispatcher();
+ }
+
+ /**
+ * Creates a new BarcodeScanDemo object
+ */
+ public BarcodeScanDemo() {
+ pushScreen(new BarcodeScanDemoScreen());
+ }
+}
+
+/**
+ * A UI screen to display the camera display and buttons
+ */
+final class BarcodeScanDemoScreen extends MainScreen {
+ private ViewFinderScreen _viewFinderScreen;
+ private final LabelField _scannedText;
+
+ /**
+ * Creates a new BarcodeScanDemoScreen object
+ */
+ public BarcodeScanDemoScreen() {
+ // Set the title of the screen
+ setTitle("Barcode Scan Demo");
+
+ // Create a button which will launch a viewfinder screen
+ final ButtonField buttonField =
+ new ButtonField("Scan QR Barcode", 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();
+ }
+ });
+
+ buttonField.setPadding(2, 2, 2, 2);
+ add(buttonField);
+
+ _scannedText = new LabelField();
+ _scannedText.setPadding(5, 5, 5, 5);
+ add(_scannedText);
+ }
+
+ /**
+ * 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.
+ */
+ 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());
+ }
+ }
+
+ /**
+ * Informs the BarcodeScanner that it should begin scanning for QR Codes
+ */
+ public void startScan() {
+ try {
+ _scanner.startScan();
+ } catch (final MediaException me) {
+ displayMessage("Error: " + me.getMessage());
+ }
+ }
+
+ /**
+ * @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());
+ }
+ }
+
+ return super.keyChar(key, status, time);
+ }
+
+ /**
+ * @see net.rim.device.api.ui.Screen#close()
+ */
+ public void close() {
+ try {
+ _scanner.stopScan();
+ } catch (final MediaException me) {
+ displayMessage("Error: " + me.getMessage());
+ }
+
+ super.close();
+ }
+
+ /**
+ * Pops the ViewFinderScreen and displays text on the main screen
+ *
+ * @param text
+ * Text to display on the screen
+ */
+ private void displayMessage(final String text) {
+ UiApplication.getUiApplication().invokeLater(new Runnable() {
+ public void run() {
+ _scannedText.setText(text);
+ UiApplication.getUiApplication().popScreen(
+ ViewFinderScreen.this);
+ }
+ });
+ }
+
+ /**
+ * 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);
+ }
+ });
+ }
+ }
+
+ /**
+ * @see net.rim.device.api.ui.container.MainScreen#onSavePrompt()
+ */
+ protected boolean onSavePrompt() {
+ // Suppress the save dialog
+ return true;
+ }
+}
View
53 com/rim/samples/device/barcodescandemo/BarcodeScanDemo.jdp
@@ -0,0 +1,53 @@
+## 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
+BarcodeScanDemo.java
+img\barcodescandemo_jde.png
+]
+HaveAlxImports=0
+HaveDefs=0
+HaveImports=0
+[Icons
+img\barcodescandemo_jde.png
+]
+[ImplicitRules
+]
+[Imports
+]
+Listing=0
+Options=-quiet
+OutputFileName=BarcodeScanDemo
+[PackageProtection
+]
+RibbonPosition=0
+[RolloverIcons
+]
+RunOnStartup=0
+SkipCompile=0
+StartupTier=7
+SystemModule=0
+Title=Barcode Scan Demo
+Type=0
+Vendor=Research in Motion Limited
+Version=0.9
View
BIN  com/rim/samples/device/barcodescandemo/beep.wav
Binary file not shown
View
BIN  com/rim/samples/device/barcodescandemo/img/barcodescandemo_jde.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
26 com/rim/samples/device/blackberrymaildemo/BlackBerryMailDemo.java
@@ -29,19 +29,21 @@
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
-/*
- * This sample demonstrates how to access email on a BlackBerry. It shows the following:
+/**
+ * This sample demonstrates how to access email on a BlackBerry. It shows the
+ * following:
+ *
+ * - Accessing all email service records (email accounts) available on a
+ * BlackBerry. - Accessing all email folders and messages for an email account.
+ * - Displaying the content of an email message. Both plain text and HTML
+ * content is displayed (if available within the message). - Saving and sending
+ * email messages.
*
- * - Accessing all email service records (email accounts) available on a BlackBerry.
- * - Accessing all email folders and messages for an email account.
- * - Displaying the content of an email message. Both plain text and HTML content
- * is displayed (if available within the message).
- * - Saving and sending email messages.
- *
- * The sample can be tested using the BlackBerry email server simulator or
- * synching the BlackBerry Desktop Manager to the BlackBerry Smartphone simulator
- * device. See the "BlackBerry Java Development Environment Development Guide"
- * for more information on the BlackBerry email server simulator.
+ * The sample can be tested using the BlackBerry email server simulator or
+ * synching the BlackBerry Desktop Manager to the BlackBerry Smartphone
+ * simulator device. See the
+ * "BlackBerry Java Development Environment Development Guide" for more
+ * information on the BlackBerry email server simulator.
*/
public final class BlackBerryMailDemo extends UiApplication {
/**
View
7 com/rim/samples/device/blackberrymaildemo/BlackBerryMailDemo.jdp
@@ -26,7 +26,7 @@ BlackBerryMailDemo.java
BlackBerryMailDemoScreen.java
ComposeScreen.java
FoldersViewScreen.java
-img\icon_jde.png
+img\blackberrymaildemo_jde.png
MessageScreen.java
MessagesListField.java
MessagesViewScreen.java
@@ -36,7 +36,7 @@ HaveAlxImports=0
HaveDefs=0
HaveImports=0
[Icons
-img\icon_jde.png
+img\blackberrymaildemo_jde.png
]
[ImplicitRules
]
@@ -44,13 +44,14 @@ img\icon_jde.png
]
Listing=0
Options=-quiet
-OutputFileName=blackberrymaildemo
+OutputFileName=BlackberryMailDemo
[PackageProtection
]
RibbonPosition=0
[RolloverIcons
]
RunOnStartup=0
+SkipCompile=0
StartupTier=7
SystemModule=0
Title=BlackBerry Mail Demo
View
131 com/rim/samples/device/blackberrymaildemo/BlackBerryMailDemoScreen.java
@@ -30,6 +30,9 @@
import net.rim.blackberry.api.mail.ServiceConfiguration;
import net.rim.blackberry.api.mail.Session;
import net.rim.blackberry.api.mail.Store;
+import net.rim.device.api.command.Command;
+import net.rim.device.api.command.CommandHandler;
+import net.rim.device.api.command.ReadOnlyCommandMetadata;
import net.rim.device.api.servicebook.ServiceBook;
import net.rim.device.api.servicebook.ServiceRecord;
import net.rim.device.api.system.Application;
@@ -40,6 +43,7 @@
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.container.MainScreen;
+import net.rim.device.api.util.StringProvider;
/**
* The parent class for MessagesListScreen and FoldersViewScreen. This class
@@ -73,6 +77,57 @@
* Default Constructor for subclasses
*/
protected BlackBerryMailDemoScreen() {
+ initializeMenuItems();
+ }
+
+ /**
+ * Initialize menu item objects
+ */
+ private void initializeMenuItems() {
+ _composeMenuItem =
+ new MenuItem(new StringProvider("Compose Email"), 0x230030, 2);
+ _composeMenuItem.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 ComposeScreen composeScreen =
+ new ComposeScreen(null, _store);
+ UiApplication.getUiApplication().pushScreen(composeScreen);
+ updateScreen();
+ }
+ }));
+
+ _openMenuItem =
+ new MenuItem(new StringProvider("Open Item"), 0x230010, 0);
+ _openMenuItem.setCommand(new Command(new CommandHandler() {
+ /**
+ * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
+ * Object)
+ */
+ public void execute(final ReadOnlyCommandMetadata metadata,
+ final Object context) {
+ openAction();
+ }
+ }));
+
+ _editMenuItem = new MenuItem(new StringProvider("Edit"), 0x230020, 1);
+ _editMenuItem.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 Message msg = (Message) getSelectedItem();
+ final MessageScreen messageScreen =
+ new MessageScreen(msg, true);
+ UiApplication.getUiApplication().pushScreen(messageScreen);
+ updateScreen();
+ }
+ }));
}
/**
@@ -82,6 +137,27 @@ protected BlackBerryMailDemoScreen() {
* Screen title
*/
public BlackBerryMailDemoScreen(final String title) {
+ initializeMenuItems();
+
+ _selectServiceMenuItem =
+ new MenuItem(new StringProvider("Choose Message Service"),
+ 0x230040, 3);
+ _selectServiceMenuItem.setCommand(new Command(new CommandHandler() {
+ /**
+ * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
+ * Object)
+ */
+ public void execute(final ReadOnlyCommandMetadata metadata,
+ final Object context) {
+ if (_currentDisplayMode == MESSAGES_VIEW_MODE) {
+ _store.removeFolderListener(_messagesViewScreen);
+ }
+
+ selectServiceDialog();
+ messageServiceChanged();
+ }
+ }));
+
setTitle(title);
_currentDisplayMode = MESSAGES_VIEW_MODE;
@@ -201,58 +277,28 @@ protected void openMessage(final Message message) {
/**
* Menu item to push a ComposeScreen
*/
- private final MenuItem _composeMenuItem = new MenuItem("Compose Email",
- 110, 11) {
- public void run() {
- final ComposeScreen composeScreen = new ComposeScreen(null, _store);
- UiApplication.getUiApplication().pushScreen(composeScreen);
- updateScreen();
- }
- };
+ private MenuItem _composeMenuItem;
/**
* Menu item to open folder
*/
- private final MenuItem _openMenuItem = new MenuItem("Open Item", 110, 10) {
- public void run() {
- openAction();
- }
- };
+ private MenuItem _openMenuItem;
/**
* Menu item to open a message for editing
*/
- private final MenuItem _editMenuItem = new MenuItem("Edit", 110, 12) {
- public void run() {
- final Message msg = (Message) getSelectedItem();
- final MessageScreen messageScreen = new MessageScreen(msg, true);
- UiApplication.getUiApplication().pushScreen(messageScreen);
- updateScreen();
- }
- };
+ private MenuItem _editMenuItem;
/**
* Menu item allows user to choose message service
*/
- private final MenuItem _selectServiceMenuItem = new MenuItem(
- "Choose Message Service", 110, 10) {
- public void run() {
- if (_currentDisplayMode == MESSAGES_VIEW_MODE) {
- _store.removeFolderListener(_messagesViewScreen);
- }
-
- selectServiceDialog();
- messageServiceChanged();
- }
- };
+ private MenuItem _selectServiceMenuItem;
/**
* @see net.rim.device.api.ui.Screen#makeMenu(Menu, int)
*/
protected void makeMenu(final Menu menu, final int instance) {
- // Have the compose menu item on top
menu.add(_composeMenuItem);
- menu.addSeparator();
// If there are messages in the list, add the menu item for viewing
// different messages.
@@ -293,31 +339,24 @@ protected void makeMenu(final Menu menu, final int instance) {
* @see net.rim.device.api.ui.Screen#invokeAction(int)
*/
protected boolean invokeAction(final int action) {
- switch (action) {
- case ACTION_INVOKE: // Trackball click
- {
+ if (action == ACTION_INVOKE) {
openAction();
return true;
}
- }
return super.invokeAction(action);
}
/**
- * Overrides default. Enter key will display the message.
- *
- * @see net.rim.device.api.ui.Screen#keyChar(char,int,int)
+ * @see net.rim.device.api.ui.Screen#keyChar(char, int, int)
*/
public boolean keyChar(final char c, final int status, final int time) {
- switch (c) {
- case Characters.ENTER:
+ if (c == Characters.ENTER) {
openAction();
return true;
-
- default:
- return super.keyChar(c, status, time);
}
+
+ return super.keyChar(c, status, time);
}
/**
View
178 com/rim/samples/device/blackberrymaildemo/ComposeScreen.java
@@ -39,6 +39,9 @@
import net.rim.blackberry.api.mail.Store;
import net.rim.blackberry.api.mail.TextBodyPart;
import net.rim.blackberry.api.mail.Transport;
+import net.rim.device.api.command.Command;
+import net.rim.device.api.command.CommandHandler;
+import net.rim.device.api.command.ReadOnlyCommandMetadata;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
@@ -48,6 +51,7 @@
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.component.TextField;
+import net.rim.device.api.util.StringProvider;
/**
* The ComposeScreen is a screen which displays either a new or saved message.
@@ -58,10 +62,6 @@
private static final int FIRST = 0;
private static final int SEND_MENU_ITEM_INDEX = 0;
- private final AddHeaderFieldAction _addToMenuItem;
- private final AddHeaderFieldAction _addCcMenuItem;
- private final AddHeaderFieldAction _addBccMenuItem;
-
private final Store _store;
/**
@@ -85,65 +85,76 @@ public ComposeScreen(final Message message, final Store store) {
// Create and add menu items specific to the Compose action (addTo,
// addBcc, addCc, etc...).
- _addToMenuItem =
+ final AddHeaderFieldAction addToMenuItem =
new AddHeaderFieldAction(Message.RecipientType.TO, "Add To: ",
"To: ");
- _addCcMenuItem =
+ final AddHeaderFieldAction addCcMenuItem =
new AddHeaderFieldAction(Message.RecipientType.CC, "Add Cc: ",
"Cc: ");
- _addBccMenuItem =
+ final AddHeaderFieldAction addBccMenuItem =
new AddHeaderFieldAction(Message.RecipientType.BCC,
"Add Bcc: ", "Bcc: ");
- addMenuItem(_sendMenuItem);
- addMenuItem(_saveMenuItem);