Skip to content

Commit 55e2afa

Browse files
Merge pull request #173 from doo/develop
Xamarin Barcode SDK 4.2.0
2 parents f5ab25c + 8f10126 commit 55e2afa

32 files changed

+2020
-19743
lines changed

Example.Forms/ScanbotBarcodeSDKFormsExample.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="io.scanbot.example.sdk.barcode.xamarin.forms">
3-
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
3+
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
44
<application android:label="ScanbotBarcodeSDK.Example.Forms" android:requestLegacyExternalStorage="true"></application>
55
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
66
<uses-permission android:name="android.permission.CAMERA" />

Example.Forms/ScanbotBarcodeSDKFormsExample.Android/ScanbotBarcodeSDKFormsExample.Android.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
1616
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
1717
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
18-
<TargetFrameworkVersion>v12.0</TargetFrameworkVersion>
18+
<TargetFrameworkVersion>v13.0</TargetFrameworkVersion>
1919
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
2020
<AndroidUseAapt2>true</AndroidUseAapt2>
21+
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
2122
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
2223
<NuGetPackageImportStamp>
2324
</NuGetPackageImportStamp>
@@ -53,16 +54,16 @@
5354
<Reference Include="System.Numerics.Vectors" />
5455
</ItemGroup>
5556
<ItemGroup>
57+
<PackageReference Include="ScanbotBarcodeSDK.Xamarin.Forms">
58+
<Version>4.2.0</Version>
59+
</PackageReference>
5660
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2578" />
5761
<PackageReference Include="Scanbot.Xamarin.Forms.ImagePicker">
5862
<Version>0.0.2</Version>
5963
</PackageReference>
6064
<PackageReference Include="Xamarin.Essentials">
6165
<Version>1.7.7</Version>
6266
</PackageReference>
63-
<PackageReference Include="ScanbotBarcodeSDK.Xamarin.Forms">
64-
<Version>4.0.2</Version>
65-
</PackageReference>
6667
</ItemGroup>
6768
<ItemGroup>
6869
<Compile Include="MainActivity.cs" />

Example.Forms/ScanbotBarcodeSDKFormsExample.iOS/ScanbotBarcodeSDKFormsExample.iOS.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,12 @@
125125
<Reference Include="System.Numerics.Vectors" />
126126
</ItemGroup>
127127
<ItemGroup>
128+
<PackageReference Include="ScanbotBarcodeSDK.Xamarin.Forms" Version="4.2.0" />
128129
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2578" />
129130
<PackageReference Include="Xamarin.Essentials" Version="1.7.7" />
130131
<PackageReference Include="Scanbot.Xamarin.Forms.ImagePicker">
131132
<Version>0.0.2</Version>
132133
</PackageReference>
133-
<PackageReference Include="ScanbotBarcodeSDK.Xamarin.Forms">
134-
<Version>4.0.2</Version>
135-
</PackageReference>
136134
</ItemGroup>
137135
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
138136
<Import Project="..\ScanbotBarcodeSDKFormsExample\ScanbotBarcodeSDKFormsExample.projitems" Label="Shared" />

Example.Forms/ScanbotBarcodeSDKFormsExample/BarcodeResultsPage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public BarcodeResultsPage(ImageSource source, List<Barcode> barcodes = null)
6565
if (barcodes == null)
6666
{
6767
//var copy = Utils.Copy(source);
68-
DetectBarcodes(Utils.Copy(source), delegate
68+
DetectBarcodes(Utils.Copy(SnappedImage.Source), delegate
6969
{
7070
InitializeList();
7171
Container.Children.Remove(Loader);
@@ -84,7 +84,7 @@ public BarcodeResultsPage(ImageSource source, List<Barcode> barcodes = null)
8484

8585
async void DetectBarcodes(ImageSource source, Action callback = null)
8686
{
87-
//Barcodes = await SBSDK.Operations.DetectBarcodesFrom(source);
87+
Barcodes = await SBSDK.Operations.DetectBarcodesFromImage(new DetectBarcodesOnImageConfiguration(source));
8888
callback();
8989
}
9090

Example.Forms/ScanbotBarcodeSDKFormsExample/MainPage.cs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public MainPage()
3535
{
3636
CreateCell("RTU UI - BARCODE SCANNER", RTUUIClicked()),
3737
CreateCell("RTU UI WITH BARCODE IMAGE", RTUUIWithImageClicked()),
38+
CreateCell("RTU UI WITH AR OVERLAY", RTUUIWithARClicked()),
3839
CreateCell("RTU UI - BATCH BARCODE SCANNER", BatchClicked()),
3940
CreateCell("PICK IMAGE FROM LIBRARY", ImportButtonClicked()),
4041
CreateCell("SET ACCEPTED BARCODE TYPES", BarcodeButtonClicked()),
@@ -99,7 +100,30 @@ EventHandler RTUUIWithImageClicked()
99100
await Navigation.PushAsync(new BarcodeResultsPage(result.Image, result.Barcodes));
100101
}
101102
};
102-
}
103+
}
104+
105+
EventHandler RTUUIWithARClicked()
106+
{
107+
return async (sender, e) =>
108+
{
109+
if (!Utils.CheckLicense(this))
110+
{
111+
return;
112+
}
113+
var config = GetScannerConfiguration(false);
114+
config.OverlayConfiguration = new SelectionOverlayConfiguration(automaticSelectionEnabled: false,
115+
overlayFormat: BarcodeDialogFormat.TypeAndCode,
116+
polygon: Color.Yellow,
117+
text: Color.Yellow,
118+
textContainer: Color.Black);
119+
TestCloseView(false);
120+
var result = await SBSDK.Scanner.Open(config);
121+
if (result.Status == OperationResult.Ok)
122+
{
123+
await Navigation.PushAsync(new BarcodeResultsPage(result.Barcodes));
124+
}
125+
};
126+
}
103127

104128
EventHandler BatchClicked()
105129
{
@@ -108,7 +132,7 @@ EventHandler BatchClicked()
108132
var configuration = new BatchBarcodeScannerConfiguration
109133
{
110134
AcceptedFormats = BarcodeTypes.Instance.AcceptedTypes,
111-
OverlayConfiguration = new SelectionOverlayConfiguration(Color.Yellow, Color.Yellow, Color.Black, automaticSelectionEnabled: true)
135+
OverlayConfiguration = new SelectionOverlayConfiguration(automaticSelectionEnabled: true, overlayFormat: BarcodeDialogFormat.TypeAndCode, Color.Yellow, Color.Yellow, Color.Black)
112136
};
113137

114138
TestCloseView(true);
@@ -210,22 +234,7 @@ BarcodeScannerConfiguration GetScannerConfiguration(bool withImage)
210234
{
211235
AcceptedFormats = BarcodeTypes.Instance.AcceptedTypes,
212236
SuccessBeepEnabled = true,
213-
OverlayConfiguration = new SelectionOverlayConfiguration (
214-
polygon: Color.Yellow,
215-
text: Color.Yellow,
216-
textContainer: Color.Black,
217-
automaticSelectionEnabled: true,
218-
highlightedPolygonColor: Color.Pink,
219-
highlightedTextColor: Color.Red,
220-
highlightedTextContainerColor: Color.PeachPuff),
221-
ConfirmationDialogConfiguration = new BarcodeConfirmationDialogConfiguration {
222-
ResultWithConfirmation = true,
223-
Title = "Barcode Results",
224-
Message = "The barcode results are shown below.",
225-
ConfirmButtonTitle = "Confirm!",
226-
RetryButtonTitle = "Try Again!",
227-
DialogTextFormat = BarcodeDialogFormat.TypeAndCode
228-
}
237+
ConfirmationDialogConfiguration = new BarcodeConfirmationDialogConfiguration { ResultWithConfirmation = true }
229238
};
230239

231240
if (withImage)

Example/Droid/BarcodeScannerExample.Droid.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
1919
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
2020
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
21+
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
2122
</PropertyGroup>
2223
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2324
<DebugSymbols>true</DebugSymbols>
@@ -154,7 +155,7 @@
154155
</ItemGroup>
155156
<ItemGroup>
156157
<PackageReference Include="ScanbotBarcodeSDK.Xamarin">
157-
<Version>4.0.2</Version>
158+
<Version>4.2.0</Version>
158159
</PackageReference>
159160
<PackageReference Include="Scanbot.Xamarin.ImagePicker">
160161
<Version>0.0.2</Version>

Example/Droid/MainActivity.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ protected override void OnCreate(Bundle savedInstanceState)
3636
FindViewById<TextView>(Resource.Id.barcode_camerax_demo).Click += OnBarcodeCameraXDemoClick;
3737
FindViewById<TextView>(Resource.Id.rtu_ui).Click += OnRTUUIClick;
3838
FindViewById<TextView>(Resource.Id.rtu_ui_image).Click += OnRTUUIImageClick;
39+
FindViewById<TextView>(Resource.Id.rtu_ui_aroverlay).Click += OnRTUUIAROverlayClick;
3940
FindViewById<TextView>(Resource.Id.batch_rtu_ui).Click += OnBatchRTUUIClick;
4041
FindViewById<TextView>(Resource.Id.rtu_ui_import).Click += OnImportClick;
4142
FindViewById<TextView>(Resource.Id.settings).Click += OnSettingsClick;
@@ -81,6 +82,15 @@ private void OnRTUUIImageClick(object sender, EventArgs e)
8182
StartBarcodeScannerActivity(BarcodeImageGenerationType.VideoFrame);
8283
}
8384

85+
private void OnRTUUIAROverlayClick(object sender, EventArgs e)
86+
{
87+
if (!Alert.CheckLicense(this, SDK))
88+
{
89+
return;
90+
}
91+
StartBarcodeScannerActivityWithAROverlay();
92+
}
93+
8494
private void OnBatchRTUUIClick(object sender, EventArgs e)
8595
{
8696
if (!Alert.CheckLicense(this, SDK))
@@ -154,15 +164,22 @@ void StartBarcodeScannerActivity(BarcodeImageGenerationType type)
154164
var list = BarcodeTypes.Instance.AcceptedTypes;
155165
configuration.SetBarcodeFormatsFilter(list);
156166
configuration.SetBarcodeImageGenerationType(type);
167+
var intent = BarcodeScannerActivity.NewIntent(this, configuration);
168+
StartActivityForResult(intent, BARCODE_DEFAULT_UI_REQUEST_CODE);
169+
}
170+
171+
void StartBarcodeScannerActivityWithAROverlay()
172+
{
173+
var configuration = new BarcodeScannerConfiguration();
174+
var list = BarcodeTypes.Instance.AcceptedTypes;
175+
configuration.SetBarcodeFormatsFilter(list);
157176
configuration.SetSelectionOverlayConfiguration(new IO.Scanbot.Sdk.UI.View.Barcode.SelectionOverlayConfiguration(
158177
overlayEnabled: true,
159178
automaticSelectionEnabled: false,
160179
textFormat: IO.Scanbot.Sdk.Barcode.UI.BarcodeOverlayTextFormat.Code,
161180
polygonColor: Color.Yellow,
162181
textColor: Color.Yellow,
163-
textContainerColor: Color.Black,
164-
highlightedPolygonColor: Color.Pink,
165-
highlightedTextColor: Color.Purple)
182+
textContainerColor: Color.Black)
166183
);
167184

168185
var intent = BarcodeScannerActivity.NewIntent(this, configuration);
@@ -174,17 +191,7 @@ void StartBatchBarcodeScannerActivity()
174191
var configuration = new BatchBarcodeScannerConfiguration();
175192
var list = BarcodeTypes.Instance.AcceptedTypes;
176193
configuration.SetBarcodeFormatsFilter(list);
177-
configuration.SetSelectionOverlayConfiguration(new IO.Scanbot.Sdk.UI.View.Barcode.SelectionOverlayConfiguration(
178-
overlayEnabled: true,
179-
automaticSelectionEnabled: false,
180-
textFormat: IO.Scanbot.Sdk.Barcode.UI.BarcodeOverlayTextFormat.Code,
181-
polygonColor: Color.Yellow,
182-
textColor: Color.Yellow,
183-
textContainerColor: Color.Black,
184-
highlightedPolygonColor: Color.Pink,
185-
highlightedTextColor: Color.Purple)
186-
);
187-
var intent = BatchBarcodeScannerActivity.NewIntent(this, configuration, null);
194+
var intent = BatchBarcodeScannerActivity.NewIntent(this, configuration);
188195
StartActivityForResult(intent, BARCODE_DEFAULT_UI_REQUEST_CODE);
189196
}
190197

0 commit comments

Comments
 (0)