feat(android): QR code scanner for Send address field

Camera2 + ZXing.Net 0.16.9 activity (ScannerActivity) that captures JPEG
frames at ~2.5 fps and decodes QR codes without Xamarin dependencies.
Result is returned to MainActivity via OnActivityResult/TaskCompletionSource.
PlatformServices.ScanQrAsync seam wires Android head to shared App layer;
ScanQrCommand in the Send ViewModel strips BIP21 URI scheme/query parameters.
CAMERA permission and uses-feature added to AndroidManifest.
This commit is contained in:
2026-06-15 10:19:24 +02:00
parent 8476eeb247
commit bfee0dde03
8 changed files with 292 additions and 5 deletions
+23 -2
View File
@@ -1,11 +1,12 @@
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Avalonia.Android;
namespace PalladiumWallet.Mobile;
// Activity di avvio. La configurazione dell'app (tipo App, font) è nella
// MainApplication (AvaloniaAndroidApplication<App>). Qui basta il launcher.
[Activity(
Label = "Palladium Wallet",
Theme = "@style/MyTheme.NoActionBar",
@@ -13,4 +14,24 @@ namespace PalladiumWallet.Mobile;
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
public class MainActivity : AvaloniaMainActivity
{
internal const int ScanRequestCode = 9001;
internal static TaskCompletionSource<string?>? ScanTcs;
internal static MainActivity? Current;
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
Current = this;
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent? data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode == ScanRequestCode)
{
var text = resultCode == Result.Ok ? data?.GetStringExtra(ScannerActivity.ResultKey) : null;
ScanTcs?.TrySetResult(text);
ScanTcs = null;
}
}
}