@hanwha-ss1/plugin 0.4.9 → 0.5.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/android/build.gradle +0 -1
- package/android/src/main/java/com/plugin/linker/LinkerPlugin.java +1 -2
- package/android/src/main/java/com/plugin/openbrowser/OpenBrowser.java +1 -2
- package/android/src/main/java/com/plugin/openbrowser/OpenBrowserPlugin.java +1 -2
- package/android/src/main/java/com/plugin/openbrowser/WebViewActivity.java +14 -75
- package/dist/esm/definitions.d.ts +0 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +0 -1
- package/dist/esm/web.js.map +1 -1
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -57,7 +57,6 @@ dependencies {
|
|
|
57
57
|
testImplementation "junit:junit:$junitVersion"
|
|
58
58
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
59
59
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
60
|
-
implementation 'com.google.code.gson:gson:2.8.9' //
|
|
61
60
|
|
|
62
61
|
implementation 'androidx.biometric:biometric:1.1.0'
|
|
63
62
|
}
|
|
@@ -113,11 +113,10 @@ public class LinkerPlugin extends Plugin{
|
|
|
113
113
|
boolean isExternal = Boolean.TRUE.equals(call.getBoolean("ext"));
|
|
114
114
|
boolean hasClose = Boolean.TRUE.equals(call.getBoolean("isCloseBtn"));
|
|
115
115
|
boolean clear = Boolean.TRUE.equals(call.getBoolean("clear"));
|
|
116
|
-
String token = call.getString("token");
|
|
117
116
|
if(openBrowserImplementation == null) {
|
|
118
117
|
openBrowserImplementation = new OpenBrowser();
|
|
119
118
|
}
|
|
120
|
-
openBrowserImplementation.open(getActivity(), url, isExternal, hasClose, clear
|
|
119
|
+
openBrowserImplementation.open(getActivity(), url, isExternal, hasClose, clear);
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
@PluginMethod
|
|
@@ -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, boolean clear
|
|
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) {
|
|
@@ -31,7 +31,6 @@ public class OpenBrowser {
|
|
|
31
31
|
intent.putExtra("url", url);
|
|
32
32
|
intent.putExtra("hasClose", hasClose);
|
|
33
33
|
intent.putExtra("clear", clear);
|
|
34
|
-
intent.putExtra("token", token);
|
|
35
34
|
|
|
36
35
|
}
|
|
37
36
|
activity.startActivity(intent);
|
|
@@ -26,10 +26,9 @@ public class OpenBrowserPlugin extends Plugin {
|
|
|
26
26
|
boolean isExternal = Boolean.TRUE.equals(call.getBoolean("ext"));
|
|
27
27
|
boolean hasClose = Boolean.TRUE.equals(call.getBoolean("isCloseBtn"));
|
|
28
28
|
boolean clear = Boolean.TRUE.equals(call.getBoolean("clear"));
|
|
29
|
-
String token = call.getString("token");
|
|
30
29
|
if(implementation == null) {
|
|
31
30
|
implementation = new OpenBrowser();
|
|
32
31
|
}
|
|
33
|
-
implementation.open(getActivity(), url, isExternal, hasClose, clear
|
|
32
|
+
implementation.open(getActivity(), url, isExternal, hasClose, clear);
|
|
34
33
|
}
|
|
35
34
|
}
|
|
@@ -2,11 +2,8 @@ package com.plugin.openbrowser;
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
4
|
import android.content.Intent;
|
|
5
|
-
import android.content.SharedPreferences;
|
|
6
5
|
import android.net.Uri;
|
|
7
6
|
import android.os.Bundle;
|
|
8
|
-
import android.preference.PreferenceManager;
|
|
9
|
-
import android.util.Log;
|
|
10
7
|
import android.view.View;
|
|
11
8
|
import android.webkit.CookieManager;
|
|
12
9
|
import android.webkit.ValueCallback;
|
|
@@ -14,7 +11,6 @@ import android.webkit.WebChromeClient;
|
|
|
14
11
|
import android.webkit.WebStorage;
|
|
15
12
|
import android.webkit.WebView;
|
|
16
13
|
import android.webkit.WebViewClient;
|
|
17
|
-
import android.widget.ImageView;
|
|
18
14
|
|
|
19
15
|
import androidx.activity.result.ActivityResult;
|
|
20
16
|
import androidx.activity.result.ActivityResultCallback;
|
|
@@ -22,19 +18,10 @@ import androidx.activity.result.ActivityResultLauncher;
|
|
|
22
18
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
23
19
|
import androidx.appcompat.app.AppCompatActivity;
|
|
24
20
|
|
|
25
|
-
import com.google.gson.Gson;
|
|
26
|
-
|
|
27
|
-
import org.json.JSONObject;
|
|
28
|
-
|
|
29
|
-
import java.io.OutputStream;
|
|
30
|
-
import java.net.HttpURLConnection;
|
|
31
21
|
import java.net.URI;
|
|
32
22
|
import java.net.URISyntaxException;
|
|
33
|
-
import java.net.URL;
|
|
34
|
-
import java.nio.charset.StandardCharsets;
|
|
35
23
|
import java.util.HashMap;
|
|
36
24
|
import java.util.Map;
|
|
37
|
-
import java.util.Scanner;
|
|
38
25
|
|
|
39
26
|
public class WebViewActivity extends AppCompatActivity {
|
|
40
27
|
|
|
@@ -42,7 +29,6 @@ public class WebViewActivity extends AppCompatActivity {
|
|
|
42
29
|
|
|
43
30
|
private ValueCallback mFilePathCallback;;
|
|
44
31
|
|
|
45
|
-
private String token;
|
|
46
32
|
|
|
47
33
|
@Override
|
|
48
34
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -53,7 +39,6 @@ public class WebViewActivity extends AppCompatActivity {
|
|
|
53
39
|
String url = getIntent().getStringExtra("url");
|
|
54
40
|
boolean hasClose = getIntent().getBooleanExtra("hasClose", true);
|
|
55
41
|
boolean clear = getIntent().getBooleanExtra("clear", false);
|
|
56
|
-
token = getIntent().getStringExtra("token");
|
|
57
42
|
initLayout(hasClose, clear);
|
|
58
43
|
|
|
59
44
|
openUrl(url);
|
|
@@ -137,7 +122,9 @@ public class WebViewActivity extends AppCompatActivity {
|
|
|
137
122
|
} else if(url.startsWith("viewer://")) {
|
|
138
123
|
Map<String, String> param = parseViewerParam(url);
|
|
139
124
|
if(param != null) {
|
|
140
|
-
|
|
125
|
+
Intent intent = new Intent("com.hanwha.cleverselite.OPEN_URL");
|
|
126
|
+
intent.putExtra("url", param.get("downloadUrl"));
|
|
127
|
+
sendBroadcast(intent);
|
|
141
128
|
}
|
|
142
129
|
return true;
|
|
143
130
|
} else {
|
|
@@ -162,7 +149,7 @@ public class WebViewActivity extends AppCompatActivity {
|
|
|
162
149
|
private Map<String, String> parseViewerParam(String uriString) {
|
|
163
150
|
try {
|
|
164
151
|
URI uri = new URI(uriString);
|
|
165
|
-
String query = uri.getRawSchemeSpecificPart().split("
|
|
152
|
+
String query = uri.getRawSchemeSpecificPart().split("//")[1];
|
|
166
153
|
Map<String, String> params = new HashMap<>();
|
|
167
154
|
Map<String, String> parsedParams = new HashMap<>();
|
|
168
155
|
|
|
@@ -171,7 +158,7 @@ public class WebViewActivity extends AppCompatActivity {
|
|
|
171
158
|
String[] keyValue = pair.split("=");
|
|
172
159
|
if (keyValue.length > 1) {
|
|
173
160
|
String key = keyValue[0];
|
|
174
|
-
String value =
|
|
161
|
+
String value = keyValue[1];
|
|
175
162
|
params.put(key, value);
|
|
176
163
|
}
|
|
177
164
|
}
|
|
@@ -180,72 +167,24 @@ public class WebViewActivity extends AppCompatActivity {
|
|
|
180
167
|
parsedParams.put("downloadUrl", params.get("file"));
|
|
181
168
|
parsedParams.put("fileExtension", params.get("extension"));
|
|
182
169
|
return parsedParams;
|
|
183
|
-
} catch (URISyntaxException
|
|
170
|
+
} catch (URISyntaxException e) {
|
|
184
171
|
return null;
|
|
185
172
|
}
|
|
186
173
|
}
|
|
187
174
|
|
|
188
|
-
private void
|
|
189
|
-
|
|
190
|
-
JSONObject responseJson;
|
|
191
|
-
HttpURLConnection urlConnection = null;
|
|
192
|
-
Gson gson = new Gson();
|
|
193
|
-
|
|
194
|
-
try {
|
|
195
|
-
URL url = new URL(urlString);
|
|
196
|
-
urlConnection = (HttpURLConnection) url.openConnection();
|
|
197
|
-
|
|
198
|
-
// 요청 설정
|
|
199
|
-
urlConnection.setRequestMethod("POST");
|
|
200
|
-
urlConnection.setRequestProperty("Content-Type", "application/json; utf-8");
|
|
201
|
-
urlConnection.setRequestProperty("Accept", "application/json");
|
|
202
|
-
|
|
203
|
-
if (token != null && !token.isEmpty()) {
|
|
204
|
-
urlConnection.setRequestProperty("Authorization", token);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
urlConnection.setDoOutput(true);
|
|
208
|
-
|
|
209
|
-
String jsonInputString = gson.toJson(params);
|
|
210
|
-
try (OutputStream os = urlConnection.getOutputStream()) {
|
|
211
|
-
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
|
212
|
-
os.write(input, 0, input.length);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// 응답 코드 확인
|
|
216
|
-
int code = urlConnection.getResponseCode();
|
|
217
|
-
if (code == HttpURLConnection.HTTP_OK) {
|
|
218
|
-
// 응답 데이터를 JSON 객체로 변환
|
|
219
|
-
try (Scanner scanner = new Scanner(urlConnection.getInputStream())) {
|
|
220
|
-
scanner.useDelimiter("\\A");
|
|
221
|
-
String response = scanner.hasNext() ? scanner.next() : "";
|
|
222
|
-
responseJson = new JSONObject(response); // 응답을 JSON 객체로 변환
|
|
223
|
-
|
|
224
|
-
if(responseJson.has("iframeURL")) {
|
|
225
|
-
String iframeURL = responseJson.getString("iframeURL");
|
|
226
|
-
openUrl(iframeURL);
|
|
227
|
-
} else {
|
|
228
|
-
String errorMessage = responseJson.getString("errorMessage");
|
|
229
|
-
Log.e("OpenBrowser", "getViewerURL Fail: " + errorMessage);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
} else {
|
|
233
|
-
System.out.println("Error: " + code);
|
|
234
|
-
}
|
|
175
|
+
private void openUrl(String url) {
|
|
176
|
+
webView.loadUrl(url);
|
|
235
177
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
178
|
+
if(url.startsWith("viewer://")) {
|
|
179
|
+
Map<String, String> param = parseViewerParam(url);
|
|
180
|
+
if(param != null) {
|
|
181
|
+
Intent intent = new Intent("com.hanwha.cleverselite.OPEN_URL");
|
|
182
|
+
intent.putExtra("url", param.get("downloadUrl"));
|
|
183
|
+
sendBroadcast(intent);
|
|
241
184
|
}
|
|
242
185
|
}
|
|
243
186
|
}
|
|
244
187
|
|
|
245
|
-
private void openUrl(String url) {
|
|
246
|
-
webView.loadUrl(url);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
188
|
@Override
|
|
250
189
|
public void onBackPressed() {
|
|
251
190
|
if(webView != null && webView.canGoBack()) {
|
|
@@ -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; isCloseBtn?: boolean; clear?: boolean
|
|
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 * EdgeSwipe 허용\n * @see default false\n */\n edgeSwipe(options: {on: boolean}): Promise<{ value: string }>;\n\n\n /**\n * 카메라앱 열기\n * @see default false\n */\n openCamera(): Promise<{ value: string }>;\n}\n\n"]}
|
package/dist/esm/web.d.ts
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAGrD,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,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAGrD,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;IAED,KAAK,CAAC,SAAS,CAAC,QAAyB;QACvC,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;YACrC,OAAO,OAAO,CAAC,MAAM,CAAC,qCAAqC,CAAC,CAAC;SAC9D;QACD,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {Capacitor, 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 async edgeSwipe(_options: { on: boolean }): Promise<any> {\n if (Capacitor.getPlatform() !== 'ios') {\n return Promise.reject('edgeSwipe is only supported on iOS.');\n }\n return { results: {} };\n }\n\n async openCamera(): Promise<any> {\n return { results: {} };\n }\n}\n"]}
|