Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes crashes Android 15 and update to net9 #216

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions BigIslandBarcode/BigIslandBarcode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<!-- iOS, Android, MacCatalyst -->
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041</TargetFrameworks>
<OutputType>Exe</OutputType>
<SingleProject>true</SingleProject>
<UseMaui>true</UseMaui>
Expand Down Expand Up @@ -53,7 +53,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.21" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions ZXing.Net.MAUI.Comet/ZXing.Net.MAUI.Comet.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net8.0-android;net8.0-maccatalyst;net8.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>net9.0;net9.0-android;net9.0-maccatalyst;net9.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041</TargetFrameworks>
<PackageId>ZXing.Net.Maui.Comet</PackageId>
<Title>ZXing.Net.MAUI Barcode Scanner for .NET MAUI</Title>
<Authors>Redth</Authors>
Expand All @@ -26,6 +26,6 @@
<ProjectReference Include="..\ZXing.Net.MAUI\ZXing.Net.MAUI.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.21" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions ZXing.Net.MAUI.Controls/ZXing.Net.MAUI.Controls.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net8.0-android;net8.0-maccatalyst;net8.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>net9.0;net9.0-android;net9.0-maccatalyst;net9.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041</TargetFrameworks>
<PackageId>ZXing.Net.Maui.Controls</PackageId>
<Title>ZXing.Net.MAUI Barcode Scanner for .NET MAUI</Title>
<Authors>Redth</Authors>
Expand All @@ -25,6 +25,6 @@
<ProjectReference Include="..\ZXing.Net.MAUI\ZXing.Net.MAUI.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.30" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions ZXing.Net.MAUI/Platforms/Android/CameraManager.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void Connect()

// Preview
cameraPreview = new AndroidX.Camera.Core.Preview.Builder().Build();
cameraPreview.SetSurfaceProvider(previewView.SurfaceProvider);
cameraPreview.SetSurfaceProvider(cameraExecutor, previewView.SurfaceProvider);

// Frame by frame analyze
imageAnalyzer = new ImageAnalysis.Builder()
Expand All @@ -67,7 +67,7 @@ public void Connect()
.Build();

imageAnalyzer.SetAnalyzer(cameraExecutor, new FrameAnalyzer((buffer, size) =>
FrameReady?.Invoke(this, new CameraFrameBufferEventArgs(new Readers.PixelBufferHolder { Data = buffer, Size = size }))));
FrameReady?.Invoke(this, new CameraFrameBufferEventArgs(new Readers.PixelBufferHolder { Data = buffer, Size = new Microsoft.Maui.Graphics.Size(size.Width, size.Height) }))));

UpdateCamera();

Expand Down
5 changes: 4 additions & 1 deletion ZXing.Net.MAUI/Platforms/Android/FrameAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
using Java.Nio;
using Microsoft.Maui.Graphics;
using System;
using Size = Android.Util.Size;

namespace ZXing.Net.Maui
{
internal class FrameAnalyzer : Java.Lang.Object, ImageAnalysis.IAnalyzer
public class FrameAnalyzer : Java.Lang.Object, ImageAnalysis.IAnalyzer
{
readonly Action<ByteBuffer, Size> frameCallback;

Expand All @@ -14,6 +15,8 @@ public FrameAnalyzer(Action<ByteBuffer, Size> callback)
frameCallback = callback;
}

public Size DefaultTargetResolution => new Size(200, 200);

public void Analyze(IImageProxy image)
{
var buffer = image.GetPlanes()[0].Buffer;
Expand Down
6 changes: 3 additions & 3 deletions ZXing.Net.MAUI/ZXing.Net.MAUI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net8.0-android;net8.0-maccatalyst;net8.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>net9.0;net9.0-android;net9.0-maccatalyst;net9.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041</TargetFrameworks>
<PackageId>ZXing.Net.Maui</PackageId>
<Title>ZXing.Net.MAUI Barcode Scanner for .NET MAUI</Title>
<Authors>Redth</Authors>
Expand Down Expand Up @@ -88,6 +88,6 @@
</Target>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.30" />
</ItemGroup>
</Project>