cordova-plugin-mserviceinterface-2.0 1.0.88 → 1.0.90
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
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
|
-
xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.90">
|
|
4
4
|
<name>mserviceinterface-2.0</name>
|
|
5
5
|
<description>This plugin establishes the connection to the native interface and performs the requested task.</description>
|
|
6
6
|
<author>selfservit@gmail.com</author>
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
<clobbers target="mInterface" />
|
|
17
17
|
</js-module>
|
|
18
18
|
<platform name="android">
|
|
19
|
-
<framework src="src/android/build-extras.gradle" custom="true" type="gradleReference" />
|
|
20
19
|
<framework src="src/android/doubleogradle.gradle" custom="true" type="gradleReference"/>
|
|
21
20
|
<framework src="androidx.camera:camera-core:1.2.0" />
|
|
22
21
|
<framework src="androidx.camera:camera-camera2:1.2.0" />
|
|
@@ -83,6 +82,7 @@
|
|
|
83
82
|
<source-file src="src/android/mInterfaceService.java" target-dir="src/com/selfservit/util/" />
|
|
84
83
|
<source-file src="src/android/mInterfaceReceiver.java" target-dir="src/com/selfservit/util/" />
|
|
85
84
|
<source-file src="src/android/mInterface.java" target-dir="src/com/selfservit/util/" />
|
|
85
|
+
<source-file src="src/android/CameraActivity.java" target-dir="src/com/selfservit/util/" />
|
|
86
86
|
<source-file src="src/android/GeofenceBroadcastReceiver.java" target-dir="src/com/selfservit/util/" />
|
|
87
87
|
<source-file src="src/android/mInterfaceUtil.java" target-dir="src/com/selfservit/util/" />
|
|
88
88
|
<source-file src="src/android/CallbackProgressDialog.java" target-dir="src/com/selfservit/util/" />
|
|
@@ -90,13 +90,13 @@
|
|
|
90
90
|
<source-file src="src/android/res/xml/opener_paths.xml" target-dir="res/xml" />
|
|
91
91
|
<source-file src="src/android/res/xml/network_security_config.xml" target-dir="res/xml" />
|
|
92
92
|
<source-file src="src/android/res/xml/my_backup_rules.xml" target-dir="res/xml" />
|
|
93
|
-
<resource-file src="src/android/res/layout/activity_camera.xml" target="
|
|
94
|
-
<resource-file src="src/android/res/drawable/focus_box.xml" target="
|
|
95
|
-
<resource-file src="src/android/res/drawable/ic_flip_camera.xml" target="
|
|
96
|
-
<resource-file src="src/android/res/drawable/circle_button.xml" target="
|
|
97
|
-
<resource-file src="src/android/res/drawable/ic_flashlight_on.xml" target="
|
|
98
|
-
<resource-file src="src/android/res/drawable/ic_flashlight_off.xml" target="
|
|
99
|
-
<resource-file src="src/android/res/values/styles.xml" target="
|
|
93
|
+
<resource-file src="src/android/res/layout/activity_camera.xml" target="res/layout/activity_camera.xml" />
|
|
94
|
+
<resource-file src="src/android/res/drawable/focus_box.xml" target="res/drawable/focus_box.xml" />
|
|
95
|
+
<resource-file src="src/android/res/drawable/ic_flip_camera.xml" target="res/drawable/ic_flip_camera.xml" />
|
|
96
|
+
<resource-file src="src/android/res/drawable/circle_button.xml" target="res/drawable/circle_button.xml" />
|
|
97
|
+
<resource-file src="src/android/res/drawable/ic_flashlight_on.xml" target="res/drawable/ic_flashlight_on.xml" />
|
|
98
|
+
<resource-file src="src/android/res/drawable/ic_flashlight_off.xml" target="res/drawable/ic_flashlight_off.xml" />
|
|
99
|
+
<resource-file src="src/android/res/values/styles.xml" target="res/values/styles.xml" />
|
|
100
100
|
</platform>
|
|
101
101
|
<platform name="ios">
|
|
102
102
|
<config-file target="*-Info.plist" parent="NSCameraUsageDescription">
|
|
@@ -315,7 +315,13 @@ public class CameraActivity extends AppCompatActivity {
|
|
|
315
315
|
}
|
|
316
316
|
return true;
|
|
317
317
|
}
|
|
318
|
-
|
|
318
|
+
@Override
|
|
319
|
+
public void onBackPressed() {
|
|
320
|
+
Intent intent = new Intent();
|
|
321
|
+
intent.putExtra("result", "cancelled");
|
|
322
|
+
setResult(Activity.RESULT_CANCELED, intent);
|
|
323
|
+
finish();
|
|
324
|
+
}
|
|
319
325
|
@Override
|
|
320
326
|
public void onRequestPermissionsResult(int rc, @NonNull String[] perms,
|
|
321
327
|
@NonNull int[] results) {
|
|
@@ -104,6 +104,8 @@ import java.util.Stack;
|
|
|
104
104
|
import java.util.TimeZone;
|
|
105
105
|
import java.util.zip.ZipEntry;
|
|
106
106
|
import java.util.zip.ZipInputStream;
|
|
107
|
+
import android.content.Context;
|
|
108
|
+
import android.provider.Settings;
|
|
107
109
|
|
|
108
110
|
import id.zelory.compressor.Compressor;
|
|
109
111
|
import com.selfservit.util.GeofenceBroadcastReceiver;
|
|
@@ -1383,30 +1385,12 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1383
1385
|
|
|
1384
1386
|
public void captureImage(CallbackContext callbackContext) {
|
|
1385
1387
|
callback = callbackContext;
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
} catch (IOException ex) {
|
|
1392
|
-
callback.error("there is error in create image");
|
|
1393
|
-
}
|
|
1394
|
-
// Continue only if the File was successfully created
|
|
1395
|
-
if (photoFile != null) {
|
|
1396
|
-
Uri photoURISample;
|
|
1397
|
-
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
|
1398
|
-
photoURISample = Uri.fromFile(photoFile);
|
|
1399
|
-
} else {
|
|
1400
|
-
photoURISample = FileProvider.getUriForFile(context, context.getPackageName() + ".provider", photoFile);
|
|
1401
|
-
}
|
|
1402
|
-
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURISample);
|
|
1403
|
-
cordova.startActivityForResult(this, takePictureIntent, REQUEST_IMAGE_CAPTURE);
|
|
1404
|
-
PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
|
|
1405
|
-
pluginResult.setKeepCallback(true);
|
|
1406
|
-
callbackContext.sendPluginResult(pluginResult);
|
|
1407
|
-
}
|
|
1388
|
+
Intent intent = new Intent(cordova.getActivity(), CameraActivity.class);
|
|
1389
|
+
cordova.startActivityForResult(this, intent, REQUEST_IMAGE_CAPTURE);
|
|
1390
|
+
PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
|
|
1391
|
+
pluginResult.setKeepCallback(true);
|
|
1392
|
+
callbackContext.sendPluginResult(pluginResult);
|
|
1408
1393
|
}
|
|
1409
|
-
|
|
1410
1394
|
public void pickImageFromGallery(CallbackContext callbackContext) {
|
|
1411
1395
|
try {
|
|
1412
1396
|
Intent openFile,
|
|
@@ -1492,6 +1476,32 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1492
1476
|
}
|
|
1493
1477
|
return 0;
|
|
1494
1478
|
}
|
|
1479
|
+
private Bitmap handleImageRotation(String imagePath) {
|
|
1480
|
+
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
|
|
1481
|
+
ExifInterface exif = null;
|
|
1482
|
+
try {
|
|
1483
|
+
exif = new ExifInterface(imagePath);
|
|
1484
|
+
} catch (IOException e) {
|
|
1485
|
+
throw new RuntimeException(e);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
|
|
1489
|
+
Matrix matrix = new Matrix();
|
|
1490
|
+
|
|
1491
|
+
switch (orientation) {
|
|
1492
|
+
case ExifInterface.ORIENTATION_ROTATE_90:
|
|
1493
|
+
matrix.postRotate(90);
|
|
1494
|
+
break;
|
|
1495
|
+
case ExifInterface.ORIENTATION_ROTATE_180:
|
|
1496
|
+
matrix.postRotate(180);
|
|
1497
|
+
break;
|
|
1498
|
+
case ExifInterface.ORIENTATION_ROTATE_270:
|
|
1499
|
+
matrix.postRotate(270);
|
|
1500
|
+
break;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
|
1504
|
+
}
|
|
1495
1505
|
|
|
1496
1506
|
public void convertImageTo64BaseString(CallbackContext callbackContext, String imageSourcePath, String imgSrcType, String destinationPath) {
|
|
1497
1507
|
InputStream srcFileReader;
|
|
@@ -1545,10 +1555,10 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1545
1555
|
srcFileReader.close();
|
|
1546
1556
|
desFileWriter.close();
|
|
1547
1557
|
}
|
|
1548
|
-
|
|
1558
|
+
bitmap = handleImageRotation(compressedImageName);
|
|
1549
1559
|
|
|
1550
1560
|
} else {
|
|
1551
|
-
bitmap =
|
|
1561
|
+
bitmap = handleImageRotation(compressedImageFile.getAbsolutePath());
|
|
1552
1562
|
}
|
|
1553
1563
|
String encodedImage;
|
|
1554
1564
|
try {
|
|
@@ -1995,17 +2005,24 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1995
2005
|
}
|
|
1996
2006
|
} else if (requestCode == REQUEST_IMAGE_CAPTURE && callback != null) {
|
|
1997
2007
|
if (resultCode == RESULT_OK) {
|
|
1998
|
-
|
|
1999
|
-
|
|
2008
|
+
String imagePath = data.getStringExtra("imagePath");
|
|
2009
|
+
if (imagePath != null && !imagePath.isEmpty()) {
|
|
2010
|
+
pictureFilePath = imagePath;
|
|
2011
|
+
if (cameraAttachmentInd.equals("true")) {
|
|
2012
|
+
convertImageTo64BaseString(callback, imagePath, "compress", attachmentDestPath);
|
|
2013
|
+
} else {
|
|
2014
|
+
convertImageTo64BaseString(callback, imagePath, "camera", "");
|
|
2015
|
+
}
|
|
2000
2016
|
} else {
|
|
2001
|
-
|
|
2017
|
+
callback.error("failure");
|
|
2002
2018
|
}
|
|
2003
|
-
|
|
2004
2019
|
} else if (resultCode == Activity.RESULT_CANCELED) {
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2020
|
+
if (pictureFilePath != null && !pictureFilePath.isEmpty()) {
|
|
2021
|
+
File file = new File(pictureFilePath);
|
|
2022
|
+
if (file.exists()) {
|
|
2023
|
+
file.delete();
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2009
2026
|
callback.error("failure");
|
|
2010
2027
|
} else {
|
|
2011
2028
|
callback.error(resultCode);
|