@capgo/inappbrowser 7.1.1 → 7.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +0 -1
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java +0 -4
- package/android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java +14 -2
- package/ios/Plugin/InAppBrowserPlugin.swift +7 -3
- package/ios/Plugin/WKWebViewController.swift +6 -2
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -54,6 +54,7 @@ dependencies {
|
|
|
54
54
|
implementation project(':capacitor-android')
|
|
55
55
|
implementation 'com.caverock:androidsvg:1.4'
|
|
56
56
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
57
|
+
implementation "androidx.window:window:1.3.0"
|
|
57
58
|
testImplementation "junit:junit:$junitVersion"
|
|
58
59
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
59
60
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -45,10 +45,6 @@ import org.json.JSONObject;
|
|
|
45
45
|
alias = "storage",
|
|
46
46
|
strings = { Manifest.permission.READ_EXTERNAL_STORAGE }
|
|
47
47
|
),
|
|
48
|
-
@Permission(
|
|
49
|
-
alias = "storage",
|
|
50
|
-
strings = { Manifest.permission.READ_MEDIA_IMAGES }
|
|
51
|
-
),
|
|
52
48
|
},
|
|
53
49
|
requestCodes = { WebViewDialog.FILE_CHOOSER_REQUEST_CODE }
|
|
54
50
|
)
|
|
@@ -38,6 +38,7 @@ import android.widget.TextView;
|
|
|
38
38
|
import android.widget.Toast;
|
|
39
39
|
import android.widget.Toolbar;
|
|
40
40
|
import androidx.annotation.RequiresApi;
|
|
41
|
+
import androidx.core.view.WindowInsetsControllerCompat;
|
|
41
42
|
import com.caverock.androidsvg.SVG;
|
|
42
43
|
import com.caverock.androidsvg.SVGParseException;
|
|
43
44
|
import com.getcapacitor.JSObject;
|
|
@@ -163,6 +164,17 @@ public class WebViewDialog extends Dialog {
|
|
|
163
164
|
WindowManager.LayoutParams.FLAG_FULLSCREEN
|
|
164
165
|
);
|
|
165
166
|
setContentView(R.layout.activity_browser);
|
|
167
|
+
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
168
|
+
|
|
169
|
+
WindowInsetsControllerCompat insetsController =
|
|
170
|
+
new WindowInsetsControllerCompat(getWindow(), getWindow().getDecorView());
|
|
171
|
+
insetsController.setAppearanceLightStatusBars(false);
|
|
172
|
+
getWindow()
|
|
173
|
+
.getDecorView()
|
|
174
|
+
.post(() -> {
|
|
175
|
+
getWindow().setStatusBarColor(Color.BLACK);
|
|
176
|
+
});
|
|
177
|
+
|
|
166
178
|
getWindow()
|
|
167
179
|
.setLayout(
|
|
168
180
|
WindowManager.LayoutParams.MATCH_PARENT,
|
|
@@ -487,7 +499,7 @@ public class WebViewDialog extends Dialog {
|
|
|
487
499
|
}
|
|
488
500
|
);
|
|
489
501
|
|
|
490
|
-
|
|
502
|
+
ImageButton closeButton = _toolbar.findViewById(R.id.closeButton);
|
|
491
503
|
closeButton.setOnClickListener(
|
|
492
504
|
new View.OnClickListener() {
|
|
493
505
|
@Override
|
|
@@ -520,7 +532,7 @@ public class WebViewDialog extends Dialog {
|
|
|
520
532
|
);
|
|
521
533
|
|
|
522
534
|
if (_options.showArrow()) {
|
|
523
|
-
closeButton.
|
|
535
|
+
closeButton.setImageResource(R.drawable.arrow_back_enabled);
|
|
524
536
|
}
|
|
525
537
|
|
|
526
538
|
if (_options.getShowReloadButton()) {
|
|
@@ -289,8 +289,10 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
289
289
|
call.reject("Cannot get script to execute")
|
|
290
290
|
return
|
|
291
291
|
}
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
DispatchQueue.main.async {
|
|
293
|
+
self.webViewController?.executeScript(script: script)
|
|
294
|
+
call.resolve()
|
|
295
|
+
}
|
|
294
296
|
}
|
|
295
297
|
|
|
296
298
|
@objc func postMessage(_ call: CAPPluginCall) {
|
|
@@ -302,7 +304,9 @@ public class InAppBrowserPlugin: CAPPlugin {
|
|
|
302
304
|
}
|
|
303
305
|
print("Event data: \(eventData)")
|
|
304
306
|
|
|
305
|
-
|
|
307
|
+
DispatchQueue.main.async {
|
|
308
|
+
self.webViewController?.postMessageToJS(message: eventData)
|
|
309
|
+
}
|
|
306
310
|
call.resolve()
|
|
307
311
|
}
|
|
308
312
|
|
|
@@ -239,7 +239,9 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
239
239
|
if let jsonData = try? JSONSerialization.data(withJSONObject: message, options: []),
|
|
240
240
|
let jsonString = String(data: jsonData, encoding: .utf8) {
|
|
241
241
|
let script = "window.dispatchEvent(new CustomEvent('messageFromNative', { detail: \(jsonString) }));"
|
|
242
|
-
|
|
242
|
+
DispatchQueue.main.async {
|
|
243
|
+
self.webView?.evaluateJavaScript(script, completionHandler: nil)
|
|
244
|
+
}
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
247
|
|
|
@@ -842,9 +844,11 @@ extension WKWebViewController: WKUIDelegate {
|
|
|
842
844
|
// Ensure UI updates are on the main thread
|
|
843
845
|
DispatchQueue.main.async {
|
|
844
846
|
let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
|
|
847
|
+
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
|
|
848
|
+
completionHandler()
|
|
849
|
+
}))
|
|
845
850
|
self.present(alertController, animated: true, completion: nil)
|
|
846
851
|
}
|
|
847
|
-
completionHandler()
|
|
848
852
|
}
|
|
849
853
|
}
|
|
850
854
|
|