2026-06-12 16:06:37 +02:00
|
|
|
using System;
|
2026-06-15 10:19:24 +02:00
|
|
|
using System.Threading.Tasks;
|
2026-06-12 16:06:37 +02:00
|
|
|
using Android.App;
|
2026-06-15 10:19:24 +02:00
|
|
|
using Android.Content;
|
2026-06-12 16:06:37 +02:00
|
|
|
using Android.Runtime;
|
|
|
|
|
using Avalonia;
|
|
|
|
|
using Avalonia.Android;
|
2026-06-15 10:19:24 +02:00
|
|
|
using PalladiumWallet.App.Services;
|
2026-06-12 16:06:37 +02:00
|
|
|
using PalladiumWallet.Core.Storage;
|
|
|
|
|
|
|
|
|
|
namespace PalladiumWallet.Mobile;
|
|
|
|
|
|
|
|
|
|
// In Avalonia 12 l'AppBuilder Android si configura nella sottoclasse Application
|
|
|
|
|
// (AvaloniaAndroidApplication<TApp>), non più nell'Activity. allowBackup=false:
|
|
|
|
|
// il file wallet cifrato/seed non deve finire nei backup cloud automatici.
|
2026-06-15 08:49:51 +02:00
|
|
|
[Application(Label = "Palladium Wallet", AllowBackup = false,
|
|
|
|
|
Icon = "@mipmap/ic_launcher", RoundIcon = "@mipmap/ic_launcher_round")]
|
2026-06-12 16:06:37 +02:00
|
|
|
public class MainApplication : AvaloniaAndroidApplication<global::PalladiumWallet.App.App>
|
|
|
|
|
{
|
|
|
|
|
public MainApplication(IntPtr javaReference, JniHandleOwnership transfer)
|
|
|
|
|
: base(javaReference, transfer)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnCreate()
|
|
|
|
|
{
|
|
|
|
|
AppPaths.OverrideDataRoot = FilesDir?.AbsolutePath;
|
2026-06-15 10:19:24 +02:00
|
|
|
|
|
|
|
|
// Registra lo scanner QR: apre ScannerActivity e ne attende il risultato.
|
|
|
|
|
PlatformServices.ScanQrAsync = async () =>
|
|
|
|
|
{
|
|
|
|
|
var activity = MainActivity.Current;
|
|
|
|
|
if (activity == null) return null;
|
|
|
|
|
var tcs = new TaskCompletionSource<string?>();
|
|
|
|
|
MainActivity.ScanTcs = tcs;
|
|
|
|
|
activity.StartActivityForResult(
|
|
|
|
|
new Intent(activity, typeof(ScannerActivity)),
|
|
|
|
|
MainActivity.ScanRequestCode);
|
|
|
|
|
return await tcs.Task;
|
|
|
|
|
};
|
|
|
|
|
|
2026-06-12 16:06:37 +02:00
|
|
|
base.OnCreate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) =>
|
|
|
|
|
base.CustomizeAppBuilder(builder).WithInterFont();
|
|
|
|
|
}
|