diff --git a/Samples/Sample.Forms/Sample.Forms.Android/Properties/AndroidManifest.xml b/Samples/Sample.Forms/Sample.Forms.Android/Properties/AndroidManifest.xml index 25ac59f65..8599f2bbe 100644 --- a/Samples/Sample.Forms/Sample.Forms.Android/Properties/AndroidManifest.xml +++ b/Samples/Sample.Forms/Sample.Forms.Android/Properties/AndroidManifest.xml @@ -1,6 +1,6 @@  - + diff --git a/Samples/Sample.Forms/Sample.Forms.Android/Sample.Forms.Android.csproj b/Samples/Sample.Forms/Sample.Forms.Android/Sample.Forms.Android.csproj index 7bd229373..fccd97543 100644 --- a/Samples/Sample.Forms/Sample.Forms.Android/Sample.Forms.Android.csproj +++ b/Samples/Sample.Forms/Sample.Forms.Android/Sample.Forms.Android.csproj @@ -16,7 +16,7 @@ Resources Assets false - v9.0 + v10.0 true true Xamarin.Android.Net.AndroidClientHandler @@ -32,11 +32,6 @@ prompt 4 None - false - false - false - false - true true diff --git a/ZXing.Net.Mobile/Android/CameraAccess/CameraAnalyzer.android.cs b/ZXing.Net.Mobile/Android/CameraAccess/CameraAnalyzer.android.cs index 1ec0c855b..d01c170f0 100644 --- a/ZXing.Net.Mobile/Android/CameraAccess/CameraAnalyzer.android.cs +++ b/ZXing.Net.Mobile/Android/CameraAccess/CameraAnalyzer.android.cs @@ -90,7 +90,7 @@ bool CanAnalyzeFrame } } - void HandleOnPreviewFrameReady(object sender, byte[] fastArray) + void HandleOnPreviewFrameReady(object sender, byte[] data) { if (!CanAnalyzeFrame) return; @@ -102,7 +102,7 @@ void HandleOnPreviewFrameReady(object sender, byte[] fastArray) { try { - DecodeFrame(fastArray); + DecodeFrame(data); } catch (Exception ex) { @@ -115,7 +115,7 @@ void HandleOnPreviewFrameReady(object sender, byte[] fastArray) }, TaskContinuationOptions.OnlyOnFaulted); } - void DecodeFrame(byte[] fastArray) + void DecodeFrame(byte[] data) { var previewSize = cameraController.IdealPhotoSize; var width = previewSize.Width; @@ -127,9 +127,9 @@ void DecodeFrame(byte[] fastArray) barcodeReader.AutoRotate = true; - var source2 = new PlanarYUVLuminanceSource(fastArray, width, height, 0, 0, width, height, false); + var source = new PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false); - result = barcodeReader.Decode(source2); + result = barcodeReader.Decode(source); PerformanceCounter.Stop(start, "Decode Time: {0} ms (width: " + width + ", height: " + height + ")"); diff --git a/ZXing.Net.Mobile/Android/CameraAccess/CameraController.android.cs b/ZXing.Net.Mobile/Android/CameraAccess/CameraController.android.cs index e3d88fa23..4109bf640 100644 --- a/ZXing.Net.Mobile/Android/CameraAccess/CameraController.android.cs +++ b/ZXing.Net.Mobile/Android/CameraAccess/CameraController.android.cs @@ -225,6 +225,7 @@ void SetUpCameraOutputs() } // 1050 and 1400 are a random guess which work pretty good + // inspired from https://github.com/vtserej/Camera2Forms/blob/master/Camera2Forms/Camera2Forms.Android/Camera2/CameraDroid.cs#L162 var idealSize = GetOptimalSize(supportedSizes, 1050, 1400); imageReader = ImageReader.NewInstance(idealSize.Width, idealSize.Height, ImageFormatType.Yuv420888, 5); @@ -274,7 +275,7 @@ public void OpenCamera() } } - private Size GetOptimalPreviewSize(SurfaceView surface) + Size GetOptimalPreviewSize(SurfaceView surface) { var characteristics = cameraManager.GetCameraCharacteristics(CameraId); var map = (StreamConfigurationMap)characteristics.Get(CameraCharacteristics.ScalerStreamConfigurationMap); diff --git a/ZXing.Net.Mobile/Android/CameraAccess/CameraEventsListener.android.cs b/ZXing.Net.Mobile/Android/CameraAccess/CameraEventsListener.android.cs index b7ccbd847..0f89c0e6e 100644 --- a/ZXing.Net.Mobile/Android/CameraAccess/CameraEventsListener.android.cs +++ b/ZXing.Net.Mobile/Android/CameraAccess/CameraEventsListener.android.cs @@ -25,10 +25,6 @@ public void OnImageAvailable(ImageReader reader) var yuvBytes = ImageToByteArray(image); OnPreviewFrameReady?.Invoke(this, yuvBytes); } - catch (Exception ex) - { - Android.Util.Log.Debug(MobileBarcodeScanner.TAG, "Could not start preview session"); - } finally { image?.Close();