Skip to content

Commit

Permalink
Merge pull request #69 from emulamer/sq-mod-dl
Browse files Browse the repository at this point in the history
Added support for sidequest protocol + desktop mode in browser
  • Loading branch information
emulamer authored Aug 29, 2019
2 parents 09a009a + 45535d9 commit 12e68b2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 3 additions & 1 deletion BeatOn/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ protected override void OnCreate(Bundle savedInstanceState)
_browserView= FindViewById<WebView>(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;
Expand Down
22 changes: 21 additions & 1 deletion BeatOn/ToastInjectorWebViewClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Android.Webkit;
using Android.Widget;
using BeatOn.ClientModels;
using Newtonsoft.Json.Linq;

namespace BeatOn
{
Expand Down Expand Up @@ -61,6 +62,25 @@ 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(dlurls);

if(urls.Count > 0)
{
for (int i = 0; i < urls.Count; i++)
{
Download?.Invoke(this, (string) urls[i]);
}
return true;
}

}
else if (lowerUrl.StartsWith("beatsaver://"))
{
string dlurl = url.Substring(12);
Expand All @@ -74,4 +94,4 @@ public override WebResourceResponse ShouldInterceptRequest(WebView view, IWebRes
return base.ShouldInterceptRequest(view, request);
}
}
}
}
3 changes: 2 additions & 1 deletion frontend/src/app/browser-nav/browser-nav.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ 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' },
// { title: 'Mods', url: 'https://github.com/RedBrumbler/BeatOnCustomSabers' },
];

@Output() linkSelected = new EventEmitter<string>();
Expand Down

0 comments on commit 12e68b2

Please sign in to comment.