From f82b4e40bad5acfbca64721f76f3c904a3861b89 Mon Sep 17 00:00:00 2001 From: Shane Harris Date: Thu, 1 Aug 2019 15:17:01 +0100 Subject: [PATCH 1/6] Added support for sidequest protocol in the browser webview - only the first item --- BeatOn/ToastInjectorWebViewClient.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/BeatOn/ToastInjectorWebViewClient.cs b/BeatOn/ToastInjectorWebViewClient.cs index 4fadfc4..f97c71a 100644 --- a/BeatOn/ToastInjectorWebViewClient.cs +++ b/BeatOn/ToastInjectorWebViewClient.cs @@ -11,6 +11,7 @@ using Android.Webkit; using Android.Widget; using BeatOn.ClientModels; +using Newtonsoft.Json; namespace BeatOn { @@ -61,6 +62,19 @@ public override bool ShouldOverrideUrlLoading(WebView view, IWebResourceRequest return true; } + else if (lowerUrl.StartsWith("sidequest://bsaber-multi/#")) + { + string dlurls = url.Substring(26) + .Replace("%22,%22", "\",\"") + .Replace("[%22", "[\"") + .Replace("%22]", "\"]"); + JArray urls = JArray.Parse(json); + if(urls.Count > 0) + { + Download?.Invoke(this, urls[0]); + return true; + } + } else if (lowerUrl.StartsWith("beatsaver://")) { string dlurl = url.Substring(12); @@ -74,4 +88,4 @@ public override WebResourceResponse ShouldInterceptRequest(WebView view, IWebRes return base.ShouldInterceptRequest(view, request); } } -} \ No newline at end of file +} From c474e3ab123211a734d9dee56b8a3718b441d20b Mon Sep 17 00:00:00 2001 From: Shane Harris Date: Thu, 1 Aug 2019 15:32:09 +0100 Subject: [PATCH 2/6] iterating over the urls array rather than the first one --- BeatOn/ToastInjectorWebViewClient.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/BeatOn/ToastInjectorWebViewClient.cs b/BeatOn/ToastInjectorWebViewClient.cs index f97c71a..883bc4b 100644 --- a/BeatOn/ToastInjectorWebViewClient.cs +++ b/BeatOn/ToastInjectorWebViewClient.cs @@ -68,12 +68,18 @@ public override bool ShouldOverrideUrlLoading(WebView view, IWebResourceRequest .Replace("%22,%22", "\",\"") .Replace("[%22", "[\"") .Replace("%22]", "\"]"); + JArray urls = JArray.Parse(json); + if(urls.Count > 0) { - Download?.Invoke(this, urls[0]); + for (int i = 0; i < urls.Count; i++) + { + Download?.Invoke(this, urls[i]); + } return true; } + } else if (lowerUrl.StartsWith("beatsaver://")) { From e866fd978a59dd68d4552fc701691664c29ba201 Mon Sep 17 00:00:00 2001 From: Shane Harris Date: Thu, 1 Aug 2019 16:36:52 +0100 Subject: [PATCH 3/6] fixed a bunch of syntax/import errors. --- BeatOn/ToastInjectorWebViewClient.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BeatOn/ToastInjectorWebViewClient.cs b/BeatOn/ToastInjectorWebViewClient.cs index 883bc4b..043d21e 100644 --- a/BeatOn/ToastInjectorWebViewClient.cs +++ b/BeatOn/ToastInjectorWebViewClient.cs @@ -11,7 +11,7 @@ using Android.Webkit; using Android.Widget; using BeatOn.ClientModels; -using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace BeatOn { @@ -69,13 +69,13 @@ public override bool ShouldOverrideUrlLoading(WebView view, IWebResourceRequest .Replace("[%22", "[\"") .Replace("%22]", "\"]"); - JArray urls = JArray.Parse(json); + JArray urls = JArray.Parse(dlurls); if(urls.Count > 0) { for (int i = 0; i < urls.Count; i++) { - Download?.Invoke(this, urls[i]); + Download?.Invoke(this, (string) urls[i]); } return true; } From 1ed834b725c3a13a14326e65df69ce9330fcaa7f Mon Sep 17 00:00:00 2001 From: Shane Harris Date: Thu, 1 Aug 2019 16:52:17 +0100 Subject: [PATCH 4/6] added sidequest to the top links --- frontend/src/app/browser-nav/browser-nav.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/app/browser-nav/browser-nav.component.ts b/frontend/src/app/browser-nav/browser-nav.component.ts index cf1db07..fa309c2 100644 --- a/frontend/src/app/browser-nav/browser-nav.component.ts +++ b/frontend/src/app/browser-nav/browser-nav.component.ts @@ -12,6 +12,7 @@ export class BrowserNavComponent implements OnInit { browserLinks: any[] = [ { title: 'Beast Saber', url: 'https://bsaber.com' }, { title: 'Beat Saver', url: 'https://beatsaver.com' }, + { title: 'SideQuest', url: 'https://sidequestvr.com/#/apps/4' }, { title: 'Google', url: 'https://google.com' }, { title: 'Mods', url: 'https://github.com/RedBrumbler/BeatOnCustomSabers' }, ]; From e34f7824563a2255086f506721f4ed79ce410274 Mon Sep 17 00:00:00 2001 From: Shane Harris Date: Thu, 1 Aug 2019 16:53:21 +0100 Subject: [PATCH 5/6] commented out the github link to RB sabers --- frontend/src/app/browser-nav/browser-nav.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/browser-nav/browser-nav.component.ts b/frontend/src/app/browser-nav/browser-nav.component.ts index fa309c2..cdcbec3 100644 --- a/frontend/src/app/browser-nav/browser-nav.component.ts +++ b/frontend/src/app/browser-nav/browser-nav.component.ts @@ -14,7 +14,7 @@ export class BrowserNavComponent implements OnInit { { title: 'Beat Saver', url: 'https://beatsaver.com' }, { title: 'SideQuest', url: 'https://sidequestvr.com/#/apps/4' }, { title: 'Google', url: 'https://google.com' }, - { title: 'Mods', url: 'https://github.com/RedBrumbler/BeatOnCustomSabers' }, + // { title: 'Mods', url: 'https://github.com/RedBrumbler/BeatOnCustomSabers' }, ]; @Output() linkSelected = new EventEmitter(); From 45535d9b0d6dd1af1ccb39e8b608467af2ec266e Mon Sep 17 00:00:00 2001 From: Shane Harris Date: Thu, 1 Aug 2019 17:54:21 +0100 Subject: [PATCH 6/6] set desktop mode with user agent --- BeatOn/MainActivity.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BeatOn/MainActivity.cs b/BeatOn/MainActivity.cs index c3c22b8..95d0ddd 100644 --- a/BeatOn/MainActivity.cs +++ b/BeatOn/MainActivity.cs @@ -144,7 +144,9 @@ protected override void OnCreate(Bundle savedInstanceState) _browserView= FindViewById(Resource.Id.webView2); _toastInjector = new ToastInjectorWebViewClient(_browserView); _browserView.SetWebViewClient(_toastInjector); - _browserView.Settings.UserAgentString += " BeatOn_Quest/" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + // _browserView.Settings.UserAgentString += " BeatOn_Quest/" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + _browserView.Settings.UserAgentString = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36" + + " BeatOn_Quest /" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); _browserView.SetWebChromeClient(new WebChromeClient()); _browserView.Settings.JavaScriptEnabled = true; _browserView.Settings.AllowContentAccess = true;