Pull Request cleanup (#16): Reinstated old interval autofocus bahaviour on Android API Level < 14 (plus minor blank line formatting)

This commit is contained in:
TJ Woon 2015-04-19 23:58:45 +08:00
parent fc6e2ff07c
commit a70a9bcb03

View File

@ -40,7 +40,7 @@ implements SurfaceHolder.Callback {
//for barcode types //for barcode types
private Collection<ZBarcodeFormat> mFormats = null; private Collection<ZBarcodeFormat> mFormats = null;
// Config ---------------------------------------------------------- // Config ----------------------------------------------------------
private static int autoFocusInterval = 500; // Interval between AFcallback and next AF attempt. private static int autoFocusInterval = 500; // Interval between AFcallback and next AF attempt.
@ -101,7 +101,7 @@ implements SurfaceHolder.Callback {
scanner = new ImageScanner(); scanner = new ImageScanner();
scanner.setConfig(0, Config.X_DENSITY, 3); scanner.setConfig(0, Config.X_DENSITY, 3);
scanner.setConfig(0, Config.Y_DENSITY, 3); scanner.setConfig(0, Config.Y_DENSITY, 3);
// Set the config for barcode formats // Set the config for barcode formats
for(ZBarcodeFormat format : getFormats()) { for(ZBarcodeFormat format : getFormats()) {
scanner.setConfig(format.getId(), Config.ENABLE, 1); scanner.setConfig(format.getId(), Config.ENABLE, 1);
@ -188,7 +188,7 @@ implements SurfaceHolder.Callback {
if (android.os.Build.VERSION.SDK_INT >= 14) { if (android.os.Build.VERSION.SDK_INT >= 14) {
camParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); camParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
} }
try { camera.setParameters(camParams); } try { camera.setParameters(camParams); }
catch (RuntimeException e) { catch (RuntimeException e) {
Log.d("csZBar", "Unsupported camera parameter reported for flash mode: "+flashMode); Log.d("csZBar", "Unsupported camera parameter reported for flash mode: "+flashMode);
@ -253,6 +253,7 @@ implements SurfaceHolder.Callback {
} }
// Continuously auto-focus ----------------------------------------- // Continuously auto-focus -----------------------------------------
// For API Level < 14
private AutoFocusCallback autoFocusCb = new AutoFocusCallback() private AutoFocusCallback autoFocusCb = new AutoFocusCallback()
{ {
@ -385,11 +386,14 @@ implements SurfaceHolder.Callback {
camera.setPreviewDisplay(holder); camera.setPreviewDisplay(holder);
camera.setPreviewCallback(previewCb); camera.setPreviewCallback(previewCb);
camera.startPreview(); camera.startPreview();
//camera.autoFocus(autoFocusCb); // We are not using any of the
// continuous autofocus modes as that does not seem to work if (android.os.Build.VERSION.SDK_INT >= 14) {
// well with flash setting of "on"... At least with this camera.autoFocus(autoFocusCb); // We are not using any of the
// simple and stupid focus method, we get to turn the flash // continuous autofocus modes as that does not seem to work
// on during autofocus. // well with flash setting of "on"... At least with this
// simple and stupid focus method, we get to turn the flash
// on during autofocus.
}
} catch (IOException e) { } catch (IOException e) {
die("Could not start camera preview: " + e.getMessage()); die("Could not start camera preview: " + e.getMessage());
} }