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

[EPIC-4283]- Xamarin Document SDK 4.2.0 #126

Merged
merged 21 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
405874b
- Updated the SDK to v4.2.0 and fixed the breaking changes.
scan-mayank Feb 12, 2024
70cfe99
Native Renderer
scan-mayank Feb 12, 2024
edc93e8
- Updated the Libraries.txt and beta packages to latest SDK 4.2.0
scan-mayank Feb 19, 2024
1775590
Forms:
scan-mayank Feb 27, 2024
21587f3
Merge pull request #118 from doo/EPIC-4279-xam-sdk-update-v4.2.0
matthewrindel Feb 27, 2024
66daffa
- Rebased develop with BarcodeImageGenerationType feature branch.
scan-mayank Feb 29, 2024
769ebbc
- [x] Adding iOS only comment for ImageGenerationType property.
scan-mayank Dec 13, 2023
2efa4d6
- Code refactoring for delegates and extension methods.
scan-mayank Feb 29, 2024
ccbd962
Merge pull request #117 from doo/EPIC-3538-bug-native-renderer-app-fr…
matthewrindel Feb 29, 2024
282e1f8
- Updated to the latest nuget package containing iOS SDK 4.2.2 Privac…
scan-mayank Mar 26, 2024
c9c1509
- Updated the iOS SDK version in libraries.txt
scan-mayank Mar 26, 2024
672755e
Merge pull request #119 from doo/mp/update-latest-nugets
scan-mayank Mar 27, 2024
b3a3c4b
Xamarin Forms Example:
scan-mayank Apr 23, 2024
a02d49c
Merge pull request #122 from doo/mp/qa-raisded-bug-fix
scan-mayank Apr 23, 2024
bdd5533
Xamarin Forms:
scan-mayank Apr 23, 2024
53c1b68
Merge pull request #123 from doo/mp/qa-raisded-bug-fix
scan-mayank Apr 23, 2024
32f1f09
Xamarin Forms:
scan-mayank Apr 24, 2024
ac0d279
Merge pull request #124 from doo/mp/qa-raisded-bug-fix
scan-mayank Apr 24, 2024
1fa6218
Xamarin Forms:
scan-mayank Apr 24, 2024
1a67ae6
Merge pull request #125 from doo/mp/qa-raisded-bug-fix
matthewrindel Apr 25, 2024
5b734ff
- Updated the packages to release version
scan-mayank Apr 25, 2024
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
853 changes: 660 additions & 193 deletions Libraries.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<JavaMaximumHeapSize></JavaMaximumHeapSize>
<AndroidFastDeploymentType></AndroidFastDeploymentType>
<AndroidManifest></AndroidManifest>
<AssemblyOriginatorKeyFile></AssemblyOriginatorKeyFile>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<LangVersion>8.0</LangVersion>
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
Expand All @@ -69,7 +68,7 @@
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2612" />
<PackageReference Include="ScanbotSDK.Xamarin.Forms">
<Version>3.10.2</Version>
<Version>4.2.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Collections.Generic;
using AndroidBarcode = IO.Scanbot.Sdk.Barcode.Entity.BarcodeItem;
using ScanbotSDK.Xamarin.Forms;
using IO.Scanbot.Barcodescanner.Model;

/*
This is the Android Custom Renderer that will provide the actual implementation for BarcodeCameraView.
Expand All @@ -43,6 +44,7 @@ class AndroidBarcodeCameraRenderer : ViewRenderer<BarcodeCameraView, FrameLayout
protected BarcodeScannerView cameraView;
private readonly int REQUEST_PERMISSION_CODE = 200;
BarcodeResultDelegate resultHandler;
private bool showToast;

public AndroidBarcodeCameraRenderer(Context context) : base(context)
{
Expand Down Expand Up @@ -136,14 +138,26 @@ public void OnCameraOpened()

private void OnSelectionOverlayBarcodeClicked(object sender, AndroidBarcode e)
{
var items = new List<AndroidBarcode> { e };
var args = new BarcodeEventArgs(new IO.Scanbot.Sdk.Barcode.Entity.BarcodeScanningResult(items, new Java.Util.Date().Time), null);
OnBarcodeResult(this, args);
ScanbotSDK.Xamarin.Forms.BarcodeScanningResult outResult = new ScanbotSDK.Xamarin.Forms.BarcodeScanningResult
{
Barcodes = new List<Barcode> { e.ToFormsBarcode() },
Image = e.Image.ToImageSource()
};

Element.OnBarcodeScanResult?.Invoke(outResult);
}

private void OnBarcodeResult(object sender, BarcodeEventArgs e)
{
if (e.Result != null)
if (!SBSDK.IsLicenseValid && !showToast)
{
showToast = true;
cameraView.Post(() => Toast.MakeText(Context.GetActivity(), "License has expired!", ToastLength.Long).Show());
return;
}

var overlayEnabled = Element.OverlayConfiguration?.Enabled ?? false;
if (overlayEnabled == false || Element.OverlayConfiguration?.AutomaticSelectionEnabled == true)
{
ScanbotSDK.Xamarin.Forms.BarcodeScanningResult outResult = new ScanbotSDK.Xamarin.Forms.BarcodeScanningResult
{
Expand All @@ -153,11 +167,6 @@ private void OnBarcodeResult(object sender, BarcodeEventArgs e)

Element.OnBarcodeScanResult?.Invoke(outResult);
}

if (e.Error != null)
{
cameraView.Post(() => Toast.MakeText(Context.GetActivity(), "License has expired!", ToastLength.Long).Show());
}
}

#endregion
Expand Down Expand Up @@ -186,11 +195,6 @@ private void SetSelectionOverlayConfiguration()
cameraView.SelectionOverlayController.SetEnabled(Element.OverlayConfiguration.Enabled);
cameraView.SelectionOverlayController.SetBarcodeHighlightedDelegate(this);
cameraView.SelectionOverlayController.SetBarcodeAppearanceDelegate(this);

if (resultHandler != null)
{
resultHandler.Success -= OnBarcodeResult;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Native.Renderers.Example.Forms.iOS.Utils;
using ScanbotSDK.iOS;
using ScanbotSDK.Xamarin.Forms;

namespace Native.Renderers.Example.Forms.iOS
{
// Since we cannot directly inherit from SBSDKBarcodeScannerViewControllerDelegate in our ViewRenderer,
// we have created this wrapper class to allow binding to its events through the use of delegates
class BarcodeScannerDelegate : SBSDKBarcodeScannerViewControllerDelegate
{
internal bool isScanning = true;
public delegate void OnDetectHandler(SBSDKBarcodeScannerResult[] codes);
public OnDetectHandler OnDetect;

public override void DidDetectBarcodes(SBSDKBarcodeScannerViewController controller, SBSDKBarcodeScannerResult[] codes)
{
if (controller.BarcodeImageGenerationType == SBSDKBarcodeImageGenerationType.CapturedImage)
{
isScanning = false; // it will restrict further scans and stop scanning when the image is captured.
}
OnDetect?.Invoke(codes);
}

public override bool ShouldDetectBarcodes(SBSDKBarcodeScannerViewController controller)
{
if (!SBSDK.IsLicenseValid)
{
ViewUtils.ShowAlert("License Expired!", "Ok");
return false;
}

return isScanning;
}
}

internal class BarcodeTrackingOverlayDelegate : SBSDKBarcodeTrackingOverlayControllerDelegate
{
public delegate void DidTapOnBarcodeAROverlay(SBSDKBarcodeScannerResult barcode);
public DidTapOnBarcodeAROverlay DidTapBarcodeOverlay;

public override void DidTapOnBarcode(SBSDKBarcodeTrackingOverlayController controller, SBSDKBarcodeScannerResult barcode)
{
DidTapBarcodeOverlay?.Invoke(barcode);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
<None Include="Info.plist" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Renderers\IOSBarcodeCameraRenderer.cs" />
<Compile Include="Renderers\Extensions.cs" />
<Compile Include="Delegates\BarcodeScannerDelegates.cs" />
<Compile Include="Utils\ViewUtils.cs" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
Expand Down Expand Up @@ -135,12 +138,14 @@
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2612" />
<PackageReference Include="ScanbotSDK.Xamarin.Forms">
<Version>3.10.2</Version>
<Version>4.2.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
<Folder Include="Renderers\" />
<Folder Include="Utils\" />
<Folder Include="Delegates\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Native.Renderers.Example.Forms\Native.Renderers.Example.Forms.csproj">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Foundation;
using ScanbotSDK.iOS;

namespace Native.Renderers.Example.Forms.iOS.Renderers
{
// Since we cannot directly inherit from SBSDKBarcodeScannerViewControllerDelegate in our ViewRenderer,
// we have created this wrapper class to allow binding to its events through the use of delegates
class BarcodeScannerDelegate : SBSDKBarcodeScannerViewControllerDelegate
{
internal bool isScanning = true;
public delegate void OnDetectHandler(SBSDKBarcodeScannerResult[] codes);
public OnDetectHandler OnDetect;

public override void DidDetectBarcodes(SBSDKBarcodeScannerViewController controller, SBSDKBarcodeScannerResult[] codes)
{
if (controller.BarcodeImageGenerationType == SBSDKBarcodeImageGenerationType.CapturedImage)
{
isScanning = false; // it will restrict further scans and stop scanning when the image is captured.
}
OnDetect?.Invoke(codes);
}

public override bool ShouldDetectBarcodes(SBSDKBarcodeScannerViewController controller)
{
return isScanning;
}
}

class BarcodeTrackingOverlayDelegate : SBSDKBarcodeTrackingOverlayControllerDelegate
{
public delegate void DidTapOnBarcodeAROverlay(SBSDKBarcodeScannerResult barcode);
public DidTapOnBarcodeAROverlay DidTapBarcodeOverlay;

[Export("barcodeTrackingOverlay:didTapOnBarcode:")]
public override void DidTapOnBarcode(SBSDKBarcodeTrackingOverlayController controller, SBSDKBarcodeScannerResult barcode)
{
DidTapBarcodeOverlay?.Invoke(barcode);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using ScanbotSDK.iOS;
using ScanbotSDK.Xamarin.Forms;

namespace Native.Renderers.Example.Forms.iOS.Renderers
{
public static class Extension
{
public static SBSDKBarcodeOverlayFormat ToNative(this OverlayFormat overlayTextFormat)
{
switch (overlayTextFormat)
{
case OverlayFormat.None:
return SBSDKBarcodeOverlayFormat.None;
case OverlayFormat.Code:
return SBSDKBarcodeOverlayFormat.Code;
default:
return SBSDKBarcodeOverlayFormat.CodeAndType;
}
}

public static SBSDKBarcodeImageGenerationType ToNative(this BarcodeImageGenerationType imageGenerationType)
{
switch (imageGenerationType)
{
case BarcodeImageGenerationType.None:
return SBSDKBarcodeImageGenerationType.None;
case BarcodeImageGenerationType.CapturedImage:
return SBSDKBarcodeImageGenerationType.CapturedImage;
case BarcodeImageGenerationType.FromVideoFrame:
return SBSDKBarcodeImageGenerationType.FromVideoFrame;
default:
return SBSDKBarcodeImageGenerationType.None;
}
}
}
}
Loading