public void Login(Authenticator authenticator)
        {
            authenticator.Completed += AuthenticatorCompleted;

            rootViewController = UIKit.UIApplication.SharedApplication.KeyWindow.RootViewController;
            rootViewController.PresentViewController(authenticator.GetUI(), true, null);
        }
Пример #2
0
        /// <summary>
        /// Gets the UI for this authenticator.
        /// </summary>
        /// <returns>
        /// The UI that needs to be presented.
        /// </returns>
        protected override AuthenticateUIType GetPlatformUI()
        {
            AuthenticateUIType ui = null;

            if (this.IsUsingNativeUI == true)
            {
                Uri uri = GetInitialUrlAsync().Result;
                IDictionary <string, string> query_parts = Utilities.WebEx.FormDecode(uri.Query);
                Uri    redirect_uri = new Uri(query_parts["redirect_uri"]);
                string scheme       = redirect_uri.Scheme;
                if (scheme.StartsWith("http", StringComparison.InvariantCultureIgnoreCase))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("WARNING");
                    sb.AppendLine($"Scheme = {scheme}");
                    sb.AppendLine($"Native UI used with http[s] schema!");
                    sb.AppendLine($"Redirect URL will be loaded in Native UI!");
                    sb.AppendLine($"OAuth Data parsing might fail!");

                    ShowErrorForNativeUI(sb.ToString());
                }
                ui = GetPlatformUINative();
            }
            else
            {
                ui = GetPlatformUIEmbeddedBrowser();
            }

            return(ui);
        }
Пример #3
0
        /// <summary>
        /// Gets the platform  UI (Android - WebView).
        /// </summary>
        /// <returns>
        /// The platform Native UI (embeded/integrated Browser Control/Widget/View (WebView)).
        /// Android.Support.CustomTabs.CustomTabsIntent
        /// </returns>
        /// <see cref="https://components.xamarin.com/gettingstarted/xamandroidsupportcustomtabs"/>
        protected AuthenticateUIType GetPlatformUIEmbeddedBrowser()
        {
            // Embedded Browser - Deprecated
            UIKit.UINavigationController nc = null;
            nc = new UIKit.UINavigationController(new WebAuthenticatorController(this));

            AuthenticateUIType ui = nc;

            return(ui);
        }
 public void MailDebugLog(UIKit.UIViewController viewController)
 {
     if (Release)
     {
         PlotRelease.MailDebugLog(viewController);
     }
     else
     {
         PlotDebug.MailDebugLog(viewController);
     }
 }
Пример #5
0
        protected override void SetTitleAndTabBarItem(UIKit.UIViewController viewController, string title, string iconName)
        {
            // you can override this method to set title or iconName
            if (string.IsNullOrEmpty(title))
            {
                title = "Tab 2";
            }
            if (string.IsNullOrEmpty(iconName))
            {
                iconName = "ic_tabbar_menu";
            }

            base.SetTitleAndTabBarItem(viewController, title, iconName);
        }
        /// <summary>
        /// Gets the UI for this authenticator.
        /// </summary>
        /// <returns>
        /// The UI that needs to be presented.
        /// </returns>
        protected override AuthenticateUIType GetPlatformUI()
        {
            AuthenticateUIType ui = null;

            if (this.IsUsingNativeUI == true)
            {
                ui = GetPlatformUINative();
            }
            else
            {
                ui = GetPlatformUIEmbeddedBrowser();
            }

            return(ui);
        }
Пример #7
0
        static void Hack()
        {
            var l = new UIKit.UILabel();

            l.Text = l.Text + "";

            var tf = new UIKit.UITextField();

            tf.Text           = tf.Text + "";
            tf.EditingDidEnd += delegate { };
            tf.ValueChanged  += delegate { };

            var vc = new UIKit.UIViewController();

            vc.Title   = vc.Title + "";
            vc.Editing = !vc.Editing;
        }
Пример #8
0
        public void OAuth2Authenticator(string clientId, string clientSecret, string scope, Uri authorizeUrl, Uri redirectUrl, Uri accessTokenUrl, GetUsernameAsyncFunc getUsernameAsync = null)
        {
            Xamarin.Auth.OAuth2Authenticator auth2 = new BaseOAuth2Authenticator(clientId, clientSecret, scope, authorizeUrl, redirectUrl, accessTokenUrl, null); // TODO: getUsernameAsync argument not implemented
            auth2.AllowCancel = AllowCancel;
            auth2.Completed  += (sender, eventArgs) =>
            {
                Completed(auth2, new AuthenticatorCompletedEventArgs(new Account(eventArgs.Account, eventArgs.Account.Properties, eventArgs.Account.Username)));
            };
#if __ANDROID__
            Android.Content.Intent intent = auth2.GetUI(Auth.context);
            Auth.context.StartActivity(intent);
#elif __IOS__
            UIKit.UIViewController vc = auth2.GetUI();
            Auth.dialog.PresentViewController(vc, true, null);
#elif SILVERLIGHT
            Uri uri = auth2.GetUI();
            NavigationService.Navigate(uri);
#endif
        }
Пример #9
0
        public virtual void OpenUrl(Uri url)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

#if Android
            var mgr = new Android.Support.CustomTabs.CustomTabsActivityManager((Android.App.Activity)_context);

            mgr.CustomTabsServiceConnected += delegate
            {
                mgr.LaunchUrl(url.ToString());
            };

            mgr.BindService();

            return;
#elif iOS
            Foundation.NSUrl destination = Foundation.NSUrl.FromString(url.AbsoluteUri);

            using (SafariServices.SFSafariViewController sfViewController = new SafariServices.SFSafariViewController(destination))
            {
                UIKit.UIWindow window = UIKit.UIApplication.SharedApplication.KeyWindow;

                UIKit.UIViewController controller = window.RootViewController;

                controller.PresentViewController(sfViewController, true, null);

                return;
            }
#else
            if (_deviceService.RuntimePlatform == RuntimePlatform.Android || _deviceService.RuntimePlatform == RuntimePlatform.iOS)
            {
                throw new InvalidOperationException($"Register {nameof(DefaultBrowserService)} using platform specific {nameof(IPlatformInitializer)}");
            }

            _deviceService.OpenUri(url);
#endif
        }
Пример #10
0
        public void OAuth2Authenticator(string clientId, string scope, Uri authorizeUrl, Uri redirectUrl, string replacementFormatUrl)
        {
            Xamarin.Auth.OAuth2Authenticator auth2 = new BaseOAuth2Authenticator(clientId, scope, authorizeUrl, redirectUrl, replacementFormatUrl);
            auth2.AllowCancel = AllowCancel;
            auth2.Completed  += (sender, eventArgs) =>
            {
                Completed(auth2, new AuthenticatorCompletedEventArgs(new Account(eventArgs.Account, eventArgs.Account.Properties, eventArgs.Account.Username)));
            };
            auth2.Error += (sender, eventArgs) =>
            {
                Error(sender, new AuthenticatorErrorEventArgs(eventArgs.Message, eventArgs.Exception));
            };
#if __ANDROID__
            Android.Content.Intent intent = auth2.GetUI(Auth.context);
            Auth.context.StartActivity(intent);
#elif __IOS__
            UIKit.UIViewController vc = auth2.GetUI();
            Auth.dialog.PresentViewController(vc, true, null);
#elif SILVERLIGHT
            Uri uri = auth2.GetUI();
            NavigationService.Navigate(uri);
#endif
        }
Пример #11
0
        public void OAuth1Authenticator(string consumerKey, string consumerSecret, Uri requestTokenUrl, Uri authorizeUrl, Uri accessTokenUrl, Uri callbackUrl, GetUsernameAsyncFunc getUsernameAsync)
        {
            Xamarin.Auth.OAuth1Authenticator auth1 = new Xamarin.Auth.OAuth1Authenticator(consumerKey, consumerSecret, requestTokenUrl, authorizeUrl, accessTokenUrl, callbackUrl, null); // TODO: getUsernameAsync argument not implemented
            auth1.AllowCancel = AllowCancel;
            auth1.Completed  += (sender, eventArgs) =>
            {
                Completed(auth1, new AuthenticatorCompletedEventArgs(new Account(eventArgs.Account, eventArgs.Account.Properties, eventArgs.Account.Username)));
            };
            auth1.Error += (sender, eventArgs) =>
            {
                Error(sender, new AuthenticatorErrorEventArgs(eventArgs.Message, eventArgs.Exception));
            };
#if __ANDROID__
            Android.Content.Intent intent = auth1.GetUI(Auth.context);
            Auth.context.StartActivity(intent);
#elif __IOS__
            UIKit.UIViewController vc = auth1.GetUI();
            Auth.dialog.PresentViewController(vc, true, null);
#elif SILVERLIGHT
            Uri uri = auth1.GetUI();
            NavigationService.Navigate(uri);
#endif
        }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RoutedViewHost"/> class.
        /// </summary>
        public RoutedViewHost()
        {
            ViewContractObservable = Observable.Return <string>(null);
            _titleUpdater          = new SerialDisposable();

            this.WhenActivated(
                d =>
            {
                d(this
                  .WhenAnyValue(x => x.Router)
                  .Where(x => x != null && x.NavigationStack.Count > 0 && ViewControllers.Length == 0)
                  .Subscribe(x =>
                {
                    _routerInstigated     = true;
                    NSViewController view = null;

                    foreach (var viewModel in x.NavigationStack)
                    {
                        view = ResolveView(Router.GetCurrentViewModel(), null);
                        PushViewController(view, false);
                    }

                    _titleUpdater.Disposable = Router.GetCurrentViewModel()
                                               .WhenAnyValue(y => y.UrlPathSegment)
                                               .Subscribe(y => view.NavigationItem.Title = y);

                    _routerInstigated = false;
                }));

                var navigationStackChanged = this.WhenAnyValue(x => x.Router)
                                             .Where(x => x != null)
                                             .Select(x => x.NavigationStack.ObserveCollectionChanges())
                                             .Switch();

                d(navigationStackChanged
                  .Where(x => x.EventArgs.Action == NotifyCollectionChangedAction.Add)
                  .Select(_ => new { View = ResolveView(Router.GetCurrentViewModel(), /*contract*/ null), Animate = Router.NavigationStack.Count > 1 })
                  .Subscribe(x =>
                {
                    if (_routerInstigated)
                    {
                        return;
                    }

                    _titleUpdater.Disposable = Router.GetCurrentViewModel()
                                               .WhenAnyValue(y => y.UrlPathSegment)
                                               .Subscribe(y => x.View.NavigationItem.Title = y);

                    _routerInstigated = true;

                    // super important that animate is false if it's the first view being pushed, otherwise iOS gets hella confused
                    // and calls PushViewController twice
                    PushViewController(x.View, x.Animate);

                    _routerInstigated = false;
                }));

                d(navigationStackChanged
                  .Where(x => x.EventArgs.Action == NotifyCollectionChangedAction.Reset)
                  .Subscribe(_ =>
                {
                    _routerInstigated = true;
                    PopToRootViewController(true);
                    _routerInstigated = false;
                }));

                d(this
                  .WhenAnyObservable(x => x.Router.NavigateBack)
                  .Subscribe(x =>
                {
                    _routerInstigated = true;
                    PopViewController(true);
                    _routerInstigated = false;
                }));
            });
        }
 public async Task <AuthenticateResult> AuthenticateAsync(UIKit.UIViewController view)
Пример #14
0
        public static void MailDebugLog(UIKit.UIViewController viewController)
        {
            PlotImplementation instance = (PlotImplementation)GetInstance();

            instance.MailDebugLog(viewController);
        }