Skip to content

Commit 9cc745d

Browse files
author
Tim Nolte
committed
Cleanup
1 parent 74aec00 commit 9cc745d

5 files changed

Lines changed: 9 additions & 17 deletions

File tree

Samples/Sample.Forms/Sample.Forms.Android/Properties/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="codes.redth.zxing.forms" android:installLocation="auto">
3-
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
3+
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />
44
<application android:label="ZXing Forms"></application>
55
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
66
<uses-permission android:name="android.permission.CAMERA" />

Samples/Sample.Forms/Sample.Forms.Android/Sample.Forms.Android.csproj

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
1717
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
1818
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
19-
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
19+
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
2020
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
2121
<AndroidUseAapt2>true</AndroidUseAapt2>
2222
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
@@ -32,11 +32,6 @@
3232
<ErrorReport>prompt</ErrorReport>
3333
<WarningLevel>4</WarningLevel>
3434
<AndroidLinkMode>None</AndroidLinkMode>
35-
<AotAssemblies>false</AotAssemblies>
36-
<EnableLLVM>false</EnableLLVM>
37-
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
38-
<BundleAssemblies>false</BundleAssemblies>
39-
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
4035
</PropertyGroup>
4136
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
4237
<DebugSymbols>true</DebugSymbols>

ZXing.Net.Mobile/Android/CameraAccess/CameraAnalyzer.android.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ bool CanAnalyzeFrame
9090
}
9191
}
9292

93-
void HandleOnPreviewFrameReady(object sender, byte[] fastArray)
93+
void HandleOnPreviewFrameReady(object sender, byte[] data)
9494
{
9595
if (!CanAnalyzeFrame)
9696
return;
@@ -102,7 +102,7 @@ void HandleOnPreviewFrameReady(object sender, byte[] fastArray)
102102
{
103103
try
104104
{
105-
DecodeFrame(fastArray);
105+
DecodeFrame(data);
106106
}
107107
catch (Exception ex)
108108
{
@@ -115,7 +115,7 @@ void HandleOnPreviewFrameReady(object sender, byte[] fastArray)
115115
}, TaskContinuationOptions.OnlyOnFaulted);
116116
}
117117

118-
void DecodeFrame(byte[] fastArray)
118+
void DecodeFrame(byte[] data)
119119
{
120120
var previewSize = cameraController.IdealPhotoSize;
121121
var width = previewSize.Width;
@@ -127,9 +127,9 @@ void DecodeFrame(byte[] fastArray)
127127

128128
barcodeReader.AutoRotate = true;
129129

130-
var source2 = new PlanarYUVLuminanceSource(fastArray, width, height, 0, 0, width, height, false);
130+
var source = new PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false);
131131

132-
result = barcodeReader.Decode(source2);
132+
result = barcodeReader.Decode(source);
133133
PerformanceCounter.Stop(start,
134134
"Decode Time: {0} ms (width: " + width + ", height: " + height + ")");
135135

ZXing.Net.Mobile/Android/CameraAccess/CameraController.android.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ void SetUpCameraOutputs()
225225
}
226226

227227
// 1050 and 1400 are a random guess which work pretty good
228+
// inspired from https://github.com/vtserej/Camera2Forms/blob/master/Camera2Forms/Camera2Forms.Android/Camera2/CameraDroid.cs#L162
228229
var idealSize = GetOptimalSize(supportedSizes, 1050, 1400);
229230
imageReader = ImageReader.NewInstance(idealSize.Width, idealSize.Height, ImageFormatType.Yuv420888, 5);
230231

@@ -274,7 +275,7 @@ public void OpenCamera()
274275
}
275276
}
276277

277-
private Size GetOptimalPreviewSize(SurfaceView surface)
278+
Size GetOptimalPreviewSize(SurfaceView surface)
278279
{
279280
var characteristics = cameraManager.GetCameraCharacteristics(CameraId);
280281
var map = (StreamConfigurationMap)characteristics.Get(CameraCharacteristics.ScalerStreamConfigurationMap);

ZXing.Net.Mobile/Android/CameraAccess/CameraEventsListener.android.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ public void OnImageAvailable(ImageReader reader)
2525
var yuvBytes = ImageToByteArray(image);
2626
OnPreviewFrameReady?.Invoke(this, yuvBytes);
2727
}
28-
catch (Exception ex)
29-
{
30-
Android.Util.Log.Debug(MobileBarcodeScanner.TAG, "Could not start preview session");
31-
}
3228
finally
3329
{
3430
image?.Close();

0 commit comments

Comments
 (0)