Example #1
0
 public override bool OnJsAlert(Android.Webkit.WebView view, string url, string message, JsResult result) {
     if(message.StartsWith("something") { //This is where you would look for your magic string, anything starting with your magic string is what you would extract and/or act on
         //Do something....
         result.Cancel(); //This cancels the JS alert (there are other talked about methods of doing this but this works for me)
         return true; //This tells the WebView "we got this"
     }
     return base.OnJsAlert(view, url, message, result); //Let the WebView handle this since we did not find out special string
 }
Example #2
0
            public override bool OnJsConfirm(WebView view, string url, string message, JsResult result)
            {
                var alertDialogBuilder = new AlertDialog.Builder(context)
                                         .SetMessage(message)
                                         .SetCancelable(false)
                                         .SetPositiveButton("Ok", (sender, args) => {
                    result.Confirm();
                })
                                         .SetNegativeButton("Cancel", (sender, args) => {
                    result.Cancel();
                });

                alertDialogBuilder.Create().Show();

                return(true);
            }
        public override bool OnJsConfirm(WebView view, string url, string message, JsResult result)
        {
            AlertDialog.Builder dialog = new AlertDialog.Builder(_activity);
            AlertDialog         alert  = dialog.Create();

            alert.SetTitle("");
            alert.SetMessage(message);
            alert.SetButton("OK", (c, ev) =>
            {
                result.Confirm();
            });
            alert.SetButton2("Cancel", (c, ev) =>
            {
                result.Cancel();
            });
            alert.Show();
            return(true);
        }
Example #4
0
        /// <summary>
        /// Confirmを表示する
        /// </summary>
        /// <param name="view"></param>
        /// <param name="url"></param>
        /// <param name="message"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public override bool OnJsConfirm(WebView view, string url, string message, JsResult result)
        {
            var dialog = new AlertDialog.Builder(view.Context);
            var dlg    = dialog.SetTitle("?")
                         .SetIcon(ContextCompat.GetDrawable(view.Context, Android.Resource.Drawable.IcDialogAlert))
                         .SetMessage(message)
                         .SetNegativeButton(Android.Resource.String.No, (object sender, DialogClickEventArgs args) =>
            {
                result.Cancel();
            }).SetPositiveButton(Android.Resource.String.Yes, (object sender, DialogClickEventArgs args) =>
            {
                result.Confirm();
            }).
                         Create();

            dlg.SetCanceledOnTouchOutside(false);

            dlg.Show();
            return(true);
        }
        public override bool OnJsAlert(WebView view, string url, string message, JsResult result)
        {
            Logger.Log("JS", message);

            if (message.StartsWith("page count: "))
            {
                int pageCount = int.Parse(message.Split(": ")[1]);

                ChapterLoaded?.Invoke(pageCount);
            }

            if (message == "swipe left")
            {
                SwipeLeft?.Invoke();
            }

            if (message == "swipe right")
            {
                SwipeRight?.Invoke();
            }

            if (message == "swipe down")
            {
                SwipeDown?.Invoke();
            }

            if (message.StartsWith("word selected: "))
            {
                string word     = message.Split(": ")[1].Split('|')[0].Trim().ToLower();
                string sentence = message.Split(": ")[1].Split('|')[1].Trim();

                WordSelected?.Invoke(word, sentence);
            }

            result.Cancel();
            return(true);
        }
 private void CancelAction(object sender, DialogClickEventArgs e)
 {
     _res.Cancel();
 }
            public override bool OnJsConfirm(WebView view, string url, string message, JsResult result)
            {
                var alertDialogBuilder = new AlertDialog.Builder (context)
                    .SetMessage (message)
                    .SetCancelable (false)
                    .SetPositiveButton ("Ok", (sender, args) => {
                        result.Confirm();
                    })
                    .SetNegativeButton ("Cancel", (sender, args) => {
                        result.Cancel();
                    });

                alertDialogBuilder.Create().Show();

                return true;
            }
Example #8
0
 public override bool OnJsConfirm(WebView view, string url, string message, JsResult result)
 {
     new AlertDialog.Builder(_context).SetTitle("提示").SetMessage(message).SetPositiveButton("确定", delegate
     {
         result.Confirm();
     }).SetNegativeButton("取消", delegate { result.Cancel(); }).SetCancelable(false).Create().Show();
     return true;
 }