Initial checkin of RIM client from LifeMarks, after initial refactorings and style...
[zxing.git] / rim / src / com / google / zxing / client / rim / ZXingMainScreen.java
diff --git a/rim/src/com/google/zxing/client/rim/ZXingMainScreen.java b/rim/src/com/google/zxing/client/rim/ZXingMainScreen.java
deleted file mode 100644 (file)
index 0d5a567..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*\r
- * Copyright 2008 ZXing authors\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package com.google.zxing.client.rim;\r
-\r
-import com.google.zxing.MonochromeBitmapSource;\r
-import com.google.zxing.MultiFormatReader;\r
-import com.google.zxing.Reader;\r
-import com.google.zxing.ReaderException;\r
-import com.google.zxing.Result;\r
-import com.google.zxing.client.j2me.LCDUIImageMonochromeBitmapSource;\r
-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
-import net.rim.device.api.ui.container.MainScreen;\r
-\r
-import javax.microedition.io.Connector;\r
-import javax.microedition.io.file.FileConnection;\r
-import javax.microedition.lcdui.Image;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-\r
-/**\r
- * @author Sean Owen (srowen@google.com)\r
- */\r
-final class ZXingMainScreen extends MainScreen {\r
-\r
-  private final ZXingUIApp app;\r
-  private final ImageCapturedJournalListener captureListener;\r
-\r
-  ZXingMainScreen() {\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
-  }\r
-\r
-  public boolean keyChar(char c, int status, int time) {\r
-    if (c == Characters.ENTER) {\r
-      Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());\r
-      return true;\r
-    } else {\r
-      return super.keyChar(c, status, time);\r
-    }\r
-  }\r
-\r
-  public void close() {\r
-    app.removeFileSystemJournalListener(captureListener);\r
-    super.close();\r
-  }\r
-\r
-  private void showMessage(String msg) {\r
-    synchronized (app.getAppEventLock()) {\r
-      Dialog.alert(msg);\r
-    }\r
-  }\r
-\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
-        InputStream is = null;\r
-        Image capturedImage;\r
-        try {\r
-          file = (FileConnection) Connector.open("file://" + path);\r
-          is = file.openInputStream();\r
-          capturedImage = Image.createImage(is);\r
-        } finally {\r
-          if (is != null) {\r
-            try {\r
-              is.close();\r
-            } catch (IOException ioe) {\r
-              // continue\r
-            }\r
-          }\r
-          if (file != null) {\r
-            try {\r
-              file.close();\r
-            } catch (IOException ioe) {\r
-              // continue\r
-            }\r
-          }\r
-        }\r
-        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
-          // continue\r
-        }\r
-        showMessage(result.getText());\r
-      } catch (IOException ioe) {\r
-        showMessage(ioe.getMessage());\r
-      } catch (ReaderException re) {\r
-        showMessage("Sorry, no barcode was found.");\r
-      }\r
-    }\r
-  }\r
-\r
-}\r