mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
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:
parent
096b73fe83
commit
9bc1fe4695
|
@ -28,6 +28,8 @@ import android.view.SurfaceHolder;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import com.google.zxing.ResultPoint;
|
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
|
* 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
|
* implementation encapsulates the steps needed to take preview-sized images, which are used for
|
||||||
|
@ -66,7 +68,7 @@ final class CameraManager {
|
||||||
mPreviewing = false;
|
mPreviewing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openDriver(SurfaceHolder holder) {
|
public void openDriver(SurfaceHolder holder) throws IOException {
|
||||||
if (mCamera == null) {
|
if (mCamera == null) {
|
||||||
mCamera = Camera.open();
|
mCamera = Camera.open();
|
||||||
mCamera.setPreviewDisplay(holder);
|
mCamera.setPreviewDisplay(holder);
|
||||||
|
@ -138,7 +140,7 @@ final class CameraManager {
|
||||||
*/
|
*/
|
||||||
public Rect getFramingRect() {
|
public Rect getFramingRect() {
|
||||||
if (mFramingRect == null) {
|
if (mFramingRect == null) {
|
||||||
int size = ((mScreenResolution.x < mScreenResolution.y) ? mScreenResolution.x :
|
int size = (mScreenResolution.x < mScreenResolution.y ? mScreenResolution.x :
|
||||||
mScreenResolution.y) * 3 / 4;
|
mScreenResolution.y) * 3 / 4;
|
||||||
int leftOffset = (mScreenResolution.x - size) / 2;
|
int leftOffset = (mScreenResolution.x - size) / 2;
|
||||||
int topOffset = (mScreenResolution.y - size) / 2;
|
int topOffset = (mScreenResolution.y - size) / 2;
|
||||||
|
@ -188,7 +190,7 @@ final class CameraManager {
|
||||||
if (mAutoFocusHandler != null) {
|
if (mAutoFocusHandler != null) {
|
||||||
Message message = mAutoFocusHandler.obtainMessage(mAutoFocusMessage, success);
|
Message message = mAutoFocusHandler.obtainMessage(mAutoFocusMessage, success);
|
||||||
// Simulate continuous autofocus by sending a focus request every 1.5 seconds.
|
// Simulate continuous autofocus by sending a focus request every 1.5 seconds.
|
||||||
mAutoFocusHandler.sendMessageDelayed(message, 1500);
|
mAutoFocusHandler.sendMessageDelayed(message, 1500L);
|
||||||
mAutoFocusHandler = null;
|
mAutoFocusHandler = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 ABOUT_ID = Menu.FIRST + 3;
|
||||||
|
|
||||||
private static final int MAX_RESULT_IMAGE_SIZE = 150;
|
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 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 PACKAGE_NAME = "com.google.zxing.client.android";
|
||||||
private static final String PRODUCT_SEARCH_URL_PREFIX = "http://www.google";
|
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() {
|
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)));
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.zxing_url)));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@ -337,20 +337,20 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
||||||
Canvas canvas = new Canvas(barcode);
|
Canvas canvas = new Canvas(barcode);
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
paint.setColor(getResources().getColor(R.color.result_image_border));
|
paint.setColor(getResources().getColor(R.color.result_image_border));
|
||||||
paint.setStrokeWidth(3);
|
paint.setStrokeWidth(3.0f);
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2);
|
Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2);
|
||||||
canvas.drawRect(border, paint);
|
canvas.drawRect(border, paint);
|
||||||
|
|
||||||
paint.setColor(getResources().getColor(R.color.result_points));
|
paint.setColor(getResources().getColor(R.color.result_points));
|
||||||
if (points.length == 2) {
|
if (points.length == 2) {
|
||||||
paint.setStrokeWidth(4);
|
paint.setStrokeWidth(4.0f);
|
||||||
canvas.drawLine(points[0].getX(), points[0].getY(), points[1].getX(),
|
canvas.drawLine(points[0].getX(), points[0].getY(), points[1].getX(),
|
||||||
points[1].getY(), paint);
|
points[1].getY(), paint);
|
||||||
} else {
|
} else {
|
||||||
paint.setStrokeWidth(10);
|
paint.setStrokeWidth(10.0f);
|
||||||
for (int x = 0; x < points.length; x++) {
|
for (ResultPoint point : points) {
|
||||||
canvas.drawPoint(points[x].getX(), points[x].getY(), paint);
|
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) {
|
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) {
|
if (mHandler == null) {
|
||||||
boolean beginScanning = mLastResult == null;
|
boolean beginScanning = mLastResult == null;
|
||||||
mHandler = new CaptureActivityHandler(this, mDecodeMode, beginScanning);
|
mHandler = new CaptureActivityHandler(this, mDecodeMode, beginScanning);
|
||||||
|
|
Loading…
Reference in a new issue