cordova-plugin-mserviceinterface-2.0 1.0.20 → 1.0.24
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/backgroundNotification.java +2 -2
- package/src/android/mInterface.java +90 -36
- package/src/android/mInterfaceService.java +16 -16
- package/src/android/mInterfaceUtil.java +146 -152
- package/src/ios/mInterface.h +1 -0
- package/src/ios/mInterface.m +9 -1
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
4
|
id="cordova-plugin-mserviceinterface-2.0"
|
|
5
|
-
version="1.0.
|
|
5
|
+
version="1.0.24">
|
|
6
6
|
<name>mserviceinterface-2.0</name>
|
|
7
7
|
<description>This plugin establishes the connection to the native interface and performs the requested task.</description>
|
|
8
8
|
<author>selfservit@gmail.com</author>
|
|
@@ -56,7 +56,7 @@ public class backgroundNotification extends NotificationExtenderService {
|
|
|
56
56
|
|
|
57
57
|
if(scrID.equals("chat")) {
|
|
58
58
|
if (!subKey.equals("")) {
|
|
59
|
-
fileDirectory = new File(
|
|
59
|
+
fileDirectory = new File(mInterfaceUtil.rootDirectory + "/" + baseDirectory[(baseDirectory.length - 1)] + "/" + clientID + "/" + countryCode + "/" + "content_store" + "/" + "msvMsg" + "/" + "history" + "/" + key + "/" + subKey);
|
|
60
60
|
if (!fileDirectory.exists()) {
|
|
61
61
|
fileDirectory.mkdirs();
|
|
62
62
|
}
|
|
@@ -97,7 +97,7 @@ public class backgroundNotification extends NotificationExtenderService {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
} else {
|
|
100
|
-
fileDirectory = new File(
|
|
100
|
+
fileDirectory = new File(mInterfaceUtil.rootDirectory + "/" + baseDirectory[(baseDirectory.length - 1)] + "/" + clientID + "/" + countryCode + "/" + "notifications" + "/" + "unread");
|
|
101
101
|
if (!fileDirectory.exists()) {
|
|
102
102
|
fileDirectory.mkdirs();
|
|
103
103
|
}
|
|
@@ -45,6 +45,8 @@ import android.util.Patterns;
|
|
|
45
45
|
import android.view.KeyEvent;
|
|
46
46
|
import android.webkit.MimeTypeMap;
|
|
47
47
|
import android.widget.ProgressBar;
|
|
48
|
+
import android.widget.Toast;
|
|
49
|
+
import android.media.ExifInterface;
|
|
48
50
|
|
|
49
51
|
import com.google.android.gms.common.ConnectionResult;
|
|
50
52
|
import com.google.android.gms.common.api.GoogleApiClient;
|
|
@@ -56,12 +58,15 @@ import com.google.android.gms.location.LocationServices;
|
|
|
56
58
|
import com.google.android.gms.location.LocationSettingsRequest;
|
|
57
59
|
import com.google.android.gms.location.LocationSettingsResult;
|
|
58
60
|
import com.google.android.gms.location.LocationSettingsStatusCodes;
|
|
61
|
+
import com.google.android.gms.tasks.Task;
|
|
59
62
|
import com.google.zxing.integration.android.IntentIntegrator;
|
|
60
63
|
import com.google.zxing.integration.android.IntentResult;
|
|
61
64
|
|
|
62
65
|
import org.apache.cordova.CallbackContext;
|
|
66
|
+
import org.apache.cordova.CordovaInterface;
|
|
63
67
|
import org.apache.cordova.CordovaPlugin;
|
|
64
68
|
import org.apache.cordova.CordovaResourceApi;
|
|
69
|
+
import org.apache.cordova.CordovaWebView;
|
|
65
70
|
import org.apache.cordova.PermissionHelper;
|
|
66
71
|
import org.apache.cordova.PluginResult;
|
|
67
72
|
import org.json.JSONArray;
|
|
@@ -82,14 +87,18 @@ import java.net.HttpURLConnection;
|
|
|
82
87
|
import java.net.URL;
|
|
83
88
|
import java.text.SimpleDateFormat;
|
|
84
89
|
import java.util.Date;
|
|
90
|
+
import java.util.List;
|
|
85
91
|
import java.util.Stack;
|
|
86
92
|
import java.util.TimeZone;
|
|
93
|
+
import java.util.regex.Matcher;
|
|
94
|
+
import java.util.regex.Pattern;
|
|
87
95
|
import java.util.zip.ZipEntry;
|
|
88
96
|
import java.util.zip.ZipInputStream;
|
|
89
97
|
|
|
90
98
|
import static android.app.Activity.RESULT_OK;
|
|
91
99
|
|
|
92
100
|
public class mInterface extends CordovaPlugin implements com.google.android.gms.location.LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, ResultCallback<LocationSettingsResult> {
|
|
101
|
+
private static final String TAG = "mInterface";
|
|
93
102
|
public Stack<ProgressDialog> spinnerDialogStack = new Stack<ProgressDialog>();
|
|
94
103
|
private static final int PICK_FILE_REQUEST = 1;
|
|
95
104
|
public CallbackContext callback;
|
|
@@ -132,6 +141,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
132
141
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
133
142
|
@Override
|
|
134
143
|
public boolean execute(final String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
|
|
144
|
+
mInterfaceUtil.rootDirectory = new File(cordova.getActivity().getExternalFilesDir(""), "");
|
|
135
145
|
if (mInterfaceUtil.packageName.equals("")) {
|
|
136
146
|
mInterfaceUtil.packageName = cordova.getActivity().getApplicationContext().getPackageName().split("\\.")[2];
|
|
137
147
|
}
|
|
@@ -152,6 +162,16 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
152
162
|
System.out.println("Service is already running");
|
|
153
163
|
}
|
|
154
164
|
callbackContext.success("Success");
|
|
165
|
+
}else if (action.equals("showToastWithOptions")) {
|
|
166
|
+
try {
|
|
167
|
+
if(args.getJSONObject(0).optString("duration").equals("long")){
|
|
168
|
+
Toast.makeText(cordova.getActivity().getApplicationContext(),args.getJSONObject(0).optString("message"), Toast.LENGTH_LONG).show();
|
|
169
|
+
} else {
|
|
170
|
+
Toast.makeText(cordova.getActivity().getApplicationContext(),args.getJSONObject(0).optString("message"), Toast.LENGTH_SHORT).show();
|
|
171
|
+
}
|
|
172
|
+
} catch (Exception exception) {
|
|
173
|
+
callbackContext.success("Show Toast having exception");
|
|
174
|
+
}
|
|
155
175
|
} else if (action.equals("CheckLocationAccuracy")) {
|
|
156
176
|
int locationInt = 111;
|
|
157
177
|
try {
|
|
@@ -161,6 +181,14 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
161
181
|
System.out.println("Exception is: " + e.getMessage());
|
|
162
182
|
callbackContext.error(e.getMessage());
|
|
163
183
|
}
|
|
184
|
+
}else if (action.equals("GetBase64String")) {
|
|
185
|
+
try {
|
|
186
|
+
String imageString = getBase64String(args.getJSONObject(0).optString("filePath"));
|
|
187
|
+
callbackContext.success(imageString);
|
|
188
|
+
} catch (Exception e) {
|
|
189
|
+
System.out.println("Exception is: " + e.getMessage());
|
|
190
|
+
callbackContext.error(e.getMessage());
|
|
191
|
+
}
|
|
164
192
|
} else if (action.equals("GetSyncIndicator")) {
|
|
165
193
|
try {
|
|
166
194
|
File newQueueFolder, oldQueueFolder;
|
|
@@ -178,8 +206,8 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
178
206
|
String requestUrl = client_url + "/common/components/QueueManager/GetSyncInd.aspx?client_id=" + client_id + "&country_code=" + country_code + "&user_id=" + user_id;
|
|
179
207
|
|
|
180
208
|
try {
|
|
181
|
-
oldQueueFolder = new File(
|
|
182
|
-
newQueueFolder = new File(
|
|
209
|
+
oldQueueFolder = new File(mInterfaceUtil.rootDirectory + "/" + mInterfaceUtil.packageName + "/database/queue");
|
|
210
|
+
newQueueFolder = new File(mInterfaceUtil.rootDirectory + "/" + mInterfaceUtil.packageName + "/" + client_id + "/" + country_code + "/database/queue");
|
|
183
211
|
if(oldQueueFolder.exists()) {
|
|
184
212
|
if(oldQueueFolder.listFiles().length == 0){
|
|
185
213
|
syncIndication = true;
|
|
@@ -265,13 +293,8 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
265
293
|
rotateScreen(args, callbackContext);
|
|
266
294
|
return true;
|
|
267
295
|
} else if (action.equals("UnZip")) {
|
|
268
|
-
//File root = Environment.getExternalStorageDirectory();
|
|
269
|
-
//String filePath = root + "/" + args.getJSONObject(0).optString("filePath");
|
|
270
|
-
//String fileLocation = root + "/" + args.getJSONObject(0).optString("destination");
|
|
271
296
|
unzip(args, callbackContext);
|
|
272
297
|
return true;
|
|
273
|
-
//new mInterfaceUtil().unzip(filePath, fileLocation,callbackContext);
|
|
274
|
-
//new mInterfaceUtil().unZipFile(filePath, fileLocation, callbackContext);
|
|
275
298
|
} else if (action.equals("EnableGPSService")) {
|
|
276
299
|
EnableGPSAutoMatically(callbackContext);
|
|
277
300
|
} else if ("GoHome".equals(action)) {
|
|
@@ -383,8 +406,8 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
383
406
|
String client_url = args.getJSONObject(0).optString("client_url");
|
|
384
407
|
String requestUrl = client_url + "/common/components/QueueManager/GetSyncInd.aspx?client_id=" + client_id + "&country_code=" + country_code + "&user_id=" + user_id;
|
|
385
408
|
try {
|
|
386
|
-
oldQueueFolder = new File(
|
|
387
|
-
newQueueFolder = new File(
|
|
409
|
+
oldQueueFolder = new File(mInterfaceUtil.rootDirectory + "/" + mInterfaceUtil.packageName + "/database/queue");
|
|
410
|
+
newQueueFolder = new File(mInterfaceUtil.rootDirectory + "/" + mInterfaceUtil.packageName + "/" + client_id + "/" + country_code + "/database/queue");
|
|
388
411
|
if (oldQueueFolder.exists()) {
|
|
389
412
|
if (oldQueueFolder.listFiles().length == 0) {
|
|
390
413
|
syncIndication = true;
|
|
@@ -436,8 +459,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
436
459
|
chooseFile(callbackContext);
|
|
437
460
|
return true;
|
|
438
461
|
} else if (action.equals("GetThumbnail")) {
|
|
439
|
-
|
|
440
|
-
String filePath = root + "/" +args.optJSONObject(0).optString("filePath");
|
|
462
|
+
String filePath = mInterfaceUtil.rootDirectory + "/" +args.optJSONObject(0).optString("filePath");
|
|
441
463
|
String thumbnail= getFileThumbnail(filePath, args.optJSONObject(0).optString("fileExtension"));
|
|
442
464
|
callback.success(thumbnail);
|
|
443
465
|
return true;
|
|
@@ -492,7 +514,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
492
514
|
else if (action.equals("ReadFile")) {
|
|
493
515
|
try {
|
|
494
516
|
new mInterfaceUtil().readFile(args, callbackContext);
|
|
495
|
-
} catch (
|
|
517
|
+
} catch (Exception e) {
|
|
496
518
|
e.printStackTrace();
|
|
497
519
|
}
|
|
498
520
|
return true;
|
|
@@ -627,8 +649,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
627
649
|
callbackContext.error("failure");
|
|
628
650
|
} else if (action.equals("OpenFileWithViewer")) {
|
|
629
651
|
Context context = cordova.getActivity().getApplicationContext();
|
|
630
|
-
|
|
631
|
-
String filePath = baseDirectory + "/" + args.optString(0);
|
|
652
|
+
String filePath = mInterfaceUtil.rootDirectory + "/" + args.optString(0);
|
|
632
653
|
File imageFilePath = new File(filePath);
|
|
633
654
|
try {
|
|
634
655
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
@@ -680,7 +701,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
680
701
|
final DownloadTask downloadTask = new DownloadTask(cordova.getActivity());
|
|
681
702
|
downloadTask.execute(args.optJSONObject(0).optString("url"), args.optJSONObject(0).optString("filePath"), args.optJSONObject(0).optString("thumbnailInd"));
|
|
682
703
|
return true;
|
|
683
|
-
}
|
|
704
|
+
}else if ("QueueProcessor".equals(action)) {
|
|
684
705
|
new mInterfaceUtil().queueProcessor(callbackContext);
|
|
685
706
|
return true;
|
|
686
707
|
} else if (action.equals("ScanQRCode")) {
|
|
@@ -829,7 +850,6 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
829
850
|
result = new PluginResult(PluginResult.Status.ERROR, "EMAIL_NOT_AVAILABLE");
|
|
830
851
|
callback.sendPluginResult(result);
|
|
831
852
|
}
|
|
832
|
-
|
|
833
853
|
} catch (Exception e) {
|
|
834
854
|
e.printStackTrace();
|
|
835
855
|
result = new PluginResult(PluginResult.Status.ERROR, e.getMessage());
|
|
@@ -910,8 +930,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
910
930
|
}
|
|
911
931
|
|
|
912
932
|
private void getStorageRoot(CallbackContext callbackContext) {
|
|
913
|
-
|
|
914
|
-
callbackContext.success("file://" + root + "/");
|
|
933
|
+
callbackContext.success("file://" + mInterfaceUtil.rootDirectory + "/");
|
|
915
934
|
}
|
|
916
935
|
|
|
917
936
|
private void getPermissions(JSONArray args, CallbackContext callbackContext) {
|
|
@@ -1018,10 +1037,9 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1018
1037
|
}
|
|
1019
1038
|
|
|
1020
1039
|
private File createImageFile() throws IOException {
|
|
1021
|
-
File baseDirectory = Environment.getExternalStorageDirectory();
|
|
1022
1040
|
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
|
1023
1041
|
String imageFileName = "JPEG_" + timeStamp + "_";
|
|
1024
|
-
String filePath =
|
|
1042
|
+
String filePath = mInterfaceUtil.rootDirectory + "/" + mInterfaceUtil.packageName + "/images";
|
|
1025
1043
|
File storageDir = new File(filePath);
|
|
1026
1044
|
if (!storageDir.exists()) {
|
|
1027
1045
|
storageDir.mkdirs();
|
|
@@ -1066,8 +1084,8 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1066
1084
|
int actualHeight = options.outHeight;
|
|
1067
1085
|
int actualWidth = options.outWidth;
|
|
1068
1086
|
//max Height and width values of the compressed image is taken as 816x612
|
|
1069
|
-
float maxHeight =
|
|
1070
|
-
float maxWidth =
|
|
1087
|
+
float maxHeight = 816.0f;
|
|
1088
|
+
float maxWidth = 612.0f;
|
|
1071
1089
|
float imgRatio = actualWidth / actualHeight;
|
|
1072
1090
|
float maxRatio = maxWidth / maxHeight;
|
|
1073
1091
|
//width and height values are set maintaining the aspect ratio of the image
|
|
@@ -1111,15 +1129,35 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1111
1129
|
Canvas canvas = new Canvas(scaledBitmap);
|
|
1112
1130
|
canvas.setMatrix(scaleMatrix);
|
|
1113
1131
|
canvas.drawBitmap(bmp, middleX - bmp.getWidth()/2, middleY - bmp.getHeight()/2, new Paint(Paint.FILTER_BITMAP_FLAG));
|
|
1132
|
+
//check the rotation of the image and display it properly
|
|
1133
|
+
ExifInterface exif;
|
|
1134
|
+
try {
|
|
1135
|
+
exif = new ExifInterface(filePath);
|
|
1136
|
+
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0);
|
|
1137
|
+
Log.d("EXIF", "Exif: " + orientation);
|
|
1138
|
+
Matrix matrix = new Matrix();
|
|
1139
|
+
if (orientation == 6) {
|
|
1140
|
+
matrix.postRotate(90);
|
|
1141
|
+
Log.d("EXIF", "Exif: " + orientation);
|
|
1142
|
+
} else if (orientation == 3) {
|
|
1143
|
+
matrix.postRotate(180);
|
|
1144
|
+
Log.d("EXIF", "Exif: " + orientation);
|
|
1145
|
+
} else if (orientation == 8) {
|
|
1146
|
+
matrix.postRotate(270);
|
|
1147
|
+
Log.d("EXIF", "Exif: " + orientation);
|
|
1148
|
+
}
|
|
1149
|
+
scaledBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0, scaledBitmap.getWidth(), scaledBitmap.getHeight(), matrix, true);
|
|
1150
|
+
} catch (IOException e) {
|
|
1151
|
+
e.printStackTrace();
|
|
1152
|
+
}
|
|
1114
1153
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
1115
1154
|
try {
|
|
1116
1155
|
if(imgSrcType.equals("compress")) {
|
|
1117
|
-
File file = Environment.getExternalStorageDirectory();
|
|
1118
1156
|
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
|
1119
1157
|
if(!destinationPath.equalsIgnoreCase("")){
|
|
1120
|
-
compressedImagePathStr =
|
|
1158
|
+
compressedImagePathStr = mInterfaceUtil.rootDirectory + "/" + destinationPath;
|
|
1121
1159
|
}else{
|
|
1122
|
-
compressedImagePathStr =
|
|
1160
|
+
compressedImagePathStr = mInterfaceUtil.rootDirectory + "/" + mInterfaceUtil.packageName + "/" + "images";
|
|
1123
1161
|
}
|
|
1124
1162
|
compressedImageName = compressedImagePathStr + "/" + fileNameToSend + "_" + timeStamp + ".jpg";
|
|
1125
1163
|
File fileSavedPath = new File(compressedImagePathStr);
|
|
@@ -1127,9 +1165,9 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1127
1165
|
fileSavedPath.mkdirs();
|
|
1128
1166
|
}
|
|
1129
1167
|
FileOutputStream out = new FileOutputStream(compressedImageName);
|
|
1130
|
-
scaledBitmap.compress(Bitmap.CompressFormat.JPEG,
|
|
1168
|
+
scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 30, out);
|
|
1131
1169
|
} else {
|
|
1132
|
-
scaledBitmap.compress(Bitmap.CompressFormat.JPEG,
|
|
1170
|
+
scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 30, baos);
|
|
1133
1171
|
}
|
|
1134
1172
|
String encodedImage = null;
|
|
1135
1173
|
byte[] byteArray;
|
|
@@ -1174,6 +1212,22 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1174
1212
|
}
|
|
1175
1213
|
}
|
|
1176
1214
|
|
|
1215
|
+
public String getBase64String(String imageSourcePath) {
|
|
1216
|
+
String resultString="";
|
|
1217
|
+
String filePath = mInterfaceUtil.rootDirectory + "/" + imageSourcePath;
|
|
1218
|
+
File image = new File(filePath);
|
|
1219
|
+
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
|
|
1220
|
+
Bitmap bitmap = BitmapFactory.decodeFile(image.getAbsolutePath(),bmOptions);
|
|
1221
|
+
try {
|
|
1222
|
+
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
1223
|
+
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
|
|
1224
|
+
resultString = Base64.encodeToString(outputStream.toByteArray(), Base64.NO_WRAP);
|
|
1225
|
+
} catch (Exception e) {
|
|
1226
|
+
e.printStackTrace();
|
|
1227
|
+
}
|
|
1228
|
+
return resultString;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1177
1231
|
public void chooseFile(CallbackContext callbackContext) {
|
|
1178
1232
|
try {
|
|
1179
1233
|
PluginResult pluginResult;
|
|
@@ -1316,7 +1370,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1316
1370
|
split = docId.split(":");
|
|
1317
1371
|
type = split[0];
|
|
1318
1372
|
if ("primary".equalsIgnoreCase(type)) {
|
|
1319
|
-
getfilePath =
|
|
1373
|
+
getfilePath = mInterfaceUtil.rootDirectory + "/" + split[1];
|
|
1320
1374
|
} else {
|
|
1321
1375
|
if (Environment.isExternalStorageRemovable()) {
|
|
1322
1376
|
storageDefinition = System.getenv("EXTERNAL_STORAGE");
|
|
@@ -1548,7 +1602,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1548
1602
|
split = docId.split(":");
|
|
1549
1603
|
type = split[0];
|
|
1550
1604
|
if ("primary".equalsIgnoreCase(type)) {
|
|
1551
|
-
getfilePath =
|
|
1605
|
+
getfilePath = mInterfaceUtil.rootDirectory + "/" + split[1];
|
|
1552
1606
|
} else {
|
|
1553
1607
|
if (Environment.isExternalStorageRemovable()) {
|
|
1554
1608
|
storageDefinition = System.getenv("EXTERNAL_STORAGE");
|
|
@@ -1690,14 +1744,14 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1690
1744
|
try {
|
|
1691
1745
|
ContentResolver content = context.getContentResolver();
|
|
1692
1746
|
inputStream = content.openInputStream(fileUri);
|
|
1693
|
-
File root =
|
|
1747
|
+
File root = mInterfaceUtil.rootDirectory;
|
|
1694
1748
|
if(root == null) {
|
|
1695
1749
|
System.out.println("Failed to get root");
|
|
1696
1750
|
}
|
|
1697
1751
|
if(!destinationPath.equalsIgnoreCase("")){
|
|
1698
|
-
saveDirectory = new File(
|
|
1752
|
+
saveDirectory = new File(mInterfaceUtil.rootDirectory + "/" + destinationPath);
|
|
1699
1753
|
}else{
|
|
1700
|
-
saveDirectory = new File(
|
|
1754
|
+
saveDirectory = new File(mInterfaceUtil.rootDirectory + "/" + mInterfaceUtil.packageName + "/" + "images");
|
|
1701
1755
|
}
|
|
1702
1756
|
|
|
1703
1757
|
saveDirectory.mkdirs();
|
|
@@ -1834,7 +1888,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1834
1888
|
int fileLength = connection.getContentLength();
|
|
1835
1889
|
// download the file
|
|
1836
1890
|
input = connection.getInputStream();
|
|
1837
|
-
File rootPath =
|
|
1891
|
+
File rootPath = mInterfaceUtil.rootDirectory;
|
|
1838
1892
|
File filesourceDirecory = new File(rootPath + "/" + pathComponent(sUrl[1]));
|
|
1839
1893
|
if (!filesourceDirecory.exists()) {
|
|
1840
1894
|
filesourceDirecory.mkdirs();
|
|
@@ -1872,7 +1926,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1872
1926
|
if (result != null) {
|
|
1873
1927
|
if(result.indexOf('.') != -1){
|
|
1874
1928
|
String extension = "." + result.substring(result.lastIndexOf(".") + 1).toLowerCase(),
|
|
1875
|
-
filePath =
|
|
1929
|
+
filePath = mInterfaceUtil.rootDirectory+"/"+result;
|
|
1876
1930
|
String thumbnail = getFileThumbnail(filePath,extension);
|
|
1877
1931
|
callback.success(thumbnail);
|
|
1878
1932
|
} else{
|
|
@@ -1887,7 +1941,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1887
1941
|
}
|
|
1888
1942
|
}
|
|
1889
1943
|
}
|
|
1890
|
-
|
|
1944
|
+
|
|
1891
1945
|
public static String pathComponent(String filename) {
|
|
1892
1946
|
int i = filename.lastIndexOf(File.separator);
|
|
1893
1947
|
return (i > -1) ? filename.substring(0, i) : filename;
|
|
@@ -1908,7 +1962,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1908
1962
|
String outputDirectory = args.getJSONObject(0).optString("destination");
|
|
1909
1963
|
// Since Cordova 3.3.0 and release of File plugins, files are accessed via cdvfile://
|
|
1910
1964
|
// Accept a path or a URI for the source zip.
|
|
1911
|
-
File root =
|
|
1965
|
+
File root = mInterfaceUtil.rootDirectory;
|
|
1912
1966
|
//callbackContext.success("file://"+root+"/");
|
|
1913
1967
|
Uri uri = null;
|
|
1914
1968
|
Uri zipUri = getUriForArg(root + "/" + zipFileName);
|
|
@@ -177,7 +177,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
177
177
|
|
|
178
178
|
String currentLine;
|
|
179
179
|
StringBuilder locConfigObj = new StringBuilder();
|
|
180
|
-
File baseDirectory =
|
|
180
|
+
File baseDirectory = mInterfaceUtil.rootDirectory;
|
|
181
181
|
File locConfigFile = new File(baseDirectory, "/" + mInterfaceUtil.packageName + "/location_configuration.txt");
|
|
182
182
|
if (locConfigFile.exists()) {
|
|
183
183
|
BufferedReader readerObj = new BufferedReader(new FileReader(locConfigFile));
|
|
@@ -321,7 +321,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
321
321
|
String[] lastKnownLocation;
|
|
322
322
|
boolean result = false;
|
|
323
323
|
try {
|
|
324
|
-
|
|
324
|
+
baseDirectory = mInterfaceUtil.rootDirectory;
|
|
325
325
|
locationData = new StringBuilder();
|
|
326
326
|
File lastKnownLocationFile = new File(baseDirectory, "/" + mInterfaceUtil.packageName + "/LastKnownLocation_encrypted.txt");
|
|
327
327
|
if (lastKnownLocationFile.exists()) {
|
|
@@ -375,8 +375,8 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
375
375
|
JSONArray accountsList;
|
|
376
376
|
JSONObject currentAccount;
|
|
377
377
|
String currentLine;
|
|
378
|
-
if (new File(
|
|
379
|
-
myAccountsFileReader = new BufferedReader(new FileReader(new File(
|
|
378
|
+
if (new File(mInterfaceUtil.rootDirectory, "/" + mInterfaceUtil.packageName + "/" + "my_accounts_encrypted.txt").exists()) {
|
|
379
|
+
myAccountsFileReader = new BufferedReader(new FileReader(new File(mInterfaceUtil.rootDirectory, "/" + mInterfaceUtil.packageName + "/" + "my_accounts_encrypted.txt")));
|
|
380
380
|
myAccountsFileBuilder = new StringBuilder();
|
|
381
381
|
while ((currentLine = myAccountsFileReader.readLine()) != null) {
|
|
382
382
|
myAccountsFileBuilder.append(currentLine);
|
|
@@ -390,12 +390,12 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
390
390
|
countryCode = currentAccount.optString("country_code").toString();
|
|
391
391
|
userID = currentAccount.optString("user_id").toString();
|
|
392
392
|
clientUrl = currentAccount.optString("client_url").toString();
|
|
393
|
-
File baseDirectory =
|
|
394
|
-
File databaseDir = new File(baseDirectory
|
|
393
|
+
File baseDirectory = mInterfaceUtil.rootDirectory;
|
|
394
|
+
File databaseDir = new File(baseDirectory + "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/database");
|
|
395
395
|
File processFileDir = new File(mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/database/process/");
|
|
396
396
|
if (databaseDir.exists()) {
|
|
397
|
-
String attachmentsPath =
|
|
398
|
-
String queuesPath = baseDirectory
|
|
397
|
+
String attachmentsPath = mInterfaceUtil.rootDirectory + "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/database/attachments";
|
|
398
|
+
String queuesPath = baseDirectory + "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/database/queue";
|
|
399
399
|
if (new File(attachmentsPath).exists()) {
|
|
400
400
|
File[] attachmentsFiles = new File(attachmentsPath).listFiles();
|
|
401
401
|
if (attachmentsFiles != null) {
|
|
@@ -461,7 +461,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
461
461
|
}
|
|
462
462
|
|
|
463
463
|
private void timeReader() throws Exception {
|
|
464
|
-
File baseDirectory =
|
|
464
|
+
File baseDirectory = mInterfaceUtil.rootDirectory;
|
|
465
465
|
File exist_time_profile = new File(baseDirectory, mInterfaceUtil.packageName + "/time_profile.txt");
|
|
466
466
|
if (exist_time_profile.exists()) {
|
|
467
467
|
exist_time_profile.delete();
|
|
@@ -474,7 +474,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
474
474
|
JSONObject serverDateObj;
|
|
475
475
|
timeObj = new StringBuilder();
|
|
476
476
|
BufferedWriter writerObj;
|
|
477
|
-
readerObj = new BufferedReader(new FileReader(new File(
|
|
477
|
+
readerObj = new BufferedReader(new FileReader(new File(mInterfaceUtil.rootDirectory, "/" + mInterfaceUtil.packageName + "/" + "time_profile_encrypted.txt")));
|
|
478
478
|
while ((currentLine = readerObj.readLine()) != null) {
|
|
479
479
|
timeObj.append(currentLine);
|
|
480
480
|
}
|
|
@@ -526,9 +526,9 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
526
526
|
String str = "";
|
|
527
527
|
|
|
528
528
|
try {
|
|
529
|
-
File baseDirectory =
|
|
530
|
-
if (new File(
|
|
531
|
-
myAccountsFileReader = new BufferedReader(new FileReader(new File(
|
|
529
|
+
File baseDirectory = mInterfaceUtil.rootDirectory;
|
|
530
|
+
if (new File(baseDirectory, "/" + mInterfaceUtil.packageName + "/" + "my_accounts_encrypted.txt").exists()) {
|
|
531
|
+
myAccountsFileReader = new BufferedReader(new FileReader(new File(baseDirectory, "/" + mInterfaceUtil.packageName + "/" + "my_accounts_encrypted.txt")));
|
|
532
532
|
myAccountsFileBuilder = new StringBuilder();
|
|
533
533
|
while ((currentLine = myAccountsFileReader.readLine()) != null) {
|
|
534
534
|
myAccountsFileBuilder.append(currentLine);
|
|
@@ -606,9 +606,9 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
606
606
|
@Override
|
|
607
607
|
protected String doInBackground(String... urls) {
|
|
608
608
|
File appDirectory,
|
|
609
|
-
baseDirectory =
|
|
609
|
+
baseDirectory = mInterfaceUtil.rootDirectory;
|
|
610
610
|
FileWriter fileWriterObj;
|
|
611
|
-
appDirectory = new File(baseDirectory
|
|
611
|
+
appDirectory = new File(baseDirectory + "/" + mInterfaceUtil.packageName);
|
|
612
612
|
if (appDirectory.exists()) {
|
|
613
613
|
try {
|
|
614
614
|
fileWriterObj = new FileWriter(new File(baseDirectory, mInterfaceUtil.packageName + "/MyLocation_encrypted.txt"), true);
|
|
@@ -731,7 +731,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
|
|
|
731
731
|
};
|
|
732
732
|
String currentLine;
|
|
733
733
|
StringBuilder locConfigObj = new StringBuilder();
|
|
734
|
-
File baseDirectory =
|
|
734
|
+
File baseDirectory = mInterfaceUtil.rootDirectory;
|
|
735
735
|
File locConfigFile = new File(baseDirectory, "/" + mInterfaceUtil.packageName + "/location_configuration.txt");
|
|
736
736
|
if (locConfigFile.exists()) {
|
|
737
737
|
BufferedReader readerObj = new BufferedReader(new FileReader(locConfigFile));
|
|
@@ -2,6 +2,8 @@ package com.selfservit.util;
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.TargetApi;
|
|
4
4
|
import android.app.Activity;
|
|
5
|
+
import android.content.ContentUris;
|
|
6
|
+
import android.content.ContentValues;
|
|
5
7
|
import android.content.Context;
|
|
6
8
|
import android.database.Cursor;
|
|
7
9
|
import android.graphics.Bitmap;
|
|
@@ -9,6 +11,7 @@ import android.graphics.BitmapFactory;
|
|
|
9
11
|
import android.location.LocationListener;
|
|
10
12
|
import android.location.LocationManager;
|
|
11
13
|
import android.media.MediaMetadataRetriever;
|
|
14
|
+
import android.media.MediaScannerConnection;
|
|
12
15
|
import android.media.ThumbnailUtils;
|
|
13
16
|
import android.net.ConnectivityManager;
|
|
14
17
|
import android.net.NetworkInfo;
|
|
@@ -19,6 +22,8 @@ import android.os.Environment;
|
|
|
19
22
|
import android.provider.MediaStore;
|
|
20
23
|
import android.support.annotation.RequiresApi;
|
|
21
24
|
import android.util.Base64;
|
|
25
|
+
import android.util.Log;
|
|
26
|
+
import android.widget.Toast;
|
|
22
27
|
|
|
23
28
|
import org.apache.cordova.CallbackContext;
|
|
24
29
|
import org.apache.cordova.PluginResult;
|
|
@@ -63,6 +68,7 @@ public class mInterfaceUtil {
|
|
|
63
68
|
LocationManager locationManager;
|
|
64
69
|
LocationListener locationListener;
|
|
65
70
|
public static String packageName = "";
|
|
71
|
+
public static File rootDirectory;
|
|
66
72
|
public static final Locale locale = Locale.US;
|
|
67
73
|
private static final String encryptionKey = "8080808080808080";
|
|
68
74
|
private static final String characterEncoding = "UTF-8";
|
|
@@ -100,6 +106,102 @@ public class mInterfaceUtil {
|
|
|
100
106
|
return decryptedText;
|
|
101
107
|
}
|
|
102
108
|
|
|
109
|
+
public void DownloadChatAttachment(String requestURL, String filePath, String thumbnailInd, Context context, CallbackContext callbackContext, Activity activity) {
|
|
110
|
+
try {
|
|
111
|
+
class DownloadFile extends AsyncTask<String, String, String> {
|
|
112
|
+
@Override
|
|
113
|
+
protected void onPreExecute() {
|
|
114
|
+
}
|
|
115
|
+
@Override
|
|
116
|
+
protected String doInBackground(String... args) {
|
|
117
|
+
BufferedInputStream input = null;
|
|
118
|
+
OutputStream output = null;
|
|
119
|
+
HttpURLConnection connection = null;
|
|
120
|
+
int count;
|
|
121
|
+
int progressCheck=10;
|
|
122
|
+
try {
|
|
123
|
+
URL url = new URL((requestURL).replaceAll(" ", "%20"));
|
|
124
|
+
connection = (HttpURLConnection) url.openConnection();
|
|
125
|
+
connection.setRequestProperty("Connection", "Keep-Alive");
|
|
126
|
+
connection.connect();
|
|
127
|
+
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
|
128
|
+
return "Server returned HTTP " + connection.getResponseCode() + " " + connection.getResponseMessage();
|
|
129
|
+
}
|
|
130
|
+
int fileLength = connection.getContentLength();
|
|
131
|
+
input = new BufferedInputStream(connection.getInputStream(),8192);
|
|
132
|
+
|
|
133
|
+
//File rootPath = Environment.getExternalStorageDirectory();
|
|
134
|
+
String rootPath = context.getExternalMediaDirs()[0].toString();
|
|
135
|
+
File filesourceDirecory = new File(rootPath + "/" + pathComponent(filePath));
|
|
136
|
+
if (!filesourceDirecory.exists()) {
|
|
137
|
+
filesourceDirecory.mkdirs();
|
|
138
|
+
}
|
|
139
|
+
File fileSavePath = new File(rootPath + "/" + filePath);
|
|
140
|
+
output = new FileOutputStream(fileSavePath);
|
|
141
|
+
byte data[] = new byte[1024];
|
|
142
|
+
long progress = 0;
|
|
143
|
+
int progressToSend = 0;
|
|
144
|
+
while ((count = input.read(data)) != -1) {
|
|
145
|
+
// allow canceling with back button
|
|
146
|
+
if (isCancelled()) {
|
|
147
|
+
input.close();
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
progress += count;
|
|
151
|
+
progressToSend = (int)((progress * 100) / fileLength);
|
|
152
|
+
|
|
153
|
+
if(progressToSend >= progressCheck){
|
|
154
|
+
JSONObject progressObj = new JSONObject();
|
|
155
|
+
progressObj.put("progress", progressCheck);
|
|
156
|
+
progressObj.put("fileLength", fileLength);
|
|
157
|
+
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, progressObj);
|
|
158
|
+
pluginResult.setKeepCallback(true);
|
|
159
|
+
callbackContext.sendPluginResult(pluginResult);
|
|
160
|
+
progressCheck = progressCheck + 10;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
output.write(data, 0, count);
|
|
164
|
+
}
|
|
165
|
+
} catch (Exception e) {
|
|
166
|
+
callbackContext.error("Failure" + e.getMessage());
|
|
167
|
+
}
|
|
168
|
+
if(thumbnailInd.equalsIgnoreCase("true")){
|
|
169
|
+
return filePath;
|
|
170
|
+
}else{
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
public void onPostExecute(String result) {
|
|
175
|
+
try {
|
|
176
|
+
MediaScannerConnection.scanFile(context,
|
|
177
|
+
new String[] { context.getExternalMediaDirs()[0].toString() },
|
|
178
|
+
null,
|
|
179
|
+
(path, uri) -> {
|
|
180
|
+
Log.i("ExternalStorage", "Scanned " + path + ":");
|
|
181
|
+
Log.i("ExternalStorage", "-> uri=" + uri);
|
|
182
|
+
});
|
|
183
|
+
if (result != null) {
|
|
184
|
+
if(result.indexOf('.') != -1){
|
|
185
|
+
String extension = "." + result.substring(result.lastIndexOf(".") + 1).toLowerCase(),
|
|
186
|
+
filePath = context.getExternalMediaDirs()[0].toString()+"/"+result;
|
|
187
|
+
String thumbnail = getFileThumbnail(filePath,extension,context);
|
|
188
|
+
callbackContext.success(thumbnail);
|
|
189
|
+
} else{
|
|
190
|
+
callbackContext.error("Failure");
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
callbackContext.success("success");
|
|
194
|
+
}
|
|
195
|
+
} catch (Exception e) {
|
|
196
|
+
e.printStackTrace();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
new DownloadFile().execute();
|
|
201
|
+
} catch (Exception e) {
|
|
202
|
+
e.printStackTrace();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
103
205
|
public static String encrypt(String plainText) {
|
|
104
206
|
String encryptedText = "";
|
|
105
207
|
try {
|
|
@@ -123,7 +225,7 @@ public class mInterfaceUtil {
|
|
|
123
225
|
|
|
124
226
|
String currentLine, lastKnownLocation = "";
|
|
125
227
|
try {
|
|
126
|
-
BufferedReader readerObj = new BufferedReader(new FileReader(new File(
|
|
228
|
+
BufferedReader readerObj = new BufferedReader(new FileReader(new File(rootDirectory, "/" + mInterfaceUtil.packageName + "/LastKnownLocation_encrypted.txt")));
|
|
127
229
|
while ((currentLine = readerObj.readLine()) != null) {
|
|
128
230
|
lastKnownLocation = currentLine;
|
|
129
231
|
}
|
|
@@ -168,8 +270,8 @@ public class mInterfaceUtil {
|
|
|
168
270
|
File queueFile, queueFolder;
|
|
169
271
|
Boolean syncIndication = false;
|
|
170
272
|
try {
|
|
171
|
-
queueFile = new File(
|
|
172
|
-
queueFolder = new File(
|
|
273
|
+
queueFile = new File(rootDirectory + "/" + mInterfaceUtil.packageName + "/database/queue_mgr_encrypted.txt");
|
|
274
|
+
queueFolder = new File(rootDirectory + "/" + mInterfaceUtil.packageName + "/database/queue");
|
|
173
275
|
if (queueFile.exists()) {
|
|
174
276
|
if (queueFile.length() == 0) {
|
|
175
277
|
syncIndication = true;
|
|
@@ -192,9 +294,9 @@ public class mInterfaceUtil {
|
|
|
192
294
|
}
|
|
193
295
|
|
|
194
296
|
public void deleteMultipleFiles(String str, CallbackContext callbackContext) {
|
|
195
|
-
File baseDirectory =
|
|
297
|
+
File baseDirectory = rootDirectory;
|
|
196
298
|
try {
|
|
197
|
-
File filePath = new File(baseDirectory
|
|
299
|
+
File filePath = new File(baseDirectory + "/" + str);
|
|
198
300
|
if (filePath.exists()) {
|
|
199
301
|
filePath.delete();
|
|
200
302
|
} else {
|
|
@@ -220,7 +322,7 @@ public class mInterfaceUtil {
|
|
|
220
322
|
try {
|
|
221
323
|
for (int index = 0; index < arguments.length(); index++) {
|
|
222
324
|
inputFileObj = arguments.getJSONObject(index);
|
|
223
|
-
File rootDir =
|
|
325
|
+
File rootDir = rootDirectory;
|
|
224
326
|
srcFilePath = rootDir + "/" + inputFileObj.optString("srcPath").toString();
|
|
225
327
|
srcFileName = inputFileObj.optString("srcFile").toString();
|
|
226
328
|
desFilePath = rootDir + "/" + inputFileObj.optString("desPath").toString();
|
|
@@ -267,9 +369,9 @@ public class mInterfaceUtil {
|
|
|
267
369
|
try {
|
|
268
370
|
for (int index = 0; index < arguments.length(); index++) {
|
|
269
371
|
inputFileObj = arguments.getJSONObject(index);
|
|
270
|
-
srcFilePath = "/
|
|
372
|
+
srcFilePath = rootDirectory + "/" + inputFileObj.optString("sourceFilePath").toString();
|
|
271
373
|
srcFileName = inputFileObj.optString("sourceFileName").toString();
|
|
272
|
-
desFilePath = "/
|
|
374
|
+
desFilePath = rootDirectory + "/" + inputFileObj.optString("targetFilePath").toString();
|
|
273
375
|
desFileName = inputFileObj.optString("targetFileName").toString();
|
|
274
376
|
sourceFileObj = new File(srcFilePath + "/" + srcFileName);
|
|
275
377
|
desFileObj = new File(desFilePath + "/" + desFileName);
|
|
@@ -317,9 +419,9 @@ public class mInterfaceUtil {
|
|
|
317
419
|
inputFileObj = arguments.getJSONObject(index);
|
|
318
420
|
srcFilePath = inputFileObj.optString("srcPath").toString();
|
|
319
421
|
srcFileName = inputFileObj.optString("srcFile").toString();
|
|
320
|
-
desFilePath = "/
|
|
422
|
+
desFilePath = rootDirectory + "/" + inputFileObj.optString("desPath").toString();
|
|
321
423
|
desFileName = inputFileObj.optString("desFile").toString();
|
|
322
|
-
queueCopyPath = "/
|
|
424
|
+
queueCopyPath = rootDirectory + "/" + inputFileObj.optString("queueAttachPath").toString();
|
|
323
425
|
queueCopyFileName = inputFileObj.optString("queueAttachFile").toString();
|
|
324
426
|
sourceFileObj = new File(srcFilePath + "/" + srcFileName);
|
|
325
427
|
desFileObj = new File(desFilePath + "/" + desFileName);
|
|
@@ -378,9 +480,9 @@ public class mInterfaceUtil {
|
|
|
378
480
|
try {
|
|
379
481
|
for (int index = 0; index < arguments.length(); index++) {
|
|
380
482
|
inputFileObj = arguments.getJSONObject(index);
|
|
381
|
-
srcFilePath = "/
|
|
483
|
+
srcFilePath = rootDirectory + "/" + inputFileObj.optString("sourceFilePath").toString();
|
|
382
484
|
srcFileName = inputFileObj.optString("sourceFileName").toString();
|
|
383
|
-
desFilePath = "/
|
|
485
|
+
desFilePath = rootDirectory + "/" + inputFileObj.optString("targetFilePath").toString();
|
|
384
486
|
desFileName = inputFileObj.optString("targetFileName").toString();
|
|
385
487
|
sourceFile = new File(srcFilePath + "/" + srcFileName);
|
|
386
488
|
desFile = new File(desFilePath + "/" + desFileName);
|
|
@@ -429,9 +531,9 @@ public class mInterfaceUtil {
|
|
|
429
531
|
inputFileObj = arguments.getJSONObject(index);
|
|
430
532
|
srcFilePath = inputFileObj.optString("srcPath").toString();
|
|
431
533
|
srcFileName = inputFileObj.optString("srcFile").toString();
|
|
432
|
-
desFilePath = "/
|
|
534
|
+
desFilePath = rootDirectory + "/" + inputFileObj.optString("desPath").toString();
|
|
433
535
|
desFileName = inputFileObj.optString("desFile").toString();
|
|
434
|
-
queueCopyPath = "/
|
|
536
|
+
queueCopyPath = rootDirectory + "/" + inputFileObj.optString("queueAttachPath").toString();
|
|
435
537
|
queueCopyFileName = inputFileObj.optString("queueAttachFile").toString();
|
|
436
538
|
sourceFileObj = new File(srcFilePath + "/" + srcFileName);
|
|
437
539
|
desFileObj = new File(desFilePath + "/" + desFileName);
|
|
@@ -485,8 +587,8 @@ public class mInterfaceUtil {
|
|
|
485
587
|
JSONArray accountsList;
|
|
486
588
|
JSONObject currentAccount;
|
|
487
589
|
String currentLine;
|
|
488
|
-
if (new File(
|
|
489
|
-
myAccountsFileReader = new BufferedReader(new FileReader(new File(
|
|
590
|
+
if (new File(rootDirectory, "/" + mInterfaceUtil.packageName + "/" + "my_accounts_encrypted.txt").exists()) {
|
|
591
|
+
myAccountsFileReader = new BufferedReader(new FileReader(new File(rootDirectory, "/" + mInterfaceUtil.packageName + "/" + "my_accounts_encrypted.txt")));
|
|
490
592
|
myAccountsFileBuilder = new StringBuilder();
|
|
491
593
|
while ((currentLine = myAccountsFileReader.readLine()) != null) {
|
|
492
594
|
myAccountsFileBuilder.append(currentLine);
|
|
@@ -499,12 +601,12 @@ public class mInterfaceUtil {
|
|
|
499
601
|
countryCode = currentAccount.optString("country_code").toString();
|
|
500
602
|
userID = currentAccount.optString("user_id").toString();
|
|
501
603
|
clientUrl = currentAccount.optString("client_url").toString();
|
|
502
|
-
File baseDirectory =
|
|
503
|
-
File databaseDir = new File(baseDirectory
|
|
604
|
+
File baseDirectory = rootDirectory;
|
|
605
|
+
File databaseDir = new File(baseDirectory + "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/database");
|
|
504
606
|
File processFileDir = new File(mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/database/process/");
|
|
505
607
|
if (databaseDir.exists()) {
|
|
506
|
-
String attachmentsPath = baseDirectory
|
|
507
|
-
String queuesPath = baseDirectory
|
|
608
|
+
String attachmentsPath = baseDirectory + "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/database/attachments";
|
|
609
|
+
String queuesPath = baseDirectory + "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/database/queue";
|
|
508
610
|
if (new File(attachmentsPath).exists()) {
|
|
509
611
|
File[] attachmentsFiles = new File(attachmentsPath).listFiles();
|
|
510
612
|
if (attachmentsFiles != null) {
|
|
@@ -617,7 +719,7 @@ public class mInterfaceUtil {
|
|
|
617
719
|
dateObj.put("serverDate", serverDate);
|
|
618
720
|
dateObj.put("initServerDate", serverDate);
|
|
619
721
|
dateObj.put("initDeviceDate", deviceDate);
|
|
620
|
-
writerObj = new BufferedWriter(new FileWriter(new File(
|
|
722
|
+
writerObj = new BufferedWriter(new FileWriter(new File(rootDirectory, "/" + mInterfaceUtil.packageName + "/time_profile_encrypted.txt")));
|
|
621
723
|
writerObj.write(encrypt(dateObj.toString()));
|
|
622
724
|
writerObj.flush();
|
|
623
725
|
writerObj.close();
|
|
@@ -632,8 +734,8 @@ public class mInterfaceUtil {
|
|
|
632
734
|
StringBuilder timeObj = new StringBuilder();
|
|
633
735
|
try {
|
|
634
736
|
Date mobileDate = new Date();
|
|
635
|
-
File baseDirectory =
|
|
636
|
-
BufferedReader readerObj = new BufferedReader(new FileReader(new File(
|
|
737
|
+
File baseDirectory = rootDirectory;
|
|
738
|
+
BufferedReader readerObj = new BufferedReader(new FileReader(new File(rootDirectory, "/" + mInterfaceUtil.packageName + "/time_profile_encrypted.txt")));
|
|
637
739
|
while ((currentLine = readerObj.readLine()) != null) {
|
|
638
740
|
timeObj.append(currentLine);
|
|
639
741
|
}
|
|
@@ -658,7 +760,7 @@ public class mInterfaceUtil {
|
|
|
658
760
|
FileWriter fileWriterObj;
|
|
659
761
|
try {
|
|
660
762
|
/* CHECKING THE DIRECTORY EXISTS OR NOT AND CREATING THE DIRECTORY */
|
|
661
|
-
appDirectory = new File(
|
|
763
|
+
appDirectory = new File(rootDirectory + "/" + fileName.substring(0, fileName.lastIndexOf("/")));
|
|
662
764
|
if (!appDirectory.exists()) {
|
|
663
765
|
appDirectory.mkdirs();
|
|
664
766
|
}
|
|
@@ -674,7 +776,7 @@ public class mInterfaceUtil {
|
|
|
674
776
|
}
|
|
675
777
|
|
|
676
778
|
public void deleteFilesFromDirectory() {
|
|
677
|
-
File dir = new File(
|
|
779
|
+
File dir = new File(rootDirectory + "/" + mInterfaceUtil.packageName + "/" + "images");
|
|
678
780
|
if (dir.isDirectory()) {
|
|
679
781
|
if (dir.exists()) {
|
|
680
782
|
String[] children = dir.list();
|
|
@@ -720,95 +822,6 @@ public class mInterfaceUtil {
|
|
|
720
822
|
return imgString;
|
|
721
823
|
}
|
|
722
824
|
|
|
723
|
-
public void DownloadChatAttachment(String requestURL, String filePath, String thumbnailInd, Context context, CallbackContext callbackContext, Activity activity) {
|
|
724
|
-
try {
|
|
725
|
-
class DownloadFile extends AsyncTask<String, String, String> {
|
|
726
|
-
@Override
|
|
727
|
-
protected void onPreExecute() {
|
|
728
|
-
}
|
|
729
|
-
@Override
|
|
730
|
-
protected String doInBackground(String... args) {
|
|
731
|
-
BufferedInputStream input = null;
|
|
732
|
-
OutputStream output = null;
|
|
733
|
-
HttpURLConnection connection = null;
|
|
734
|
-
int count;
|
|
735
|
-
int progressCheck=10;
|
|
736
|
-
try {
|
|
737
|
-
URL url = new URL((requestURL).replaceAll(" ", "%20"));
|
|
738
|
-
connection = (HttpURLConnection) url.openConnection();
|
|
739
|
-
connection.setRequestProperty("Connection", "Keep-Alive");
|
|
740
|
-
connection.connect();
|
|
741
|
-
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
|
742
|
-
return "Server returned HTTP " + connection.getResponseCode() + " " + connection.getResponseMessage();
|
|
743
|
-
}
|
|
744
|
-
int fileLength = connection.getContentLength();
|
|
745
|
-
input = new BufferedInputStream(connection.getInputStream(),8192);
|
|
746
|
-
|
|
747
|
-
File rootPath = Environment.getExternalStorageDirectory();
|
|
748
|
-
File filesourceDirecory = new File(rootPath + "/" + pathComponent(filePath));
|
|
749
|
-
if (!filesourceDirecory.exists()) {
|
|
750
|
-
filesourceDirecory.mkdirs();
|
|
751
|
-
}
|
|
752
|
-
File fileSavePath = new File(rootPath + "/" + filePath);
|
|
753
|
-
output = new FileOutputStream(fileSavePath);
|
|
754
|
-
byte data[] = new byte[1024];
|
|
755
|
-
long progress = 0;
|
|
756
|
-
int progressToSend = 0;
|
|
757
|
-
while ((count = input.read(data)) != -1) {
|
|
758
|
-
// allow canceling with back button
|
|
759
|
-
if (isCancelled()) {
|
|
760
|
-
input.close();
|
|
761
|
-
return null;
|
|
762
|
-
}
|
|
763
|
-
progress += count;
|
|
764
|
-
progressToSend = (int)((progress * 100) / fileLength);
|
|
765
|
-
|
|
766
|
-
if(progressToSend >= progressCheck){
|
|
767
|
-
JSONObject progressObj = new JSONObject();
|
|
768
|
-
progressObj.put("progress", progressCheck);
|
|
769
|
-
progressObj.put("fileLength", fileLength);
|
|
770
|
-
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, progressObj);
|
|
771
|
-
pluginResult.setKeepCallback(true);
|
|
772
|
-
callbackContext.sendPluginResult(pluginResult);
|
|
773
|
-
progressCheck = progressCheck + 10;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
output.write(data, 0, count);
|
|
777
|
-
}
|
|
778
|
-
} catch (Exception e) {
|
|
779
|
-
callbackContext.error("Failure" + e.getMessage());
|
|
780
|
-
}
|
|
781
|
-
if(thumbnailInd.equalsIgnoreCase("true")){
|
|
782
|
-
return filePath;
|
|
783
|
-
}else{
|
|
784
|
-
return null;
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
public void onPostExecute(String result) {
|
|
788
|
-
try {
|
|
789
|
-
if (result != null) {
|
|
790
|
-
if(result.indexOf('.') != -1){
|
|
791
|
-
String extension = "." + result.substring(result.lastIndexOf(".") + 1).toLowerCase(),
|
|
792
|
-
filePath = Environment.getExternalStorageDirectory()+"/"+result;
|
|
793
|
-
String thumbnail = getFileThumbnail(filePath,extension,context);
|
|
794
|
-
callbackContext.success(thumbnail);
|
|
795
|
-
} else{
|
|
796
|
-
callbackContext.error("Failure");
|
|
797
|
-
}
|
|
798
|
-
} else {
|
|
799
|
-
callbackContext.success("success");
|
|
800
|
-
}
|
|
801
|
-
} catch (Exception e) {
|
|
802
|
-
e.printStackTrace();
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
new DownloadFile().execute();
|
|
807
|
-
} catch (Exception e) {
|
|
808
|
-
e.printStackTrace();
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
|
|
812
825
|
public void sendChatAttachment(String filePath, String fileName, String requestURL, Context context, CallbackContext callbackContext) {
|
|
813
826
|
try {
|
|
814
827
|
class SendFile extends AsyncTask<String, String, String> {
|
|
@@ -1103,9 +1116,9 @@ public class mInterfaceUtil {
|
|
|
1103
1116
|
|
|
1104
1117
|
public void readFile(JSONArray args, CallbackContext callbackContext) throws IOException {
|
|
1105
1118
|
String str = "";
|
|
1106
|
-
File baseDirectory =
|
|
1119
|
+
File baseDirectory = rootDirectory;
|
|
1107
1120
|
try {
|
|
1108
|
-
File filePath = new File(baseDirectory
|
|
1121
|
+
File filePath = new File(baseDirectory + "/" + args.getJSONObject(0).optString("filePath"));
|
|
1109
1122
|
if (filePath.exists()) {
|
|
1110
1123
|
String content = new Scanner(filePath).useDelimiter("\\A").next();
|
|
1111
1124
|
callbackContext.success(content);
|
|
@@ -1118,9 +1131,9 @@ public class mInterfaceUtil {
|
|
|
1118
1131
|
}
|
|
1119
1132
|
|
|
1120
1133
|
public void deleteFile(JSONArray args, CallbackContext callbackContext) {
|
|
1121
|
-
File baseDirectory =
|
|
1134
|
+
File baseDirectory = rootDirectory;
|
|
1122
1135
|
try {
|
|
1123
|
-
File filePath = new File(baseDirectory
|
|
1136
|
+
File filePath = new File(baseDirectory + "/" + args.getJSONObject(0).optString("filePath"));
|
|
1124
1137
|
if (filePath.exists()) {
|
|
1125
1138
|
filePath.delete();
|
|
1126
1139
|
callbackContext.success();
|
|
@@ -1138,9 +1151,7 @@ public class mInterfaceUtil {
|
|
|
1138
1151
|
try {
|
|
1139
1152
|
String fileName = args.getJSONObject(0).optString("filePath");
|
|
1140
1153
|
String data = args.getJSONObject(0).optString("data");
|
|
1141
|
-
|
|
1142
|
-
String aaaa = fileName.substring(0, fileName.lastIndexOf("/"));
|
|
1143
|
-
appDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + fileName.substring(0, fileName.lastIndexOf("/")));
|
|
1154
|
+
appDirectory = new File(rootDirectory + "/" + fileName.substring(0, fileName.lastIndexOf("/")));
|
|
1144
1155
|
if (!appDirectory.exists()) {
|
|
1145
1156
|
appDirectory.mkdirs();
|
|
1146
1157
|
}
|
|
@@ -1157,9 +1168,9 @@ public class mInterfaceUtil {
|
|
|
1157
1168
|
}
|
|
1158
1169
|
|
|
1159
1170
|
public void validateFile(JSONArray args, CallbackContext callbackContext) {
|
|
1160
|
-
File baseDirectory =
|
|
1171
|
+
File baseDirectory = rootDirectory;
|
|
1161
1172
|
try {
|
|
1162
|
-
File filePath = new File(baseDirectory
|
|
1173
|
+
File filePath = new File(baseDirectory + "/" + args.getJSONObject(0).optString("filePath"));
|
|
1163
1174
|
boolean sss = filePath.exists() ? true : false;
|
|
1164
1175
|
callbackContext.success(sss ? "true" : "false");
|
|
1165
1176
|
} catch (Exception e) {
|
|
@@ -1172,7 +1183,7 @@ public class mInterfaceUtil {
|
|
|
1172
1183
|
FileWriter fileWriterObj;
|
|
1173
1184
|
try {
|
|
1174
1185
|
String fileName = args.getJSONObject(0).optString("filePath");
|
|
1175
|
-
appDirectory = new File(
|
|
1186
|
+
appDirectory = new File(rootDirectory + "/" + fileName);
|
|
1176
1187
|
if (!appDirectory.exists()) {
|
|
1177
1188
|
appDirectory.mkdirs();
|
|
1178
1189
|
}
|
|
@@ -1190,7 +1201,7 @@ public class mInterfaceUtil {
|
|
|
1190
1201
|
if (fileName.equals("")) {
|
|
1191
1202
|
callbackContext.error("Given directory path is empty.");
|
|
1192
1203
|
} else {
|
|
1193
|
-
File dir = new File(
|
|
1204
|
+
File dir = new File(rootDirectory + "/" + fileName);
|
|
1194
1205
|
if (dir.exists()) {
|
|
1195
1206
|
deleteRecursive(dir);
|
|
1196
1207
|
callbackContext.success();
|
|
@@ -1215,23 +1226,6 @@ public class mInterfaceUtil {
|
|
|
1215
1226
|
fileOrDirectory.delete();
|
|
1216
1227
|
}
|
|
1217
1228
|
|
|
1218
|
-
/* public void deleteDirectory(JSONArray args, CallbackContext callbackContext) {
|
|
1219
|
-
File appDirectory;
|
|
1220
|
-
FileWriter fileWriterObj;
|
|
1221
|
-
try {
|
|
1222
|
-
String fileName = args.getJSONObject(0).optString("filePath");
|
|
1223
|
-
appDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + fileName);
|
|
1224
|
-
if (appDirectory.exists()) {
|
|
1225
|
-
appDirectory.delete();
|
|
1226
|
-
callbackContext.success();
|
|
1227
|
-
}else{
|
|
1228
|
-
callbackContext.success("There is no directory to delete");
|
|
1229
|
-
}
|
|
1230
|
-
} catch (Exception e) {
|
|
1231
|
-
callbackContext.error(e.getMessage());
|
|
1232
|
-
}
|
|
1233
|
-
} */
|
|
1234
|
-
|
|
1235
1229
|
private static int BUFFER_SIZE = 6 * 1024;
|
|
1236
1230
|
|
|
1237
1231
|
public static void unzip(String zipFile, String location, CallbackContext callbackContext) throws JSONException {
|
|
@@ -1281,7 +1275,7 @@ public class mInterfaceUtil {
|
|
|
1281
1275
|
if (fileName.equals("")) {
|
|
1282
1276
|
callbackContext.error("Given directory path is empty.");
|
|
1283
1277
|
} else {
|
|
1284
|
-
File dir = new File(
|
|
1278
|
+
File dir = new File(rootDirectory + "/" + fileName);
|
|
1285
1279
|
String[] subDirectories = dir.list(new FilenameFilter() {
|
|
1286
1280
|
@Override
|
|
1287
1281
|
public boolean accept(File current, String name) {
|
|
@@ -1307,7 +1301,7 @@ public class mInterfaceUtil {
|
|
|
1307
1301
|
if (fileName.equals("")) {
|
|
1308
1302
|
callbackContext.error("Given directory path is empty.");
|
|
1309
1303
|
} else {
|
|
1310
|
-
File dir = new File(
|
|
1304
|
+
File dir = new File(rootDirectory + "/" + fileName);
|
|
1311
1305
|
String[] subDirectories = dir.list(new FilenameFilter() {
|
|
1312
1306
|
@Override
|
|
1313
1307
|
public boolean accept(File current, String name) {
|
|
@@ -1330,7 +1324,7 @@ public class mInterfaceUtil {
|
|
|
1330
1324
|
String currentLine;
|
|
1331
1325
|
File appStateIndicatorFile;
|
|
1332
1326
|
try {
|
|
1333
|
-
appStateIndicatorFile = new File(
|
|
1327
|
+
appStateIndicatorFile = new File(rootDirectory, "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/" + "app_state_info.txt");
|
|
1334
1328
|
if (appStateIndicatorFile.exists()) {
|
|
1335
1329
|
BufferedReader authFileReader = new BufferedReader(new FileReader(appStateIndicatorFile));
|
|
1336
1330
|
StringBuilder authFileBuilder = new StringBuilder();
|
|
@@ -1399,7 +1393,7 @@ public class mInterfaceUtil {
|
|
|
1399
1393
|
}
|
|
1400
1394
|
responseReaderObj.close();
|
|
1401
1395
|
urlConObj.disconnect();
|
|
1402
|
-
writerObj = new BufferedWriter(new FileWriter(new File(
|
|
1396
|
+
writerObj = new BufferedWriter(new FileWriter(new File(rootDirectory, "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/" + "client_configuration_encrypted.txt")));
|
|
1403
1397
|
writerObj.write(encrypt(serverResponseObj.toString()));
|
|
1404
1398
|
writerObj.flush();
|
|
1405
1399
|
writerObj.close();
|
|
@@ -1470,7 +1464,7 @@ public class mInterfaceUtil {
|
|
|
1470
1464
|
JSONObject resultJsonObj = new JSONObject(responseStr).getJSONObject("outputparam");
|
|
1471
1465
|
responseDataObj = responseDataObj.put("validDevice", "true");
|
|
1472
1466
|
/* RESPONSE FOR AUTHENTICATION & VALIDATE DEVICE REQUESTS */
|
|
1473
|
-
writerObj = new BufferedWriter(new FileWriter(new File(
|
|
1467
|
+
writerObj = new BufferedWriter(new FileWriter(new File(rootDirectory, "/" + packageName + "/" + clientID + "/" + countryCode + "/" + "app_state_info.txt")));
|
|
1474
1468
|
writerObj.write(encrypt(responseDataObj.toString()));
|
|
1475
1469
|
writerObj.flush();
|
|
1476
1470
|
writerObj.close();
|
|
@@ -1478,7 +1472,7 @@ public class mInterfaceUtil {
|
|
|
1478
1472
|
|
|
1479
1473
|
} catch (Exception ex) {
|
|
1480
1474
|
responseDataObj = responseDataObj.put("validDevice", "nostatus");
|
|
1481
|
-
writerObj = new BufferedWriter(new FileWriter(new File(
|
|
1475
|
+
writerObj = new BufferedWriter(new FileWriter(new File(rootDirectory, "/" + packageName + "/" + clientID + "/" + countryCode + "/" + "app_state_info.txt")));
|
|
1482
1476
|
writerObj.write(encrypt(responseDataObj.toString()));
|
|
1483
1477
|
writerObj.flush();
|
|
1484
1478
|
writerObj.close();
|
|
@@ -1493,7 +1487,7 @@ public class mInterfaceUtil {
|
|
|
1493
1487
|
public static void validateAppStateInfo(Context applicationContext) {
|
|
1494
1488
|
String currentLine;
|
|
1495
1489
|
try {
|
|
1496
|
-
File appStateIndicatorFile = new File(
|
|
1490
|
+
File appStateIndicatorFile = new File(rootDirectory, "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/" + "app_state_info.txt");
|
|
1497
1491
|
if (appStateIndicatorFile.exists()) {
|
|
1498
1492
|
BufferedReader authFileReader = new BufferedReader(new FileReader(appStateIndicatorFile));
|
|
1499
1493
|
StringBuilder authFileBuilder = new StringBuilder();
|
|
@@ -1567,7 +1561,7 @@ public class mInterfaceUtil {
|
|
|
1567
1561
|
}
|
|
1568
1562
|
responseReaderObj.close();
|
|
1569
1563
|
urlConObj.disconnect();
|
|
1570
|
-
writerObj = new BufferedWriter(new FileWriter(new File(
|
|
1564
|
+
writerObj = new BufferedWriter(new FileWriter(new File(rootDirectory, "/" + mInterfaceUtil.packageName + "/" + clientID + "/" + countryCode + "/" + "client_configuration_encrypted.txt")));
|
|
1571
1565
|
writerObj.write(encrypt(serverResponseObj.toString()));
|
|
1572
1566
|
writerObj.flush();
|
|
1573
1567
|
writerObj.close();
|
|
@@ -1637,7 +1631,7 @@ public class mInterfaceUtil {
|
|
|
1637
1631
|
JSONObject resultJsonObj = new JSONObject(responseStr).getJSONObject("outputparam");
|
|
1638
1632
|
responseDataObj = responseDataObj.put("validDevice", "true");
|
|
1639
1633
|
/* RESPONSE FOR AUTHENTICATION & VALIDATE DEVICE REQUESTS */
|
|
1640
|
-
writerObj = new BufferedWriter(new FileWriter(new File(
|
|
1634
|
+
writerObj = new BufferedWriter(new FileWriter(new File(rootDirectory, "/" + packageName + "/" + clientID + "/" + countryCode + "/" + "app_state_info.txt")));
|
|
1641
1635
|
writerObj.write(encrypt(responseDataObj.toString()));
|
|
1642
1636
|
writerObj.flush();
|
|
1643
1637
|
writerObj.close();
|
|
@@ -1646,7 +1640,7 @@ public class mInterfaceUtil {
|
|
|
1646
1640
|
|
|
1647
1641
|
} catch (Exception ex) {
|
|
1648
1642
|
responseDataObj = responseDataObj.put("validDevice", "nostatus");
|
|
1649
|
-
writerObj = new BufferedWriter(new FileWriter(new File(
|
|
1643
|
+
writerObj = new BufferedWriter(new FileWriter(new File(rootDirectory, "/" + packageName + "/" + clientID + "/" + countryCode + "/" + "app_state_info.txt")));
|
|
1650
1644
|
writerObj.write(encrypt(responseDataObj.toString()));
|
|
1651
1645
|
writerObj.flush();
|
|
1652
1646
|
writerObj.close();
|
package/src/ios/mInterface.h
CHANGED
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
UIInterfaceOrientation _lastOrientation;
|
|
41
41
|
}
|
|
42
42
|
@property(strong) NSString* callbackID;
|
|
43
|
+
-(void)GetBase64String:(CDVInvokedUrlCommand *)command;
|
|
43
44
|
- (void)ValidateAppStateInfo;
|
|
44
45
|
-(void)HandleAppStateTimer:(NSString *)status;
|
|
45
46
|
-(void)GetAppStateInfo:(CDVInvokedUrlCommand *)command;
|
package/src/ios/mInterface.m
CHANGED
|
@@ -26,6 +26,15 @@
|
|
|
26
26
|
@synthesize controller = docController;
|
|
27
27
|
@synthesize callbackID;
|
|
28
28
|
|
|
29
|
+
-(void)GetBase64String:(CDVInvokedUrlCommand *)command {
|
|
30
|
+
NSMutableDictionary *dict = [[command arguments] objectAtIndex:0];
|
|
31
|
+
NSString *directory = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
|
|
32
|
+
NSString *workSpacePath=[NSString stringWithFormat:@"%@/%@", directory, dict[@"filePath"]];
|
|
33
|
+
NSString *imageString = [UIImagePNGRepresentation([UIImage imageWithData:[NSData dataWithContentsOfFile:workSpacePath]]) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
|
|
34
|
+
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:imageString];
|
|
35
|
+
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
|
36
|
+
}
|
|
37
|
+
|
|
29
38
|
-(void)GetAppStateInfo:(CDVInvokedUrlCommand *)command {
|
|
30
39
|
appInfoCaller = @"true";
|
|
31
40
|
NSString *appInfoUpdate = [self UpdateAppInfo:command];
|
|
@@ -2250,4 +2259,3 @@
|
|
|
2250
2259
|
}
|
|
2251
2260
|
@end
|
|
2252
2261
|
|
|
2253
|
-
|