예제 #1
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            var webView = (TencentWebView)sender;

            if (e.PropertyName == TencentWebView.UrlProperty.PropertyName)
            {
                tencentWebView.LoadUrl(webView.Url);
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <TencentWebView> e)
        {
            mRelativeLayout = Inflate(Context, Resource.Layout.WebViewLayout, null) as Android.Widget.RelativeLayout;

            tencentWebView = mRelativeLayout.FindViewById <Com.Tencent.Smtt.Sdk.WebView>(Resource.Id.forum_context);
            tencentWebView.Settings.JavaScriptCanOpenWindowsAutomatically = true;
            //x变量非null表示启用x5内核成功
            var x = tencentWebView.X5WebViewExtension;

            tencentWebView.SetMinimumWidth(100);
            tencentWebView.SetMinimumHeight(800);
            SetNativeControl(mRelativeLayout);
            //tencentWebView.LoadUrl("http://soft.imtt.qq.com/browser/tes/feedback.html");
            tencentWebView.LoadUrl("https://www.qq.com");
            //tencentWebView.LoadUrl("https://debugtbs.qq.com");
        }
예제 #3
0
 public override bool ShouldOverrideUrlLoading(Com.Tencent.Smtt.Sdk.WebView view, string url)
 {
     if (url.IndexOf("https://oauth.cnblogs.com/auth/callback#code=") > -1)
     {
         var codeindex  = url.IndexOf("#code=") + 6;
         var tokenindex = url.IndexOf("&id_token=");
         var code       = url.Substring(codeindex, tokenindex - codeindex);
         if (code != "")
         {
             (renderer.Element as AuthorizeView).OnAuthorizeStarted(new AuthorizeStartedEventArgs
             {
                 Code = code
             });
         }
         view.StopLoading();
         return(true);
     }
     else
     {
         view.LoadUrl(url);
         return(true);
     }
 }
예제 #4
0
        protected override void OnElementChanged(ElementChangedEventArgs <TencentWebView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                // Unsubscribe from event handlers and cleanup any resources
            }

            if (e.NewElement != null)
            {
                if (Control == null)
                {
                    // Instantiate the native control and assign it to the Control property with
                    // the SetNativeControl method
                    mRelativeLayout = Inflate(Context, Resource.Layout.WebViewLayout, null) as Android.Widget.RelativeLayout;

                    tencentWebView = mRelativeLayout.FindViewById <Com.Tencent.Smtt.Sdk.WebView>(Resource.Id.forum_context);
                    tencentWebView.Settings.JavaScriptCanOpenWindowsAutomatically = true;
                    //x变量非null表示启用x5内核成功
                    var x = tencentWebView.X5WebViewExtension;
                    tencentWebView.SetMinimumWidth(100);
                    tencentWebView.SetMinimumHeight(800);
                    //tencentWebView.SetLayerType();
                    tencentWebView.Settings.UseWideViewPort      = true;
                    tencentWebView.Settings.LoadWithOverviewMode = true;
                    tencentWebView.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn);
                    tencentWebView.Settings.TextZoom   = 100;
                    tencentWebView.DrawingCacheEnabled = true;

                    SetNativeControl(mRelativeLayout);
                    tencentWebView.LoadUrl(e.NewElement.Url);
                }
                // Configure the control and subscribe to event handlers
            }
        }