-
-
Notifications
You must be signed in to change notification settings - Fork 95
fix(android): return openWebView id exactly once #476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,6 +135,7 @@ public ProxiedRequest() { | |
| public static final int FILE_CHOOSER_REQUEST_CODE = 1000; | ||
| public ValueCallback<Uri> mUploadMessage; | ||
| public ValueCallback<Uri[]> mFilePathCallback; | ||
| private boolean openWebViewResolved; | ||
|
|
||
| // Temporary URI for storing camera capture | ||
| public Uri tempCameraUri; | ||
|
|
@@ -154,6 +155,7 @@ public WebViewDialog(Context context, int theme, Options options, PermissionHand | |
| this._context = context; | ||
| this.permissionHandler = permissionHandler; | ||
| this.isInitialized = false; | ||
| this.openWebViewResolved = false; | ||
| this.capacitorWebView = capacitorWebView; | ||
| } | ||
|
|
||
|
|
@@ -165,6 +167,16 @@ public String getInstanceId() { | |
| return instanceId; | ||
| } | ||
|
|
||
| private void resolveOpenWebViewIfNeeded() { | ||
| if (openWebViewResolved || _options == null || _options.getPluginCall() == null) { | ||
| return; | ||
| } | ||
| openWebViewResolved = true; | ||
| JSObject result = new JSObject(); | ||
| result.put("id", instanceId); | ||
| _options.getPluginCall().resolve(result); | ||
| } | ||
|
|
||
| // Add this class to provide safer JavaScript interface | ||
| private class JavaScriptInterface { | ||
|
|
||
|
|
@@ -978,10 +990,10 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) { | |
| show(); | ||
| applyHiddenMode(); | ||
| } | ||
| _options.getPluginCall().resolve(); | ||
| resolveOpenWebViewIfNeeded(); | ||
| } else if (!this._options.isPresentAfterPageLoad()) { | ||
| show(); | ||
| _options.getPluginCall().resolve(); | ||
| resolveOpenWebViewIfNeeded(); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -2796,7 +2808,7 @@ public void onPageFinished(WebView view, String url) { | |
| boolean usePreShowScript = _options.getPreShowScript() != null && !_options.getPreShowScript().isEmpty(); | ||
| if (!usePreShowScript) { | ||
| show(); | ||
| _options.getPluginCall().resolve(); | ||
| resolveOpenWebViewIfNeeded(); | ||
|
Comment on lines
2835
to
+2838
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in d26c6c7. The deferred-load path now rejects the original |
||
| } else { | ||
| executorService.execute( | ||
| new Runnable() { | ||
|
|
@@ -2811,7 +2823,7 @@ public void run() { | |
| @Override | ||
| public void run() { | ||
| show(); | ||
| _options.getPluginCall().resolve(); | ||
| resolveOpenWebViewIfNeeded(); | ||
| } | ||
| } | ||
| ); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.