mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Slight improvement to the crudeness of the BB client -- now tries to auto-exit the Camera app
git-svn-id: https://zxing.googlecode.com/svn/trunk@255 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
e1cd031da8
commit
4abc8aecec
|
@ -25,6 +25,7 @@ import com.google.zxing.client.j2me.LCDUIImageMonochromeBitmapSource;
|
||||||
import net.rim.blackberry.api.invoke.CameraArguments;
|
import net.rim.blackberry.api.invoke.CameraArguments;
|
||||||
import net.rim.blackberry.api.invoke.Invoke;
|
import net.rim.blackberry.api.invoke.Invoke;
|
||||||
import net.rim.device.api.system.Characters;
|
import net.rim.device.api.system.Characters;
|
||||||
|
import net.rim.device.api.system.EventInjector;
|
||||||
import net.rim.device.api.ui.UiApplication;
|
import net.rim.device.api.ui.UiApplication;
|
||||||
import net.rim.device.api.ui.component.Dialog;
|
import net.rim.device.api.ui.component.Dialog;
|
||||||
import net.rim.device.api.ui.component.LabelField;
|
import net.rim.device.api.ui.component.LabelField;
|
||||||
|
@ -45,8 +46,12 @@ final class ZXingMainScreen extends MainScreen {
|
||||||
private final ImageCapturedJournalListener captureListener;
|
private final ImageCapturedJournalListener captureListener;
|
||||||
|
|
||||||
ZXingMainScreen() {
|
ZXingMainScreen() {
|
||||||
setTitle("Barcode Reader");
|
setTitle("ZXing Barcode Reader");
|
||||||
add(new LabelField("ZXing"));
|
add(new LabelField("UNDER CONSTRUCTION"));
|
||||||
|
add(new LabelField("1. Press 'Enter' at right to launch the Camera application"));
|
||||||
|
add(new LabelField("2. Configure Camera to capture 640x480 image"));
|
||||||
|
add(new LabelField("3. Take a picture of a barcode"));
|
||||||
|
add(new LabelField("4. If not returned to this application to see result, close Camera application"));
|
||||||
app = (ZXingUIApp) UiApplication.getUiApplication();
|
app = (ZXingUIApp) UiApplication.getUiApplication();
|
||||||
captureListener = new ImageCapturedJournalListener(this);
|
captureListener = new ImageCapturedJournalListener(this);
|
||||||
app.addFileSystemJournalListener(captureListener);
|
app.addFileSystemJournalListener(captureListener);
|
||||||
|
@ -74,6 +79,10 @@ final class ZXingMainScreen extends MainScreen {
|
||||||
|
|
||||||
void handleFile(String path) {
|
void handleFile(String path) {
|
||||||
if (path.endsWith(".jpg") && path.indexOf("IMG") >= 0) {
|
if (path.endsWith(".jpg") && path.indexOf("IMG") >= 0) {
|
||||||
|
// Get out of camera app
|
||||||
|
EventInjector.invokeEvent(new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 0, 1));
|
||||||
|
EventInjector.invokeEvent(new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_UP, Characters.ESCAPE, 0, 1));
|
||||||
|
// Try to come to foreground for good measure
|
||||||
app.requestForeground();
|
app.requestForeground();
|
||||||
try {
|
try {
|
||||||
FileConnection file = null;
|
FileConnection file = null;
|
||||||
|
@ -102,6 +111,7 @@ final class ZXingMainScreen extends MainScreen {
|
||||||
MonochromeBitmapSource source = new LCDUIImageMonochromeBitmapSource(capturedImage);
|
MonochromeBitmapSource source = new LCDUIImageMonochromeBitmapSource(capturedImage);
|
||||||
Reader reader = new MultiFormatReader();
|
Reader reader = new MultiFormatReader();
|
||||||
Result result = reader.decode(source);
|
Result result = reader.decode(source);
|
||||||
|
// If decode was successful...
|
||||||
try {
|
try {
|
||||||
file.delete();
|
file.delete();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
|
Loading…
Reference in a new issue