@hanwha-ss1/plugin 0.4.1 → 0.4.2

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.
@@ -1,18 +1,30 @@
1
1
  package com.plugin.openbrowser;
2
2
 
3
3
  import android.app.Activity;
4
+ import android.content.Intent;
5
+ import android.net.Uri;
4
6
  import android.os.Bundle;
5
7
  import android.view.View;
8
+ import android.webkit.CookieManager;
9
+ import android.webkit.ValueCallback;
10
+ import android.webkit.WebChromeClient;
11
+ import android.webkit.WebStorage;
6
12
  import android.webkit.WebView;
7
13
  import android.webkit.WebViewClient;
8
14
  import android.widget.ImageView;
9
15
 
16
+ import androidx.activity.result.ActivityResult;
17
+ import androidx.activity.result.ActivityResultCallback;
18
+ import androidx.activity.result.ActivityResultLauncher;
19
+ import androidx.activity.result.contract.ActivityResultContracts;
10
20
  import androidx.appcompat.app.AppCompatActivity;
11
21
 
12
22
  public class WebViewActivity extends AppCompatActivity {
13
23
 
14
24
  private WebView webView;
15
25
 
26
+ private ValueCallback mFilePathCallback;;
27
+
16
28
  @Override
17
29
  protected void onCreate(Bundle savedInstanceState) {
18
30
  super.onCreate(savedInstanceState);
@@ -27,6 +39,20 @@ public class WebViewActivity extends AppCompatActivity {
27
39
  openUrl(url);
28
40
  }
29
41
 
42
+ private final ActivityResultLauncher<Intent> startActivityResult = registerForActivityResult(
43
+ new ActivityResultContracts.StartActivityForResult(),
44
+ new ActivityResultCallback<ActivityResult>() {
45
+ @Override
46
+ public void onActivityResult(ActivityResult result) {
47
+ if (result.getResultCode() == Activity.RESULT_OK) {
48
+ mFilePathCallback.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(result.getResultCode(), result.getData()));
49
+ mFilePathCallback = null;
50
+ } else {
51
+ mFilePathCallback.onReceiveValue(null);
52
+ }
53
+ }
54
+ });
55
+
30
56
  private void initLayout(boolean hasClose, boolean clear) {
31
57
  webView = findViewById(R.id.webView);
32
58
 
@@ -58,7 +84,41 @@ public class WebViewActivity extends AppCompatActivity {
58
84
  webView.getSettings().setDisplayZoomControls(false);
59
85
  webView.getSettings().setLoadWithOverviewMode(true);
60
86
  webView.getSettings().setUseWideViewPort(true);
61
- webView.setWebChromeClient(new ChromeClient((Activity)this));
87
+ // webView.setWebChromeClient(new ChromeClient((Activity)this));
88
+ webView.setWebChromeClient(new ChromeClient(this) {
89
+ @Override
90
+ public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
91
+ mFilePathCallback = filePathCallback;
92
+
93
+ Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
94
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
95
+ intent.setType("image/*");
96
+
97
+ // startActivityForResult(intent, 0);
98
+ startActivityResult.launch(intent);
99
+ return true;
100
+ }
101
+ });
102
+
103
+ webView.setWebViewClient(new WebViewClient(){
104
+ @Override
105
+ public boolean shouldOverrideUrlLoading(WebView view, String url) {
106
+ if(url.startsWith("close://")){
107
+ WebViewActivity.this.finish();
108
+ } else if(url.startsWith("tel:")){
109
+ Intent intent = new Intent(Intent.ACTION_DIAL);
110
+ intent.setData(Uri.parse(url));
111
+ startActivity(intent);
112
+ } else if(url.startsWith("sms:")){
113
+ Intent intent = new Intent(Intent.ACTION_SENDTO);
114
+ intent.setData(Uri.parse(url));
115
+ startActivity(intent);
116
+ }
117
+ return super.shouldOverrideUrlLoading(view, url);
118
+ }
119
+ });
120
+
121
+
62
122
  webView.setWebViewClient(new WebViewClient(){
63
123
  @Override
64
124
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
@@ -39,6 +39,7 @@ class ViewController: UIViewController {
39
39
  if clear {
40
40
  clearCache()
41
41
  }
42
+ wkWebview.uiDelegate = self
42
43
  wkWebview.navigationDelegate = self
43
44
  wkWebview.load(URLRequest.init(url: URL(string: url)!))
44
45
  }
@@ -69,7 +70,7 @@ class ViewController: UIViewController {
69
70
  }
70
71
 
71
72
 
72
- extension ViewController: WKNavigationDelegate {
73
+ extension ViewController: WKNavigationDelegate, WKUIDelegate {
73
74
  func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
74
75
  indicator.stopAnimating()
75
76
  webView.isHidden = false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanwha-ss1/plugin",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",