Skip to content

Commit

Permalink
Fixed Android default context menu over custom context menu on API Le…
Browse files Browse the repository at this point in the history
…vel 31+
  • Loading branch information
pichillilorenzo committed Apr 23, 2022
1 parent 2d31a2f commit f511e4d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import android.webkit.ValueCallback;
import android.webkit.WebBackForwardList;
import android.webkit.WebHistoryItem;
import android.webkit.WebMessage;
import android.webkit.WebSettings;
import android.webkit.WebStorage;
import android.widget.HorizontalScrollView;
Expand All @@ -55,8 +54,6 @@
import androidx.webkit.WebViewFeature;

import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin;
import com.pichillilorenzo.flutter_inappwebview.types.DownloadStartRequest;
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;
Expand All @@ -77,6 +74,8 @@
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;
Expand Down Expand Up @@ -1357,8 +1356,16 @@ public ActionMode rebuildActionMode(
}

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 (options.disableContextMenu) {
actionMenu.clear();
return actionMode;
}

Expand All @@ -1379,8 +1386,7 @@ public ActionMode rebuildActionMode(
customMenuItems = customMenuItems == null ? new ArrayList<Map<String, Object>>() : customMenuItems;

if (contextMenuOptions.hideDefaultSystemContextMenuItems == null || !contextMenuOptions.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();

Expand Down Expand Up @@ -1457,7 +1463,6 @@ public void onGlobalLayout() {
checkContextMenuShouldBeClosedTask.run();
}
}
actionMenu.clear();

return actionMode;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_inappwebview
description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window.
version: 5.4.1
version: 5.4.1+1
homepage: https://github.com/pichillilorenzo/flutter_inappwebview

environment:
Expand Down

0 comments on commit f511e4d

Please sign in to comment.