Slight improvement to the crudeness of the BB client -- now tries to auto-exit the...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 6 Mar 2008 22:02:12 +0000 (22:02 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 6 Mar 2008 22:02:12 +0000 (22:02 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@255 59b500cc-1b3d-0410-9834-0bbf25fbcc57

rim/src/com/google/zxing/client/rim/ZXingMainScreen.java

index 9ded1ed..860cd21 100644 (file)
@@ -25,6 +25,7 @@ import com.google.zxing.client.j2me.LCDUIImageMonochromeBitmapSource;
 import net.rim.blackberry.api.invoke.CameraArguments;\r
 import net.rim.blackberry.api.invoke.Invoke;\r
 import net.rim.device.api.system.Characters;\r
+import net.rim.device.api.system.EventInjector;\r
 import net.rim.device.api.ui.UiApplication;\r
 import net.rim.device.api.ui.component.Dialog;\r
 import net.rim.device.api.ui.component.LabelField;\r
@@ -45,8 +46,12 @@ final class ZXingMainScreen extends MainScreen {
   private final ImageCapturedJournalListener captureListener;\r
 \r
   ZXingMainScreen() {\r
-    setTitle("Barcode Reader");\r
-    add(new LabelField("ZXing"));\r
+    setTitle("ZXing Barcode Reader");\r
+    add(new LabelField("UNDER CONSTRUCTION"));\r
+    add(new LabelField("1. Press 'Enter' at right to launch the Camera application"));\r
+    add(new LabelField("2. Configure Camera to capture 640x480 image"));\r
+    add(new LabelField("3. Take a picture of a barcode"));\r
+    add(new LabelField("4. If not returned to this application to see result, close Camera application"));\r
     app = (ZXingUIApp) UiApplication.getUiApplication();\r
     captureListener = new ImageCapturedJournalListener(this);\r
     app.addFileSystemJournalListener(captureListener);\r
@@ -74,6 +79,10 @@ final class ZXingMainScreen extends MainScreen {
 \r
   void handleFile(String path) {\r
     if (path.endsWith(".jpg") && path.indexOf("IMG") >= 0) {\r
+      // Get out of camera app\r
+      EventInjector.invokeEvent(new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 0, 1));\r
+      EventInjector.invokeEvent(new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_UP, Characters.ESCAPE, 0, 1));\r
+      // Try to come to foreground for good measure\r
       app.requestForeground();\r
       try {\r
         FileConnection file = null;\r
@@ -87,14 +96,14 @@ final class ZXingMainScreen extends MainScreen {
           if (is != null) {\r
             try {\r
               is.close();\r
-            } catch (IOException ioe ) {\r
+            } catch (IOException ioe) {\r
               // continue\r
             }\r
           }\r
           if (file != null) {\r
             try {\r
               file.close();\r
-            } catch (IOException ioe ) {\r
+            } catch (IOException ioe) {\r
               // continue\r
             }\r
           }\r
@@ -102,6 +111,7 @@ final class ZXingMainScreen extends MainScreen {
         MonochromeBitmapSource source = new LCDUIImageMonochromeBitmapSource(capturedImage);\r
         Reader reader = new MultiFormatReader();\r
         Result result = reader.decode(source);\r
+        // If decode was successful...\r
         try {\r
           file.delete();\r
         } catch (IOException ioe) {\r