Adding Features to the BarcodeScanner Plugin

Web Development

barcode_scanner

Guest blog post by: Tim Windsor

Some of the more intricate Cordova plugins have been projects we’ve worked on through multiple terms with different students through the UCOSP program. This time we worked on adding features to the BarcodeScanner plugin. Sean from the University of Alberta worked on the BarcodeScanner, after confirming that implementing a NavigationHandler plugin was not going to be possible. Here is his account of the term:

Being a part of the UCOSP program and working on BlackBerry 10 plugins for Cordova has been a great experience. The first issue I worked on was the NavigationHandler plugin, for getting low level trackpad events on the BlackBerry Classic.

Initially I researched the Gamepad plugin to see how gamepad events were consumed there, and then used the same approach for my project. In this case no trackpad events were received so Tim suggested I look at the BarcodeScanner plugin, and how it first grabs the current window’s context and passes that to the native layer. Using the BarcodeScanner method and not getting the results I wanted, I tried using an entirely JavaScript method for event handling used by the BlackBerry Passport Input plugin; but, this did not work for trackpad events either. It became clear that none of these approaches would work because the trackpad events were likely already being consumed by the WebView. So I documented the methods I had tried and the issue was closed.

From my perspective of a student, closing the issue without having finished the plugin felt weird, and was definitely not something I was used to from my University courses. However, I learned from this project that even though I never finished the plugin, documenting the work I had done was important. Now other developers will not have to try the same methods I did, if the issue is ever reopened. Furthermore, I gained valuable experience reading and understanding other developer’s code and have a much better understanding of how BlackBerry 10 Cordova plugins work. Consequently, I learned an important lesson about software development, which is not everything you work on will be doable, but what you learn from trying can be just as valuable.

The issue I am currently working on is adding the BarcodeScanner encode method. Since the ZXing C++ port does not yet support encoding, I aim to implement the encode method using a JavaScript library.

Sean was able to complete his work on the encode method and that code has been integrated into the upstream branch on the PhoneGap GitHub. This feature puts the BlackBerry 10 implementation more on par with iOS and Android.

In addition to the plugin, Sean wrote a sample that has been published in our BB10-WebWorks-Community-Samples repo. You can see how to use the encode method of the BarcodeScanner in this sample.

Join the conversation

Show comments Hide comments
+ -
blog comments powered by Disqus