コード例 #1
0
            public override void OnProgressChanged(global::Android.Webkit.WebView view, int newProgress)
            {
                if (newProgress == 100)
                {
                    new Android.OS.Handler().PostDelayed(() =>
                    {
                        try
                        {
                            var newContentHeight = view.ContentHeight;

                            if (newContentHeight == 0 || customWebViewRenderer == null)
                            {
                                return;
                            }
                            var element           = customWebViewRenderer.Element;
                            element.HeightRequest = newContentHeight;
                        }
                        catch (System.Exception ex)
                        {
                            DependencyService.Get <ILog>().SaveLog("HtmlWebChromeClient", ex);
                        }
                    }, 225);
                }
                base.OnProgressChanged(view, newProgress);
            }
コード例 #2
0
ファイル: CookieWebClient.cs プロジェクト: mfreedm52/My-Notes
        public override void OnPageFinished(global::Android.Webkit.WebView view, string url)
        {
            var cookieHeader = CookieManager.Instance.GetCookie(url);
            var cookies      = new CookieCollection();
            var cookiePairs  = cookieHeader.Split('&');

            foreach (var cookiePair in cookiePairs)
            {
                var cookiePieces = cookiePair.Split('=');
                if (cookiePieces[0].Contains(":"))
                {
                    cookiePieces[0] = cookiePieces[0].Substring(0, cookiePieces[0].IndexOf(":"));
                }
                cookies.Add(new Cookie
                {
                    Name  = cookiePieces[0],
                    Value = cookiePieces[1]
                });
            }

            _cookieWebView.OnNavigated(new CookieNavigatedEventArgs
            {
                Cookies = cookies,
                Url     = url
            });
        }
コード例 #3
0
    protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.WebView> e)
    {
        try
        {
            base.OnElementChanged(e);
            if (this.Control != null)
            {
                var webView = new global::Android.Webkit.WebView(this.Context);
                var view    = (ExtendedWebView)Element;


                Control.Settings.JavaScriptEnabled = true;
                Control.Settings.SetSupportZoom(false);
                Control.Settings.DomStorageEnabled    = true;
                Control.Settings.LoadWithOverviewMode = true;
                Control.Settings.UseWideViewPort      = true;
                Control.Settings.CacheMode            = CacheModes.NoCache;
                Control.Settings.SetSupportMultipleWindows(true);
                Control.Settings.JavaScriptCanOpenWindowsAutomatically = true;
                Control.AddJavascriptInterface(new PayUJavaScriptInterface(this.Context), "PayUMoney");          //JavaInterface

                url_s = "https://test.payu.in/_payment";



                Control.PostUrl(url_s, Encoding.UTF8.GetBytes(getPostString()));

                Control.SetWebViewClient(webViewClient);
            }
        }
        catch (System.Exception ex)
        {
        }
    }
コード例 #4
0
        public override void OnPageStarted(global::Android.Webkit.WebView view, string url, Bitmap favicon)
        {
            if (_renderer?.Element == null || url == HybridWebViewRenderer.AssetBaseUrl)
            {
                return;
            }

            var args = new WebNavigatingEventArgs(WebNavigationEvent.NewPage, new UrlWebViewSource {
                Url = url
            }, url);

            _renderer.ElementController.SendNavigating(args);
            _navigationResult = WebNavigationResult.Success;

            _renderer.UpdateCanGoBackForward();

            if (args.Cancel)
            {
                _renderer.Control.StopLoading();
            }
            else
            {
                base.OnPageStarted(view, url, favicon);
            }
        }
コード例 #5
0
    public IPlatformHandle CreateControl(bool isSecond, IPlatformHandle parent, Func <IPlatformHandle> createDefault)
    {
        var parentContext = (parent as AndroidViewControlHandle)?.View.Context
                            ?? global::Android.App.Application.Context;

        if (isSecond)
        {
            var webView = new global::Android.Webkit.WebView(parentContext);
            webView.LoadUrl("https://www.android.com/");

            return(new AndroidViewControlHandle(webView));
        }
        else
        {
            var button = new global::Android.Widget.Button(parentContext)
            {
                Text = "Hello world"
            };
            var clickCount = 0;
            button.Click += (sender, args) =>
            {
                clickCount++;
                button.Text = $"Click count {clickCount}";
            };

            return(new AndroidViewControlHandle(button));
        }
    }
コード例 #6
0
        public override bool OnShowFileChooser(global::Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            base.OnShowFileChooser(webView, filePathCallback, fileChooserParams);

            var chooserIntent = fileChooserParams.CreateIntent();
            RegisterCustomFileUploadActivity(filePathCallback, chooserIntent, fileChooserParams.Title);

            return true;
        }
コード例 #7
0
 public override void OnReceivedError(global::Android.Webkit.WebView view, IWebResourceRequest request, WebResourceError error)
 {
     _navigationResult = WebNavigationResult.Failure;
     if (error.ErrorCode == ClientError.Timeout)
     {
         _navigationResult = WebNavigationResult.Timeout;
     }
     base.OnReceivedError(view, request, error);
 }
コード例 #8
0
ファイル: CookieWebClient.cs プロジェクト: mfreedm52/My-Notes
        public override void OnPageStarted(global::Android.Webkit.WebView view, string url, Bitmap favicon)
        {
            base.OnPageStarted(view, url, favicon);

            _cookieWebView.OnNavigating(new CookieNavigationEventArgs
            {
                Url = url
            });
        }
コード例 #9
0
        public override bool OnShowFileChooser(global::Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            if (fileChooserParams is null)
            {
                throw new ArgumentNullException(nameof(fileChooserParams));
            }

            base.OnShowFileChooser(webView, filePathCallback, fileChooserParams);
            return(ChooseFile(filePathCallback, fileChooserParams.CreateIntent(), fileChooserParams.Title));
        }
        public unsafe void StartAssistantLocation(global::Android.Webkit.WebView p0)
        {
            if (id_startAssistantLocation_Landroid_webkit_WebView_ == IntPtr.Zero)
            {
                id_startAssistantLocation_Landroid_webkit_WebView_ = JNIEnv.GetMethodID(class_ref, "startAssistantLocation", "(Landroid/webkit/WebView;)V");
            }
            JValue *__args = stackalloc JValue [1];

            __args [0] = new JValue((p0 == null) ? IntPtr.Zero : ((global::Java.Lang.Object)p0).Handle);
            JNIEnv.CallVoidMethod(((global::Java.Lang.Object) this).Handle, id_startAssistantLocation_Landroid_webkit_WebView_, __args);
        }
コード例 #11
0
        public unsafe void EnableAssistantLocation(global::Android.Webkit.WebView p0)
        {
            const string __id = "enableAssistantLocation.(Landroid/webkit/WebView;)V";

            try {
                JniArgumentValue *__args = stackalloc JniArgumentValue [1];
                __args [0] = new JniArgumentValue((p0 == null) ? IntPtr.Zero : ((global::Java.Lang.Object)p0).Handle);
                _members.InstanceMethods.InvokeAbstractVoidMethod(__id, this, __args);
            } finally {
            }
        }
コード例 #12
0
        public override void OnReceivedError(global::Android.Webkit.WebView view, ClientError errorCode, string description, string failingUrl)
        {
            _navigationResult = WebNavigationResult.Failure;
            if (errorCode == ClientError.Timeout)
            {
                _navigationResult = WebNavigationResult.Timeout;
            }
#pragma warning disable 618
            base.OnReceivedError(view, errorCode, description, failingUrl);
#pragma warning restore 618
        }
コード例 #13
0
        public AndroidBridge(global::Android.Webkit.WebView webViewControl, Activity activity)
        {
            this.webViewControl = webViewControl;

            var javaScriptMessageHandler =
                new JavaScriptMessageHandler(activity)
            {
                NotifyAction = this.WebViewControlScriptNotify
            };

            webViewControl.AddJavascriptInterface(javaScriptMessageHandler, "NotifyCs");
        }
コード例 #14
0
 public static unsafe void SetDisableJSChromeClient(global::Android.Webkit.WebView p0)
 {
     if (id_setDisableJSChromeClient_Landroid_webkit_WebView_ == IntPtr.Zero)
     {
         id_setDisableJSChromeClient_Landroid_webkit_WebView_ = JNIEnv.GetStaticMethodID(class_ref, "setDisableJSChromeClient", "(Landroid/webkit/WebView;)V");
     }
     try {
         JValue *__args = stackalloc JValue [1];
         __args [0] = new JValue(p0);
         JNIEnv.CallStaticVoidMethod(class_ref, id_setDisableJSChromeClient_Landroid_webkit_WebView_, __args);
     } finally {
     }
 }
コード例 #15
0
 public static unsafe void OnResume(global::Android.Webkit.WebView p0)
 {
     if (id_onResume_Landroid_webkit_WebView_ == IntPtr.Zero)
     {
         id_onResume_Landroid_webkit_WebView_ = JNIEnv.GetStaticMethodID(class_ref, "onResume", "(Landroid/webkit/WebView;)V");
     }
     try {
         JValue *__args = stackalloc JValue [1];
         __args [0] = new JValue(p0);
         JNIEnv.CallStaticVoidMethod(class_ref, id_onResume_Landroid_webkit_WebView_, __args);
     } finally {
     }
 }
コード例 #16
0
 public override unsafe void SetClient(global::Android.Webkit.WebView p0)
 {
     if (id_setClient_Landroid_webkit_WebView_ == IntPtr.Zero)
     {
         id_setClient_Landroid_webkit_WebView_ = JNIEnv.GetMethodID(class_ref, "setClient", "(Landroid/webkit/WebView;)V");
     }
     try {
         JValue *__args = stackalloc JValue [1];
         __args [0] = new JValue(p0);
         JNIEnv.CallVoidMethod(((global::Java.Lang.Object) this).Handle, id_setClient_Landroid_webkit_WebView_, __args);
     } finally {
     }
 }
コード例 #17
0
 public static unsafe void OnPause(global::Android.Webkit.WebView p0, bool p1)
 {
     if (id_onPause_Landroid_webkit_WebView_Z == IntPtr.Zero)
     {
         id_onPause_Landroid_webkit_WebView_Z = JNIEnv.GetStaticMethodID(class_ref, "onPause", "(Landroid/webkit/WebView;Z)V");
     }
     try {
         JValue *__args = stackalloc JValue [2];
         __args [0] = new JValue(p0);
         __args [1] = new JValue(p1);
         JNIEnv.CallStaticVoidMethod(class_ref, id_onPause_Landroid_webkit_WebView_Z, __args);
     } finally {
     }
 }
コード例 #18
0
            // Override the page started call to trigger the Navigating callback

            /*public override void OnPageStarted(global::Android.Webkit.WebView view, string url, Bitmap favicon)
             * {
             *  if (_renderer.Element == null || url == WebViewRenderer.AssetBaseUrl)
             *      return;
             *  var args = new WebNavigatingEventArgs(WebNavigationEvent.NewPage, new UrlWebViewSource { Url = url }, url);
             *  _renderer.ElementController.SendNavigating(args);
             *  _navigationResult = WebNavigationResult.Success;
             *  _renderer.UpdateCanGoBackForward();
             *
             *  if (args.Cancel)
             *  {
             *      _renderer.Control.StopLoading();
             *  }
             *  else
             *  {
             *      base.OnPageStarted(view, url, favicon);
             *  }
             * }
             */

            // Hackish solution to the Xamarin ERR_UNKNOWN_URL_SCHEME issue plaguing the latest releases
            // TODO: find a better way to handle the Navigating event without triggering a page load
            public override bool ShouldOverrideUrlLoading(global::Android.Webkit.WebView view, string url)
            {
                var args = new WebNavigatingEventArgs(WebNavigationEvent.NewPage, new UrlWebViewSource {
                    Url = url
                }, url);

                _renderer.ElementController.SendNavigating(args);
                if (args.Cancel)
                {
                    return(true);
                }

                return(false);
            }
コード例 #19
0
            public override void OnPageFinished(global::Android.Webkit.WebView view, string url)
            {
                if (_renderer.Element == null || url == WebViewRenderer.AssetBaseUrl)
                {
                    return;
                }
                var source = new UrlWebViewSource {
                    Url = url
                };
                var args = new WebNavigatedEventArgs(WebNavigationEvent.NewPage, source, url, _navigationResult);

                _renderer.ElementController.SendNavigated(args);
                _renderer.UpdateCanGoBackForward();
                base.OnPageFinished(view, url);
            }
コード例 #20
0
 public override void OnPageFinished(global::Android.Webkit.WebView view, string url)
 {
     Console.WriteLine("Finished =" + url);
     if (url.Contains("https://localhost:52457/Finalize.aspx"))
     {
         HybridWebViewPage hyPage = new HybridWebViewPage();
         hyPage.GetResp(url);
         view.Destroy();
         view.GoBack();
     }
     else
     {
         // base.OnPageFinished(view, url);
     }
 }
コード例 #21
0
        public override void OnPageFinished(global::Android.Webkit.WebView myWebview, string url)
        {
            PdfDocument document = new PdfDocument();

            PdfDocument.Page page = document.StartPage(new PdfDocument.PageInfo.Builder(width, height, 1).Create());

            myWebview.Draw(page.Canvas);
            document.FinishPage(page);
            Stream filestream = new MemoryStream();

            Java.IO.FileOutputStream fos = new Java.IO.FileOutputStream(fileNameWithPath, false);
            document.WriteTo(filestream);
            fos.Write(((MemoryStream)filestream).ToArray(), 0, (int)filestream.Length);
            fos.Close();
        }
コード例 #22
0
        protected virtual unsafe bool ProcessRedirectUrl(global::Android.Webkit.WebView view, string url)
        {
            const string __id       = "processRedirectUrl.(Landroid/webkit/WebView;Ljava/lang/String;)Z";
            IntPtr       native_url = JNIEnv.NewString(url);

            try {
                JniArgumentValue *__args = stackalloc JniArgumentValue [2];
                __args [0] = new JniArgumentValue((view == null) ? IntPtr.Zero : ((global::Java.Lang.Object)view).Handle);
                __args [1] = new JniArgumentValue(native_url);
                var __rm = _members.InstanceMethods.InvokeVirtualBooleanMethod(__id, this, __args);
                return(__rm);
            } finally {
                JNIEnv.DeleteLocalRef(native_url);
                global::System.GC.KeepAlive(view);
            }
        }
コード例 #23
0
 public override void OnPageStarted(global::Android.Webkit.WebView view, string url, Bitmap favicon)
 {
     Console.WriteLine("Started=" + url);
     if (url.Contains("https://localhost:52457/Finalize.aspx"))
     {
         //if (WebCallBack.mySelf != null)
         //{
         //    string pos = "";
         //    pos = "Finally value is updated";
         //    WebCallBack.mySelf.receivedNewPosition(pos);
         //}
     }
     else
     {
         //  base.OnPageStarted(view, url, favicon);
     }
 }
コード例 #24
0
        public static unsafe void H5UT(string jsonStr, global::Android.Webkit.WebView view)
        {
            if (id_h5UT_Ljava_lang_String_Landroid_webkit_WebView_ == IntPtr.Zero)
            {
                id_h5UT_Ljava_lang_String_Landroid_webkit_WebView_ = JNIEnv.GetStaticMethodID(class_ref, "h5UT", "(Ljava/lang/String;Landroid/webkit/WebView;)V");
            }
            IntPtr native_jsonStr = JNIEnv.NewString(jsonStr);

            try {
                JValue *__args = stackalloc JValue [2];
                __args [0] = new JValue(native_jsonStr);
                __args [1] = new JValue(view);
                JNIEnv.CallStaticVoidMethod(class_ref, id_h5UT_Ljava_lang_String_Landroid_webkit_WebView_, __args);
            } finally {
                JNIEnv.DeleteLocalRef(native_jsonStr);
            }
        }
コード例 #25
0
        public string SafeHTMLToPDF(string html, string filename, int flag)
        {
            global::Android.Webkit.WebView webpage = null;
            //var dir = new Java.IO.File(global::Android.OS.Environment.DirectoryDocuments + "/KegIdFiles/");
            var dir = new Java.IO.File(global::Android.OS.Environment.GetExternalStoragePublicDirectory(Environment.CurrentDirectory) + "/KegIdFiles/");

            var file = new Java.IO.File(dir + "/" + filename + ".pdf");

            if (!dir.Exists())
            {
                dir.Mkdirs();
            }

            int x = 0;

            while (file.Exists())
            {
                x++;
                file = new Java.IO.File(dir + "/" + filename + "( " + x + " ).pdf");
            }

            if (webpage == null)
            {
                webpage = new global::Android.Webkit.WebView(Application.Context);
            }

            int height;
            int width;

            if (flag == 0)
            {
                width  = 2959;
                height = 3873;
            }
            else
            {
                width  = 3659;
                height = 4573;
            }
            webpage.Layout(0, 0, width, height);
            webpage.LoadDataWithBaseURL("", html, "text/html", "UTF-8", null);
            webpage.SetWebViewClient(new WebViewCallBack(file.ToString(), flag));

            return(file.ToString());
        }
コード例 #26
0
            public override bool ShouldOverrideUrlLoading(global::Android.Webkit.WebView view, string url)
            {
                var args = new WebNavigatingEventArgs(WebNavigationEvent.NewPage, new UrlWebViewSource {
                    Url = url
                }, url);

                try
                {
                    _renderer.ElementController.SendNavigating(args);
                }catch (Exception e)
                {
                    Logging.error("Exception in should override url loading {0}", e);
                }
                if (args.Cancel)
                {
                    return(true);
                }
                return(false);
            }
コード例 #27
0
        public virtual unsafe void RemoveJavascriptInterface(global::Android.Webkit.WebView p0)
        {
            if (id_removeJavascriptInterface_Landroid_webkit_WebView_ == IntPtr.Zero)
            {
                id_removeJavascriptInterface_Landroid_webkit_WebView_ = JNIEnv.GetMethodID(class_ref, "removeJavascriptInterface", "(Landroid/webkit/WebView;)V");
            }
            try {
                JValue *__args = stackalloc JValue [1];
                __args [0] = new JValue(p0);

                if (GetType() == ThresholdType)
                {
                    JNIEnv.CallVoidMethod(((global::Java.Lang.Object) this).Handle, id_removeJavascriptInterface_Landroid_webkit_WebView_, __args);
                }
                else
                {
                    JNIEnv.CallNonvirtualVoidMethod(((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID(ThresholdClass, "removeJavascriptInterface", "(Landroid/webkit/WebView;)V"), __args);
                }
            } finally {
            }
        }
        public unsafe PKeyAuthChallengeHandler(global::Android.Webkit.WebView view, global::Com.Microsoft.Identity.Common.Internal.UI.Webview.Challengehandlers.IAuthorizationCompletionCallback completionCallback) : base(IntPtr.Zero, JniHandleOwnership.DoNotTransfer)
        {
            const string __id = "(Landroid/webkit/WebView;Lcom/microsoft/identity/common/internal/ui/webview/challengehandlers/IAuthorizationCompletionCallback;)V";

            if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero)
            {
                return;
            }

            try {
                JniArgumentValue *__args = stackalloc JniArgumentValue [2];
                __args [0] = new JniArgumentValue((view == null) ? IntPtr.Zero : ((global::Java.Lang.Object)view).Handle);
                __args [1] = new JniArgumentValue((completionCallback == null) ? IntPtr.Zero : ((global::Java.Lang.Object)completionCallback).Handle);
                var __r = _members.InstanceMethods.StartCreateInstance(__id, ((object)this).GetType(), __args);
                SetHandle(__r.Handle, JniHandleOwnership.TransferLocalRef);
                _members.InstanceMethods.FinishCreateInstance(__id, this, __args);
            } finally {
                global::System.GC.KeepAlive(view);
                global::System.GC.KeepAlive(completionCallback);
            }
        }
コード例 #29
0
        public override void OnPageFinished(global::Android.Webkit.WebView view, string url)
        {
            if (_renderer?.Element == null || url == HybridWebViewRenderer.AssetBaseUrl)
            {
                return;
            }

            var source = new UrlWebViewSource {
                Url = url
            };

            _renderer.IgnoreSourceChanges = true;
            _renderer.ElementController.SetValueFromRenderer(HybridWebView.SourceProperty, source);
            _renderer.IgnoreSourceChanges = false;

            var args = new WebNavigatedEventArgs(WebNavigationEvent.NewPage, source, url, _navigationResult);

            _renderer.ElementController.SendNavigated(args);

            _renderer.UpdateCanGoBackForward();

            base.OnPageFinished(view, url);
        }
コード例 #30
0
        public unsafe ExposedJsApi(global::Android.App.Activity p0, global::Android.Webkit.WebView p1, string p2, bool p3)
            : base(IntPtr.Zero, JniHandleOwnership.DoNotTransfer)
        {
            if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero)
            {
                return;
            }

            IntPtr native_p2 = JNIEnv.NewString(p2);

            try {
                JValue *__args = stackalloc JValue [4];
                __args [0] = new JValue(p0);
                __args [1] = new JValue(p1);
                __args [2] = new JValue(native_p2);
                __args [3] = new JValue(p3);
                if (((object)this).GetType() != typeof(ExposedJsApi))
                {
                    SetHandle(
                        global::Android.Runtime.JNIEnv.StartCreateInstance(((object)this).GetType(), "(Landroid/app/Activity;Landroid/webkit/WebView;Ljava/lang/String;Z)V", __args),
                        JniHandleOwnership.TransferLocalRef);
                    global::Android.Runtime.JNIEnv.FinishCreateInstance(((global::Java.Lang.Object) this).Handle, "(Landroid/app/Activity;Landroid/webkit/WebView;Ljava/lang/String;Z)V", __args);
                    return;
                }

                if (id_ctor_Landroid_app_Activity_Landroid_webkit_WebView_Ljava_lang_String_Z == IntPtr.Zero)
                {
                    id_ctor_Landroid_app_Activity_Landroid_webkit_WebView_Ljava_lang_String_Z = JNIEnv.GetMethodID(class_ref, "<init>", "(Landroid/app/Activity;Landroid/webkit/WebView;Ljava/lang/String;Z)V");
                }
                SetHandle(
                    global::Android.Runtime.JNIEnv.StartCreateInstance(class_ref, id_ctor_Landroid_app_Activity_Landroid_webkit_WebView_Ljava_lang_String_Z, __args),
                    JniHandleOwnership.TransferLocalRef);
                JNIEnv.FinishCreateInstance(((global::Java.Lang.Object) this).Handle, class_ref, id_ctor_Landroid_app_Activity_Landroid_webkit_WebView_Ljava_lang_String_Z, __args);
            } finally {
                JNIEnv.DeleteLocalRef(native_p2);
            }
        }