Skip to content

Commit

Permalink
Merge pull request #125 from doo/mp/qa-raisded-bug-fix
Browse files Browse the repository at this point in the history
Xamarin Forms Acceptance
  • Loading branch information
matthewrindel authored Apr 25, 2024
2 parents ac0d279 + 1fa6218 commit 1a67ae6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
1 change: 1 addition & 0 deletions Scanbot.SDK.Example.Forms.Android/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public override void OnCreate()
// encrypted.
};
SBSDKInitializer.Initialize(this, LICENSE_KEY, configuration);
App.IsEncryptionEnabled = configuration.Encryption != null;
}

string GetDemoStorageBaseDirectory()
Expand Down
7 changes: 5 additions & 2 deletions Scanbot.SDK.Example.Forms.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)
ImagePicker.Forms.iOS.DependencyManager.Register();

Console.WriteLine("Scanbot SDK Example: Initializing Scanbot SDK...");
SBSDKInitializer.Initialize(app, LICENSE_KEY, new SBSDKConfiguration
var configuration = new SBSDKConfiguration
{
EnableLogging = true,
StorageBaseDirectory = GetDemoStorageBaseDirectory(),
Expand All @@ -40,7 +40,10 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)
// Note: all the images and files exported through the SDK will
// not be openable from external applications, since they will be
// encrypted.
});
};

SBSDKInitializer.Initialize(app, LICENSE_KEY, configuration);
App.IsEncryptionEnabled = configuration.Encryption != null;

global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
Expand Down
2 changes: 2 additions & 0 deletions Scanbot.SDK.Example.Forms/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public partial class App : Application
{
public static Color ScanbotRed = Color.FromRgb(200, 25, 60);

public static bool IsEncryptionEnabled = false;

public App()
{
InitializeComponent();
Expand Down
23 changes: 18 additions & 5 deletions Scanbot.SDK.Example.Forms/Pages/ImageDetailPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ async void LoadImage()
{
// If encryption is enabled, load the decrypted document.
// Else accessible via Document or DocumentPreview
Image.Source = await Pages.Instance.SelectedPage.DecryptedDocument();
//Image.Source = Pages.Instance.SelectedPage.Document;
if (App.IsEncryptionEnabled)
{
Image.Source = await Pages.Instance.SelectedPage.DecryptedDocument();
}
else
{
Image.Source = Pages.Instance.SelectedPage.Document;
}
}

async void OnCropButtonClick()
Expand Down Expand Up @@ -103,10 +109,17 @@ async void OnDeleteButtonClick()

private async void OnCheckQualityClick()
{
ImageSource imageSource;
// Please use the DecryptedDocunent() to retrieve the document when encryption is enabled.
//Pages.Instance.SelectedPage.DecryptedDocument();

var imageSource = Pages.Instance.SelectedPage.Document;
if (App.IsEncryptionEnabled)
{
imageSource = await Pages.Instance.SelectedPage.DecryptedDocument();
}
else
{
imageSource = Pages.Instance.SelectedPage.Document;
}

var quality = await SBSDK.Operations.DetectDocumentQualityAsync(imageSource);
await DisplayAlert("Alert", "The Document Quality is: " + quality.ToString(), "Ok");
}
Expand Down
5 changes: 1 addition & 4 deletions Scanbot.SDK.Example.Forms/Pages/ImageResultsPage.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.IO;
using Foundation;
using ScanbotSDK.Xamarin;
using ScanbotSDK.Xamarin.Forms;
using Xamarin.Essentials;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
using Application = Xamarin.Forms.Application;
using ListView = Xamarin.Forms.ListView;

Expand Down Expand Up @@ -111,8 +109,7 @@ async void OnAddButtonClick()
PolygonColor = Color.Red,
PolygonColorOK = Color.Green,
BottomBarBackgroundColor = Color.Blue,
PageCounterButtonTitle = "%d Page(s)",

PageCounterButtonTitle = "%d Page(s)"
};
var result = await SBSDK.UI.LaunchDocumentScannerAsync(configuration);
if (result.Status == OperationResult.Ok)
Expand Down

0 comments on commit 1a67ae6

Please sign in to comment.