/// <summary> /// Intercept request. /// </summary> /// <returns>The intercept request.</returns> /// <param name="view">View.</param> /// <param name="request">Request.</param> public override WebResourceResponse ShouldInterceptRequest(Android.Webkit.WebView view, IWebResourceRequest request) { string url = request.Url.ToString(); string ext = MimeTypeMap.GetFileExtensionFromUrl(url); string mime = MimeTypeMap.Singleton.GetMimeTypeFromExtension(ext); if (url.ToLower().Contains("logoff")) { Xamarin.Forms.Device.BeginInvokeOnMainThread(App.Instance.Logout); } else if (request.Url.ToString().Contains("geofenceAutoCreate")) { } else if (mime != null) { HttpURLConnection conn = (HttpURLConnection) new URL(url).OpenConnection(); foreach (var i in request.RequestHeaders) { conn.SetRequestProperty(i.Key, i.Value); } var webResourceResponse = new WebResourceResponse(mime, "UTF-8", conn.InputStream); return(webResourceResponse); } BrowserPage.CheckWebSession(); return(base.ShouldInterceptRequest(view, request)); }
private bool GameTimerCallback() { Count--; if (Count < 0) { timerIsVisible = false; canvasView.InvalidateSurface(); DisplayAlert("Defeat", "You have lost", "Ok").GetAwaiter().OnCompleted(async() => { if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS) { await Navigation.PushAsync(new AdvPage()); } else { BrowserPage browser = new BrowserPage(); await Navigation.PushAsync(browser); browser.Navigate(App.Rest.advUrl); } }); return(false); } else { canvasView.InvalidateSurface(); return(true); } }
private async void ShowAd() { if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS) { await Navigation.PushAsync(new AdvPage()); } else { BrowserPage browser = new BrowserPage(); await Navigation.PushAsync(browser); browser.Navigate(App.Rest.advUrl); } }
protected override void OnCreate(Bundle bundle) { GhostlyLog.BrowserPage.HomeLocation = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; SeriousGames.HomeLocation = GhostlyLog.BrowserPage.HomeLocation; base.OnCreate(bundle); Forms.Init(this, bundle); Instance = this; this.RequestPermissions(new String[] { Manifest.Permission.ReadExternalStorage, }, 1); SetContentView(Resource.Layout.GhostlyLogMain); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = SeriousGames.GetPatientDirectory(SeriousGames.CurrentPatient); FolderPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData)); BrowserPage mainPage = new BrowserPage(VersionTracking.CurrentVersion); mainPage.DetailedPageRequested += MainPage_DetailedPageRequested; var mainFragment = mainPage.CreateSupportFragment(this); //FragmentManager // .BeginTransaction() // .Replace(Resource.Id.fragment_frame_layout, mainFragment) // .Commit(); SupportFragmentManager.BackStackChanged += (sender, e) => { bool hasBack = SupportFragmentManager.BackStackEntryCount > 0; SupportActionBar.SetHomeButtonEnabled(hasBack); SupportActionBar.SetDisplayHomeAsUpEnabled(hasBack); SupportActionBar.Title = hasBack ? "Detailed report" : "Ghostly Log"; }; }
private async void OnWrongConfiguration(object sender, ConfigEventArgs args) { const float degreeStep = 15.0f; const int delayMicrosecond = 15; int FRow = args.FRow; int FCol = args.FCol; int SRow = args.SRow; int SCol = args.SCol; int soundId = rnd.Next(defeats.Length); await defeats[soundId].PlaySoundAsync(); tiles[FRow][FCol].IsRotating = true; tiles[SRow][SCol].IsRotating = true; await Task.Delay(1000); while (tiles[FRow][FCol].Deg <= 90 - degreeStep) { await Task.Delay(delayMicrosecond); await Device.InvokeOnMainThreadAsync(() => tiles[FRow][FCol].Deg = tiles[FRow][FCol].Deg + degreeStep); await Device.InvokeOnMainThreadAsync(() => tiles[SRow][SCol].Deg = tiles[SRow][SCol].Deg + degreeStep); } while (tiles[FRow][FCol].Deg >= 0 + degreeStep) { await Task.Delay(delayMicrosecond); await Device.InvokeOnMainThreadAsync(() => tiles[FRow][FCol].Deg = tiles[FRow][FCol].Deg - degreeStep); await Device.InvokeOnMainThreadAsync(() => tiles[SRow][SCol].Deg = tiles[SRow][SCol].Deg - degreeStep); } await Device.InvokeOnMainThreadAsync(() => tiles[FRow][FCol].Deg = 0); await Device.InvokeOnMainThreadAsync(() => tiles[SRow][SCol].Deg = 0); tiles[FRow][FCol].IsRotating = false; tiles[SRow][SCol].IsRotating = false; //// _Busy.Release(); bool cond1 = tiles[FRow][FCol].WasTapped; bool cond2 = tiles[SRow][SCol].WasTapped; if (cond1 || cond2) { ErrorCounter++; if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS) { await Navigation.PushAsync(new AdvPage()); } else { BrowserPage browser = new BrowserPage(); await Navigation.PushAsync(browser); browser.Navigate(App.Rest.advUrl); } } tiles[FRow][FCol].WasTapped = true; tiles[SRow][SCol].WasTapped = true; tiles[FRow][FCol].Flipped = false; tiles[SRow][SCol].Flipped = false; }
public static bool canInitWithRequest(NSUrlRequest request) { BrowserPage.CheckWebSession(); if (request.Body != null) { if (request.Body.ToString().Contains("Logoff")) { Device.BeginInvokeOnMainThread(App.Instance.Logout); } else if (request.Url.ToString().Contains("localisation")) { return(!request.Body.ToString().Contains("Longitude") && !request.Body.ToString().Contains("Latitude") && request.Body.ToString().Contains("pheidiparams")); } else if (request.Url.ToString().Contains("geofenceAutoCreate")) { return(!CurrentlyProcessingRequestLocaly); } } if (request.Url.ToString().Contains("ImportImage")) { try { var param = request.Body.ToString().Split('&'); PheidiParams pp = new PheidiParams(); int index = 0; for (int i = 0; i < param.Length; i++) { if (param[i].Contains("pheidiparams")) { pp.Load(WebUtility.UrlDecode(param[i])); index = i; } } Task.Run(async() => { string answer = ""; if (pp.ContainsKey("FIELDVALUE")) { if (!string.IsNullOrEmpty(pp["FIELDVALUE"])) { var dic = new Dictionary <string, string>(); dic.Add("OTHERFIELD", pp["FIELD"]); dic.Add("NOSEQ", pp["NOSEQ"]); dic.Add("FIELD", pp["FIELD"]); string p = ""; foreach (var d in dic) { p += d.Key + "**:**" + d.Value + "**,**"; } var parameters = new Dictionary <string, string> { { "pheidiaction", "GetFieldValueFromOtherField" }, { "pheidiparams", p } }; HttpResponseMessage response = await PheidiNetworkManager.SendHttpRequestAsync(parameters, new TimeSpan(0, 0, 30)); if (response != null) { if (response.StatusCode == HttpStatusCode.OK) { string responseContent = response.Content.ReadAsStringAsync().Result; Debug.WriteLine("Reponse:" + responseContent); try { answer = PheidiNetworkManager.GetFields(responseContent)[0][dic["FIELD"]] as string; } catch (Exception e) { Debug.WriteLine(e.Message); } } } } } if (!string.IsNullOrEmpty(answer)) { var p = ""; var dic = new Dictionary <string, string>(); dic.Add("FIELD", pp["FIELD"]); dic.Add("NOSEQ", pp["NOSEQ"]); dic.Add("VALUE", "NULL"); foreach (var d in dic) { p += d.Key + "**:**" + d.Value + "**,**"; } var parameters = new Dictionary <string, string> { { "pheidiaction", "UpdateFieldValue" }, { "pheidiparams", p } }; var response = await PheidiNetworkManager.SendHttpRequestAsync(parameters, new TimeSpan(0, 0, 30)); if (response != null) { if (response.StatusCode == HttpStatusCode.OK) { var responseContent = response.Content.ReadAsStringAsync().Result; Debug.WriteLine("Reponse:" + responseContent); } } } else { Device.BeginInvokeOnMainThread(() => { UIAlertController actionSheetAlert = UIAlertController.Create(null, null, UIAlertControllerStyle.ActionSheet); // Add Actions var a1 = UIAlertAction.Create(AppResources.CameraFileChooser, UIAlertActionStyle.Default, (action) => ImageHelper.ImageImport(UIImagePickerControllerSourceType.Camera, request)); a1.SetValueForKey(new UIImage("camera.png"), new NSString("image")); actionSheetAlert.AddAction(a1); var a2 = UIAlertAction.Create(AppResources.GaleriePhotoFileChooser, UIAlertActionStyle.Default, (action) => ImageHelper.ImageImport(UIImagePickerControllerSourceType.PhotoLibrary, request)); a2.SetValueForKey(new UIImage("sort.png"), new NSString("image")); actionSheetAlert.AddAction(a2); actionSheetAlert.AddAction(UIAlertAction.Create(AppResources.AnnulerBouton, UIAlertActionStyle.Cancel, null)); UIViewController rootView = UIApplication.SharedApplication.KeyWindow.RootViewController; //Setting du popoverPresentationController, obligatoire pour iPad if (Device.Idiom == TargetIdiom.Tablet) { actionSheetAlert.PopoverPresentationController.SourceView = rootView.View; var width = rootView.View.Bounds.Width; var height = rootView.View.Bounds.Height; Debug.WriteLine("Width: " + width + ", Height: " + height); actionSheetAlert.PopoverPresentationController.SourceRect = new CGRect(width / 4, 3 * height / 4, width / 2, height / 4); actionSheetAlert.PopoverPresentationController.WillReposition += (sender, e) => { //Changement d'orientation if (width > height != rootView.View.Bounds.Width > rootView.View.Bounds.Height) { actionSheetAlert.DismissViewController(false, null); } }; actionSheetAlert.PopoverPresentationController.PermittedArrowDirections = 0; } rootView.PresentViewController(actionSheetAlert, true, null); }); } }); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } return(false); }
public void AfterMethod() { BrowserPage.Close(); }
public void GivenIAmOnGoogleSearchPage() { BrowserPage.GotoUrl("http://google.com"); }
public void BeforeScenario() { BrowserPage.InstantiateDriver(); }