diff --git a/CHANGELOG.md b/CHANGELOG.md index 33a1b223..e3c7f40e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## [1.9.8] - August 18, 2017 +* One more attempt to fix Nexus 5x portrait scanning problems + ## [1.9.7] - August 2, 2017 * Fix everything that was broken since 1.9.5 (Relevant issues: #336, #315, #339, #338) diff --git a/README.md b/README.md index ac0e1001..49d46514 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Installation Add the following dependency to your build.gradle file. -`compile 'me.dm7.barcodescanner:zxing:1.9.7'` +`compile 'me.dm7.barcodescanner:zxing:1.9.8'` Simple Usage ------------ @@ -126,7 +126,7 @@ Installation Add the following dependency to your build.gradle file. -`compile 'me.dm7.barcodescanner:zbar:1.9.7'` +`compile 'me.dm7.barcodescanner:zbar:1.9.8'` Simple Usage ------------ diff --git a/build.gradle b/build.gradle index d24758c2..31235da4 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ buildscript { allprojects { group = 'me.dm7.barcodescanner' - version = '1.9.7' + version = '1.9.8' repositories { mavenCentral() @@ -44,8 +44,8 @@ subprojects { defaultConfig { minSdkVersion versions.min_sdk targetSdkVersion versions.target_sdk - versionCode 197 - versionName "1.9.7" + versionCode 198 + versionName "1.9.8" } } } diff --git a/core/src/main/java/me/dm7/barcodescanner/core/BarcodeScannerView.java b/core/src/main/java/me/dm7/barcodescanner/core/BarcodeScannerView.java index 6409fde3..42863e19 100644 --- a/core/src/main/java/me/dm7/barcodescanner/core/BarcodeScannerView.java +++ b/core/src/main/java/me/dm7/barcodescanner/core/BarcodeScannerView.java @@ -8,6 +8,7 @@ import android.hardware.Camera; import android.support.annotation.ColorInt; import android.util.AttributeSet; +import android.util.Log; import android.view.Gravity; import android.view.View; import android.widget.FrameLayout; @@ -322,6 +323,9 @@ public byte[] getRotatedData(byte[] data, Camera camera) { rotatedData[x * height + height - y - 1] = data[x + y * width]; } data = rotatedData; + int tmp = width; + width = height; + height = tmp; } } diff --git a/dependencies.gradle b/dependencies.gradle index 169640c8..075b1dd4 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -5,7 +5,7 @@ ext.versions = [ build_tools : "25.0.2", support_lib : "25.3.1", zxing : "3.3.0", - barcodescanner: "1.9.7" + barcodescanner: "1.9.8" ] ext.libraries = [ diff --git a/zbar/src/main/java/me/dm7/barcodescanner/zbar/ZBarScannerView.java b/zbar/src/main/java/me/dm7/barcodescanner/zbar/ZBarScannerView.java index 99375422..439bac6b 100644 --- a/zbar/src/main/java/me/dm7/barcodescanner/zbar/ZBarScannerView.java +++ b/zbar/src/main/java/me/dm7/barcodescanner/zbar/ZBarScannerView.java @@ -1,6 +1,7 @@ package me.dm7.barcodescanner.zbar; import android.content.Context; +import android.content.res.Configuration; import android.graphics.Rect; import android.hardware.Camera; import android.os.Handler; @@ -20,6 +21,7 @@ import java.util.List; import me.dm7.barcodescanner.core.BarcodeScannerView; +import me.dm7.barcodescanner.core.DisplayUtils; public class ZBarScannerView extends BarcodeScannerView { private static final String TAG = "ZBarScannerView"; @@ -84,13 +86,16 @@ public void onPreviewFrame(byte[] data, Camera camera) { Camera.Size size = parameters.getPreviewSize(); int width = size.width; int height = size.height; - int rotationCount = getRotationCount(); - if(rotationCount == 1 || rotationCount == 3) { - int tmp = width; - width = height; - height = tmp; + + if (DisplayUtils.getScreenOrientation(getContext()) == Configuration.ORIENTATION_PORTRAIT) { + int rotationCount = getRotationCount(); + if (rotationCount == 1 || rotationCount == 3) { + int tmp = width; + width = height; + height = tmp; + } + data = getRotatedData(data, camera); } - data = getRotatedData(data, camera); Rect rect = getFramingRectInPreview(width, height); Image barcode = new Image(width, height, "Y800"); diff --git a/zxing/src/main/java/me/dm7/barcodescanner/zxing/ZXingScannerView.java b/zxing/src/main/java/me/dm7/barcodescanner/zxing/ZXingScannerView.java index e5018920..d1717ba5 100644 --- a/zxing/src/main/java/me/dm7/barcodescanner/zxing/ZXingScannerView.java +++ b/zxing/src/main/java/me/dm7/barcodescanner/zxing/ZXingScannerView.java @@ -1,6 +1,7 @@ package me.dm7.barcodescanner.zxing; import android.content.Context; +import android.content.res.Configuration; import android.graphics.Rect; import android.hardware.Camera; import android.os.Handler; @@ -26,6 +27,7 @@ import java.util.Map; import me.dm7.barcodescanner.core.BarcodeScannerView; +import me.dm7.barcodescanner.core.DisplayUtils; public class ZXingScannerView extends BarcodeScannerView { private static final String TAG = "ZXingScannerView"; @@ -103,14 +105,16 @@ public void onPreviewFrame(byte[] data, Camera camera) { Camera.Size size = parameters.getPreviewSize(); int width = size.width; int height = size.height; - int rotationCount = getRotationCount(); - if(rotationCount == 1 || rotationCount == 3) { - int tmp = width; - width = height; - height = tmp; - } - data = getRotatedData(data, camera); + if (DisplayUtils.getScreenOrientation(getContext()) == Configuration.ORIENTATION_PORTRAIT) { + int rotationCount = getRotationCount(); + if (rotationCount == 1 || rotationCount == 3) { + int tmp = width; + width = height; + height = tmp; + } + data = getRotatedData(data, camera); + } Result rawResult = null; PlanarYUVLuminanceSource source = buildLuminanceSource(data, width, height);