diff --git a/plugin.xml b/plugin.xml index 465c0db5..0792ad80 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,7 +1,7 @@ + version="1.2.8"> BarcodeScanner You can use the BarcodeScanner plugin to scan different types of barcodes (using the device's camera) and get the metadata encoded in them for processing within your application. diff --git a/src/android/LibraryProject/src/com/google/zxing/client/android/camera/CameraConfigurationManager.java b/src/android/LibraryProject/src/com/google/zxing/client/android/camera/CameraConfigurationManager.java index 59ec9627..b7120ef8 100644 --- a/src/android/LibraryProject/src/com/google/zxing/client/android/camera/CameraConfigurationManager.java +++ b/src/android/LibraryProject/src/com/google/zxing/client/android/camera/CameraConfigurationManager.java @@ -18,6 +18,7 @@ import android.content.Context; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.graphics.Point; import android.hardware.Camera; import android.preference.PreferenceManager; @@ -25,7 +26,6 @@ import android.util.Log; import android.util.TypedValue; import android.view.Display; -import android.view.Surface; import android.view.WindowManager; import com.google.zxing.client.android.PreferencesActivity; @@ -75,7 +75,8 @@ void initFromCameraParameters(Camera camera) { if (this.context.getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) { height -= TypedValue.complexToDimensionPixelSize(typedValue.data, displayMetrics); } else { - if (display.getRotation() == Surface.ROTATION_0) { + int rotation = context.getApplicationContext().getResources().getConfiguration().orientation; + if (rotation == Configuration.ORIENTATION_PORTRAIT) { height -= 40 * displayMetrics.density; } else { height -= 48 * displayMetrics.density; @@ -92,10 +93,9 @@ void initFromCameraParameters(Camera camera) { } void setDesiredCameraParameters(Camera camera, boolean safeMode) { - // Checkout of screen orientation - WindowManager manager = (WindowManager) this.context.getSystemService(Context.WINDOW_SERVICE); - int rotation = manager.getDefaultDisplay().getRotation(); - if (rotation == Surface.ROTATION_0) { + // Checkout screen orientation + int rotation = context.getApplicationContext().getResources().getConfiguration().orientation; + if (rotation == Configuration.ORIENTATION_PORTRAIT) { camera.setDisplayOrientation(90); } diff --git a/src/android/LibraryProject/src/com/google/zxing/client/android/camera/CameraManager.java b/src/android/LibraryProject/src/com/google/zxing/client/android/camera/CameraManager.java index f7edf5f0..3fc5e0bb 100644 --- a/src/android/LibraryProject/src/com/google/zxing/client/android/camera/CameraManager.java +++ b/src/android/LibraryProject/src/com/google/zxing/client/android/camera/CameraManager.java @@ -17,13 +17,12 @@ package com.google.zxing.client.android.camera; import android.content.Context; +import android.content.res.Configuration; import android.graphics.Point; import android.graphics.Rect; import android.hardware.Camera; import android.os.Handler; import android.util.Log; -import android.view.Display; -import android.view.Surface; import android.view.SurfaceHolder; import android.view.WindowManager; import com.google.zxing.PlanarYUVLuminanceSource; @@ -257,9 +256,8 @@ public synchronized Rect getFramingRectInPreview() { return null; } - Display display = windowManager.getDefaultDisplay(); - int rotation = display.getRotation(); - if (rotation == Surface.ROTATION_0) { + int rotation = context.getApplicationContext().getResources().getConfiguration().orientation; + if (rotation == Configuration.ORIENTATION_PORTRAIT) { rect.left = rect.left * cameraResolution.y / screenResolution.x; rect.right = rect.right * cameraResolution.y / screenResolution.x; rect.top = rect.top * cameraResolution.x / screenResolution.y; @@ -295,12 +293,9 @@ public synchronized void setManualFramingRect(int width, int height) { } public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) { - // Hack of orientation - Display display = windowManager.getDefaultDisplay(); - int rotation = display.getRotation(); - byte[] rotatedData = new byte[data.length]; - if (rotation == Surface.ROTATION_0) { + int rotation = context.getApplicationContext().getResources().getConfiguration().orientation; + if (rotation == Configuration.ORIENTATION_PORTRAIT) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { rotatedData[x * height + height - y - 1] = data[x + y * width]; @@ -318,7 +313,7 @@ public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int return null; } // Go ahead and assume it's YUV rather than die. - return new PlanarYUVLuminanceSource(rotation == Surface.ROTATION_0 ? rotatedData : data, width, height, rect.left, rect.top, + return new PlanarYUVLuminanceSource(rotation == Configuration.ORIENTATION_PORTRAIT ? rotatedData : data, width, height, rect.left, rect.top, rect.width(), rect.height(), false); } }