This commit is contained in:
Lorenzo Pichilli 2022-04-23 15:51:17 +02:00
commit 9e6feccbf6
2 changed files with 19 additions and 10 deletions

View File

@ -6,6 +6,10 @@
- Added support for `onPermissionRequest` event on iOS 15.0+
- Updated `getMetaThemeColor` on iOS 15.0+
## 5.4.1+1
- Fixed Android default context menu over custom context menu on API Level 31+
## 5.4.1
- Managed iOS native `detachFromEngine` flutter plugin event and updated `dispose` methods

View File

@ -54,9 +54,6 @@ import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin;
import com.pichillilorenzo.flutter_inappwebview.types.DownloadStartRequest;
import com.pichillilorenzo.flutter_inappwebview.types.HitTestResult;
import com.pichillilorenzo.flutter_inappwebview.types.InAppWebViewInterface;
import com.pichillilorenzo.flutter_inappwebview.JavaScriptBridgeInterface;
import com.pichillilorenzo.flutter_inappwebview.R;
import com.pichillilorenzo.flutter_inappwebview.Util;
@ -77,6 +74,8 @@ import com.pichillilorenzo.flutter_inappwebview.plugin_scripts_js.PrintJS;
import com.pichillilorenzo.flutter_inappwebview.plugin_scripts_js.PromisePolyfillJS;
import com.pichillilorenzo.flutter_inappwebview.pull_to_refresh.PullToRefreshLayout;
import com.pichillilorenzo.flutter_inappwebview.types.ContentWorld;
import com.pichillilorenzo.flutter_inappwebview.types.DownloadStartRequest;
import com.pichillilorenzo.flutter_inappwebview.types.InAppWebViewInterface;
import com.pichillilorenzo.flutter_inappwebview.types.PluginScript;
import com.pichillilorenzo.flutter_inappwebview.types.PreferredContentModeOptionType;
import com.pichillilorenzo.flutter_inappwebview.types.URLRequest;
@ -1357,8 +1356,16 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
}
Menu actionMenu = actionMode.getMenu();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
actionMode.hide(3000);
}
List<MenuItem> defaultMenuItems = new ArrayList<>();
for (int i = 0; i < actionMenu.size(); i++) {
defaultMenuItems.add(actionMenu.getItem(i));
}
actionMenu.clear();
actionMode.finish();
if (customSettings.disableContextMenu) {
actionMenu.clear();
return actionMode;
}
@ -1371,16 +1378,15 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
ContextMenuSettings contextMenuSettings = new ContextMenuSettings();
if (contextMenu != null) {
customMenuItems = (List<Map<String, Object>>) contextMenu.get("menuItems");
Map<String, Object> contextMenuOptionsMap = (Map<String, Object>) contextMenu.get("settings");
if (contextMenuOptionsMap != null) {
contextMenuSettings.parse(contextMenuOptionsMap);
Map<String, Object> contextMenuSettingsMap = (Map<String, Object>) contextMenu.get("settings");
if (contextMenuSettingsMap != null) {
contextMenuSettings.parse(contextMenuSettingsMap);
}
}
customMenuItems = customMenuItems == null ? new ArrayList<Map<String, Object>>() : customMenuItems;
if (contextMenuSettings.hideDefaultSystemContextMenuItems == null || !contextMenuSettings.hideDefaultSystemContextMenuItems) {
for (int i = 0; i < actionMenu.size(); i++) {
final MenuItem menuItem = actionMenu.getItem(i);
for (final MenuItem menuItem : defaultMenuItems) {
final int itemId = menuItem.getItemId();
final String itemTitle = menuItem.getTitle().toString();
@ -1459,7 +1465,6 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
checkContextMenuShouldBeClosedTask.run();
}
}
actionMenu.clear();
return actionMode;
}