cordova-plugin-mserviceinterface-2.0 1.0.50 → 1.0.52
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 +3 -3
- package/src/android/backgroundNotification.java +14 -14
- package/src/android/mInterface.java +305 -282
- package/src/android/mInterfaceService.java +68 -140
- package/src/android/mInterfaceUtil.java +116 -118
- package/src/ios/mInterface.m +3 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
package com.selfservit.util;
|
|
2
2
|
|
|
3
|
+
import static com.selfservit.util.mInterface.pathComponent;
|
|
4
|
+
|
|
3
5
|
import android.annotation.TargetApi;
|
|
4
6
|
import android.app.Activity;
|
|
5
|
-
import android.content.ContentUris;
|
|
6
|
-
import android.content.ContentValues;
|
|
7
7
|
import android.content.Context;
|
|
8
8
|
import android.database.Cursor;
|
|
9
9
|
import android.graphics.Bitmap;
|
|
@@ -18,11 +18,9 @@ import android.net.NetworkInfo;
|
|
|
18
18
|
import android.net.Uri;
|
|
19
19
|
import android.os.AsyncTask;
|
|
20
20
|
import android.os.Build;
|
|
21
|
-
import android.os.Environment;
|
|
22
21
|
import android.provider.MediaStore;
|
|
23
22
|
import android.util.Base64;
|
|
24
23
|
import android.util.Log;
|
|
25
|
-
import android.widget.Toast;
|
|
26
24
|
|
|
27
25
|
import org.apache.cordova.CallbackContext;
|
|
28
26
|
import org.apache.cordova.PluginResult;
|
|
@@ -48,6 +46,7 @@ import java.io.OutputStream;
|
|
|
48
46
|
import java.io.OutputStreamWriter;
|
|
49
47
|
import java.net.HttpURLConnection;
|
|
50
48
|
import java.net.URL;
|
|
49
|
+
import java.nio.charset.StandardCharsets;
|
|
51
50
|
import java.text.SimpleDateFormat;
|
|
52
51
|
import java.util.Arrays;
|
|
53
52
|
import java.util.Date;
|
|
@@ -60,10 +59,6 @@ import javax.crypto.Cipher;
|
|
|
60
59
|
import javax.crypto.spec.IvParameterSpec;
|
|
61
60
|
import javax.crypto.spec.SecretKeySpec;
|
|
62
61
|
|
|
63
|
-
import static com.selfservit.util.mInterface.pathComponent;
|
|
64
|
-
|
|
65
|
-
import androidx.annotation.RequiresApi;
|
|
66
|
-
|
|
67
62
|
public class mInterfaceUtil {
|
|
68
63
|
|
|
69
64
|
LocationManager locationManager;
|
|
@@ -90,7 +85,6 @@ public class mInterfaceUtil {
|
|
|
90
85
|
public static String deviceID = "";
|
|
91
86
|
public static String timerInd = "";
|
|
92
87
|
|
|
93
|
-
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
94
88
|
public static String decrypt(String encryptedText) {
|
|
95
89
|
String decryptedText = "";
|
|
96
90
|
try {
|
|
@@ -100,7 +94,7 @@ public class mInterfaceUtil {
|
|
|
100
94
|
IvParameterSpec ivparameterspec = new IvParameterSpec(key);
|
|
101
95
|
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivparameterspec);
|
|
102
96
|
byte[] cipherText = android.util.Base64.decode(encryptedText, 0);
|
|
103
|
-
decryptedText = new String(cipher.doFinal(cipherText),
|
|
97
|
+
decryptedText = new String(cipher.doFinal(cipherText), StandardCharsets.UTF_8);
|
|
104
98
|
} catch (Exception E) {
|
|
105
99
|
System.out.println("decrypt Exception : " + E.getMessage());
|
|
106
100
|
}
|
|
@@ -113,13 +107,14 @@ public class mInterfaceUtil {
|
|
|
113
107
|
@Override
|
|
114
108
|
protected void onPreExecute() {
|
|
115
109
|
}
|
|
110
|
+
|
|
116
111
|
@Override
|
|
117
112
|
protected String doInBackground(String... args) {
|
|
118
113
|
BufferedInputStream input = null;
|
|
119
114
|
OutputStream output = null;
|
|
120
115
|
HttpURLConnection connection = null;
|
|
121
116
|
int count;
|
|
122
|
-
int progressCheck=10;
|
|
117
|
+
int progressCheck = 10;
|
|
123
118
|
try {
|
|
124
119
|
URL url = new URL((requestURL).replaceAll(" ", "%20"));
|
|
125
120
|
connection = (HttpURLConnection) url.openConnection();
|
|
@@ -129,9 +124,7 @@ public class mInterfaceUtil {
|
|
|
129
124
|
return "Server returned HTTP " + connection.getResponseCode() + " " + connection.getResponseMessage();
|
|
130
125
|
}
|
|
131
126
|
int fileLength = connection.getContentLength();
|
|
132
|
-
input = new BufferedInputStream(connection.getInputStream(),8192);
|
|
133
|
-
|
|
134
|
-
//File rootPath = Environment.getExternalStorageDirectory();
|
|
127
|
+
input = new BufferedInputStream(connection.getInputStream(), 8192);
|
|
135
128
|
String rootPath = context.getExternalMediaDirs()[0].toString();
|
|
136
129
|
File filesourceDirecory = new File(rootPath + "/" + pathComponent(filePath));
|
|
137
130
|
if (!filesourceDirecory.exists()) {
|
|
@@ -139,7 +132,7 @@ public class mInterfaceUtil {
|
|
|
139
132
|
}
|
|
140
133
|
File fileSavePath = new File(rootPath + "/" + filePath);
|
|
141
134
|
output = new FileOutputStream(fileSavePath);
|
|
142
|
-
byte
|
|
135
|
+
byte[] data = new byte[1024];
|
|
143
136
|
long progress = 0;
|
|
144
137
|
int progressToSend = 0;
|
|
145
138
|
while ((count = input.read(data)) != -1) {
|
|
@@ -149,9 +142,9 @@ public class mInterfaceUtil {
|
|
|
149
142
|
return null;
|
|
150
143
|
}
|
|
151
144
|
progress += count;
|
|
152
|
-
progressToSend = (int)((progress * 100) / fileLength);
|
|
145
|
+
progressToSend = (int) ((progress * 100) / fileLength);
|
|
153
146
|
|
|
154
|
-
if(progressToSend >= progressCheck){
|
|
147
|
+
if (progressToSend >= progressCheck) {
|
|
155
148
|
JSONObject progressObj = new JSONObject();
|
|
156
149
|
progressObj.put("progress", progressCheck);
|
|
157
150
|
progressObj.put("fileLength", fileLength);
|
|
@@ -166,28 +159,29 @@ public class mInterfaceUtil {
|
|
|
166
159
|
} catch (Exception e) {
|
|
167
160
|
callbackContext.error("Failure" + e.getMessage());
|
|
168
161
|
}
|
|
169
|
-
if(thumbnailInd.equalsIgnoreCase("true")){
|
|
162
|
+
if (thumbnailInd.equalsIgnoreCase("true")) {
|
|
170
163
|
return filePath;
|
|
171
|
-
}else{
|
|
172
|
-
return
|
|
164
|
+
} else {
|
|
165
|
+
return null;
|
|
173
166
|
}
|
|
174
167
|
}
|
|
168
|
+
|
|
175
169
|
public void onPostExecute(String result) {
|
|
176
170
|
try {
|
|
177
171
|
MediaScannerConnection.scanFile(context,
|
|
178
|
-
new String[]
|
|
172
|
+
new String[]{context.getExternalMediaDirs()[0].toString()},
|
|
179
173
|
null,
|
|
180
174
|
(path, uri) -> {
|
|
181
175
|
Log.i("ExternalStorage", "Scanned " + path + ":");
|
|
182
176
|
Log.i("ExternalStorage", "-> uri=" + uri);
|
|
183
177
|
});
|
|
184
178
|
if (result != null) {
|
|
185
|
-
if(result.indexOf('.') != -1){
|
|
179
|
+
if (result.indexOf('.') != -1) {
|
|
186
180
|
String extension = "." + result.substring(result.lastIndexOf(".") + 1).toLowerCase(),
|
|
187
|
-
filePath = context.getExternalMediaDirs()[0].toString()+"/"+result;
|
|
188
|
-
String thumbnail = getFileThumbnail(filePath,extension,context);
|
|
181
|
+
filePath = context.getExternalMediaDirs()[0].toString() + "/" + result;
|
|
182
|
+
String thumbnail = getFileThumbnail(filePath, extension, context);
|
|
189
183
|
callbackContext.success(thumbnail);
|
|
190
|
-
} else{
|
|
184
|
+
} else {
|
|
191
185
|
callbackContext.error("Failure");
|
|
192
186
|
}
|
|
193
187
|
} else {
|
|
@@ -203,6 +197,7 @@ public class mInterfaceUtil {
|
|
|
203
197
|
e.printStackTrace();
|
|
204
198
|
}
|
|
205
199
|
}
|
|
200
|
+
|
|
206
201
|
public static String encrypt(String plainText) {
|
|
207
202
|
String encryptedText = "";
|
|
208
203
|
try {
|
|
@@ -211,7 +206,7 @@ public class mInterfaceUtil {
|
|
|
211
206
|
SecretKeySpec secretKey = new SecretKeySpec(key, aesEncryptionAlgorithem);
|
|
212
207
|
IvParameterSpec ivparameterspec = new IvParameterSpec(key);
|
|
213
208
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivparameterspec);
|
|
214
|
-
byte[] cipherText = android.util.Base64.encode(cipher.doFinal(plainText.getBytes(
|
|
209
|
+
byte[] cipherText = android.util.Base64.encode(cipher.doFinal(plainText.getBytes(StandardCharsets.UTF_8)), 0);
|
|
215
210
|
encryptedText = new String(cipherText);
|
|
216
211
|
} catch (Exception E) {
|
|
217
212
|
System.out.println("decrypt Exception : " + E.getMessage());
|
|
@@ -225,20 +220,23 @@ public class mInterfaceUtil {
|
|
|
225
220
|
longitude = "";
|
|
226
221
|
|
|
227
222
|
String currentLine, lastKnownLocation = "";
|
|
223
|
+
File locationFile;
|
|
228
224
|
try {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
225
|
+
locationFile = new File(rootDirectory, "/" + mInterfaceUtil.packageName + "/LastKnownLocation_encrypted.txt");
|
|
226
|
+
if (locationFile.exists() && !locationFile.isDirectory()) {
|
|
227
|
+
BufferedReader readerObj = new BufferedReader(new FileReader(locationFile));
|
|
228
|
+
while ((currentLine = readerObj.readLine()) != null) {
|
|
229
|
+
lastKnownLocation = currentLine;
|
|
230
|
+
}
|
|
231
|
+
readerObj.close();
|
|
232
|
+
String encryptedLocation = decrypt(lastKnownLocation);
|
|
233
|
+
String[] splitStr = encryptedLocation.split(",");
|
|
234
|
+
latitude = splitStr[0];
|
|
235
|
+
longitude = splitStr[1];
|
|
232
236
|
}
|
|
233
|
-
readerObj.close();
|
|
234
|
-
String encryptedLocation = decrypt(lastKnownLocation);
|
|
235
|
-
String[] splitStr = encryptedLocation.split(",");
|
|
236
|
-
latitude = splitStr[0];
|
|
237
|
-
longitude = splitStr[1];
|
|
238
237
|
} catch (Exception e) {
|
|
239
238
|
e.printStackTrace();
|
|
240
239
|
}
|
|
241
|
-
|
|
242
240
|
//*** SUBSTRING LATITUDE,LONGITUDE IF GREATER THAN 10 POINTS ***//
|
|
243
241
|
if (latitude.length() > 10) {
|
|
244
242
|
latitude = latitude.substring(0, 10);
|
|
@@ -255,7 +253,7 @@ public class mInterfaceUtil {
|
|
|
255
253
|
Boolean isEnabled = false;
|
|
256
254
|
|
|
257
255
|
//*** REGISTER THE LOCATION MANAGER *** //
|
|
258
|
-
locationManager = (LocationManager) context.getSystemService(
|
|
256
|
+
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
|
259
257
|
//*** CHECK LOCATION SETTING ENABLED OR NOT ***//
|
|
260
258
|
isEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
|
261
259
|
|
|
@@ -324,10 +322,10 @@ public class mInterfaceUtil {
|
|
|
324
322
|
for (int index = 0; index < arguments.length(); index++) {
|
|
325
323
|
inputFileObj = arguments.getJSONObject(index);
|
|
326
324
|
File rootDir = rootDirectory;
|
|
327
|
-
srcFilePath = rootDir + "/" + inputFileObj.optString("srcPath")
|
|
328
|
-
srcFileName = inputFileObj.optString("srcFile")
|
|
329
|
-
desFilePath = rootDir + "/" + inputFileObj.optString("desPath")
|
|
330
|
-
desFileName = inputFileObj.optString("desFile")
|
|
325
|
+
srcFilePath = rootDir + "/" + inputFileObj.optString("srcPath");
|
|
326
|
+
srcFileName = inputFileObj.optString("srcFile");
|
|
327
|
+
desFilePath = rootDir + "/" + inputFileObj.optString("desPath");
|
|
328
|
+
desFileName = inputFileObj.optString("desFile");
|
|
331
329
|
sourceFileObj = new File(srcFilePath + "/" + srcFileName);
|
|
332
330
|
desFileObj = new File(desFilePath + "/" + desFileName);
|
|
333
331
|
//** CHECK DESTINATION FILE PATH EXITS OR NOT **//
|
|
@@ -370,10 +368,10 @@ public class mInterfaceUtil {
|
|
|
370
368
|
try {
|
|
371
369
|
for (int index = 0; index < arguments.length(); index++) {
|
|
372
370
|
inputFileObj = arguments.getJSONObject(index);
|
|
373
|
-
srcFilePath = rootDirectory + "/" + inputFileObj.optString("sourceFilePath")
|
|
374
|
-
srcFileName = inputFileObj.optString("sourceFileName")
|
|
375
|
-
desFilePath = rootDirectory + "/" + inputFileObj.optString("targetFilePath")
|
|
376
|
-
desFileName = inputFileObj.optString("targetFileName")
|
|
371
|
+
srcFilePath = rootDirectory + "/" + inputFileObj.optString("sourceFilePath");
|
|
372
|
+
srcFileName = inputFileObj.optString("sourceFileName");
|
|
373
|
+
desFilePath = rootDirectory + "/" + inputFileObj.optString("targetFilePath");
|
|
374
|
+
desFileName = inputFileObj.optString("targetFileName");
|
|
377
375
|
sourceFileObj = new File(srcFilePath + "/" + srcFileName);
|
|
378
376
|
desFileObj = new File(desFilePath + "/" + desFileName);
|
|
379
377
|
//** CHECK DESTINATION FILE PATH EXITS OR NOT **//
|
|
@@ -418,12 +416,12 @@ public class mInterfaceUtil {
|
|
|
418
416
|
try {
|
|
419
417
|
for (int index = 0; index < arguments.length(); index++) {
|
|
420
418
|
inputFileObj = arguments.getJSONObject(index);
|
|
421
|
-
srcFilePath = inputFileObj.optString("srcPath")
|
|
422
|
-
srcFileName = inputFileObj.optString("srcFile")
|
|
423
|
-
desFilePath = rootDirectory + "/" + inputFileObj.optString("desPath")
|
|
424
|
-
desFileName = inputFileObj.optString("desFile")
|
|
425
|
-
queueCopyPath = rootDirectory + "/" + inputFileObj.optString("queueAttachPath")
|
|
426
|
-
queueCopyFileName = inputFileObj.optString("queueAttachFile")
|
|
419
|
+
srcFilePath = inputFileObj.optString("srcPath");
|
|
420
|
+
srcFileName = inputFileObj.optString("srcFile");
|
|
421
|
+
desFilePath = rootDirectory + "/" + inputFileObj.optString("desPath");
|
|
422
|
+
desFileName = inputFileObj.optString("desFile");
|
|
423
|
+
queueCopyPath = rootDirectory + "/" + inputFileObj.optString("queueAttachPath");
|
|
424
|
+
queueCopyFileName = inputFileObj.optString("queueAttachFile");
|
|
427
425
|
sourceFileObj = new File(srcFilePath + "/" + srcFileName);
|
|
428
426
|
desFileObj = new File(desFilePath + "/" + desFileName);
|
|
429
427
|
queueFileObj = new File(queueCopyPath + "/" + queueCopyFileName);
|
|
@@ -481,10 +479,10 @@ public class mInterfaceUtil {
|
|
|
481
479
|
try {
|
|
482
480
|
for (int index = 0; index < arguments.length(); index++) {
|
|
483
481
|
inputFileObj = arguments.getJSONObject(index);
|
|
484
|
-
srcFilePath = rootDirectory + "/" + inputFileObj.optString("sourceFilePath")
|
|
485
|
-
srcFileName = inputFileObj.optString("sourceFileName")
|
|
486
|
-
desFilePath = rootDirectory + "/" + inputFileObj.optString("targetFilePath")
|
|
487
|
-
desFileName = inputFileObj.optString("targetFileName")
|
|
482
|
+
srcFilePath = rootDirectory + "/" + inputFileObj.optString("sourceFilePath");
|
|
483
|
+
srcFileName = inputFileObj.optString("sourceFileName");
|
|
484
|
+
desFilePath = rootDirectory + "/" + inputFileObj.optString("targetFilePath");
|
|
485
|
+
desFileName = inputFileObj.optString("targetFileName");
|
|
488
486
|
sourceFile = new File(srcFilePath + "/" + srcFileName);
|
|
489
487
|
desFile = new File(desFilePath + "/" + desFileName);
|
|
490
488
|
//** CHECK DESTINATION FILE PATH EXITS OR NOT **//
|
|
@@ -530,12 +528,12 @@ public class mInterfaceUtil {
|
|
|
530
528
|
try {
|
|
531
529
|
for (int index = 0; index < arguments.length(); index++) {
|
|
532
530
|
inputFileObj = arguments.getJSONObject(index);
|
|
533
|
-
srcFilePath = inputFileObj.optString("srcPath")
|
|
534
|
-
srcFileName = inputFileObj.optString("srcFile")
|
|
535
|
-
desFilePath = rootDirectory + "/" + inputFileObj.optString("desPath")
|
|
536
|
-
desFileName = inputFileObj.optString("desFile")
|
|
537
|
-
queueCopyPath = rootDirectory + "/" + inputFileObj.optString("queueAttachPath")
|
|
538
|
-
queueCopyFileName = inputFileObj.optString("queueAttachFile")
|
|
531
|
+
srcFilePath = inputFileObj.optString("srcPath");
|
|
532
|
+
srcFileName = inputFileObj.optString("srcFile");
|
|
533
|
+
desFilePath = rootDirectory + "/" + inputFileObj.optString("desPath");
|
|
534
|
+
desFileName = inputFileObj.optString("desFile");
|
|
535
|
+
queueCopyPath = rootDirectory + "/" + inputFileObj.optString("queueAttachPath");
|
|
536
|
+
queueCopyFileName = inputFileObj.optString("queueAttachFile");
|
|
539
537
|
sourceFileObj = new File(srcFilePath + "/" + srcFileName);
|
|
540
538
|
desFileObj = new File(desFilePath + "/" + desFileName);
|
|
541
539
|
queueFileObj = new File(queueCopyPath + "/" + queueCopyFileName);
|
|
@@ -598,10 +596,10 @@ public class mInterfaceUtil {
|
|
|
598
596
|
accountsList = new JSONArray(decrypt(myAccountsFileBuilder.toString()));
|
|
599
597
|
for (int index = 0; index < accountsList.length(); index++) {
|
|
600
598
|
currentAccount = accountsList.optJSONObject(index);
|
|
601
|
-
clientID = currentAccount.optString("client_id")
|
|
602
|
-
countryCode = currentAccount.optString("country_code")
|
|
603
|
-
userID = currentAccount.optString("user_id")
|
|
604
|
-
clientUrl = currentAccount.optString("client_url")
|
|
599
|
+
clientID = currentAccount.optString("client_id");
|
|
600
|
+
countryCode = currentAccount.optString("country_code");
|
|
601
|
+
userID = currentAccount.optString("user_id");
|
|
602
|
+
clientUrl = currentAccount.optString("client_url");
|
|
605
603
|
File baseDirectory = rootDirectory;
|
|
606
604
|
File databaseDir = new File(baseDirectory + "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/database");
|
|
607
605
|
File processFileDir = new File(mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/database/process/");
|
|
@@ -618,8 +616,8 @@ public class mInterfaceUtil {
|
|
|
618
616
|
break;
|
|
619
617
|
}
|
|
620
618
|
String[] fileName = attachmentsFiles[attachIndex].toString().split("/");
|
|
621
|
-
String attachURL = clientUrl + "/common/components/QueueManager/QueueUpload.aspx?file_path=attachments&client_id=" + clientID + "&country_code=" + countryCode + "&user_id=" + userID + "&file_name=" + fileName[fileName.length - 1]
|
|
622
|
-
statusIndication = sendFilesToServer(attachmentsFiles[attachIndex].toString(), fileName[fileName.length - 1]
|
|
619
|
+
String attachURL = clientUrl + "/common/components/QueueManager/QueueUpload.aspx?file_path=attachments&client_id=" + clientID + "&country_code=" + countryCode + "&user_id=" + userID + "&file_name=" + fileName[fileName.length - 1];
|
|
620
|
+
statusIndication = sendFilesToServer(attachmentsFiles[attachIndex].toString(), fileName[fileName.length - 1], attachURL);
|
|
623
621
|
if (statusIndication.equals("true")) {
|
|
624
622
|
breakIndication = "true";
|
|
625
623
|
break;
|
|
@@ -638,8 +636,8 @@ public class mInterfaceUtil {
|
|
|
638
636
|
break;
|
|
639
637
|
}
|
|
640
638
|
String[] fileName = queueFiles[queueIndex].toString().split("/");
|
|
641
|
-
String queueURL = clientUrl + "/common/components/QueueManager/QueueUpload.aspx?file_path=queue&client_id=" + clientID + "&country_code=" + countryCode + "&user_id=" + userID + "&file_name=" + fileName[fileName.length - 1]
|
|
642
|
-
sendFilesToServer(queueFiles[queueIndex].toString(), fileName[fileName.length - 1]
|
|
639
|
+
String queueURL = clientUrl + "/common/components/QueueManager/QueueUpload.aspx?file_path=queue&client_id=" + clientID + "&country_code=" + countryCode + "&user_id=" + userID + "&file_name=" + fileName[fileName.length - 1];
|
|
640
|
+
sendFilesToServer(queueFiles[queueIndex].toString(), fileName[fileName.length - 1], queueURL);
|
|
643
641
|
}
|
|
644
642
|
}
|
|
645
643
|
}
|
|
@@ -742,7 +740,7 @@ public class mInterfaceUtil {
|
|
|
742
740
|
}
|
|
743
741
|
readerObj.close();
|
|
744
742
|
JSONObject serverDateObj = new JSONObject(decrypt(timeObj.toString()));
|
|
745
|
-
String serverTimeObj = serverDateObj.optString("serverDate")
|
|
743
|
+
String serverTimeObj = serverDateObj.optString("serverDate");
|
|
746
744
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy,MM,dd,HH,mm,ss", locale);
|
|
747
745
|
Date serverDate = simpleDateFormat.parse(serverTimeObj);
|
|
748
746
|
long timeDiff = mobileDate.getTime() - serverDate.getTime();
|
|
@@ -787,37 +785,39 @@ public class mInterfaceUtil {
|
|
|
787
785
|
}
|
|
788
786
|
}
|
|
789
787
|
}
|
|
788
|
+
|
|
790
789
|
public String convertBitmapToString(Bitmap bitmap) {
|
|
791
790
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
792
791
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
|
|
793
792
|
return Base64.encodeToString(outputStream.toByteArray(), Base64.NO_WRAP);
|
|
794
793
|
}
|
|
795
|
-
|
|
794
|
+
|
|
795
|
+
public String getFileThumbnail(String filePath, String extension, Context context) {
|
|
796
796
|
Bitmap thumb;
|
|
797
797
|
String imgString = "";
|
|
798
798
|
try {
|
|
799
|
-
if(extension.equalsIgnoreCase(".mp4")){
|
|
799
|
+
if (extension.equalsIgnoreCase(".mp4")) {
|
|
800
800
|
thumb = ThumbnailUtils.createVideoThumbnail(filePath,
|
|
801
801
|
MediaStore.Images.Thumbnails.MINI_KIND);
|
|
802
802
|
imgString = convertBitmapToString(thumb);
|
|
803
|
-
}else if(extension.equalsIgnoreCase(".heic") || extension.equalsIgnoreCase(".jpeg")|| extension.equalsIgnoreCase(".jpg")|| extension.equalsIgnoreCase(".png")){
|
|
803
|
+
} else if (extension.equalsIgnoreCase(".heic") || extension.equalsIgnoreCase(".jpeg") || extension.equalsIgnoreCase(".jpg") || extension.equalsIgnoreCase(".png")) {
|
|
804
804
|
thumb = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(filePath),
|
|
805
805
|
76, 76);
|
|
806
806
|
|
|
807
807
|
imgString = convertBitmapToString(thumb);
|
|
808
|
-
}else
|
|
808
|
+
} else if (extension.equalsIgnoreCase(".mp3")) {
|
|
809
809
|
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
|
|
810
810
|
byte[] bytes;
|
|
811
|
-
BitmapFactory.Options bfo=new BitmapFactory.Options();
|
|
811
|
+
BitmapFactory.Options bfo = new BitmapFactory.Options();
|
|
812
812
|
|
|
813
813
|
mmr.setDataSource(context, Uri.fromFile(new File(filePath)));
|
|
814
814
|
bytes = mmr.getEmbeddedPicture();
|
|
815
|
-
if (bytes != null){
|
|
815
|
+
if (bytes != null) {
|
|
816
816
|
thumb = BitmapFactory.decodeByteArray(bytes, 0, bytes.length, bfo);
|
|
817
817
|
imgString = convertBitmapToString(thumb);
|
|
818
818
|
}
|
|
819
819
|
}
|
|
820
|
-
}catch (Exception e){
|
|
820
|
+
} catch (Exception e) {
|
|
821
821
|
|
|
822
822
|
}
|
|
823
823
|
return imgString;
|
|
@@ -829,6 +829,7 @@ public class mInterfaceUtil {
|
|
|
829
829
|
@Override
|
|
830
830
|
protected void onPreExecute() {
|
|
831
831
|
}
|
|
832
|
+
|
|
832
833
|
@Override
|
|
833
834
|
protected String doInBackground(String... args) {
|
|
834
835
|
FileInputStream fileInputStream;
|
|
@@ -845,7 +846,7 @@ public class mInterfaceUtil {
|
|
|
845
846
|
BufferedReader readerObj;
|
|
846
847
|
String currentLine,
|
|
847
848
|
receiveData = "", statusIndication = null;
|
|
848
|
-
int progressCheck=10;
|
|
849
|
+
int progressCheck = 10;
|
|
849
850
|
try {
|
|
850
851
|
if (new File(filePath).exists()) {
|
|
851
852
|
if (new File(filePath).exists()) {
|
|
@@ -876,22 +877,22 @@ public class mInterfaceUtil {
|
|
|
876
877
|
int progressToSend = 0;
|
|
877
878
|
int fileLength = (int) new File(filePath).length();
|
|
878
879
|
int bytesReadValue = 0;
|
|
879
|
-
byte
|
|
880
|
+
byte[] buf = new byte[1024];
|
|
880
881
|
BufferedInputStream bufInput = new BufferedInputStream(new FileInputStream(new File(filePath)));
|
|
881
882
|
while ((bytesReadValue = bufInput.read(buf)) != -1) {
|
|
882
883
|
// write output
|
|
883
884
|
dos.write(buf, 0, bytesReadValue);
|
|
884
885
|
progress += bytesReadValue;
|
|
885
|
-
progressToSend = (int)((progress * 100) / fileLength);
|
|
886
|
-
|
|
887
|
-
if(progressToSend >= progressCheck){
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
886
|
+
progressToSend = (int) ((progress * 100) / fileLength);
|
|
887
|
+
|
|
888
|
+
if (progressToSend >= progressCheck) {
|
|
889
|
+
JSONObject progressObj = new JSONObject();
|
|
890
|
+
progressObj.put("progress", progressCheck);
|
|
891
|
+
progressObj.put("fileLength", fileLength);
|
|
892
|
+
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, progressObj);
|
|
893
|
+
pluginResult.setKeepCallback(true);
|
|
894
|
+
callbackContext.sendPluginResult(pluginResult);
|
|
895
|
+
progressCheck = progressCheck + 10;
|
|
895
896
|
}
|
|
896
897
|
}
|
|
897
898
|
|
|
@@ -906,7 +907,7 @@ public class mInterfaceUtil {
|
|
|
906
907
|
readerObj = new BufferedReader(new InputStreamReader(urlConObj.getInputStream()));
|
|
907
908
|
currentLine = readerObj.readLine();
|
|
908
909
|
readerObj.close();
|
|
909
|
-
receiveData = currentLine
|
|
910
|
+
receiveData = currentLine;
|
|
910
911
|
urlConObj.disconnect();
|
|
911
912
|
JSONObject resultObj = new JSONObject(receiveData);
|
|
912
913
|
if (resultObj.getString("status").equalsIgnoreCase("success")) {
|
|
@@ -924,6 +925,7 @@ public class mInterfaceUtil {
|
|
|
924
925
|
return statusIndication;
|
|
925
926
|
|
|
926
927
|
}
|
|
928
|
+
|
|
927
929
|
public void onPostExecute(String statusIndication) {
|
|
928
930
|
try {
|
|
929
931
|
if (statusIndication == null) {
|
|
@@ -1012,7 +1014,7 @@ public class mInterfaceUtil {
|
|
|
1012
1014
|
readerObj = new BufferedReader(new InputStreamReader(urlConObj.getInputStream()));
|
|
1013
1015
|
currentLine = readerObj.readLine();
|
|
1014
1016
|
readerObj.close();
|
|
1015
|
-
receiveData = currentLine
|
|
1017
|
+
receiveData = currentLine;
|
|
1016
1018
|
urlConObj.disconnect();
|
|
1017
1019
|
JSONObject resultObj = new JSONObject(receiveData);
|
|
1018
1020
|
if (resultObj.getString("status").equalsIgnoreCase("success")) {
|
|
@@ -1028,7 +1030,7 @@ public class mInterfaceUtil {
|
|
|
1028
1030
|
}
|
|
1029
1031
|
return statusIndication;
|
|
1030
1032
|
}
|
|
1031
|
-
|
|
1033
|
+
|
|
1032
1034
|
private void UpdateProgressBar(CallbackContext callbackContext, int progress) {
|
|
1033
1035
|
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, progress);
|
|
1034
1036
|
pluginResult.setKeepCallback(true); // keep callback
|
|
@@ -1099,7 +1101,7 @@ public class mInterfaceUtil {
|
|
|
1099
1101
|
readerObj = new BufferedReader(new InputStreamReader(urlConObj.getInputStream()));
|
|
1100
1102
|
currentLine = readerObj.readLine();
|
|
1101
1103
|
readerObj.close();
|
|
1102
|
-
receiveData = currentLine
|
|
1104
|
+
receiveData = currentLine;
|
|
1103
1105
|
urlConObj.disconnect();
|
|
1104
1106
|
if (receiveData.equals("true")) {
|
|
1105
1107
|
new File(filePath).delete();
|
|
@@ -1172,7 +1174,7 @@ public class mInterfaceUtil {
|
|
|
1172
1174
|
File baseDirectory = rootDirectory;
|
|
1173
1175
|
try {
|
|
1174
1176
|
File filePath = new File(baseDirectory + "/" + args.getJSONObject(0).optString("filePath"));
|
|
1175
|
-
boolean sss = filePath.exists()
|
|
1177
|
+
boolean sss = filePath.exists();
|
|
1176
1178
|
callbackContext.success(sss ? "true" : "false");
|
|
1177
1179
|
} catch (Exception e) {
|
|
1178
1180
|
callbackContext.error(e.getMessage());
|
|
@@ -1206,7 +1208,7 @@ public class mInterfaceUtil {
|
|
|
1206
1208
|
if (dir.exists()) {
|
|
1207
1209
|
deleteRecursive(dir);
|
|
1208
1210
|
callbackContext.success();
|
|
1209
|
-
}else{
|
|
1211
|
+
} else {
|
|
1210
1212
|
callbackContext.error("File does not exists");
|
|
1211
1213
|
}
|
|
1212
1214
|
|
|
@@ -1227,7 +1229,7 @@ public class mInterfaceUtil {
|
|
|
1227
1229
|
fileOrDirectory.delete();
|
|
1228
1230
|
}
|
|
1229
1231
|
|
|
1230
|
-
private static int BUFFER_SIZE = 6 * 1024;
|
|
1232
|
+
private static final int BUFFER_SIZE = 6 * 1024;
|
|
1231
1233
|
|
|
1232
1234
|
public static void unzip(String zipFile, String location, CallbackContext callbackContext) throws JSONException {
|
|
1233
1235
|
try {
|
|
@@ -1339,7 +1341,7 @@ public class mInterfaceUtil {
|
|
|
1339
1341
|
date.setTime(lastModifiedTime);
|
|
1340
1342
|
String lastModifiedDate = new SimpleDateFormat("yyyyMMdd", new mInterfaceUtil().locale).format(date);
|
|
1341
1343
|
|
|
1342
|
-
if (authFileObj.optString("validDevice").
|
|
1344
|
+
if (authFileObj.optString("validDevice").equals("nostatus") || !lastModifiedDate.equals(new SimpleDateFormat("yyyyMMdd", new mInterfaceUtil().locale).format(new Date()))) {
|
|
1343
1345
|
if (isConnected(applicationContext)) {
|
|
1344
1346
|
downloadAppStateInfo(callbackContext);
|
|
1345
1347
|
} else {
|
|
@@ -1373,7 +1375,7 @@ public class mInterfaceUtil {
|
|
|
1373
1375
|
String currentLine;
|
|
1374
1376
|
try {
|
|
1375
1377
|
getKeysPath = new URL(clientUrl + "/" + "common/components/Keys/" + "RetrieveKey.aspx");
|
|
1376
|
-
urlConObj = (HttpURLConnection)getKeysPath.openConnection();
|
|
1378
|
+
urlConObj = (HttpURLConnection) getKeysPath.openConnection();
|
|
1377
1379
|
urlConObj.setDoOutput(true);
|
|
1378
1380
|
urlConObj.setRequestMethod("POST");
|
|
1379
1381
|
urlConObj.setRequestProperty("CONTENT-TYPE", "application/json");
|
|
@@ -1382,7 +1384,7 @@ public class mInterfaceUtil {
|
|
|
1382
1384
|
jsonObject1 = jsonObject1.put("client_id", clientID);
|
|
1383
1385
|
jsonObject1 = jsonObject1.put("country_code", countryCode);
|
|
1384
1386
|
jsonObject1 = jsonObject1.put("purposeCode", "mobile_address_store");
|
|
1385
|
-
System.out.println("data format: " + jsonObject1
|
|
1387
|
+
System.out.println("data format: " + jsonObject1);
|
|
1386
1388
|
oStreamObj = new OutputStreamWriter(urlConObj.getOutputStream());
|
|
1387
1389
|
oStreamObj.write(jsonObject1.toString());
|
|
1388
1390
|
oStreamObj.flush();
|
|
@@ -1502,7 +1504,7 @@ public class mInterfaceUtil {
|
|
|
1502
1504
|
date.setTime(lastModifiedTime);
|
|
1503
1505
|
String lastModifiedDate = new SimpleDateFormat("yyyyMMdd", new mInterfaceUtil().locale).format(date);
|
|
1504
1506
|
|
|
1505
|
-
if (authFileObj.optString("validDevice").
|
|
1507
|
+
if (authFileObj.optString("validDevice").equals("nostatus") || !lastModifiedDate.equals(new SimpleDateFormat("yyyyMMdd", new mInterfaceUtil().locale).format(new Date()))) {
|
|
1506
1508
|
if (isConnected(applicationContext)) {
|
|
1507
1509
|
new UpdateAppStateInfo().execute();
|
|
1508
1510
|
} else {
|
|
@@ -1541,7 +1543,7 @@ public class mInterfaceUtil {
|
|
|
1541
1543
|
JSONObject responseDataObj;
|
|
1542
1544
|
try {
|
|
1543
1545
|
getKeysPath = new URL(clientUrl + "/" + "common/components/Keys/" + "RetrieveKey.aspx");
|
|
1544
|
-
urlConObj = (HttpURLConnection)getKeysPath.openConnection();
|
|
1546
|
+
urlConObj = (HttpURLConnection) getKeysPath.openConnection();
|
|
1545
1547
|
urlConObj.setDoOutput(true);
|
|
1546
1548
|
urlConObj.setRequestMethod("POST");
|
|
1547
1549
|
urlConObj.setRequestProperty("CONTENT-TYPE", "application/json");
|
|
@@ -1550,7 +1552,7 @@ public class mInterfaceUtil {
|
|
|
1550
1552
|
jsonObject1 = jsonObject1.put("client_id", clientID);
|
|
1551
1553
|
jsonObject1 = jsonObject1.put("country_code", countryCode);
|
|
1552
1554
|
jsonObject1 = jsonObject1.put("purposeCode", "mobile_address_store");
|
|
1553
|
-
System.out.println("data format: " + jsonObject1
|
|
1555
|
+
System.out.println("data format: " + jsonObject1);
|
|
1554
1556
|
oStreamObj = new OutputStreamWriter(urlConObj.getOutputStream());
|
|
1555
1557
|
oStreamObj.write(jsonObject1.toString());
|
|
1556
1558
|
oStreamObj.flush();
|
|
@@ -1658,18 +1660,18 @@ public class mInterfaceUtil {
|
|
|
1658
1660
|
public boolean updateAppInfo(JSONArray args) {
|
|
1659
1661
|
try {
|
|
1660
1662
|
JSONObject appInfo = args.getJSONObject(0);
|
|
1661
|
-
mInterfaceUtil.app_id = appInfo.optString("app_id")
|
|
1662
|
-
mInterfaceUtil.platform = appInfo.optString("platform")
|
|
1663
|
-
mInterfaceUtil.deviceID = appInfo.optString("device_id")
|
|
1664
|
-
mInterfaceUtil.clientID = appInfo.optString("client_id")
|
|
1665
|
-
mInterfaceUtil.countryCode = appInfo.optString("country_code")
|
|
1666
|
-
mInterfaceUtil.localeID = appInfo.optString("locale_id")
|
|
1667
|
-
mInterfaceUtil.sessionID = appInfo.optString("session_id")
|
|
1668
|
-
mInterfaceUtil.userID = appInfo.optString("user_Id")
|
|
1669
|
-
mInterfaceUtil.employeeId = appInfo.optString("employee_id")
|
|
1670
|
-
mInterfaceUtil.clientUrl = appInfo.optString("client_url")
|
|
1671
|
-
mInterfaceUtil.cvsUrl = appInfo.optString("cvs_url")
|
|
1672
|
-
mInterfaceUtil.store = appInfo.optString("store_name")
|
|
1663
|
+
mInterfaceUtil.app_id = appInfo.optString("app_id");
|
|
1664
|
+
mInterfaceUtil.platform = appInfo.optString("platform");
|
|
1665
|
+
mInterfaceUtil.deviceID = appInfo.optString("device_id");
|
|
1666
|
+
mInterfaceUtil.clientID = appInfo.optString("client_id");
|
|
1667
|
+
mInterfaceUtil.countryCode = appInfo.optString("country_code");
|
|
1668
|
+
mInterfaceUtil.localeID = appInfo.optString("locale_id");
|
|
1669
|
+
mInterfaceUtil.sessionID = appInfo.optString("session_id");
|
|
1670
|
+
mInterfaceUtil.userID = appInfo.optString("user_Id");
|
|
1671
|
+
mInterfaceUtil.employeeId = appInfo.optString("employee_id");
|
|
1672
|
+
mInterfaceUtil.clientUrl = appInfo.optString("client_url");
|
|
1673
|
+
mInterfaceUtil.cvsUrl = appInfo.optString("cvs_url");
|
|
1674
|
+
mInterfaceUtil.store = appInfo.optString("store_name");
|
|
1673
1675
|
} catch (Exception e) {
|
|
1674
1676
|
return false;
|
|
1675
1677
|
}
|
|
@@ -1679,10 +1681,6 @@ public class mInterfaceUtil {
|
|
|
1679
1681
|
public static boolean isConnected(Context applicationContext) {
|
|
1680
1682
|
ConnectivityManager online = (ConnectivityManager) applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
1681
1683
|
NetworkInfo networkInfo = online.getActiveNetworkInfo();
|
|
1682
|
-
|
|
1683
|
-
return true;
|
|
1684
|
-
} else {
|
|
1685
|
-
return false;
|
|
1686
|
-
}
|
|
1684
|
+
return networkInfo != null && networkInfo.isConnected();
|
|
1687
1685
|
}
|
|
1688
1686
|
}
|
package/src/ios/mInterface.m
CHANGED
|
@@ -2077,6 +2077,7 @@
|
|
|
2077
2077
|
}
|
|
2078
2078
|
} else if ([picker isEqual:imagePicker]) {
|
|
2079
2079
|
if ([imageAttachmentInd isEqualToString:@"true"]) {
|
|
2080
|
+
[picker dismissViewControllerAnimated:YES completion:nil];
|
|
2080
2081
|
UIImageView *ivPickedImage = [[UIImageView alloc] init];
|
|
2081
2082
|
ivPickedImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
|
|
2082
2083
|
NSURL *refURL = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL];
|
|
@@ -2336,7 +2337,8 @@
|
|
|
2336
2337
|
@"version": [device systemVersion],
|
|
2337
2338
|
@"uuid": [self uniqueAppInstanceIdentifier:device],
|
|
2338
2339
|
@"cordova": [[self class] cordovaVersion],
|
|
2339
|
-
@"isVirtual": @([self isVirtual])
|
|
2340
|
+
@"isVirtual": @([self isVirtual]),
|
|
2341
|
+
@"applicationName": [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
|
|
2340
2342
|
};
|
|
2341
2343
|
}
|
|
2342
2344
|
|