mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
- Added Joseph's excellent supermarket checkout beep. There seems to be a bug in the M3 framework where it sometimes plays twice or hiccups.
- Changed the status bar to flash green for a second when the result points are drawn. - Added install as a target to the build file. - Fixed a crashing bug when decoding from preview mode (driver problem). git-svn-id: https://zxing.googlecode.com/svn/trunk@378 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
38867c7ddc
commit
2db1ea526f
|
@ -49,6 +49,7 @@
|
||||||
|
|
||||||
<!-- Tools -->
|
<!-- Tools -->
|
||||||
<property name="aapt" value="${android-tools}/aapt"/>
|
<property name="aapt" value="${android-tools}/aapt"/>
|
||||||
|
<property name="adb" value="${android-tools}/adb"/>
|
||||||
<property name="aidl" value="${android-tools}/aidl"/>
|
<property name="aidl" value="${android-tools}/aidl"/>
|
||||||
<!-- dx is a special case as it is a .bat file on Windows -->
|
<!-- dx is a special case as it is a .bat file on Windows -->
|
||||||
<condition property="dx" value="${android-tools}/dx.bat" else="${android-tools}/dx">
|
<condition property="dx" value="${android-tools}/dx.bat" else="${android-tools}/dx">
|
||||||
|
@ -257,6 +258,15 @@ only when the assets dir exists. -->
|
||||||
<!-- Create the package file for this project from the sources. -->
|
<!-- Create the package file for this project from the sources. -->
|
||||||
<target name="package" depends="package-dex"/>
|
<target name="package" depends="package-dex"/>
|
||||||
|
|
||||||
|
<!-- Install package on the default emulator -->
|
||||||
|
<target name="install">
|
||||||
|
<echo>Sending package to default emulator...</echo>
|
||||||
|
<exec executable="${adb}" failonerror="true">
|
||||||
|
<arg value="install" />
|
||||||
|
<arg value="${out-package}" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="clean">
|
<target name="clean">
|
||||||
<delete dir="${outdir}"/>
|
<delete dir="${outdir}"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="48px"
|
android:layout_height="48px"
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:background="#55000000"
|
android:background="#50000000"
|
||||||
android:baselineAligned="false"
|
android:baselineAligned="false"
|
||||||
android:padding="4px">
|
android:padding="4px">
|
||||||
|
|
||||||
|
|
BIN
android-m3/res/raw/beep.wav
Normal file
BIN
android-m3/res/raw/beep.wav
Normal file
Binary file not shown.
|
@ -20,6 +20,7 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
@ -173,6 +174,7 @@ public final class BarcodeReaderCaptureActivity extends Activity {
|
||||||
};
|
};
|
||||||
|
|
||||||
public void restartPreview() {
|
public void restartPreview() {
|
||||||
|
resetStatusViewColor();
|
||||||
Message restart = Message.obtain(cameraThread.handler, R.id.restart_preview);
|
Message restart = Message.obtain(cameraThread.handler, R.id.restart_preview);
|
||||||
restart.sendToTarget();
|
restart.sendToTarget();
|
||||||
}
|
}
|
||||||
|
@ -180,6 +182,7 @@ public final class BarcodeReaderCaptureActivity extends Activity {
|
||||||
private void handleDecode(Result rawResult, int duration) {
|
private void handleDecode(Result rawResult, int duration) {
|
||||||
if (!rawResult.toString().equals(lastResult)) {
|
if (!rawResult.toString().equals(lastResult)) {
|
||||||
lastResult = rawResult.toString();
|
lastResult = rawResult.toString();
|
||||||
|
playBeepSound();
|
||||||
|
|
||||||
ResultPoint[] points = rawResult.getResultPoints();
|
ResultPoint[] points = rawResult.getResultPoints();
|
||||||
if (points != null && points.length > 0) {
|
if (points != null && points.length > 0) {
|
||||||
|
@ -202,6 +205,9 @@ public final class BarcodeReaderCaptureActivity extends Activity {
|
||||||
actionButton.setVisibility(View.GONE);
|
actionButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
View statusView = findViewById(R.id.status_view);
|
||||||
|
statusView.setBackgroundColor(0xc000ff00);
|
||||||
|
|
||||||
// Show the green finder patterns for one second, then restart the preview
|
// Show the green finder patterns for one second, then restart the preview
|
||||||
Message message = Message.obtain(messageHandler, R.id.restart_preview);
|
Message message = Message.obtain(messageHandler, R.id.restart_preview);
|
||||||
messageHandler.sendMessageDelayed(message, 1000);
|
messageHandler.sendMessageDelayed(message, 1000);
|
||||||
|
@ -210,7 +216,14 @@ public final class BarcodeReaderCaptureActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void playBeepSound() {
|
||||||
|
MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.beep);
|
||||||
|
mediaPlayer.prepare();
|
||||||
|
mediaPlayer.start();
|
||||||
|
}
|
||||||
|
|
||||||
private void resetStatusView() {
|
private void resetStatusView() {
|
||||||
|
resetStatusViewColor();
|
||||||
TextView textView = (TextView) findViewById(R.id.status_text_view);
|
TextView textView = (TextView) findViewById(R.id.status_text_view);
|
||||||
textView.setText(R.string.msg_default_status);
|
textView.setText(R.string.msg_default_status);
|
||||||
Button actionButton = (Button) findViewById(R.id.status_action_button);
|
Button actionButton = (Button) findViewById(R.id.status_action_button);
|
||||||
|
@ -218,6 +231,11 @@ public final class BarcodeReaderCaptureActivity extends Activity {
|
||||||
lastResult = "";
|
lastResult = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resetStatusViewColor() {
|
||||||
|
View statusView = findViewById(R.id.status_view);
|
||||||
|
statusView.setBackgroundColor(0x50000000);
|
||||||
|
}
|
||||||
|
|
||||||
private static ParsedReaderResult parseReaderResult(Result rawResult) {
|
private static ParsedReaderResult parseReaderResult(Result rawResult) {
|
||||||
ParsedReaderResult readerResult = ParsedReaderResult.parseReaderResult(rawResult);
|
ParsedReaderResult readerResult = ParsedReaderResult.parseReaderResult(rawResult);
|
||||||
if (readerResult.getType().equals(ParsedReaderResultType.TEXT)) {
|
if (readerResult.getType().equals(ParsedReaderResultType.TEXT)) {
|
||||||
|
|
|
@ -247,7 +247,7 @@ final class CameraManager {
|
||||||
*/
|
*/
|
||||||
private void calculatePreviewResolution() {
|
private void calculatePreviewResolution() {
|
||||||
if (previewResolution == null) {
|
if (previewResolution == null) {
|
||||||
int previewHeight = (int) (stillResolution.x * stillMultiplier * 1.8f);
|
int previewHeight = (int) (stillResolution.x * stillMultiplier * 1.5f);
|
||||||
int previewWidth = previewHeight * screenResolution.x / screenResolution.y;
|
int previewWidth = previewHeight * screenResolution.x / screenResolution.y;
|
||||||
previewWidth = ((previewWidth + 7) >> 3) << 3;
|
previewWidth = ((previewWidth + 7) >> 3) << 3;
|
||||||
if (previewWidth > cameraResolution.x) previewWidth = cameraResolution.x;
|
if (previewWidth > cameraResolution.x) previewWidth = cameraResolution.x;
|
||||||
|
|
Loading…
Reference in a new issue