Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BlackBerry NFC sample app which demonstrates using NFC tags to trigge…

…r actions
  • Loading branch information...
commit b0fd22c9cdf6a1127e28a8d735213e19b96f9064 1 parent dd48cb5
@mdwoolley mdwoolley authored
Showing with 1,219 additions and 0 deletions.
  1. +28 −0 NFC/NfcRaceTime7/BlackBerry_App_Descriptor.xml
  2. +204 −0 NFC/NfcRaceTime7/LICENSE
  3. +70 −0 NFC/NfcRaceTime7/README.md
  4. BIN  NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.cod
  5. +1 −0  NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.csl
  6. +5 −0 NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.cso
  7. BIN  NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.debug
  8. +18 −0 NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.jad
  9. BIN  NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.jar
  10. +12 −0 NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.rapc
  11. +31 −0 NFC/NfcRaceTime7/deliverables/Standard/NfcRaceTime7.alx
  12. BIN  NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.cod
  13. +1 −0  NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.csl
  14. +5 −0 NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.cso
  15. BIN  NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.debug
  16. +18 −0 NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.jad
  17. BIN  NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.jar
  18. +12 −0 NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.rapc
  19. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_0.png
  20. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_1.png
  21. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_2.png
  22. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_3.png
  23. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_4.png
  24. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_5.png
  25. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_6.png
  26. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_7.png
  27. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_8.png
  28. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_9.png
  29. BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_colon.png
  30. BIN  NFC/NfcRaceTime7/res/img/icon.png
  31. BIN  NFC/NfcRaceTime7/res/img/photothumb.db
  32. +31 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/ColouredBackground.java
  33. +17 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/ColouredBackground.java.bak
  34. +27 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Constants.java
  35. +60 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Listener.java
  36. +46 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Listener.java.bak
  37. +42 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/MyApp.java
  38. +28 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/MyApp.java.bak
  39. +74 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/NdefListenerManager.java
  40. +33 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/RaceTimer.java
  41. +19 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/RaceTimer.java.bak
  42. +117 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Time.java
  43. +103 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Time.java.bak
  44. +100 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/TimerScreen.java
  45. +86 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/TimerScreen.java.bak
  46. +31 −0 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Utilities.java
View
28 NFC/NfcRaceTime7/BlackBerry_App_Descriptor.xml
@@ -0,0 +1,28 @@
+<!-- This file has been generated by the BlackBerry Plugin for Eclipse v3.6.1. -->
+
+<Properties ModelVersion="1.1.2">
+ <General Title="" Version="1.0.0" Vendor="BlackBerry Developer" Description=""/>
+ <Application Type="BlackBerry Application" MainMIDletName="" MainArgs="" HomeScreenPosition="0" StartupTier="7" IsSystemModule="false" IsAutostartup="false"/>
+ <Resources hasTitleResource="false" TitleResourceBundleName="" TitleResourceBundleRelativePath="" TitleResourceBundleClassName="" TitleResourceBundleKey="" DescriptionId="">
+ <Icons>
+ <Icon CanonicalFileName="res\img\icon.png" IsFocus="false"/>
+ </Icons>
+ </Resources>
+ <KeywordResources KeywordResourceBundleName="" KeywordResourceBundleRelativePath="" KeywordResourceBundleClassName="" KeywordResourceBundleKey=""/>
+ <Compile OutputCompilerMessages="false" ConvertImages="true" CreateWarningForNoExportedRoutine="true" CompressResources="false" AliasList="">
+ <PreprocessorDefines/>
+ </Compile>
+ <Packaging PreBuildStep="" PostBuildStep="" CleanStep="" OutputFileName="NfcRaceTime7" OutputFolder="deliverables" GenerateALXFile="true">
+ <AlxFiles/>
+ </Packaging>
+ <HiddenProperties>
+ <ClassProtection/>
+ <PackageProtection/>
+ </HiddenProperties>
+ <AlternateEntryPoints>
+ <AlternateEntryPoint Title="auto" MainMIDletName="" ArgumentsForMain="auto" HomeScreenPosition="0" StartupTier="7" IsSystemModule="true" IsAutostartup="true" hasTitleResource="false" TitleResourceBundleKey="" TitleResourceBundleName="" TitleResourceBundleClassName="" TitleResourceBundleRelativePath="">
+ <Icons/>
+ <KeywordResources KeywordResourceBundleName="" KeywordResourceBundleRelativePath="" KeywordResourceBundleClassName="" KeywordResourceBundleKey=""/>
+ </AlternateEntryPoint>
+ </AlternateEntryPoints>
+</Properties>
View
204 NFC/NfcRaceTime7/LICENSE
@@ -0,0 +1,204 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+-------------------------------------------------------
+Copyright 2012 Research In Motion Limited.
View
70 NFC/NfcRaceTime7/README.md
@@ -0,0 +1,70 @@
+# NfcRaceTime7
+
+The purpose of this application is to demonstrate how NFC tags can be used to trigger actions.
+
+The use case examines how to use an NFC Tag to trigger the starting and stopping of a timer in the application that could be used in the context of an event like a "fun run".
+
+The sample code for this application is Open Source under the Apache 2.0 License.
+
+Note that there is also a BlackBerry 10 Cascades version of this application. https://github.com/blackberry/Cascades-Community-Samples/tree/master/NfcRaceTimeWay
+
+The sample code for this application is Open Source under
+the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).
+
+**Applies To**
+
+* [Cascades for BlackBerry 10](https://bdsc.webapps.blackberry.com/cascades/)
+* [BlackBerry Native SDK for Tablet OS](https://bdsc.webapps.blackberry.com/native/)
+
+**Author(s)**
+
+* [John Murray](https://github.com/jcmurray)
+* [Martin Woolley](https://github.com/mdwoolley)
+
+
+**Release History**
+* **V1** - Initial release
+
+**Known Issues**
+1. To start a new game it may be necessary to exit and then start again
+
+**Dependencies**
+
+1. BlackBerry Dev Alpha Device Software **10.0.9**
+2. BlackBerry 10 Native SDK **10.0.9**
+
+
+**I don't want to build it myself**
+
+If you don't want to build this sample application yourself we've included a
+pre-build and signed BAR files for each version. You can find them in the
+folder "installable-bar-files":
+
+
+**To contribute code to this repository you must be [signed up as an
+official contributor](http://blackberry.github.com/howToContribute.html).**
+
+
+## Contributing Changes
+
+Please see the [README](https://github.com/blackberry/Cascades-Community-Samples/blob/master/README.md)
+of the Cascades-Community-Samples repository for instructions on how to add new Samples or
+make modifications to existing Samples.
+
+
+## Bug Reporting and Feature Requests
+
+If you find a bug in a Sample, or have an enhancement request, simply file
+an [Issue](https://github.com/blackberry/Cascades-Community-Samples/issues) for
+the Sample and send a message (via github messages) to the Sample Author(s) to let
+them know that you have filed an [Issue](https://github.com/blackberry/Cascades-Community-Samples/issues).
+
+
+## Disclaimer
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
View
BIN  NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.cod
Binary file not shown
View
1  NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.csl
@@ -0,0 +1 @@
+52525400=RIM Runtime API
View
5 NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.cso
@@ -0,0 +1,5 @@
+33000000=RIMAPPSA2
+52424200=RIM Blackberry Apps API
+52434900=RIM Crypto API - Internal
+52435200=RIM Crypto API - RIM
+4e464352=NFCRoutingAPI
View
BIN  NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.debug
Binary file not shown
View
18 NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.jad
@@ -0,0 +1,18 @@
+MIDlet-Name: NfcRaceTime7
+MIDlet-Version: 1.0.0
+MIDlet-Vendor: BlackBerry Developer
+MIDlet-Jar-URL: NfcRaceTime7.jar
+MIDlet-Jar-Size: 49188
+MicroEdition-Profile: MIDP-2.0
+MicroEdition-Configuration: CLDC-1.1
+MIDlet-1: ,img/icon.png,
+RIM-MIDlet-Flags-1: 0
+MIDlet-2: auto,,auto
+RIM-MIDlet-Flags-2: 3
+Manifest-Version: 1.0
+RIM-COD-URL: NfcRaceTime7.cod
+RIM-COD-Size: 29132
+RIM-COD-Creation-Time: 1349091932
+RIM-COD-Module-Name: NfcRaceTime7
+RIM-COD-Module-Dependencies: net_rim_cldc,net_rim_nfc
+RIM-COD-SHA1: 23 9d 48 1d 07 55 e1 20 ed aa c9 7c 47 6f 92 e8 9c 4c 24 e4
View
BIN  NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.jar
Binary file not shown
View
12 NFC/NfcRaceTime7/deliverables/Standard/7.0.0/NfcRaceTime7.rapc
@@ -0,0 +1,12 @@
+MIDlet-Name: NfcRaceTime7
+MIDlet-Version: 1.0.0
+MIDlet-Vendor: BlackBerry Developer
+MIDlet-Jar-URL: NfcRaceTime7.jar
+MIDlet-Jar-Size: 0
+MicroEdition-Profile: MIDP-2.0
+MicroEdition-Configuration: CLDC-1.1
+MIDlet-1: ,img/icon.png,
+RIM-MIDlet-Flags-1: 0
+MIDlet-2: auto,,auto
+RIM-MIDlet-Flags-2: 3
+
View
31 NFC/NfcRaceTime7/deliverables/Standard/NfcRaceTime7.alx
@@ -0,0 +1,31 @@
+<loader version="1.0">
+ <application id="NfcRaceTime7">
+ <name >
+
+ </name>
+ <description >
+
+ </description>
+ <version >
+ 1.0.0
+ </version>
+ <vendor >
+ BlackBerry Developer
+ </vendor>
+ <copyright >
+ Copyright (c) 2012 BlackBerry Developer
+ </copyright>
+ <fileset Java="1.54" _blackberryVersion="[7.0.0)">
+ <directory >
+ 7.0.0
+ </directory>
+ <files >
+ NfcRaceTime7.cod
+
+ </files>
+
+ </fileset>
+
+ </application>
+
+</loader>
View
BIN  NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.cod
Binary file not shown
View
1  NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.csl
@@ -0,0 +1 @@
+52525400=RIM Runtime API
View
5 NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.cso
@@ -0,0 +1,5 @@
+33000000=RIMAPPSA2
+52424200=RIM Blackberry Apps API
+52434900=RIM Crypto API - Internal
+52435200=RIM Crypto API - RIM
+4e464352=NFCRoutingAPI
View
BIN  NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.debug
Binary file not shown
View
18 NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.jad
@@ -0,0 +1,18 @@
+MIDlet-Name: NfcRaceTime7
+MIDlet-Version: 1.0.0
+MIDlet-Vendor: BlackBerry Developer
+MIDlet-Jar-URL: NfcRaceTime7.jar
+MIDlet-Jar-Size: 49188
+MicroEdition-Profile: MIDP-2.0
+MicroEdition-Configuration: CLDC-1.1
+MIDlet-1: ,img/icon.png,
+RIM-MIDlet-Flags-1: 0
+MIDlet-2: auto,,auto
+RIM-MIDlet-Flags-2: 3
+Manifest-Version: 1.0
+RIM-COD-URL: NfcRaceTime7.cod
+RIM-COD-Size: 29132
+RIM-COD-Creation-Time: 1349091932
+RIM-COD-Module-Name: NfcRaceTime7
+RIM-COD-Module-Dependencies: net_rim_cldc,net_rim_nfc
+RIM-COD-SHA1: 23 9d 48 1d 07 55 e1 20 ed aa c9 7c 47 6f 92 e8 9c 4c 24 e4
View
BIN  NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.jar
Binary file not shown
View
12 NFC/NfcRaceTime7/deliverables/Web/7.0.0/NfcRaceTime7.rapc
@@ -0,0 +1,12 @@
+MIDlet-Name: NfcRaceTime7
+MIDlet-Version: 1.0.0
+MIDlet-Vendor: BlackBerry Developer
+MIDlet-Jar-URL: NfcRaceTime7.jar
+MIDlet-Jar-Size: 0
+MicroEdition-Profile: MIDP-2.0
+MicroEdition-Configuration: CLDC-1.1
+MIDlet-1: ,img/icon.png,
+RIM-MIDlet-Flags-1: 0
+MIDlet-2: auto,,auto
+RIM-MIDlet-Flags-2: 3
+
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_6.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_7.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_8.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/60px-Seven-segment_colon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  NFC/NfcRaceTime7/res/img/photothumb.db
Binary file not shown
View
31 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/ColouredBackground.java
@@ -0,0 +1,31 @@
+package nfc.sample.racetimebb7;
+/*
+* Copyright (c) 2012 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.
+*/
+import net.rim.device.api.ui.container.HorizontalFieldManager;
+import net.rim.device.api.ui.decor.Background;
+import net.rim.device.api.ui.decor.BackgroundFactory;
+
+public class ColouredBackground extends HorizontalFieldManager {
+
+ Background background;
+
+ public ColouredBackground(int colour, long style) {
+ super(style);
+ background = BackgroundFactory.createSolidBackground(colour);
+ setBackground(background);
+ }
+
+}
View
17 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/ColouredBackground.java.bak
@@ -0,0 +1,17 @@
+package nfc.sample.racetimebb7;
+
+import net.rim.device.api.ui.container.HorizontalFieldManager;
+import net.rim.device.api.ui.decor.Background;
+import net.rim.device.api.ui.decor.BackgroundFactory;
+
+public class ColouredBackground extends HorizontalFieldManager {
+
+ Background background;
+
+ public ColouredBackground(int colour, long style) {
+ super(style);
+ background = BackgroundFactory.createSolidBackground(colour);
+ setBackground(background);
+ }
+
+}
View
27 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Constants.java
@@ -0,0 +1,27 @@
+package nfc.sample.racetimebb7;
+/*
+* Copyright (c) 2012 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.
+*/
+public interface Constants {
+
+ public static final String MYAPP_VERSION = "1.0.0";
+
+ public static final long LISTENER_STATE_TOKEN = 0xbceb71d8f675e991L;
+
+ public static final int REGISTER=0;
+ public static final int UNREGISTER=1;
+
+
+}
View
60 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Listener.java
@@ -0,0 +1,60 @@
+package nfc.sample.racetimebb7;
+/*
+* Copyright (c) 2012 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.
+*/
+import java.io.UnsupportedEncodingException;
+import java.util.Timer;
+
+import net.rim.device.api.io.nfc.ndef.NDEFMessage;
+import net.rim.device.api.io.nfc.ndef.NDEFMessageListener;
+import net.rim.device.api.io.nfc.ndef.NDEFRecord;
+
+public class Listener implements NDEFMessageListener {
+
+ Timer timer;
+
+ public void onNDEFMessageDetected(NDEFMessage msg) {
+ Utilities.log("XXXX onNDEFMessageDetected");
+ NDEFRecord[] records = msg.getRecords();
+ int numRecords = records.length;
+ if(numRecords > 0) {
+ byte[] payloadBytes = records[0].getPayload();
+ try {
+ String ascii_payload = new String(payloadBytes,"US-ASCII");
+ Utilities.log("XXXX payload="+ascii_payload);
+ if (ascii_payload.equals("start")) {
+ startTimer();
+ }
+ if (ascii_payload.equals("stop")) {
+ stopTimer();
+ }
+ } catch(UnsupportedEncodingException e) {
+ Utilities.log("XXXX "+e.getClass().getName()+":"+e.getMessage());
+ }
+ }
+
+ }
+
+ private void startTimer() {
+ RaceTimer race_timer = new RaceTimer();
+ timer = new Timer();
+ timer.scheduleAtFixedRate(race_timer, 1000, 1000);
+ }
+
+ private void stopTimer() {
+ timer.cancel();
+ }
+
+}
View
46 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Listener.java.bak
@@ -0,0 +1,46 @@
+package nfc.sample.racetimebb7;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Timer;
+
+import net.rim.device.api.io.nfc.ndef.NDEFMessage;
+import net.rim.device.api.io.nfc.ndef.NDEFMessageListener;
+import net.rim.device.api.io.nfc.ndef.NDEFRecord;
+
+public class Listener implements NDEFMessageListener {
+
+ Timer timer;
+
+ public void onNDEFMessageDetected(NDEFMessage msg) {
+ Utilities.log("XXXX onNDEFMessageDetected");
+ NDEFRecord[] records = msg.getRecords();
+ int numRecords = records.length;
+ if(numRecords > 0) {
+ byte[] payloadBytes = records[0].getPayload();
+ try {
+ String ascii_payload = new String(payloadBytes,"US-ASCII");
+ Utilities.log("XXXX payload="+ascii_payload);
+ if (ascii_payload.equals("start")) {
+ startTimer();
+ }
+ if (ascii_payload.equals("stop")) {
+ stopTimer();
+ }
+ } catch(UnsupportedEncodingException e) {
+ Utilities.log("XXXX "+e.getClass().getName()+":"+e.getMessage());
+ }
+ }
+
+ }
+
+ private void startTimer() {
+ RaceTimer race_timer = new RaceTimer();
+ timer = new Timer();
+ timer.scheduleAtFixedRate(race_timer, 1000, 1000);
+ }
+
+ private void stopTimer() {
+ timer.cancel();
+ }
+
+}
View
42 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/MyApp.java
@@ -0,0 +1,42 @@
+package nfc.sample.racetimebb7;
+/*
+* Copyright (c) 2012 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.
+*/
+import net.rim.device.api.ui.UiApplication;
+
+public class MyApp extends UiApplication {
+
+ public static void main(String[] args) {
+ MyApp app = new MyApp();
+ NdefListenerManager ndef_mgr = NdefListenerManager.getInstance();
+ Utilities.initLogging();
+ if (args.length > 0) {
+ if (args[0].equals("auto")) {
+ Listener listener = new Listener();
+ ndef_mgr.registerListener(listener);
+ }
+ } else {
+ Listener listener = new Listener();
+ ndef_mgr.registerListener(listener);
+ app.pushScreen(TimerScreen.getTimerScreen());
+ app.enterEventDispatcher();
+ }
+ Utilities.log("XXXX exiting");
+ }
+
+ public MyApp() {
+ }
+
+}
View
28 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/MyApp.java.bak
@@ -0,0 +1,28 @@
+package nfc.sample.racetimebb7;
+
+import net.rim.device.api.ui.UiApplication;
+
+public class MyApp extends UiApplication {
+
+ public static void main(String[] args) {
+ MyApp app = new MyApp();
+ NdefListenerManager ndef_mgr = NdefListenerManager.getInstance();
+ Utilities.initLogging();
+ if (args.length > 0) {
+ if (args[0].equals("auto")) {
+ Listener listener = new Listener();
+ ndef_mgr.registerListener(listener);
+ }
+ } else {
+ Listener listener = new Listener();
+ ndef_mgr.registerListener(listener);
+ app.pushScreen(TimerScreen.getTimerScreen());
+ app.enterEventDispatcher();
+ }
+ Utilities.log("XXXX exiting");
+ }
+
+ public MyApp() {
+ }
+
+}
View
74 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/NdefListenerManager.java
@@ -0,0 +1,74 @@
+package nfc.sample.racetimebb7;
+
+/*
+ * Copyright (c) 2012 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.
+ */
+import net.rim.device.api.io.nfc.NFCException;
+import net.rim.device.api.io.nfc.ndef.NDEFRecord;
+import net.rim.device.api.io.nfc.readerwriter.ReaderWriterManager;
+import net.rim.device.api.system.RuntimeStore;
+
+public class NdefListenerManager {
+
+ private static NdefListenerManager _mgr;
+
+ private RuntimeStore rts = RuntimeStore.getRuntimeStore();
+
+ private NdefListenerManager() {
+ }
+
+ public synchronized static NdefListenerManager getInstance() {
+ if(_mgr == null) {
+ _mgr = new NdefListenerManager();
+ }
+ return _mgr;
+ }
+
+ public void registerListener(Listener listener) {
+// unRegisterListener(); // just in case already registered
+ ReaderWriterManager nfcManager;
+ try {
+ nfcManager = ReaderWriterManager.getInstance();
+ nfcManager.addNDEFMessageListener(listener, NDEFRecord.TNF_EXTERNAL, "my.rim.com:myrecordtype", true);
+ rts.replace(Constants.LISTENER_STATE_TOKEN, new Boolean(true));
+ Utilities.log("XXXX listener registered");
+ } catch(NFCException e) {
+ Utilities.log("XXXX "+e.getClass().getName()+":"+e.getMessage());
+ }
+ }
+
+ public void unRegisterListener() {
+ ReaderWriterManager nfcManager;
+ try {
+ nfcManager = ReaderWriterManager.getInstance();
+ nfcManager.removeNDEFMessageListener(NDEFRecord.TNF_EXTERNAL, "my.rim.com:myrecordtype");
+ Utilities.log("XXXX NfcReadNdefSmartTag remove NDEF Message Listener success");
+ rts.replace(Constants.LISTENER_STATE_TOKEN, new Boolean(false));
+ } catch(NFCException e) {
+ Utilities.log("XXXX "+e.getClass().getName()+":"+e.getMessage());
+ }
+ }
+
+ public boolean is_listening() {
+ Boolean state = (Boolean) rts.get(Constants.LISTENER_STATE_TOKEN);
+ if(state != null) {
+ return state.booleanValue();
+ } else {
+ rts.replace(Constants.LISTENER_STATE_TOKEN, new Boolean(false));
+ return false;
+ }
+ }
+
+}
View
33 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/RaceTimer.java
@@ -0,0 +1,33 @@
+package nfc.sample.racetimebb7;
+/*
+* Copyright (c) 2012 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.
+*/
+import java.util.TimerTask;
+
+public class RaceTimer extends TimerTask {
+
+ private Time time = Time.getInstance();
+
+ public RaceTimer() {
+ time.start();
+ }
+
+ public void run() {
+ TimerScreen screen = TimerScreen.getTimerScreen();
+ time.setNow();
+ screen.updateTime(time);
+ }
+
+}
View
19 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/RaceTimer.java.bak
@@ -0,0 +1,19 @@
+package nfc.sample.racetimebb7;
+
+import java.util.TimerTask;
+
+public class RaceTimer extends TimerTask {
+
+ private Time time = Time.getInstance();
+
+ public RaceTimer() {
+ time.start();
+ }
+
+ public void run() {
+ TimerScreen screen = TimerScreen.getTimerScreen();
+ time.setNow();
+ screen.updateTime(time);
+ }
+
+}
View
117 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Time.java
@@ -0,0 +1,117 @@
+package nfc.sample.racetimebb7;
+/*
+* Copyright (c) 2012 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.
+*/
+import java.util.Calendar;
+import java.util.Date;
+
+public class Time {
+
+ private static Time time;
+
+// private Calendar cal = Calendar.getInstance();
+ private long started_at_ms=0;
+ private long now=0;
+ private long elapsed=0;
+
+ private int hour1;
+ private int hour2;
+ private int minute1;
+ private int minute2;
+ private int second1;
+ private int second2;
+
+ private long MS_HOUR=3600000;
+ private long MS_MINUTE=60000;
+ private long MS_SECOND=1000;
+
+ public static Time getInstance() {
+ if (time == null) {
+ time = new Time();
+ }
+ return time;
+ }
+
+ private Time() {
+ }
+
+ public void start() {
+ started_at_ms = System.currentTimeMillis();
+ Utilities.log("XXXX started_at_ms set to:"+started_at_ms);
+ }
+
+ public void setNow() {
+ now = System.currentTimeMillis();
+ Utilities.log("XXXX started_at_ms:"+started_at_ms);
+ Utilities.log("XXXX now:"+now);
+ elapsed = now - started_at_ms;
+ Utilities.log("XXXX elapsed:"+elapsed);
+// cal.setTime(new Date(elapsed));
+
+// int hours = cal.get(Calendar.HOUR_OF_DAY);
+// int minutes = cal.get(Calendar.MINUTE);
+// int seconds = cal.get(Calendar.SECOND);
+
+ int hours = (int) (elapsed / MS_HOUR);
+ int remainder = (int) (elapsed - (hours * MS_HOUR));
+ int minutes = (int) (remainder / MS_MINUTE);
+ remainder = (int) (remainder - (minutes * MS_MINUTE));
+ int seconds = (int) (remainder / MS_SECOND);
+
+ Utilities.log("XXXX hours="+hours+",minutes="+minutes+",seconds="+seconds);
+
+ hour1 = hours / 10;
+ hour2 = hours % 10;
+ minute1 = minutes / 10;
+ minute2 = minutes % 10;
+ second1 = seconds / 10;
+ second2 = seconds % 10;
+
+ Utilities.log("XXXX hour1="+hour1+",hour2="+hour2+",minute1="+minute1+",minute2="+minute2+",second1="+second1+",second2="+second2);
+ }
+
+ public long getStarted_at_ms() {
+ return started_at_ms;
+ }
+
+ public void setStarted_at_ms(long started_at_ms) {
+ this.started_at_ms = started_at_ms;
+ }
+
+ public int getHour1() {
+ return hour1;
+ }
+
+ public int getHour2() {
+ return hour2;
+ }
+
+ public int getMinute1() {
+ return minute1;
+ }
+
+ public int getMinute2() {
+ return minute2;
+ }
+
+ public int getSecond1() {
+ return second1;
+ }
+
+ public int getSecond2() {
+ return second2;
+ }
+
+}
View
103 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Time.java.bak
@@ -0,0 +1,103 @@
+package nfc.sample.racetimebb7;
+
+import java.util.Calendar;
+import java.util.Date;
+
+public class Time {
+
+ private static Time time;
+
+// private Calendar cal = Calendar.getInstance();
+ private long started_at_ms=0;
+ private long now=0;
+ private long elapsed=0;
+
+ private int hour1;
+ private int hour2;
+ private int minute1;
+ private int minute2;
+ private int second1;
+ private int second2;
+
+ private long MS_HOUR=3600000;
+ private long MS_MINUTE=60000;
+ private long MS_SECOND=1000;
+
+ public static Time getInstance() {
+ if (time == null) {
+ time = new Time();
+ }
+ return time;
+ }
+
+ private Time() {
+ }
+
+ public void start() {
+ started_at_ms = System.currentTimeMillis();
+ Utilities.log("XXXX started_at_ms set to:"+started_at_ms);
+ }
+
+ public void setNow() {
+ now = System.currentTimeMillis();
+ Utilities.log("XXXX started_at_ms:"+started_at_ms);
+ Utilities.log("XXXX now:"+now);
+ elapsed = now - started_at_ms;
+ Utilities.log("XXXX elapsed:"+elapsed);
+// cal.setTime(new Date(elapsed));
+
+// int hours = cal.get(Calendar.HOUR_OF_DAY);
+// int minutes = cal.get(Calendar.MINUTE);
+// int seconds = cal.get(Calendar.SECOND);
+
+ int hours = (int) (elapsed / MS_HOUR);
+ int remainder = (int) (elapsed - (hours * MS_HOUR));
+ int minutes = (int) (remainder / MS_MINUTE);
+ remainder = (int) (remainder - (minutes * MS_MINUTE));
+ int seconds = (int) (remainder / MS_SECOND);
+
+ Utilities.log("XXXX hours="+hours+",minutes="+minutes+",seconds="+seconds);
+
+ hour1 = hours / 10;
+ hour2 = hours % 10;
+ minute1 = minutes / 10;
+ minute2 = minutes % 10;
+ second1 = seconds / 10;
+ second2 = seconds % 10;
+
+ Utilities.log("XXXX hour1="+hour1+",hour2="+hour2+",minute1="+minute1+",minute2="+minute2+",second1="+second1+",second2="+second2);
+ }
+
+ public long getStarted_at_ms() {
+ return started_at_ms;
+ }
+
+ public void setStarted_at_ms(long started_at_ms) {
+ this.started_at_ms = started_at_ms;
+ }
+
+ public int getHour1() {
+ return hour1;
+ }
+
+ public int getHour2() {
+ return hour2;
+ }
+
+ public int getMinute1() {
+ return minute1;
+ }
+
+ public int getMinute2() {
+ return minute2;
+ }
+
+ public int getSecond1() {
+ return second1;
+ }
+
+ public int getSecond2() {
+ return second2;
+ }
+
+}
View
100 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/TimerScreen.java
@@ -0,0 +1,100 @@
+package nfc.sample.racetimebb7;
+/*
+* Copyright (c) 2012 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.
+*/
+import net.rim.device.api.system.Bitmap;
+import net.rim.device.api.system.Display;
+import net.rim.device.api.ui.Color;
+import net.rim.device.api.ui.Field;
+import net.rim.device.api.ui.Screen;
+import net.rim.device.api.ui.UiApplication;
+import net.rim.device.api.ui.component.BitmapField;
+import net.rim.device.api.ui.container.AbsoluteFieldManager;
+import net.rim.device.api.ui.container.MainScreen;
+
+public final class TimerScreen extends MainScreen {
+
+ public static TimerScreen screen;
+
+ Bitmap[] digits = { Bitmap.getBitmapResource("60px-Seven-segment_0.png"), Bitmap.getBitmapResource("60px-Seven-segment_1.png"), Bitmap.getBitmapResource("60px-Seven-segment_2.png"),
+ Bitmap.getBitmapResource("60px-Seven-segment_3.png"), Bitmap.getBitmapResource("60px-Seven-segment_4.png"), Bitmap.getBitmapResource("60px-Seven-segment_5.png"),
+ Bitmap.getBitmapResource("60px-Seven-segment_6.png"), Bitmap.getBitmapResource("60px-Seven-segment_7.png"), Bitmap.getBitmapResource("60px-Seven-segment_8.png"),
+ Bitmap.getBitmapResource("60px-Seven-segment_9.png") };
+
+ Bitmap colon = Bitmap.getBitmapResource("60px-Seven-segment_colon.png");
+
+ BitmapField hour1;
+ BitmapField hour2;
+ BitmapField colon1;
+ BitmapField minute1;
+ BitmapField minute2;
+ BitmapField colon2;
+ BitmapField second1;
+ BitmapField second2;
+
+ public synchronized static TimerScreen getTimerScreen() {
+ if(screen == null) {
+ screen = new TimerScreen();
+ }
+ return screen;
+ }
+
+ private TimerScreen() {
+ super(Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH | Screen.NO_VERTICAL_SCROLL);
+ ColouredBackground bg = new ColouredBackground(Color.WHITE, Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH | Screen.NO_VERTICAL_SCROLL);
+ AbsoluteFieldManager ab_mgr = new AbsoluteFieldManager();
+ hour1 = new BitmapField(digits[0]);
+ hour2 = new BitmapField(digits[0]);
+ minute1 = new BitmapField(digits[0]);
+ minute2 = new BitmapField(digits[0]);
+ second1 = new BitmapField(digits[0]);
+ second2 = new BitmapField(digits[0]);
+ colon1 = new BitmapField(colon);
+ colon2 = new BitmapField(colon);
+ bg.add(ab_mgr);
+
+ int y = (Display.getHeight() - 112) / 2; // images are 112 pixels high
+ int x = (Display.getWidth() - (8 * 60)) / 2; // and 60 pixels wide
+
+ ab_mgr.add(hour1, x, y);
+ x = x + 60;
+ ab_mgr.add(hour2, x, y);
+ x = x + 60;
+ ab_mgr.add(colon1, x, y);
+ x = x + 60;
+ ab_mgr.add(minute1, x, y);
+ x = x + 60;
+ ab_mgr.add(minute2, x, y);
+ x = x + 60;
+ ab_mgr.add(colon2, x, y);
+ x = x + 60;
+ ab_mgr.add(second1, x, y);
+ x = x + 60;
+ ab_mgr.add(second2, x, y);
+ add(bg);
+ }
+
+ public void updateTime(Time time) {
+ synchronized(UiApplication.getEventLock()) {
+ hour1.setBitmap(digits[time.getHour1()]);
+ hour2.setBitmap(digits[time.getHour2()]);
+ minute1.setBitmap(digits[time.getMinute1()]);
+ minute2.setBitmap(digits[time.getMinute2()]);
+ second1.setBitmap(digits[time.getSecond1()]);
+ second2.setBitmap(digits[time.getSecond2()]);
+ invalidate();
+ }
+ }
+}
View
86 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/TimerScreen.java.bak
@@ -0,0 +1,86 @@
+package nfc.sample.racetimebb7;
+
+import net.rim.device.api.system.Bitmap;
+import net.rim.device.api.system.Display;
+import net.rim.device.api.ui.Color;
+import net.rim.device.api.ui.Field;
+import net.rim.device.api.ui.Screen;
+import net.rim.device.api.ui.UiApplication;
+import net.rim.device.api.ui.component.BitmapField;
+import net.rim.device.api.ui.container.AbsoluteFieldManager;
+import net.rim.device.api.ui.container.MainScreen;
+
+public final class TimerScreen extends MainScreen {
+
+ public static TimerScreen screen;
+
+ Bitmap[] digits = { Bitmap.getBitmapResource("60px-Seven-segment_0.png"), Bitmap.getBitmapResource("60px-Seven-segment_1.png"), Bitmap.getBitmapResource("60px-Seven-segment_2.png"),
+ Bitmap.getBitmapResource("60px-Seven-segment_3.png"), Bitmap.getBitmapResource("60px-Seven-segment_4.png"), Bitmap.getBitmapResource("60px-Seven-segment_5.png"),
+ Bitmap.getBitmapResource("60px-Seven-segment_6.png"), Bitmap.getBitmapResource("60px-Seven-segment_7.png"), Bitmap.getBitmapResource("60px-Seven-segment_8.png"),
+ Bitmap.getBitmapResource("60px-Seven-segment_9.png") };
+
+ Bitmap colon = Bitmap.getBitmapResource("60px-Seven-segment_colon.png");
+
+ BitmapField hour1;
+ BitmapField hour2;
+ BitmapField colon1;
+ BitmapField minute1;
+ BitmapField minute2;
+ BitmapField colon2;
+ BitmapField second1;
+ BitmapField second2;
+
+ public synchronized static TimerScreen getTimerScreen() {
+ if(screen == null) {
+ screen = new TimerScreen();
+ }
+ return screen;
+ }
+
+ private TimerScreen() {
+ super(Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH | Screen.NO_VERTICAL_SCROLL);
+ ColouredBackground bg = new ColouredBackground(Color.WHITE, Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH | Screen.NO_VERTICAL_SCROLL);
+ AbsoluteFieldManager ab_mgr = new AbsoluteFieldManager();
+ hour1 = new BitmapField(digits[0]);
+ hour2 = new BitmapField(digits[0]);
+ minute1 = new BitmapField(digits[0]);
+ minute2 = new BitmapField(digits[0]);
+ second1 = new BitmapField(digits[0]);
+ second2 = new BitmapField(digits[0]);
+ colon1 = new BitmapField(colon);
+ colon2 = new BitmapField(colon);
+ bg.add(ab_mgr);
+
+ int y = (Display.getHeight() - 112) / 2; // images are 112 pixels high
+ int x = (Display.getWidth() - (8 * 60)) / 2; // and 60 pixels wide
+
+ ab_mgr.add(hour1, x, y);
+ x = x + 60;
+ ab_mgr.add(hour2, x, y);
+ x = x + 60;
+ ab_mgr.add(colon1, x, y);
+ x = x + 60;
+ ab_mgr.add(minute1, x, y);
+ x = x + 60;
+ ab_mgr.add(minute2, x, y);
+ x = x + 60;
+ ab_mgr.add(colon2, x, y);
+ x = x + 60;
+ ab_mgr.add(second1, x, y);
+ x = x + 60;
+ ab_mgr.add(second2, x, y);
+ add(bg);
+ }
+
+ public void updateTime(Time time) {
+ synchronized(UiApplication.getEventLock()) {
+ hour1.setBitmap(digits[time.getHour1()]);
+ hour2.setBitmap(digits[time.getHour2()]);
+ minute1.setBitmap(digits[time.getMinute1()]);
+ minute2.setBitmap(digits[time.getMinute2()]);
+ second1.setBitmap(digits[time.getSecond1()]);
+ second2.setBitmap(digits[time.getSecond2()]);
+ invalidate();
+ }
+ }
+}
View
31 NFC/NfcRaceTime7/src/nfc/sample/racetimebb7/Utilities.java
@@ -0,0 +1,31 @@
+package nfc.sample.racetimebb7;
+/*
+* Copyright (c) 2012 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.
+*/
+import net.rim.device.api.system.EventLogger;
+
+public class Utilities {
+
+ private static final long MYAPP_ID = 0x54817ed4771a5343L;
+
+ public static void log(String logMessage) {
+ boolean ok = EventLogger.logEvent(MYAPP_ID, logMessage.getBytes(), EventLogger.INFORMATION);
+ }
+
+ public static void initLogging() {
+ EventLogger.register(MYAPP_ID, "NfcRaceTimeBB7", EventLogger.VIEWER_STRING);
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.