private void Platform_FetchAuthCode(string oauthUrl)
        {
            authDialog = new Dialog(context);
            var linearLayout = new LinearLayout(authDialog.Context);

            webView = new Android.Webkit.WebView(authDialog.Context);
            linearLayout.AddView(webView);
            authDialog.SetContentView(linearLayout);
            webView.SetWebChromeClient(new WebChromeClient());
            webView.Settings.JavaScriptEnabled = true;
            webView.Settings.DomStorageEnabled = true;
            webView.LoadUrl(oauthUrl);
            webView.SetWebViewClient(new MsaWebViewClient(this));
            authDialog.Show();
            authDialog.SetCancelable(true);
        }
Ejemplo n.º 2
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _webView = this
                       .GetChildren(v => v is Android.Webkit.WebView)
                       .FirstOrDefault() as Android.Webkit.WebView;

            // For some reason, the native WebView requires this internal registration
            // to avoid launching an external task, out of context of the current activity.
            //
            // This will still be used to handle extra activity with the native control.
            _webView.SetWebViewClient(new InternalClient(this));
            _webView.SetWebChromeClient(new InternalWebChromeClient());
            _webView.Settings.JavaScriptEnabled   = true;
            _webView.Settings.DomStorageEnabled   = true;
            _webView.Settings.BuiltInZoomControls = true;
            _webView.Settings.DisplayZoomControls = false;
            _webView.Settings.SetSupportZoom(true);
            _webView.Settings.LoadWithOverviewMode = true;
            _webView.Settings.UseWideViewPort      = true;

            //Allow ThirdPartyCookies by default only on Android 5.0 and UP
            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                Android.Webkit.CookieManager.Instance.SetAcceptThirdPartyCookies(_webView, true);
            }


            // The native webview control requires to have LayoutParameters to function properly.
            _webView.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

            //The nativate WebView already navigate to a blank page if no source is set.
            //Avoid a bug where invoke GoBack() on WebView do nothing in Android 4.4
            this.UpdateFromInternalSource();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called when the element is changed
        /// </summary>
        /// <param name="e">The <see cref="ElementChangedEventArgs{TElement}"/> instance containing the event data.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <PdfWebView> e)
        {
            base.OnElementChanged(e);

            if (this.Control == null)
            {
                var webView = new Android.Webkit.WebView(this.context);

                webView.Settings.JavaScriptEnabled                = true;
                webView.Settings.AllowFileAccess                  = true;
                webView.Settings.DomStorageEnabled                = true;
                webView.Settings.AllowFileAccessFromFileURLs      = true;
                webView.Settings.AllowUniversalAccessFromFileURLs = true;
                webView.SetWebChromeClient(new WebChromeClient());

                this.SetNativeControl(webView);
            }

            if (e.NewElement != null)
            {
                var url = string.Format("file:///android_asset/pdfjs/web/viewer.html?file={0}", string.Format("file:///android_asset/Content/{0}", WebUtility.UrlEncode(Element.Uri)));
                Control.LoadUrl(url);
            }
        }