using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Plugin.NFC;

namespace WorkFlowCheck.MAUI
{
    [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
    public class MainActivity : MauiAppCompatActivity
    {
        protected async override void OnDestroy()
        {
            SecureStorage.Default.Remove("WFCUser");
            SecureStorage.Default.Remove("AuthToken");
            base.OnDestroy();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            // Plugin NFC: Initialization before base.OnCreate(...) (Important on .NET MAUI)
            CrossNFC.Init(this);

            base.OnCreate(savedInstanceState);
        }
        protected override void OnResume()
        {
            base.OnResume();

            // Plugin NFC: Restart NFC listening on resume (needed for Android 10+) 
            CrossNFC.OnResume();
        }
        protected override void OnNewIntent(Intent intent)
        {
            base.OnNewIntent(intent);

            // Plugin NFC: Tag Discovery Interception
            CrossNFC.OnNewIntent(intent);
        }
    }
}
