コード例 #1
0
        public override void ViewDidLoad()
        {
            SetIoc();
            SetCulture();

            base.ViewDidLoad();
            View.BackgroundColor    = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
            _context.ExtContext     = ExtensionContext;
            _googleAnalyticsService = Resolver.Resolve <IGoogleAnalyticsService>();
            _lockService            = Resolver.Resolve <ILockService>();

            if (!_setupHockeyApp)
            {
                var appIdService         = Resolver.Resolve <IAppIdService>();
                var crashManagerDelegate = new HockeyAppCrashManagerDelegate(appIdService, Resolver.Resolve <IAuthService>());
                var manager = HockeyApp.iOS.BITHockeyManager.SharedHockeyManager;
                manager.Configure("51f96ae568ba45f699a18ad9f63046c3", crashManagerDelegate);
                manager.CrashManager.CrashManagerStatus = HockeyApp.iOS.BITCrashManagerStatus.AutoSend;
                manager.UserId = appIdService.AppId;
                manager.StartManager();
                manager.Authenticator.AuthenticateInstallation();
                _setupHockeyApp = true;
            }

            foreach (var item in ExtensionContext.InputItems)
            {
                var processed = false;
                foreach (var itemProvider in item.Attachments)
                {
                    if (ProcessWebUrlProvider(itemProvider) ||
                        ProcessFindLoginProvider(itemProvider) ||
                        ProcessFindLoginBrowserProvider(itemProvider, Constants.UTTypeAppExtensionFillBrowserAction) ||
                        ProcessFindLoginBrowserProvider(itemProvider, Constants.UTTypeAppExtensionFillWebViewAction) ||
                        ProcessSaveLoginProvider(itemProvider) ||
                        ProcessChangePasswordProvider(itemProvider) ||
                        ProcessExtensionSetupProvider(itemProvider))
                    {
                        processed = true;
                        break;
                    }
                }

                if (processed)
                {
                    break;
                }
            }
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            SetIoc();
            SetCulture();
            base.ViewDidLoad();
            _context                = new Context();
            _context.ExtContext     = ExtensionContext;
            _googleAnalyticsService = Resolver.Resolve <IGoogleAnalyticsService>();
            _settings               = Resolver.Resolve <ISettings>();

            if (!_setupHockeyApp)
            {
                var appIdService         = Resolver.Resolve <IAppIdService>();
                var crashManagerDelegate = new HockeyAppCrashManagerDelegate(appIdService, Resolver.Resolve <IAuthService>());
                var manager = HockeyApp.iOS.BITHockeyManager.SharedHockeyManager;
                manager.Configure("51f96ae568ba45f699a18ad9f63046c3", crashManagerDelegate);
                manager.CrashManager.CrashManagerStatus = HockeyApp.iOS.BITCrashManagerStatus.AutoSend;
                manager.UserId = appIdService.AppId;
                manager.StartManager();
                manager.Authenticator.AuthenticateInstallation();
                _setupHockeyApp = true;
            }
        }
コード例 #3
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Forms.Init();

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

            _lockService       = Resolver.Resolve <ILockService>();
            _deviceInfoService = Resolver.Resolve <IDeviceInfoService>();
            _pushHandler       = new iOSPushNotificationHandler(Resolver.Resolve <IPushNotificationListener>());
            _nfcDelegate       = new NFCReaderDelegate((success, message) => ProcessYubikey(success, message));
            var appIdService = Resolver.Resolve <IAppIdService>();

            var crashManagerDelegate = new HockeyAppCrashManagerDelegate(
                appIdService, Resolver.Resolve <IAuthService>());
            var manager = BITHockeyManager.SharedHockeyManager;

            manager.Configure("51f96ae568ba45f699a18ad9f63046c3", crashManagerDelegate);
            manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
            manager.UserId = appIdService.AppId;
            manager.StartManager();
            manager.Authenticator.AuthenticateInstallation();
            manager.DisableMetricsManager = manager.DisableFeedbackManager = manager.DisableUpdateManager = true;

            LoadApplication(new App.App(
                                null,
                                Resolver.Resolve <IAuthService>(),
                                Resolver.Resolve <IConnectivity>(),
                                Resolver.Resolve <IDatabaseService>(),
                                Resolver.Resolve <ISyncService>(),
                                Resolver.Resolve <ISettings>(),
                                _lockService,
                                Resolver.Resolve <ILocalizeService>(),
                                Resolver.Resolve <IAppInfoService>(),
                                Resolver.Resolve <IAppSettingsService>(),
                                Resolver.Resolve <IDeviceActionService>()));

            // Appearance stuff

            var primaryColor = new UIColor(red: 0.24f, green: 0.55f, blue: 0.74f, alpha: 1.0f);
            var grayLight    = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f);

            UINavigationBar.Appearance.ShadowImage = new UIImage();
            UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
            UIBarButtonItem.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor;
            UIButton.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).SetTitleColor(primaryColor,
                                                                                                 UIControlState.Normal);
            UIButton.AppearanceWhenContainedIn(new Type[] { typeof(UISearchBar) }).TintColor = primaryColor;
            UIStepper.Appearance.TintColor = grayLight;
            UISlider.Appearance.TintColor  = primaryColor;

            MessagingCenter.Subscribe <Xamarin.Forms.Application, ToolsExtensionPage>(
                Xamarin.Forms.Application.Current, "ShowAppExtension", (sender, page) =>
            {
                var itemProvider           = new NSItemProvider(new NSDictionary(), Core.Constants.UTTypeAppExtensionSetup);
                var extensionItem          = new NSExtensionItem();
                extensionItem.Attachments  = new NSItemProvider[] { itemProvider };
                var activityViewController = new UIActivityViewController(new NSExtensionItem[] { extensionItem }, null);
                activityViewController.CompletionHandler = (activityType, completed) =>
                {
                    page.EnabledExtension(completed && activityType == "com.8bit.bitwarden.find-login-action-extension");
                };

                var modal = UIApplication.SharedApplication.KeyWindow.RootViewController.ModalViewController;
                if (activityViewController.PopoverPresentationController != null)
                {
                    activityViewController.PopoverPresentationController.SourceView = modal.View;
                    var frame     = UIScreen.MainScreen.Bounds;
                    frame.Height /= 2;
                    activityViewController.PopoverPresentationController.SourceRect = frame;
                }

                modal.PresentViewController(activityViewController, true, null);
            });

            MessagingCenter.Subscribe <Xamarin.Forms.Application, bool>(Xamarin.Forms.Application.Current,
                                                                        "ListenYubiKeyOTP", (sender, listen) =>
            {
                if (_deviceInfoService.NfcEnabled)
                {
                    _nfcSession?.InvalidateSession();
                    _nfcSession?.Dispose();
                    _nfcSession = null;
                    if (listen)
                    {
                        _nfcSession = new NFCNdefReaderSession(_nfcDelegate, null, true);
                        _nfcSession.AlertMessage = AppResources.HoldYubikeyNearTop;
                        _nfcSession.BeginSession();
                    }
                }
            });

            UIApplication.SharedApplication.StatusBarHidden = false;
            UIApplication.SharedApplication.StatusBarStyle  = UIStatusBarStyle.LightContent;

            MessagingCenter.Subscribe <Xamarin.Forms.Application, bool>(Xamarin.Forms.Application.Current,
                                                                        "ShowStatusBar", (sender, show) =>
            {
                UIApplication.SharedApplication.SetStatusBarHidden(!show, false);
            });

            ZXing.Net.Mobile.Forms.iOS.Platform.Init();
            return(base.FinishedLaunching(app, options));
        }