mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
Progress on a crude Blackberry client -- still needs much polish but basic functionality exists.
git-svn-id: https://zxing.googlecode.com/svn/trunk@203 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
9ac09235d4
commit
9c6a626b90
|
@ -25,6 +25,7 @@
|
|||
<ant dir="javame" target="build"/>
|
||||
<ant dir="javase" target="build"/>
|
||||
<ant dir="android" target="package"/>
|
||||
<ant dir="rim" target="build"/>
|
||||
</target>
|
||||
|
||||
<target name="buildwithoutj2me">
|
||||
|
@ -37,6 +38,7 @@
|
|||
<ant dir="javame" target="clean"/>
|
||||
<ant dir="javase" target="clean"/>
|
||||
<ant dir="android" target="clean"/>
|
||||
<ant dir="rim" target="clean"/>
|
||||
</target>
|
||||
|
||||
<target name="test">
|
||||
|
@ -55,8 +57,10 @@
|
|||
<include name="core/**"/>
|
||||
<include name="javame/**"/>
|
||||
<include name="javase/**"/>
|
||||
<!-- Only include the build script for now -->
|
||||
<include name="rim/build.xml"/>
|
||||
<include name="rim/src/**"/>
|
||||
<include name="rim/res/**"/>
|
||||
<include name="rim/BarcodeReader.rapc"/>
|
||||
<include name="docs/**"/>
|
||||
</zipfileset>
|
||||
</zip>
|
||||
|
@ -71,6 +75,7 @@
|
|||
<pathelement location="core/src"/>
|
||||
<pathelement location="javame/src"/>
|
||||
<pathelement location="javase/src"/>
|
||||
<pathelement location="rim/src"/>
|
||||
</sourcepath>
|
||||
<classpath>
|
||||
<pathelement location="${WTK-home}/lib/cldcapi11.jar"/>
|
||||
|
@ -78,6 +83,7 @@
|
|||
<pathelement location="${WTK-home}/lib/mmapi.jar"/>
|
||||
<pathelement location="${WTK-home}/lib/jsr234.jar"/>
|
||||
<pathelement location="${android-home}/android.jar"/>
|
||||
<pathelement location="${BB-JDK-home}/lib/net_rim_api.jar"/>
|
||||
</classpath>
|
||||
</javadoc>
|
||||
</target>
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
fork="true">
|
||||
<classpath refid="wtk-build-path"/>
|
||||
</javac>
|
||||
<jar jarfile="javame.jar" basedir="build" level="9"/>
|
||||
</target>
|
||||
|
||||
<target name="compile-basic" depends="init">
|
||||
|
@ -107,13 +108,14 @@
|
|||
<classpath refid="wtk-build-path"/>
|
||||
<exclude name="com/google/zxing/client/j2me/AdvancedMultimediaManager.java"/>
|
||||
</javac>
|
||||
<jar jarfile="javame-basic.jar" basedir="build" level="9"/>
|
||||
</target>
|
||||
|
||||
<target name="package">
|
||||
<unzip src="../core/core.jar" dest="build"/>
|
||||
|
||||
<mkdir dir="build-j2me"/>
|
||||
<exec executable="${WTK-home}/bin/preverify1.1">
|
||||
<exec executable="${WTK-home}/bin/preverify1.1" failonerror="true">
|
||||
<arg line="-classpath ${preverify-classpath} -d build-j2me build"/>
|
||||
</exec>
|
||||
|
||||
|
|
16
rim/BarcodeReader.rapc
Normal file
16
rim/BarcodeReader.rapc
Normal file
|
@ -0,0 +1,16 @@
|
|||
Manifest-Version: 1.0
|
||||
RIM-COD-Module-Name: BarcodeReader
|
||||
RIM-COD-Module-Dependencies: net_rim_cldc,net_rim_bbapi_invoke
|
||||
MIDlet-Jar-Size: 31621
|
||||
MIDlet-1: BarcodeReader,,com.google.zxing.client.rim.ZXingUIApp
|
||||
RIM-COD-Creation-Time: 1203088206
|
||||
MIDlet-Jar-URL: BarcodeReader.jar
|
||||
RIM-COD-URL: BarcodeReader.cod
|
||||
RIM-COD-SHA1: 82 7e 06 9b 39 6e 8c 49 33 54 37 1d 6d 3d 7b 07 d1 86 c8 d3
|
||||
RIM-COD-Size: 56372
|
||||
MicroEdition-Configuration: CLDC-1.1
|
||||
MIDlet-Version: 0.5
|
||||
MIDlet-Name: BarcodeReader
|
||||
MIDlet-Vendor: ZXing Project
|
||||
MicroEdition-Profile: MIDP-2.0
|
||||
RIM-MIDlet-Flags-1: 0
|
|
@ -19,6 +19,7 @@
|
|||
<project name="rim" default="build">
|
||||
|
||||
<property file="../build.properties"/>
|
||||
<property name="rim-api-jar" value="${BB-JDK-home}/lib/net_rim_api.jar"/>
|
||||
|
||||
<target name="init">
|
||||
<tstamp/>
|
||||
|
@ -29,29 +30,75 @@
|
|||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<fail message="Please build target 'build-basic' in 'javame' first">
|
||||
<fail message="Please set 'WTK-home' in build.properties">
|
||||
<condition>
|
||||
<not>
|
||||
<available file="../javame/BarcodeReaderBasic.jar" type="file"/>
|
||||
<available file="${WTK-home}" type="dir"/>
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<fail message="Please build 'core' first">
|
||||
<condition>
|
||||
<not>
|
||||
<available file="../core/core.jar" type="file"/>
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<fail message="Please build 'build-basic' in 'javame' first">
|
||||
<condition>
|
||||
<not>
|
||||
<available file="../javame/javame-basic.jar" type="file"/>
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="init,clean">
|
||||
<copy file="../javame/BarcodeReaderBasic.jad" todir="."/>
|
||||
<target name="build" depends="init">
|
||||
|
||||
<mkdir dir="build"/>
|
||||
<javac srcdir="src"
|
||||
destdir="build"
|
||||
source="1.2"
|
||||
target="1.2"
|
||||
bootclasspath="${rim-api-jar}"
|
||||
optimize="true"
|
||||
debug="true"
|
||||
deprecation="true"
|
||||
fork="true">
|
||||
<classpath>
|
||||
<pathelement location="../core/core.jar"/>
|
||||
<pathelement location="../javame/javame-basic.jar"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
|
||||
<unzip src="../core/core.jar" dest="build"/>
|
||||
<unzip src="../javame/javame-basic.jar" dest="build"/>
|
||||
|
||||
<mkdir dir="build-j2me"/>
|
||||
<exec executable="${WTK-home}/bin/preverify1.1" failonerror="true">
|
||||
<arg line="-classpath ${rim-api-jar} -d build-j2me build"/>
|
||||
</exec>
|
||||
|
||||
<jar jarfile="temp.jar" basedir="build-j2me"/>
|
||||
<java jar="${BB-JDK-home}/bin/rapc.jar" fork="true">
|
||||
<arg value="import=${BB-JDK-home}/lib/net_rim_api.jar"/>
|
||||
<arg value="codename=BarcodeReaderBasic"/>
|
||||
<arg value="-midlet"/>
|
||||
<arg value="jad=BarcodeReaderBasic.jad"/>
|
||||
<arg value="../javame/BarcodeReaderBasic.jar"/>
|
||||
<arg value="-quiet"/>
|
||||
<arg value="import=${rim-api-jar}"/>
|
||||
<arg value="jad=BarcodeReader.rapc"/>
|
||||
<arg value="codename=BarcodeReader"/>
|
||||
<arg value="temp.jar"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="." includes="BarcodeReader*"/>
|
||||
<delete dir="build"/>
|
||||
<delete dir="build-j2me"/>
|
||||
<delete file="temp.jar"/>
|
||||
<delete file="BarcodeReader.cod"/>
|
||||
<delete file="BarcodeReader.csl"/>
|
||||
<delete file="BarcodeReader.cso"/>
|
||||
<delete file="BarcodeReader.debug"/>
|
||||
<delete file="BarcodeReader.jar"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
BIN
rim/res/zxing-icon.png
Normal file
BIN
rim/res/zxing-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2008 Google Inc.
|
||||
*
|
||||
* 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.rim;
|
||||
|
||||
import net.rim.device.api.io.file.FileSystemJournal;
|
||||
import net.rim.device.api.io.file.FileSystemJournalEntry;
|
||||
import net.rim.device.api.io.file.FileSystemJournalListener;
|
||||
|
||||
/**
|
||||
* @author Sean Owen (srowen@google.com)
|
||||
*/
|
||||
final class ImageCapturedJournalListener implements FileSystemJournalListener {
|
||||
|
||||
private final ZXingMainScreen screen;
|
||||
private long lastUSN;
|
||||
|
||||
ImageCapturedJournalListener(ZXingMainScreen screen) {
|
||||
this.screen = screen;
|
||||
}
|
||||
|
||||
public void fileJournalChanged() {
|
||||
long nextUSN = FileSystemJournal.getNextUSN();
|
||||
for (long lookUSN = nextUSN - 1; lookUSN >= lastUSN; --lookUSN) {
|
||||
FileSystemJournalEntry entry = FileSystemJournal.getEntry(lookUSN);
|
||||
if (entry == null) {
|
||||
break;
|
||||
}
|
||||
if (entry.getEvent() == FileSystemJournalEntry.FILE_ADDED) {
|
||||
screen.handleFile(entry.getPath());
|
||||
}
|
||||
}
|
||||
lastUSN = nextUSN;
|
||||
}
|
||||
|
||||
|
||||
}
|
119
rim/src/com/google/zxing/client/rim/ZXingMainScreen.java
Normal file
119
rim/src/com/google/zxing/client/rim/ZXingMainScreen.java
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright 2008 Google Inc.
|
||||
*
|
||||
* 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.rim;
|
||||
|
||||
import com.google.zxing.MonochromeBitmapSource;
|
||||
import com.google.zxing.MultiFormatReader;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.client.j2me.LCDUIImageMonochromeBitmapSource;
|
||||
import net.rim.blackberry.api.invoke.CameraArguments;
|
||||
import net.rim.blackberry.api.invoke.Invoke;
|
||||
import net.rim.device.api.system.Characters;
|
||||
import net.rim.device.api.ui.UiApplication;
|
||||
import net.rim.device.api.ui.component.Dialog;
|
||||
import net.rim.device.api.ui.component.LabelField;
|
||||
import net.rim.device.api.ui.container.MainScreen;
|
||||
|
||||
import javax.microedition.io.Connector;
|
||||
import javax.microedition.io.file.FileConnection;
|
||||
import javax.microedition.lcdui.Image;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author Sean Owen (srowen@google.com)
|
||||
*/
|
||||
final class ZXingMainScreen extends MainScreen {
|
||||
|
||||
private final ZXingUIApp app;
|
||||
private final ImageCapturedJournalListener captureListener;
|
||||
|
||||
ZXingMainScreen() {
|
||||
setTitle("Barcode Reader");
|
||||
add(new LabelField("ZXing"));
|
||||
app = (ZXingUIApp) UiApplication.getUiApplication();
|
||||
captureListener = new ImageCapturedJournalListener(this);
|
||||
app.addFileSystemJournalListener(captureListener);
|
||||
}
|
||||
|
||||
public boolean keyChar(char c, int status, int time) {
|
||||
if (c == Characters.ENTER) {
|
||||
Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());
|
||||
return true;
|
||||
} else {
|
||||
return super.keyChar(c, status, time);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
app.removeFileSystemJournalListener(captureListener);
|
||||
super.close();
|
||||
}
|
||||
|
||||
private void showMessage(String msg) {
|
||||
synchronized (app.getAppEventLock()) {
|
||||
Dialog.alert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void handleFile(String path) {
|
||||
if (path.endsWith(".jpg") && path.indexOf("IMG") >= 0) {
|
||||
app.requestForeground();
|
||||
try {
|
||||
FileConnection file = null;
|
||||
InputStream is = null;
|
||||
Image capturedImage;
|
||||
try {
|
||||
file = (FileConnection) Connector.open("file://" + path);
|
||||
is = file.openInputStream();
|
||||
capturedImage = Image.createImage(is);
|
||||
} finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException ioe ) {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
if (file != null) {
|
||||
try {
|
||||
file.close();
|
||||
} catch (IOException ioe ) {
|
||||
// continue
|
||||
}
|
||||
}
|
||||
}
|
||||
MonochromeBitmapSource source = new LCDUIImageMonochromeBitmapSource(capturedImage);
|
||||
Reader reader = new MultiFormatReader();
|
||||
Result result = reader.decode(source);
|
||||
try {
|
||||
file.delete();
|
||||
} catch (IOException ioe) {
|
||||
// continue
|
||||
}
|
||||
showMessage(result.getText());
|
||||
} catch (IOException ioe) {
|
||||
showMessage(ioe.getMessage());
|
||||
} catch (ReaderException re) {
|
||||
showMessage("Sorry, no barcode was found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
34
rim/src/com/google/zxing/client/rim/ZXingUIApp.java
Normal file
34
rim/src/com/google/zxing/client/rim/ZXingUIApp.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2008 Google Inc.
|
||||
*
|
||||
* 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.rim;
|
||||
|
||||
import net.rim.device.api.ui.UiApplication;
|
||||
|
||||
/**
|
||||
* @author Sean Owen (srowen@google.com)
|
||||
*/
|
||||
public final class ZXingUIApp extends UiApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new ZXingUIApp().enterEventDispatcher();
|
||||
}
|
||||
|
||||
ZXingUIApp() {
|
||||
pushScreen(new ZXingMainScreen());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue