Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ExtendedWebView/ExtendedWebView.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Com.Bnotech.ExtendedWebView</RootNamespace>
<MauiVersion>9.0.90</MauiVersion>
<MauiVersion>9.0.120</MauiVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">12.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
Expand All @@ -23,7 +23,7 @@
<Owners>bnotech</Owners>
<Company>BNO Technology Solutions e.K.</Company>
<Description>This package provides support for a extended WebView</Description>
<Copyright>©Copyright 2024, BNO Technology Solutions e.K.</Copyright>
<Copyright>©Copyright 2025, BNO Technology Solutions e.K.</Copyright>
<Tags>WebView Extended ExtendedWebView</Tags>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
Expand Down
37 changes: 36 additions & 1 deletion ExtendedWebView/Platforms/Android/Handlers/ExtWebViewHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Android.Graphics;
using AApp = Android.App;
using AOS = Android.OS;
using AWebKit = Android.Webkit;

using Java.Interop;
Expand Down Expand Up @@ -36,8 +38,9 @@

webView.Settings.JavaScriptEnabled = true;
webView.Settings.DomStorageEnabled = true;

webView.SetWebViewClient(new JavascriptWebViewClient($"javascript: {JavascriptFunction}", VirtualView));
webView.SetWebChromeClient(new MultiWindowWebChromeClient()); // Multi-Window Unterstützung
webView.AddJavascriptInterface(_jsBridgeHandler, "jsBridge");

if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
Expand Down Expand Up @@ -148,3 +151,35 @@
}
}
}

public class MultiWindowWebChromeClient : AWebKit.WebChromeClient
{
private AApp.AlertDialog? _dialog;

public override bool OnCreateWindow(AWebKit.WebView view, bool isDialog, bool isUserGesture, AOS.Message resultMsg)

Check warning on line 159 in ExtendedWebView/Platforms/Android/Handlers/ExtWebViewHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Nullability of type of parameter 'resultMsg' doesn't match overridden member (possibly because of nullability attributes).

Check warning on line 159 in ExtendedWebView/Platforms/Android/Handlers/ExtWebViewHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Nullability of type of parameter 'view' doesn't match overridden member (possibly because of nullability attributes).
{
var newWebView = new AWebKit.WebView(view.Context);

Check warning on line 161 in ExtendedWebView/Platforms/Android/Handlers/ExtWebViewHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Possible null reference argument for parameter 'context' in 'WebView.WebView(Context context)'.
newWebView.Settings.JavaScriptEnabled = true;
newWebView.Settings.DomStorageEnabled = true;
newWebView.SetWebChromeClient(this);

var transport = (AWebKit.WebView.WebViewTransport)resultMsg.Obj;

Check warning on line 166 in ExtendedWebView/Platforms/Android/Handlers/ExtWebViewHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Converting null literal or possible null value to non-nullable type.
transport.WebView = newWebView;

Check warning on line 167 in ExtendedWebView/Platforms/Android/Handlers/ExtWebViewHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Dereference of a possibly null reference.
resultMsg.SendToTarget();

_dialog = new AApp.AlertDialog.Builder(view.Context)
.SetView(newWebView)
.SetPositiveButton("X", (sender, args) => newWebView.Destroy())
.Create();
_dialog.Show();

return true;
}

public override void OnCloseWindow(AWebKit.WebView window)

Check warning on line 179 in ExtendedWebView/Platforms/Android/Handlers/ExtWebViewHandler.cs

View workflow job for this annotation

GitHub Actions / Build

Nullability of type of parameter 'window' doesn't match overridden member (possibly because of nullability attributes).
{
window.Destroy();
_dialog?.Dismiss();
_dialog = null;
}
}
Loading