@hanwha-ss1/plugin 0.4.0 → 0.4.1

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/README.md CHANGED
@@ -25,6 +25,9 @@ await HanwhaPlugin.addContact({
25
25
  ext: "내선"
26
26
  })
27
27
 
28
+ // 모달
29
+ HanwhaPlugin.open({url: "{{url}}", isCloseBtn:true, clear: true, ext: false})
30
+
28
31
  // 생체인증
29
32
  await HanwhaPlugin.auth()
30
33
  ```
@@ -21,7 +21,7 @@ public class OpenBrowser {
21
21
  * @param url
22
22
  * @param isExternal
23
23
  */
24
- public void open(AppCompatActivity activity, String url, boolean isExternal, boolean hasClose) {
24
+ public void open(AppCompatActivity activity, String url, boolean isExternal, boolean hasClose, boolean clear) {
25
25
  if(activity != null && url != null && !url.isEmpty()) {
26
26
  Intent intent;
27
27
  if(isExternal) {
@@ -30,6 +30,8 @@ public class OpenBrowser {
30
30
  intent = new Intent(activity, WebViewActivity.class);
31
31
  intent.putExtra("url", url);
32
32
  intent.putExtra("hasClose", hasClose);
33
+ intent.putExtra("clear", clear);
34
+
33
35
  }
34
36
  activity.startActivity(intent);
35
37
  }
@@ -25,9 +25,10 @@ public class OpenBrowserPlugin extends Plugin {
25
25
  String url = call.getString("url");
26
26
  boolean isExternal = Boolean.TRUE.equals(call.getBoolean("ext"));
27
27
  boolean hasClose = Boolean.TRUE.equals(call.getBoolean("isCloseBtn"));
28
+ boolean clear = Boolean.TRUE.equals(call.getBoolean("clear"));
28
29
  if(implementation == null) {
29
30
  implementation = new OpenBrowser();
30
31
  }
31
- implementation.open(getActivity(), url, isExternal, hasClose);
32
+ implementation.open(getActivity(), url, isExternal, hasClose, clear);
32
33
  }
33
34
  }
@@ -21,15 +21,25 @@ public class WebViewActivity extends AppCompatActivity {
21
21
 
22
22
  String url = getIntent().getStringExtra("url");
23
23
  boolean hasClose = getIntent().getBooleanExtra("hasClose", true);
24
-
25
- initLayout(hasClose);
24
+ boolean clear = getIntent().getBooleanExtra("clear", false);
25
+ initLayout(hasClose, clear);
26
26
 
27
27
  openUrl(url);
28
28
  }
29
29
 
30
- private void initLayout(boolean hasClose) {
30
+ private void initLayout(boolean hasClose, boolean clear) {
31
31
  webView = findViewById(R.id.webView);
32
32
 
33
+ if(clear) {
34
+ webView.clearCache(true);
35
+ webView.clearHistory();
36
+ webView.clearFormData();
37
+ CookieManager cookieManager = CookieManager.getInstance();
38
+ cookieManager.removeAllCookies(null);
39
+ cookieManager.flush();
40
+ WebStorage.getInstance().deleteAllData();
41
+ }
42
+
33
43
  if(hasClose) {
34
44
  findViewById(R.id.ivClose).setOnClickListener(new View.OnClickListener() {
35
45
  @Override
@@ -72,4 +82,4 @@ public class WebViewActivity extends AppCompatActivity {
72
82
  super.onBackPressed();
73
83
  }
74
84
  }
75
- }
85
+ }
@@ -48,6 +48,8 @@ export interface Plugin {
48
48
  open(options: {
49
49
  url: string;
50
50
  ext: boolean;
51
+ isCloseBtn?: boolean;
52
+ clear?: boolean;
51
53
  }): Promise<{
52
54
  value: string;
53
55
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface Plugin {\n /**\n * 앱 실행\n * @param options package : 패키지명\n */\n executeApp(options: {\n package: string;\n }): Promise<{ value: string }>;\n\n /**\n * 연락처 저장\n * @param options name : 성명\n * @param options phone : 전화번호\n * @param options email : 이메일\n * @param options dept : 소속\n * @param options ext : 내선번호\n */\n addContact(options: {\n name: string;\n phone: string;\n email: string;\n dept: string;\n ext: string;\n }): Promise<{ value: string }>;\n\n /**\n * TouchID, FaceID\n */\n auth(): Promise<{ value: string }>;\n\n /**\n * 시스템에 설정된 지역이 서울인지 확인\n */\n checkSeoulTimeZone(): Promise<{ value: string }>;\n\n timezone(): Promise<{ value: string }>;\n\n /**\n *\n * @param options url : \"웹 페이지 주소\"\n * @param options ext : false(내부 웹뷰), true(외부 브라우저)\n */\n open(options: { url: string; ext: boolean; }): Promise<{ value: string }>;\n}\n\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface Plugin {\n /**\n * 앱 실행\n * @param options package : 패키지명\n */\n executeApp(options: {\n package: string;\n }): Promise<{ value: string }>;\n\n /**\n * 연락처 저장\n * @param options name : 성명\n * @param options phone : 전화번호\n * @param options email : 이메일\n * @param options dept : 소속\n * @param options ext : 내선번호\n */\n addContact(options: {\n name: string;\n phone: string;\n email: string;\n dept: string;\n ext: string;\n }): Promise<{ value: string }>;\n\n /**\n * TouchID, FaceID\n */\n auth(): Promise<{ value: string }>;\n\n /**\n * 시스템에 설정된 지역이 서울인지 확인\n */\n checkSeoulTimeZone(): Promise<{ value: string }>;\n\n timezone(): Promise<{ value: string }>;\n\n /**\n *\n * @param options url : \"웹 페이지 주소\"\n * @param options ext : false(내부 웹뷰), true(외부 브라우저)\n */\n open(options: { url: string; ext: boolean; isCloseBtn?: boolean; clear?: boolean }): Promise<{ value: string }>;\n}\n\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -9,5 +9,7 @@ export declare class PluginWeb extends WebPlugin implements Plugin {
9
9
  open(_options: {
10
10
  url: string;
11
11
  ext: boolean;
12
+ isCloseBtn?: boolean;
13
+ clear?: boolean;
12
14
  }): Promise<any>;
13
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAG1C,MAAM,OAAO,SAAU,SAAQ,SAAS;IAEtC,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAuC;QAChD,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {WebPlugin} from '@capacitor/core';\nimport type {Plugin} from './definitions';\n\nexport class PluginWeb extends WebPlugin implements Plugin {\n\n async executeApp(): Promise<any> {\n return { results: {} };\n }\n\n async addContact(): Promise<any> {\n return { results: {} };\n }\n\n async auth(): Promise<any> {\n return { results: {} };\n }\n\n async checkSeoulTimeZone(): Promise<any> {\n return { results: {} };\n }\n\n async timezone(): Promise<any> {\n return { results: {} };\n }\n\n async open(_options: { url: string, ext: boolean }): Promise<any> {\n return { results: {} };\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAG1C,MAAM,OAAO,SAAU,SAAQ,SAAS;IAEtC,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAA8E;QACvF,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {WebPlugin} from '@capacitor/core';\nimport type {Plugin} from './definitions';\n\nexport class PluginWeb extends WebPlugin implements Plugin {\n\n async executeApp(): Promise<any> {\n return { results: {} };\n }\n\n async addContact(): Promise<any> {\n return { results: {} };\n }\n\n async auth(): Promise<any> {\n return { results: {} };\n }\n\n async checkSeoulTimeZone(): Promise<any> {\n return { results: {} };\n }\n\n async timezone(): Promise<any> {\n return { results: {} };\n }\n\n async open(_options: { url: string, ext: boolean, isCloseBtn?: boolean; clear?: boolean }): Promise<any> {\n return { results: {} };\n }\n}\n"]}
@@ -11,10 +11,11 @@ public class OpenBrowserPlugin: CAPPlugin {
11
11
 
12
12
  @objc func openBrowser(_ call: CAPPluginCall, _bridge: CAPBridgeProtocol) {
13
13
  let url = call.getString("url") ?? ""
14
-
14
+ let isCloseBtn = call.getBool("isCloseBtn") ?? true
15
+ let clear = call.getBool("clear") ?? false
15
16
 
16
17
  DispatchQueue.main.async {
17
- let controller = self.implementation.builder(url: url)
18
+ let controller = self.implementation.builder(url: url, isCloseBtn: isCloseBtn, clear: clear)
18
19
  controller.modalPresentationStyle = .fullScreen
19
20
 
20
21
  _bridge.viewController?.present(controller, animated: true)
@@ -6,10 +6,12 @@ import Capacitor
6
6
 
7
7
 
8
8
  public class OpenBrowserService: NSObject {
9
- @objc public func builder(url: String) -> UIViewController {
9
+ @objc public func builder(url: String, isCloseBtn: Bool, clear: Bool) -> UIViewController {
10
10
  let bundle = Bundle(for: self.classForCoder)
11
11
  let controller = ViewController(nibName: "ViewController", bundle: bundle)
12
+ controller.isCloseBtn = isCloseBtn
12
13
  controller.url = url
14
+ controller.clear = clear
13
15
  return controller
14
16
  }
15
17
 
@@ -13,16 +13,32 @@ import WebKit
13
13
 
14
14
  class ViewController: UIViewController {
15
15
  @IBOutlet var wkWebview: WKWebView!
16
+ @IBOutlet var btnPanel: UIView!
17
+ @IBOutlet var constraintPanelHeight: NSLayoutConstraint!
16
18
  @IBOutlet var btnClose: UIButton!
17
19
  @IBOutlet var indicator: UIActivityIndicatorView!
18
-
20
+
19
21
 
20
22
  var url: String = ""
23
+ var isCloseBtn: Bool = false
24
+ var clear: Bool = false
21
25
  var naviTitle: String = ""
26
+
22
27
 
23
28
  override func viewDidLoad() {
24
29
  super.viewDidLoad()
30
+ if isCloseBtn {
31
+ btnPanel.isHidden = false
32
+ constraintPanelHeight.constant = 48
33
+ } else {
34
+ btnPanel.isHidden = true
35
+ constraintPanelHeight.constant = 0
36
+ }
37
+
25
38
  indicator.startAnimating()
39
+ if clear {
40
+ clearCache()
41
+ }
26
42
  wkWebview.navigationDelegate = self
27
43
  wkWebview.load(URLRequest.init(url: URL(string: url)!))
28
44
  }
@@ -41,6 +57,15 @@ class ViewController: UIViewController {
41
57
  @IBAction func doClose() {
42
58
  self.dismiss(animated: true)
43
59
  }
60
+
61
+ func clearCache() {
62
+ let websiteDataTypes = Set([WKWebsiteDataTypeMemoryCache, WKWebsiteDataTypeDiskCache, WKWebsiteDataTypeCookies, WKWebsiteDataTypeSessionStorage, WKWebsiteDataTypeLocalStorage, WKWebsiteDataTypeIndexedDBDatabases, WKWebsiteDataTypeWebSQLDatabases])
63
+ let dateFrom = Date(timeIntervalSince1970: 0)
64
+
65
+ WKWebsiteDataStore.default().removeData(ofTypes: websiteDataTypes, modifiedSince: dateFrom) {
66
+ print("Cache cleared")
67
+ }
68
+ }
44
69
  }
45
70
 
46
71
 
@@ -50,6 +75,35 @@ extension ViewController: WKNavigationDelegate {
50
75
  webView.isHidden = false
51
76
  }
52
77
 
78
+ func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Swift.Void) {
79
+
80
+ let alertController = UIAlertController(title: message, message: nil, preferredStyle: .alert);
81
+
82
+ let cancelAction = UIAlertAction(title: "확인", style: .cancel) {
83
+ _ in completionHandler()
84
+ }
85
+
86
+ alertController.addAction(cancelAction)
87
+ DispatchQueue.main.async {
88
+ self.present(alertController, animated: true, completion: nil)
89
+ }
90
+ }
91
+
92
+ func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
93
+ let alertController = UIAlertController(title: "", message: message, preferredStyle: .alert)
94
+ let cancelAction = UIAlertAction(title: "취소", style: .cancel) { _ in
95
+ completionHandler(false)
96
+ }
97
+ let okAction = UIAlertAction(title: "확인", style: .default) { _ in
98
+ completionHandler(true)
99
+ }
100
+ alertController.addAction(cancelAction)
101
+ alertController.addAction(okAction)
102
+ DispatchQueue.main.async {
103
+ self.present(alertController, animated: true, completion: nil)
104
+ }
105
+ }
106
+
53
107
  func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
54
108
 
55
109
  let url = navigationAction.request.url?.absoluteString
@@ -3,14 +3,16 @@
3
3
  <device id="retina6_0" orientation="portrait" appearance="light"/>
4
4
  <dependencies>
5
5
  <deployment identifier="iOS"/>
6
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
6
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
7
7
  <capability name="Safe area layout guides" minToolsVersion="9.0"/>
8
8
  <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9
9
  </dependencies>
10
10
  <objects>
11
- <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ViewController" customModule="HanwhaSs1Plugin" customModuleProvider="target">
11
+ <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ViewController" customModule="Plugin" customModuleProvider="target">
12
12
  <connections>
13
13
  <outlet property="btnClose" destination="1PV-Mj-hAT" id="mlS-cq-Qaz"/>
14
+ <outlet property="btnPanel" destination="Uoe-RW-I9y" id="iTQ-0F-k59"/>
15
+ <outlet property="constraintPanelHeight" destination="G6Y-b0-xtz" id="QkE-B3-I13"/>
14
16
  <outlet property="indicator" destination="Vt7-sZ-fvc" id="LWz-jE-fvu"/>
15
17
  <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
16
18
  <outlet property="wkWebview" destination="gNx-5x-FOs" id="rA7-7h-TvS"/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanwha-ss1/plugin",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",