cordova-plugin-mserviceinterface-2.0 1.0.91 → 1.0.93
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/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/android/mInterface.java +369 -0
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
|
-
xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.93">
|
|
4
4
|
<name>mserviceinterface-2.0</name>
|
|
5
5
|
<description>This plugin establishes the connection to the native interface and performs the requested task.</description>
|
|
6
6
|
<author>selfservit@gmail.com</author>
|
|
@@ -39,6 +39,7 @@ import android.provider.DocumentsContract;
|
|
|
39
39
|
import android.provider.MediaStore;
|
|
40
40
|
import android.provider.OpenableColumns;
|
|
41
41
|
import android.provider.Settings;
|
|
42
|
+
import android.text.TextUtils;
|
|
42
43
|
import android.util.Base64;
|
|
43
44
|
import android.util.Log;
|
|
44
45
|
import android.util.Patterns;
|
|
@@ -94,6 +95,7 @@ import java.io.OutputStream;
|
|
|
94
95
|
import java.io.OutputStreamWriter;
|
|
95
96
|
import java.net.HttpURLConnection;
|
|
96
97
|
import java.net.URL;
|
|
98
|
+
import java.nio.charset.StandardCharsets;
|
|
97
99
|
import java.text.SimpleDateFormat;
|
|
98
100
|
import java.util.ArrayList;
|
|
99
101
|
import java.util.Arrays;
|
|
@@ -144,6 +146,8 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
144
146
|
|
|
145
147
|
private GeofencingClient geofencingClient;
|
|
146
148
|
private PendingIntent geofencePendingIntent;
|
|
149
|
+
private static final int REQ_SCAN_QR = 3001;
|
|
150
|
+
private static final int REQ_SCAN_BAR = 3002;
|
|
147
151
|
/* START SERVICE WHEN USER COMES FROM INACTIVE TO ACTIVE STATE IF SERVICE NOT RUNNING */
|
|
148
152
|
@Override
|
|
149
153
|
public void onResume(boolean multitasking) {
|
|
@@ -315,6 +319,140 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
315
319
|
} catch (Exception e) {
|
|
316
320
|
callbackContext.error(e.getMessage());
|
|
317
321
|
}
|
|
322
|
+
} else if ("GetConfigCascade".equals(action)) {
|
|
323
|
+
final org.json.JSONObject p;
|
|
324
|
+
try {
|
|
325
|
+
p = args.getJSONObject(0);
|
|
326
|
+
} catch (Exception e) {
|
|
327
|
+
callbackContext.error("Invalid arguments: " + e.getMessage());
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
cordova.getThreadPool().execute(new Runnable() {
|
|
332
|
+
@Override
|
|
333
|
+
public void run() {
|
|
334
|
+
java.io.File baseDir;
|
|
335
|
+
String kind, id, clientId, countryCode, clientGroup, vertical, solution, scope, transNo, rootPrefix, localeId;
|
|
336
|
+
java.util.List<java.io.File> roots;
|
|
337
|
+
java.util.List<String> keys, scopesToTry;
|
|
338
|
+
boolean found;
|
|
339
|
+
String resolvedKey, content, usedExt, absPath;
|
|
340
|
+
org.json.JSONObject out;
|
|
341
|
+
|
|
342
|
+
try {
|
|
343
|
+
baseDir = cordova.getActivity().getExternalFilesDir(null);
|
|
344
|
+
if (baseDir == null) baseDir = cordova.getActivity().getFilesDir();
|
|
345
|
+
|
|
346
|
+
kind = p.optString("configType", "controller"); // controller|label|rule|template|ui
|
|
347
|
+
id = p.optString("id", "");
|
|
348
|
+
clientId = p.optString("clientId", "");
|
|
349
|
+
countryCode = p.optString("countryCode", "");
|
|
350
|
+
clientGroup = p.optString("clientGroup", "");
|
|
351
|
+
vertical = p.optString("vertical", "");
|
|
352
|
+
solution = p.optString("solution", "");
|
|
353
|
+
scope = p.optString("scope", kind); // preferred scope (or "containR")
|
|
354
|
+
transNo = p.optString("transNo", "");
|
|
355
|
+
rootPrefix = p.optString("root", "");
|
|
356
|
+
localeId = p.optString("localeId", ""); // <<--- NEW
|
|
357
|
+
|
|
358
|
+
roots = buildRoots(baseDir, rootPrefix, clientGroup, clientId, countryCode);
|
|
359
|
+
|
|
360
|
+
// Build key cascade (label uses locale-aware order)
|
|
361
|
+
keys = new java.util.ArrayList<>();
|
|
362
|
+
if ("label".equals(kind) && !android.text.TextUtils.isEmpty(localeId)) {
|
|
363
|
+
// 1) id_clientId_country_locale
|
|
364
|
+
if (!android.text.TextUtils.isEmpty(clientId) && !android.text.TextUtils.isEmpty(countryCode)) {
|
|
365
|
+
keys.add(id + "_" + clientId + "_" + countryCode + "_" + localeId);
|
|
366
|
+
}
|
|
367
|
+
// 2) id_clientId_locale
|
|
368
|
+
if (!android.text.TextUtils.isEmpty(clientId)) {
|
|
369
|
+
keys.add(id + "_" + clientId + "_" + localeId);
|
|
370
|
+
}
|
|
371
|
+
// 3) id_clientGroup_locale
|
|
372
|
+
if (!android.text.TextUtils.isEmpty(clientGroup)) {
|
|
373
|
+
keys.add(id + "_" + clientGroup + "_" + localeId);
|
|
374
|
+
}
|
|
375
|
+
// 4) id_vertical_locale
|
|
376
|
+
if (!android.text.TextUtils.isEmpty(vertical)) {
|
|
377
|
+
keys.add(id + "_" + vertical + "_" + localeId);
|
|
378
|
+
}
|
|
379
|
+
// 5) id_solution_locale
|
|
380
|
+
if (!android.text.TextUtils.isEmpty(solution)) {
|
|
381
|
+
keys.add(id + "_" + solution + "_" + localeId);
|
|
382
|
+
}
|
|
383
|
+
// 6) id_locale
|
|
384
|
+
keys.add(id + "_" + localeId);
|
|
385
|
+
} else {
|
|
386
|
+
// Default order for controller/rule/template/ui
|
|
387
|
+
if (!android.text.TextUtils.isEmpty(clientId) && !android.text.TextUtils.isEmpty(countryCode)) {
|
|
388
|
+
keys.add(id + "_" + clientId + "_" + countryCode);
|
|
389
|
+
}
|
|
390
|
+
if (!android.text.TextUtils.isEmpty(clientId)) {
|
|
391
|
+
keys.add(id + "_" + clientId);
|
|
392
|
+
}
|
|
393
|
+
if (!android.text.TextUtils.isEmpty(clientGroup))
|
|
394
|
+
keys.add(id + "_" + clientGroup);
|
|
395
|
+
if (!android.text.TextUtils.isEmpty(vertical))
|
|
396
|
+
keys.add(id + "_" + vertical);
|
|
397
|
+
if (!android.text.TextUtils.isEmpty(solution))
|
|
398
|
+
keys.add(id + "_" + solution);
|
|
399
|
+
keys.add(id);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
scopesToTry = new java.util.ArrayList<>();
|
|
403
|
+
if ("containR".equals(scope)) {
|
|
404
|
+
scopesToTry.add("containR");
|
|
405
|
+
scopesToTry.add(kind);
|
|
406
|
+
} else {
|
|
407
|
+
scopesToTry.add(kind);
|
|
408
|
+
scopesToTry.add("containR");
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
found = false;
|
|
412
|
+
resolvedKey = null;
|
|
413
|
+
content = null;
|
|
414
|
+
usedExt = null;
|
|
415
|
+
absPath = null;
|
|
416
|
+
|
|
417
|
+
for (String key : keys) {
|
|
418
|
+
for (String sc : scopesToTry) {
|
|
419
|
+
ResolveResult r;
|
|
420
|
+
try {
|
|
421
|
+
r = resolveGenericFile(roots, sc, kind, id, transNo, key);
|
|
422
|
+
if (r != null && r.file != null) {
|
|
423
|
+
android.util.Log.d("mInterface", "Trying: " + r.file.getAbsolutePath());
|
|
424
|
+
if (r.file.exists() && r.file.isFile()) {
|
|
425
|
+
content = readTextFile(r.file);
|
|
426
|
+
resolvedKey = key;
|
|
427
|
+
usedExt = r.ext;
|
|
428
|
+
absPath = r.file.getAbsolutePath();
|
|
429
|
+
found = true;
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
} catch (Exception ignored) {
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
if (found) break; // early exit once a key resolves
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (found) {
|
|
440
|
+
out = new org.json.JSONObject();
|
|
441
|
+
out.put("configType", kind);
|
|
442
|
+
out.put("srcKey", resolvedKey);
|
|
443
|
+
out.put("ext", usedExt);
|
|
444
|
+
out.put("path", absPath);
|
|
445
|
+
out.put("content", content);
|
|
446
|
+
callbackContext.success(out.toString());
|
|
447
|
+
} else {
|
|
448
|
+
callbackContext.error("NOT_FOUND");
|
|
449
|
+
}
|
|
450
|
+
} catch (Exception e) {
|
|
451
|
+
callbackContext.error("GetConfigCascade failed: " + e.getMessage());
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
return true;
|
|
318
456
|
} else if (action.equals("CheckAutomaticTime")) {
|
|
319
457
|
try {
|
|
320
458
|
boolean timeValue = isTimeAutomatic(cordova.getActivity().getApplicationContext());
|
|
@@ -1015,6 +1153,237 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1015
1153
|
}
|
|
1016
1154
|
return true;
|
|
1017
1155
|
}
|
|
1156
|
+
private static class ResolveResult {
|
|
1157
|
+
java.io.File file;
|
|
1158
|
+
String ext;
|
|
1159
|
+
ResolveResult(java.io.File f, String e) { this.file = f; this.ext = e; }
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
// Build roots under baseDir/rootPrefix/... (deduped)
|
|
1163
|
+
private java.util.List<java.io.File> buildRoots(java.io.File baseDir,
|
|
1164
|
+
String rootPrefix,
|
|
1165
|
+
String clientGroup,
|
|
1166
|
+
String clientId,
|
|
1167
|
+
String countryCode) {
|
|
1168
|
+
java.util.List<java.io.File> roots;
|
|
1169
|
+
java.io.File r1, r2, r3;
|
|
1170
|
+
try {
|
|
1171
|
+
roots = new java.util.ArrayList<>();
|
|
1172
|
+
|
|
1173
|
+
r1 = new java.io.File(new java.io.File(new java.io.File(baseDir, rootPrefix), clientId), countryCode);
|
|
1174
|
+
addIfUnique(roots, r1);
|
|
1175
|
+
|
|
1176
|
+
r2 = new java.io.File(new java.io.File(new java.io.File(new java.io.File(baseDir, rootPrefix), clientId), clientId), countryCode);
|
|
1177
|
+
addIfUnique(roots, r2);
|
|
1178
|
+
|
|
1179
|
+
if (!android.text.TextUtils.isEmpty(clientGroup)) {
|
|
1180
|
+
r3 = new java.io.File(new java.io.File(new java.io.File(new java.io.File(baseDir, rootPrefix), clientGroup), clientId), countryCode);
|
|
1181
|
+
addIfUnique(roots, r3);
|
|
1182
|
+
}
|
|
1183
|
+
return roots;
|
|
1184
|
+
} catch (Exception e) {
|
|
1185
|
+
return new java.util.ArrayList<>();
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
private void addIfUnique(java.util.List<java.io.File> list, java.io.File candidate) {
|
|
1190
|
+
if (candidate == null) return;
|
|
1191
|
+
String path = candidate.getAbsolutePath();
|
|
1192
|
+
for (java.io.File f : list) { if (f.getAbsolutePath().equals(path)) return; }
|
|
1193
|
+
list.add(candidate);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
// Map: filename prefix and extensions by kind
|
|
1197
|
+
private String prefixForKind(String kind) {
|
|
1198
|
+
if ("controller".equals(kind)) return "controller_";
|
|
1199
|
+
if ("label".equals(kind)) return "label_";
|
|
1200
|
+
if ("rule".equals(kind)) return "rule_";
|
|
1201
|
+
if ("template".equals(kind)) return "template_";
|
|
1202
|
+
if ("ui".equals(kind)) return "ui_";
|
|
1203
|
+
return kind + "_";
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
private String[] extensionsForKind(String kind) {
|
|
1207
|
+
if ("controller".equals(kind)) return new String[]{"json"};
|
|
1208
|
+
if ("label".equals(kind)) return new String[]{"json","txt"};
|
|
1209
|
+
if ("rule".equals(kind)) return new String[]{"txt","json"}; // .txt first
|
|
1210
|
+
if ("template".equals(kind)) return new String[]{"html","json"};
|
|
1211
|
+
if ("ui".equals(kind)) return new String[]{"html","json"};
|
|
1212
|
+
return new String[]{"json"};
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
// Build and test all plausible shapes for this root/scope/kind/key
|
|
1216
|
+
private ResolveResult resolveGenericFile(java.util.List<java.io.File> roots,
|
|
1217
|
+
String scope,
|
|
1218
|
+
String kind,
|
|
1219
|
+
String id,
|
|
1220
|
+
String transNo,
|
|
1221
|
+
String key) {
|
|
1222
|
+
String[] exts = extensionsForKind(kind);
|
|
1223
|
+
String prefix = prefixForKind(kind);
|
|
1224
|
+
|
|
1225
|
+
// For labels, support both with-prefix and no-prefix filenames.
|
|
1226
|
+
String[] nameVariants = "label".equals(kind)
|
|
1227
|
+
? new String[] { prefix + key, /* no prefix */ key }
|
|
1228
|
+
: new String[] { prefix + key };
|
|
1229
|
+
|
|
1230
|
+
try {
|
|
1231
|
+
for (java.io.File root : roots) {
|
|
1232
|
+
if (root == null) continue;
|
|
1233
|
+
|
|
1234
|
+
for (String ext : exts) {
|
|
1235
|
+
|
|
1236
|
+
if ("containR".equals(scope)) {
|
|
1237
|
+
java.io.File containRDir = new java.io.File(root, "containR");
|
|
1238
|
+
java.io.File screenDir = new java.io.File(containRDir, id);
|
|
1239
|
+
|
|
1240
|
+
// With transNo
|
|
1241
|
+
if (!android.text.TextUtils.isEmpty(transNo)) {
|
|
1242
|
+
java.io.File transDir = new java.io.File(screenDir, transNo);
|
|
1243
|
+
|
|
1244
|
+
if ("label".equals(kind)) {
|
|
1245
|
+
java.io.File labelDir = new java.io.File(transDir, "label");
|
|
1246
|
+
java.io.File labelsDir = new java.io.File(transDir, "labels");
|
|
1247
|
+
for (String nameVar : nameVariants) {
|
|
1248
|
+
java.io.File[] cands = new java.io.File[] {
|
|
1249
|
+
new java.io.File(labelDir, nameVar + "." + ext),
|
|
1250
|
+
new java.io.File(labelsDir, nameVar + "." + ext),
|
|
1251
|
+
new java.io.File(transDir, nameVar + "." + ext) // legacy
|
|
1252
|
+
};
|
|
1253
|
+
for (java.io.File f : cands) {
|
|
1254
|
+
android.util.Log.d("mInterface", "Trying: " + f.getAbsolutePath());
|
|
1255
|
+
if (f.exists() && f.isFile()) return new ResolveResult(f, ext);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
} else {
|
|
1259
|
+
java.io.File typeDir = new java.io.File(transDir, kind);
|
|
1260
|
+
java.io.File f1 = new java.io.File(typeDir, prefix + key + "." + ext);
|
|
1261
|
+
java.io.File f2 = new java.io.File(transDir, prefix + key + "." + ext); // legacy
|
|
1262
|
+
android.util.Log.d("mInterface", "Trying: " + f1.getAbsolutePath());
|
|
1263
|
+
if (f1.exists() && f1.isFile()) return new ResolveResult(f1, ext);
|
|
1264
|
+
android.util.Log.d("mInterface", "Trying: " + f2.getAbsolutePath());
|
|
1265
|
+
if (f2.exists() && f2.isFile()) return new ResolveResult(f2, ext);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
// No transNo
|
|
1270
|
+
if ("label".equals(kind)) {
|
|
1271
|
+
java.io.File labelDirNT = new java.io.File(screenDir, "label");
|
|
1272
|
+
java.io.File labelsDirNT = new java.io.File(screenDir, "labels");
|
|
1273
|
+
for (String nameVar : nameVariants) {
|
|
1274
|
+
java.io.File[] cands = new java.io.File[] {
|
|
1275
|
+
new java.io.File(labelDirNT, nameVar + "." + ext),
|
|
1276
|
+
new java.io.File(labelsDirNT, nameVar + "." + ext),
|
|
1277
|
+
new java.io.File(screenDir, nameVar + "." + ext) // legacy
|
|
1278
|
+
};
|
|
1279
|
+
for (java.io.File f : cands) {
|
|
1280
|
+
android.util.Log.d("mInterface", "Trying: " + f.getAbsolutePath());
|
|
1281
|
+
if (f.exists() && f.isFile()) return new ResolveResult(f, ext);
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
} else {
|
|
1285
|
+
java.io.File typeDirNT = new java.io.File(screenDir, kind);
|
|
1286
|
+
java.io.File f1 = new java.io.File(typeDirNT, prefix + key + "." + ext);
|
|
1287
|
+
java.io.File f2 = new java.io.File(screenDir, prefix + key + "." + ext); // legacy
|
|
1288
|
+
android.util.Log.d("mInterface", "Trying: " + f1.getAbsolutePath());
|
|
1289
|
+
if (f1.exists() && f1.isFile()) return new ResolveResult(f1, ext);
|
|
1290
|
+
android.util.Log.d("mInterface", "Trying: " + f2.getAbsolutePath());
|
|
1291
|
+
if (f2.exists() && f2.isFile()) return new ResolveResult(f2, ext);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
} else {
|
|
1295
|
+
// configuration_package / configuration
|
|
1296
|
+
java.io.File cfg = new java.io.File(root, "configuration_package");
|
|
1297
|
+
|
|
1298
|
+
if ("label".equals(kind)) {
|
|
1299
|
+
// Support /label/ and /labels/
|
|
1300
|
+
java.io.File labelDir = new java.io.File(cfg, "label");
|
|
1301
|
+
java.io.File labelsDir = new java.io.File(cfg, "labels");
|
|
1302
|
+
|
|
1303
|
+
for (String nameVar : nameVariants) {
|
|
1304
|
+
// standard
|
|
1305
|
+
java.io.File[] cands1 = new java.io.File[] {
|
|
1306
|
+
new java.io.File(labelDir, nameVar + "." + ext),
|
|
1307
|
+
new java.io.File(labelsDir, nameVar + "." + ext)
|
|
1308
|
+
};
|
|
1309
|
+
for (java.io.File f : cands1) {
|
|
1310
|
+
android.util.Log.d("mInterface", "Trying: " + f.getAbsolutePath());
|
|
1311
|
+
if (f.exists() && f.isFile()) return new ResolveResult(f, ext);
|
|
1312
|
+
}
|
|
1313
|
+
// variant: per-screen folder
|
|
1314
|
+
java.io.File[] cands2 = new java.io.File[] {
|
|
1315
|
+
new java.io.File(new java.io.File(labelDir, id), nameVar + "." + ext),
|
|
1316
|
+
new java.io.File(new java.io.File(labelsDir, id), nameVar + "." + ext)
|
|
1317
|
+
};
|
|
1318
|
+
for (java.io.File f : cands2) {
|
|
1319
|
+
android.util.Log.d("mInterface", "Trying: " + f.getAbsolutePath());
|
|
1320
|
+
if (f.exists() && f.isFile()) return new ResolveResult(f, ext);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
// legacy 'configuration'
|
|
1325
|
+
java.io.File cfg2 = new java.io.File(root, "configuration");
|
|
1326
|
+
java.io.File label2 = new java.io.File(cfg2, "label");
|
|
1327
|
+
java.io.File labels2 = new java.io.File(cfg2, "labels");
|
|
1328
|
+
for (String nameVar : nameVariants) {
|
|
1329
|
+
java.io.File[] cands3 = new java.io.File[] {
|
|
1330
|
+
new java.io.File(label2, nameVar + "." + ext),
|
|
1331
|
+
new java.io.File(labels2, nameVar + "." + ext),
|
|
1332
|
+
new java.io.File(new java.io.File(label2, id), nameVar + "." + ext),
|
|
1333
|
+
new java.io.File(new java.io.File(labels2, id), nameVar + "." + ext)
|
|
1334
|
+
};
|
|
1335
|
+
for (java.io.File f : cands3) {
|
|
1336
|
+
android.util.Log.d("mInterface", "Trying: " + f.getAbsolutePath());
|
|
1337
|
+
if (f.exists() && f.isFile()) return new ResolveResult(f, ext);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
} else {
|
|
1342
|
+
// non-label kinds
|
|
1343
|
+
java.io.File typeDir = new java.io.File(cfg, kind);
|
|
1344
|
+
java.io.File f1 = new java.io.File(typeDir, prefix + key + "." + ext);
|
|
1345
|
+
java.io.File f2 = new java.io.File(new java.io.File(typeDir, id), prefix + key + "." + ext);
|
|
1346
|
+
android.util.Log.d("mInterface", "Trying: " + f1.getAbsolutePath());
|
|
1347
|
+
if (f1.exists() && f1.isFile()) return new ResolveResult(f1, ext);
|
|
1348
|
+
android.util.Log.d("mInterface", "Trying: " + f2.getAbsolutePath());
|
|
1349
|
+
if (f2.exists() && f2.isFile()) return new ResolveResult(f2, ext);
|
|
1350
|
+
|
|
1351
|
+
// legacy 'configuration'
|
|
1352
|
+
java.io.File cfg2 = new java.io.File(root, "configuration");
|
|
1353
|
+
java.io.File type2 = new java.io.File(cfg2, kind);
|
|
1354
|
+
java.io.File f3 = new java.io.File(type2, prefix + key + "." + ext);
|
|
1355
|
+
java.io.File f4 = new java.io.File(new java.io.File(type2, id), prefix + key + "." + ext);
|
|
1356
|
+
android.util.Log.d("mInterface", "Trying: " + f3.getAbsolutePath());
|
|
1357
|
+
if (f3.exists() && f3.isFile()) return new ResolveResult(f3, ext);
|
|
1358
|
+
android.util.Log.d("mInterface", "Trying: " + f4.getAbsolutePath());
|
|
1359
|
+
if (f4.exists() && f4.isFile()) return new ResolveResult(f4, ext);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
} catch (Exception ignored) { }
|
|
1365
|
+
return null;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
private String readTextFile(java.io.File file) throws Exception {
|
|
1369
|
+
java.io.BufferedInputStream in = null;
|
|
1370
|
+
java.io.InputStreamReader isr = null;
|
|
1371
|
+
java.io.BufferedReader reader = null;
|
|
1372
|
+
StringBuilder sb = new StringBuilder();
|
|
1373
|
+
String line;
|
|
1374
|
+
try {
|
|
1375
|
+
in = new java.io.BufferedInputStream(new java.io.FileInputStream(file));
|
|
1376
|
+
isr = new java.io.InputStreamReader(in, java.nio.charset.StandardCharsets.UTF_8);
|
|
1377
|
+
reader = new java.io.BufferedReader(isr);
|
|
1378
|
+
while ((line = reader.readLine()) != null) { sb.append(line); }
|
|
1379
|
+
} finally {
|
|
1380
|
+
try { if (reader != null) reader.close(); } catch (Exception ignored) {}
|
|
1381
|
+
try { if (isr != null) isr.close(); } catch (Exception ignored) {}
|
|
1382
|
+
try { if (in != null) in.close(); } catch (Exception ignored) {}
|
|
1383
|
+
}
|
|
1384
|
+
return sb.toString();
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1018
1387
|
private void addGeofence(double latitude, double longitude, float radius, String geofenceId, String enterMessage, String exitMessage, CallbackContext callbackContext, Context context) {
|
|
1019
1388
|
Geofence geofence = new Geofence.Builder()
|
|
1020
1389
|
.setRequestId(geofenceId)
|