@hanwha-ss1/plugin 0.4.8 → 0.5.0
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.
|
@@ -11,7 +11,6 @@ import android.webkit.WebChromeClient;
|
|
|
11
11
|
import android.webkit.WebStorage;
|
|
12
12
|
import android.webkit.WebView;
|
|
13
13
|
import android.webkit.WebViewClient;
|
|
14
|
-
import android.widget.ImageView;
|
|
15
14
|
|
|
16
15
|
import androidx.activity.result.ActivityResult;
|
|
17
16
|
import androidx.activity.result.ActivityResultCallback;
|
|
@@ -19,12 +18,18 @@ import androidx.activity.result.ActivityResultLauncher;
|
|
|
19
18
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
20
19
|
import androidx.appcompat.app.AppCompatActivity;
|
|
21
20
|
|
|
21
|
+
import java.net.URI;
|
|
22
|
+
import java.net.URISyntaxException;
|
|
23
|
+
import java.util.HashMap;
|
|
24
|
+
import java.util.Map;
|
|
25
|
+
|
|
22
26
|
public class WebViewActivity extends AppCompatActivity {
|
|
23
27
|
|
|
24
28
|
private WebView webView;
|
|
25
29
|
|
|
26
30
|
private ValueCallback mFilePathCallback;;
|
|
27
31
|
|
|
32
|
+
|
|
28
33
|
@Override
|
|
29
34
|
protected void onCreate(Bundle savedInstanceState) {
|
|
30
35
|
super.onCreate(savedInstanceState);
|
|
@@ -114,15 +119,70 @@ public class WebViewActivity extends AppCompatActivity {
|
|
|
114
119
|
intent.setData(Uri.parse(url));
|
|
115
120
|
startActivity(intent);
|
|
116
121
|
return true;
|
|
122
|
+
} else if(url.startsWith("viewer://")) {
|
|
123
|
+
Map<String, String> param = parseViewerParam(url);
|
|
124
|
+
if(param != null) {
|
|
125
|
+
Intent intent = new Intent("com.hanwha.cleverselite.OPEN_URL");
|
|
126
|
+
intent.putExtra("url", param.get("downloadUrl"));
|
|
127
|
+
sendBroadcast(intent);
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
117
130
|
} else {
|
|
118
131
|
return super.shouldOverrideUrlLoading(view, url);
|
|
119
132
|
}
|
|
120
133
|
}
|
|
121
134
|
});
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* OneBill 시스템 파일 뷰어 프로세스
|
|
141
|
+
*
|
|
142
|
+
* @param uriString ex: //viewer://
|
|
143
|
+
* serviceid=onebill&
|
|
144
|
+
* file= https%3A%2F%2Fone-erp.com%3Flang%3Dkor%26manager%3D%EC%86%8C%EB%8B%A4%EB%A7%9B%EC%82%AC%ED%83%95&
|
|
145
|
+
* filetype=uri&
|
|
146
|
+
* extension=pdf
|
|
147
|
+
* @return file 주소
|
|
148
|
+
*/
|
|
149
|
+
private Map<String, String> parseViewerParam(String uriString) {
|
|
150
|
+
try {
|
|
151
|
+
URI uri = new URI(uriString);
|
|
152
|
+
String query = uri.getRawSchemeSpecificPart().split("//")[1];
|
|
153
|
+
Map<String, String> params = new HashMap<>();
|
|
154
|
+
Map<String, String> parsedParams = new HashMap<>();
|
|
155
|
+
|
|
156
|
+
String[] pairs = query.split("&");
|
|
157
|
+
for (String pair : pairs) {
|
|
158
|
+
String[] keyValue = pair.split("=");
|
|
159
|
+
if (keyValue.length > 1) {
|
|
160
|
+
String key = keyValue[0];
|
|
161
|
+
String value = keyValue[1];
|
|
162
|
+
params.put(key, value);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
parsedParams.put("serviceId", params.get("serviceid"));
|
|
167
|
+
parsedParams.put("downloadUrl", params.get("file"));
|
|
168
|
+
parsedParams.put("fileExtension", params.get("extension"));
|
|
169
|
+
return parsedParams;
|
|
170
|
+
} catch (URISyntaxException e) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
122
173
|
}
|
|
123
174
|
|
|
124
175
|
private void openUrl(String url) {
|
|
125
176
|
webView.loadUrl(url);
|
|
177
|
+
|
|
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);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
126
186
|
}
|
|
127
187
|
|
|
128
188
|
@Override
|