46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
using Android.App;
|
|
using Android.Net.Http;
|
|
using Android.OS;
|
|
using Android.Webkit;
|
|
|
|
namespace dashboard
|
|
{
|
|
[Activity(Label = "@string/app_name", MainLauncher = true, LaunchMode = Android.Content.PM.LaunchMode.SingleTask)]
|
|
[IntentFilter(new[] { "android.intent.action.MAIN" }, Categories = new[] { "android.intent.category.HOME", "android.intent.category.DEFAULT" })]
|
|
public class MainActivity : Activity
|
|
{
|
|
protected override void OnCreate(Bundle savedInstanceState)
|
|
{
|
|
base.OnCreate(savedInstanceState);
|
|
SetContentView(Resource.Layout.main);
|
|
|
|
var webView = FindViewById<WebView>(Resource.Id.webView);
|
|
webView.Settings.JavaScriptEnabled = true;
|
|
webView.Settings.BuiltInZoomControls = false;
|
|
webView.Settings.DisplayZoomControls = false;
|
|
|
|
// Use subclassed WebViewClient to hide default chrome (url bar and stuff)
|
|
webView.SetWebViewClient(new HybridWebViewClient());
|
|
|
|
webView.LoadUrl("https://api.mayer.life/dashboard/");
|
|
}
|
|
|
|
private class HybridWebViewClient : WebViewClient
|
|
{
|
|
public override void OnReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
|
|
{
|
|
// ignore "untrusted" ssl errors (due to LetsEncrypt changes in January 2021 and compatibility with only Android 7.1+)
|
|
if (error.PrimaryError == SslErrorType.Untrusted || error.PrimaryError == SslErrorType.Invalid)
|
|
{
|
|
handler.Proceed();
|
|
}
|
|
else
|
|
{
|
|
handler.Cancel();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|