コード例 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            if (!Resolver.IsSet)
            {
                MainApplication.SetIoc(Application);
            }

            var policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build();

            StrictMode.SetThreadPolicy(policy);

            ToolbarResource   = Resource.Layout.toolbar;
            TabLayoutResource = Resource.Layout.tabs;

            base.OnCreate(bundle);

            // workaround for app compat bug
            // ref https://forums.xamarin.com/discussion/62414/app-resuming-results-in-crash-with-formsappcompatactivity
            Task.Delay(10).Wait();

            Console.WriteLine("A OnCreate");
            if (!App.Utilities.Helpers.InDebugMode())
            {
                Window.AddFlags(WindowManagerFlags.Secure);
            }

            var appIdService = Resolver.Resolve <IAppIdService>();
            var authService  = Resolver.Resolve <IAuthService>();

#if !FDROID
            HockeyApp.Android.CrashManager.Register(this, HockeyAppId,
                                                    new HockeyAppCrashManagerListener(appIdService, authService));
#endif

            Forms.Init(this, bundle);

            typeof(Color).GetProperty("Accent", BindingFlags.Public | BindingFlags.Static)
            .SetValue(null, Color.FromHex("d2d6de"));

            _deviceActionService = Resolver.Resolve <IDeviceActionService>();
            _settings            = Resolver.Resolve <ISettings>();
            _appOptions          = GetOptions();
            LoadApplication(new App.App(
                                _appOptions,
                                Resolver.Resolve <IAuthService>(),
                                Resolver.Resolve <IConnectivity>(),
                                Resolver.Resolve <IDatabaseService>(),
                                Resolver.Resolve <ISyncService>(),
                                _settings,
                                Resolver.Resolve <ILockService>(),
                                Resolver.Resolve <ILocalizeService>(),
                                Resolver.Resolve <IAppInfoService>(),
                                Resolver.Resolve <IAppSettingsService>(),
                                _deviceActionService));

            if (_appOptions?.Uri == null)
            {
                MessagingCenter.Subscribe <Xamarin.Forms.Application, bool>(Xamarin.Forms.Application.Current,
                                                                            "ListenYubiKeyOTP", (sender, listen) => ListenYubiKey(listen));

                MessagingCenter.Subscribe <Xamarin.Forms.Application>(Xamarin.Forms.Application.Current,
                                                                      "FinishMainActivity", (sender) => Finish());
            }
        }
コード例 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            var uri = Intent.GetStringExtra("uri");

            if (Intent.HasExtra("uri"))
            {
                Intent.RemoveExtra("uri");
            }

            if (uri != null && !Resolver.IsSet)
            {
                MainApplication.SetIoc(Application);
            }

            var policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build();

            StrictMode.SetThreadPolicy(policy);

            ToolbarResource   = Resource.Layout.toolbar;
            TabLayoutResource = Resource.Layout.tabs;

            base.OnCreate(bundle);

            // workaround for app compat bug
            // ref https://forums.xamarin.com/discussion/62414/app-resuming-results-in-crash-with-formsappcompatactivity
            Task.Delay(10).Wait();

            Console.WriteLine("A OnCreate");
            Window.SetSoftInputMode(SoftInput.StateHidden);
            Window.AddFlags(WindowManagerFlags.Secure);

            var appIdService = Resolver.Resolve <IAppIdService>();
            var authService  = Resolver.Resolve <IAuthService>();

            HockeyApp.Android.CrashManager.Register(this, HockeyAppId,
                                                    new HockeyAppCrashManagerListener(appIdService, authService));

            Forms.Init(this, bundle);

            typeof(Color).GetProperty("Accent", BindingFlags.Public | BindingFlags.Static)
            .SetValue(null, Color.FromHex("d2d6de"));

            LoadApplication(new App.App(
                                uri,
                                Resolver.Resolve <IAuthService>(),
                                Resolver.Resolve <IConnectivity>(),
                                Resolver.Resolve <IUserDialogs>(),
                                Resolver.Resolve <IDatabaseService>(),
                                Resolver.Resolve <ISyncService>(),
                                Resolver.Resolve <IFingerprint>(),
                                Resolver.Resolve <ISettings>(),
                                Resolver.Resolve <ILockService>(),
                                Resolver.Resolve <IGoogleAnalyticsService>(),
                                Resolver.Resolve <ILocalizeService>()));

            MessagingCenter.Subscribe <Xamarin.Forms.Application>(Xamarin.Forms.Application.Current, "RateApp", (sender) =>
            {
                RateApp();
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application>(Xamarin.Forms.Application.Current, "Accessibility", (sender) =>
            {
                OpenAccessibilitySettings();
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application, VaultListPageModel.Login>(
                Xamarin.Forms.Application.Current, "Autofill", (sender, args) =>
            {
                ReturnCredentials(args);
            });
        }
コード例 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            var uri = Intent.GetStringExtra("uri");

            if (!Resolver.IsSet)
            {
                MainApplication.SetIoc(Application);
            }

            var policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build();

            StrictMode.SetThreadPolicy(policy);

            ToolbarResource   = Resource.Layout.toolbar;
            TabLayoutResource = Resource.Layout.tabs;

            base.OnCreate(bundle);

            // workaround for app compat bug
            // ref https://forums.xamarin.com/discussion/62414/app-resuming-results-in-crash-with-formsappcompatactivity
            Task.Delay(10).Wait();

            Console.WriteLine("A OnCreate");
            if (!App.Utilities.Helpers.InDebugMode())
            {
                Window.AddFlags(WindowManagerFlags.Secure);
            }

            var appIdService = Resolver.Resolve <IAppIdService>();
            var authService  = Resolver.Resolve <IAuthService>();

            HockeyApp.Android.CrashManager.Register(this, HockeyAppId,
                                                    new HockeyAppCrashManagerListener(appIdService, authService));

            Forms.Init(this, bundle);

            typeof(Color).GetProperty("Accent", BindingFlags.Public | BindingFlags.Static)
            .SetValue(null, Color.FromHex("d2d6de"));

            _deviceActionService = Resolver.Resolve <IDeviceActionService>();
            _settings            = Resolver.Resolve <ISettings>();
            LoadApplication(new App.App(
                                uri,
                                Intent.GetBooleanExtra("myVaultTile", false),
                                Resolver.Resolve <IAuthService>(),
                                Resolver.Resolve <IConnectivity>(),
                                Resolver.Resolve <IUserDialogs>(),
                                Resolver.Resolve <IDatabaseService>(),
                                Resolver.Resolve <ISyncService>(),
                                _settings,
                                Resolver.Resolve <ILockService>(),
                                Resolver.Resolve <IGoogleAnalyticsService>(),
                                Resolver.Resolve <ILocalizeService>(),
                                Resolver.Resolve <IAppInfoService>(),
                                Resolver.Resolve <IAppSettingsService>(),
                                _deviceActionService));

            MessagingCenter.Subscribe <Xamarin.Forms.Application>(
                Xamarin.Forms.Application.Current, "DismissKeyboard", (sender) =>
            {
                DismissKeyboard();
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application>(Xamarin.Forms.Application.Current, "RateApp", (sender) =>
            {
                RateApp();
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application>(Xamarin.Forms.Application.Current, "Accessibility", (sender) =>
            {
                OpenAccessibilitySettings();
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application, VaultListPageModel.Login>(
                Xamarin.Forms.Application.Current, "Autofill", (sender, args) =>
            {
                ReturnCredentials(args);
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application>(Xamarin.Forms.Application.Current, "BackgroundApp", (sender) =>
            {
                MoveTaskToBack(true);
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application, string>(
                Xamarin.Forms.Application.Current, "LaunchApp", (sender, args) =>
            {
                LaunchApp(args);
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application, bool>(
                Xamarin.Forms.Application.Current, "ListenYubiKeyOTP", (sender, listen) =>
            {
                ListenYubiKey(listen);
            });
        }