- Added Joseph's excellent supermarket checkout beep. There seems to be a bug in...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 29 Apr 2008 01:27:27 +0000 (01:27 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 29 Apr 2008 01:27:27 +0000 (01:27 +0000)
- 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: http://zxing.googlecode.com/svn/trunk@378 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android-m3/build.xml
android-m3/res/layout/main.xml
android-m3/res/raw/beep.wav [new file with mode: 0644]
android-m3/src/com/google/zxing/client/android/BarcodeReaderCaptureActivity.java
android-m3/src/com/google/zxing/client/android/CameraManager.java

index b439800..0ad6739 100644 (file)
@@ -49,6 +49,7 @@
 
   <!-- Tools -->
   <property name="aapt" value="${android-tools}/aapt"/>
+  <property name="adb" value="${android-tools}/adb"/>
   <property name="aidl" value="${android-tools}/aidl"/>
   <!-- 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">
@@ -257,6 +258,15 @@ only when the assets dir exists. -->
   <!-- Create the package file for this project from the sources. -->
   <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">
     <delete dir="${outdir}"/>
   </target>
index a711e08..bd1a60a 100644 (file)
@@ -40,7 +40,7 @@
                   android:layout_width="fill_parent"
                   android:layout_height="48px"
                   android:layout_weight="0"
-                  android:background="#55000000"
+                  android:background="#50000000"
                   android:baselineAligned="false"
                   android:padding="4px">
 
diff --git a/android-m3/res/raw/beep.wav b/android-m3/res/raw/beep.wav
new file mode 100644 (file)
index 0000000..1a11aad
Binary files /dev/null and b/android-m3/res/raw/beep.wav differ
index eca4b1e..fb5c872 100644 (file)
@@ -20,6 +20,7 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.PixelFormat;
+import android.media.MediaPlayer;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
@@ -173,6 +174,7 @@ public final class BarcodeReaderCaptureActivity extends Activity {
   };
 
   public void restartPreview() {
+    resetStatusViewColor();
     Message restart = Message.obtain(cameraThread.handler, R.id.restart_preview);
     restart.sendToTarget();
   }
@@ -180,6 +182,7 @@ public final class BarcodeReaderCaptureActivity extends Activity {
   private void handleDecode(Result rawResult, int duration) {
     if (!rawResult.toString().equals(lastResult)) {
       lastResult = rawResult.toString();
+      playBeepSound();
 
       ResultPoint[] points = rawResult.getResultPoints();
       if (points != null && points.length > 0) {
@@ -202,6 +205,9 @@ public final class BarcodeReaderCaptureActivity extends Activity {
         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
       Message message = Message.obtain(messageHandler, R.id.restart_preview);
       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() {
+    resetStatusViewColor();
     TextView textView = (TextView) findViewById(R.id.status_text_view);
     textView.setText(R.string.msg_default_status);
     Button actionButton = (Button) findViewById(R.id.status_action_button);
@@ -218,6 +231,11 @@ public final class BarcodeReaderCaptureActivity extends Activity {
     lastResult = "";
   }
 
+  private void resetStatusViewColor() {
+    View statusView = findViewById(R.id.status_view);
+    statusView.setBackgroundColor(0x50000000);
+  }
+
   private static ParsedReaderResult parseReaderResult(Result rawResult) {
     ParsedReaderResult readerResult = ParsedReaderResult.parseReaderResult(rawResult);
     if (readerResult.getType().equals(ParsedReaderResultType.TEXT)) {
index 1cc1138..f7ba984 100644 (file)
@@ -247,7 +247,7 @@ final class CameraManager {
    */
   private void calculatePreviewResolution() {
     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;
       previewWidth = ((previewWidth + 7) >> 3) << 3;
       if (previewWidth > cameraResolution.x) previewWidth = cameraResolution.x;