Updates to compile against 1.5; figuring we will shortly need to be 1.5-friendly

git-svn-id: https://zxing.googlecode.com/svn/trunk@964 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-06-06 19:50:27 +00:00
parent 096b73fe83
commit 9bc1fe4695
2 changed files with 19 additions and 12 deletions

View file

@ -28,6 +28,8 @@ import android.view.SurfaceHolder;
import android.view.WindowManager;
import com.google.zxing.ResultPoint;
import java.io.IOException;
/**
* This object wraps the Camera service object and expects to be the only one talking to it. The
* implementation encapsulates the steps needed to take preview-sized images, which are used for
@ -66,7 +68,7 @@ final class CameraManager {
mPreviewing = false;
}
public void openDriver(SurfaceHolder holder) {
public void openDriver(SurfaceHolder holder) throws IOException {
if (mCamera == null) {
mCamera = Camera.open();
mCamera.setPreviewDisplay(holder);
@ -138,7 +140,7 @@ final class CameraManager {
*/
public Rect getFramingRect() {
if (mFramingRect == null) {
int size = ((mScreenResolution.x < mScreenResolution.y) ? mScreenResolution.x :
int size = (mScreenResolution.x < mScreenResolution.y ? mScreenResolution.x :
mScreenResolution.y) * 3 / 4;
int leftOffset = (mScreenResolution.x - size) / 2;
int topOffset = (mScreenResolution.y - size) / 2;
@ -188,7 +190,7 @@ final class CameraManager {
if (mAutoFocusHandler != null) {
Message message = mAutoFocusHandler.obtainMessage(mAutoFocusMessage, success);
// Simulate continuous autofocus by sending a focus request every 1.5 seconds.
mAutoFocusHandler.sendMessageDelayed(message, 1500);
mAutoFocusHandler.sendMessageDelayed(message, 1500L);
mAutoFocusHandler = null;
}
}

View file

@ -76,9 +76,9 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
private static final int ABOUT_ID = Menu.FIRST + 3;
private static final int MAX_RESULT_IMAGE_SIZE = 150;
private static final int INTENT_RESULT_DURATION = 1500;
private static final long INTENT_RESULT_DURATION = 1500L;
private static final float BEEP_VOLUME = 0.15f;
private static final long VIBRATE_DURATION = 200;
private static final long VIBRATE_DURATION = 200L;
private static final String PACKAGE_NAME = "com.google.zxing.client.android";
private static final String PRODUCT_SEARCH_URL_PREFIX = "http://www.google";
@ -281,7 +281,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
}
private final DialogInterface.OnClickListener mAboutListener = new DialogInterface.OnClickListener() {
public void onClick(android.content.DialogInterface dialogInterface, int i) {
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.zxing_url)));
startActivity(intent);
}
@ -337,20 +337,20 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
Canvas canvas = new Canvas(barcode);
Paint paint = new Paint();
paint.setColor(getResources().getColor(R.color.result_image_border));
paint.setStrokeWidth(3);
paint.setStrokeWidth(3.0f);
paint.setStyle(Paint.Style.STROKE);
Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2);
canvas.drawRect(border, paint);
paint.setColor(getResources().getColor(R.color.result_points));
if (points.length == 2) {
paint.setStrokeWidth(4);
paint.setStrokeWidth(4.0f);
canvas.drawLine(points[0].getX(), points[0].getY(), points[1].getX(),
points[1].getY(), paint);
} else {
paint.setStrokeWidth(10);
for (int x = 0; x < points.length; x++) {
canvas.drawPoint(points[x].getX(), points[x].getY(), paint);
paint.setStrokeWidth(10.0f);
for (ResultPoint point : points) {
canvas.drawPoint(point.getX(), point.getY(), paint);
}
}
}
@ -503,7 +503,12 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
}
private void initCamera(SurfaceHolder surfaceHolder) {
CameraManager.get().openDriver(surfaceHolder);
try {
CameraManager.get().openDriver(surfaceHolder);
} catch (IOException ioe) {
Log.w(TAG, ioe);
return;
}
if (mHandler == null) {
boolean beginScanning = mLastResult == null;
mHandler = new CaptureActivityHandler(this, mDecodeMode, beginScanning);