From ab76e4e052d595b4fce8eaf2fecce773613e7720 Mon Sep 17 00:00:00 2001 From: James Crutchley Date: Tue, 17 Dec 2024 23:17:05 -0800 Subject: [PATCH 1/3] - Update Nuget Dependancies - Fix Camera Zoom --- .../Pages/Views/CameraView/CameraViewPage.xaml.cs | 10 ++++++++-- .../CameraManager.android.cs | 3 ++- .../CommunityToolkit.Maui.Camera.csproj | 9 +++++++-- .../Views/CameraView.shared.cs | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs index 2dfe6e4165..cd01b2bb94 100644 --- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs +++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs @@ -87,11 +87,17 @@ void OnMediaCaptured(object? sender, MediaCapturedEventArgs e) void ZoomIn(object? sender, EventArgs e) { - Camera.ZoomFactor += 1.0f; + Dispatcher.Dispatch(() => + { + Camera.ZoomFactor += 1.0f; + }); } void ZoomOut(object? sender, EventArgs e) { - Camera.ZoomFactor -= 1.0f; + Dispatcher.Dispatch(() => + { + Camera.ZoomFactor -= 1.0f; + }); } } \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs b/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs index 23cfdd4c63..924116efbe 100644 --- a/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs +++ b/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs @@ -183,7 +183,8 @@ protected async Task StartUseCase(CancellationToken token) imageCapture?.Dispose(); cameraPreview = new Preview.Builder().SetResolutionSelector(resolutionSelector).Build(); - cameraPreview.SetSurfaceProvider(previewView?.SurfaceProvider); + IExecutor executor = Executors.NewSingleThreadExecutor() ?? throw new CameraException($"Unable to retrieve {nameof(IExecutor)}"); + cameraPreview.SetSurfaceProvider(executor, previewView?.SurfaceProvider); imageCapture = new ImageCapture.Builder() .SetCaptureMode(ImageCapture.CaptureModeMaximizeQuality) diff --git a/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj b/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj index abb23f8555..2f428b01e9 100644 --- a/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj +++ b/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj @@ -51,9 +51,14 @@ - - + + + + + + + diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index 84e0db8da1..14460af39f 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -11,7 +11,7 @@ namespace CommunityToolkit.Maui.Views; /// A visual element that provides the ability to show a camera preview and capture images. /// [SupportedOSPlatform("windows10.0.10240.0")] -[SupportedOSPlatform("android21.0")] +[SupportedOSPlatform("android26.0")] [SupportedOSPlatform("ios")] [SupportedOSPlatform("maccatalyst")] public partial class CameraView : View, ICameraView From 50847aabb15a25f4caf8d89cfec19cdf8c965b59 Mon Sep 17 00:00:00 2001 From: James Crutchley Date: Tue, 17 Dec 2024 23:27:04 -0800 Subject: [PATCH 2/3] Fix Android supported version --- src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index 14460af39f..84e0db8da1 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -11,7 +11,7 @@ namespace CommunityToolkit.Maui.Views; /// A visual element that provides the ability to show a camera preview and capture images. /// [SupportedOSPlatform("windows10.0.10240.0")] -[SupportedOSPlatform("android26.0")] +[SupportedOSPlatform("android21.0")] [SupportedOSPlatform("ios")] [SupportedOSPlatform("maccatalyst")] public partial class CameraView : View, ICameraView From 028024cb2720e5b3a4cbd460a83dfa23a3b33cac Mon Sep 17 00:00:00 2001 From: James Crutchley Date: Wed, 18 Dec 2024 03:11:36 -0800 Subject: [PATCH 3/3] Remove fix for zoom. It does not work. --- .../Pages/Views/CameraView/CameraViewPage.xaml.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs index cd01b2bb94..2dfe6e4165 100644 --- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs +++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs @@ -87,17 +87,11 @@ void OnMediaCaptured(object? sender, MediaCapturedEventArgs e) void ZoomIn(object? sender, EventArgs e) { - Dispatcher.Dispatch(() => - { - Camera.ZoomFactor += 1.0f; - }); + Camera.ZoomFactor += 1.0f; } void ZoomOut(object? sender, EventArgs e) { - Dispatcher.Dispatch(() => - { - Camera.ZoomFactor -= 1.0f; - }); + Camera.ZoomFactor -= 1.0f; } } \ No newline at end of file