Commit Simon's changes for Issue 134
[zxing.git] / javame / src / com / google / zxing / client / j2me / VideoCanvas.java
index d156b20..a24d802 100644 (file)
@@ -1,66 +1,71 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * 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.
- */
-
-package com.google.zxing.client.j2me;
-
-import javax.microedition.lcdui.Canvas;
-import javax.microedition.lcdui.Command;
-import javax.microedition.lcdui.CommandListener;
-import javax.microedition.lcdui.Displayable;
-import javax.microedition.lcdui.Graphics;
-
-/**
- * The main {@link Canvas} onto which the camera's field of view is painted.
- * This class manages decoding via {@link SnapshotThread}.
- *
- * @author Sean Owen
- */
-final class VideoCanvas extends Canvas implements CommandListener {
-
-  private static final Command exit = new Command("Exit", Command.EXIT, 1);
-
-  private final ZXingMIDlet zXingMIDlet;
-  private final SnapshotThread snapshotThread;
-
-  VideoCanvas(ZXingMIDlet zXingMIDlet) {
-    this.zXingMIDlet = zXingMIDlet;
-    addCommand(exit);
-    setCommandListener(this);
-    snapshotThread = new SnapshotThread(zXingMIDlet);
-    new Thread(snapshotThread).start();
-  }
-
-  protected void paint(Graphics graphics) {
-    // do nothing
-  }
-
-  protected void keyPressed(int keyCode) {
-    // Any valid game key will trigger a capture
-    if (getGameAction(keyCode) != 0) {
-      snapshotThread.continueRun();
-    } else {
-      super.keyPressed(keyCode);
-    }
-  }
-
-  public void commandAction(Command command, Displayable displayable) {
-    int type = command.getCommandType();
-    if (type == Command.EXIT || type == Command.STOP || type == Command.BACK || type == Command.CANCEL) {
-      snapshotThread.stop();
-      zXingMIDlet.stop();
-    }
-  }
-}
+/*\r
+ * Copyright 2007 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.j2me;\r
+\r
+import javax.microedition.lcdui.Canvas;\r
+import javax.microedition.lcdui.Command;\r
+import javax.microedition.lcdui.CommandListener;\r
+import javax.microedition.lcdui.Displayable;\r
+import javax.microedition.lcdui.Graphics;\r
+\r
+/**\r
+ * The main {@link Canvas} onto which the camera's field of view is painted.\r
+ * This class manages decoding via {@link SnapshotThread}.\r
+ *\r
+ * @author Sean Owen\r
+ * @author Simon Flannery\r
+ */\r
+final class VideoCanvas extends Canvas implements CommandListener {\r
+\r
+  private static final Command exit = new Command("Exit", Command.EXIT, 1);\r
+  private static final Command history = new Command("History", Command.ITEM, 0);\r
+\r
+  private final ZXingMIDlet zXingMIDlet;\r
+  private final SnapshotThread snapshotThread;\r
+\r
+  VideoCanvas(ZXingMIDlet zXingMIDlet) {\r
+    this.zXingMIDlet = zXingMIDlet;\r
+    addCommand(exit);\r
+    addCommand(history);\r
+    setCommandListener(this);\r
+    snapshotThread = new SnapshotThread(zXingMIDlet);\r
+    new Thread(snapshotThread).start();\r
+  }\r
+\r
+  protected void paint(Graphics graphics) {\r
+    // do nothing\r
+  }\r
+\r
+  protected void keyPressed(int keyCode) {\r
+    // Any valid game key will trigger a capture\r
+    if (getGameAction(keyCode) != 0) {\r
+      snapshotThread.continueRun();\r
+    } else {\r
+      super.keyPressed(keyCode);\r
+    }\r
+  }\r
+\r
+  public void commandAction(Command command, Displayable displayable) {\r
+    int type = command.getCommandType();\r
+    if (command == history) {\r
+      zXingMIDlet.historyRequest();\r
+    } else if (type == Command.EXIT || type == Command.STOP || type == Command.BACK || type == Command.CANCEL) {\r
+      snapshotThread.stop();\r
+      zXingMIDlet.stop();\r
+    }\r
+  }\r
+}\r