cordova-plugin-mserviceinterface-2.0 1.0.88 → 1.0.89

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-mserviceinterface-2.0",
3
- "version": "1.0.88",
3
+ "version": "1.0.89",
4
4
  "description": "This plugin establishes the connection to the native interface and performs the requested task.",
5
5
  "main": "index.js",
6
6
  "scripts": {
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.88">
3
+ xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.89">
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="app/src/main/res/layout/activity_camera.xml" />
94
- <resource-file src="src/android/res/drawable/focus_box.xml" target="app/src/main/res/drawable/focus_box.xml" />
95
- <resource-file src="src/android/res/drawable/ic_flip_camera.xml" target="app/src/main/res/drawable/ic_flip_camera.xml" />
96
- <resource-file src="src/android/res/drawable/circle_button.xml" target="app/src/main/res/drawable/circle_button.xml" />
97
- <resource-file src="src/android/res/drawable/ic_flashlight_on.xml" target="app/src/main/res/drawable/ic_flashlight_on.xml" />
98
- <resource-file src="src/android/res/drawable/ic_flashlight_off.xml" target="app/src/main/res/drawable/ic_flashlight_off.xml" />
99
- <resource-file src="src/android/res/values/styles.xml" target="app/src/main/res/values/styles.xml" />
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">
@@ -3,4 +3,8 @@ android {
3
3
  multiDexEnabled true
4
4
 
5
5
  }
6
+ compileOptions {
7
+ sourceCompatibility JavaVersion.VERSION_1_8
8
+ targetCompatibility JavaVersion.VERSION_1_8
9
+ }
6
10
  }
@@ -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
- Context context = cordova.getActivity().getApplicationContext();
1387
- Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
1388
- File photoFile = null;
1389
- try {
1390
- photoFile = createImageFile();
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
- bitmap = BitmapFactory.decodeFile(compressedImageName);
1558
+ bitmap = handleImageRotation(compressedImageName);
1549
1559
 
1550
1560
  } else {
1551
- bitmap = BitmapFactory.decodeFile(compressedImageFile.getAbsolutePath());
1561
+ bitmap = handleImageRotation(compressedImageFile.getAbsolutePath());
1552
1562
  }
1553
1563
  String encodedImage;
1554
1564
  try {
@@ -1995,12 +2005,15 @@ 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
- if (cameraAttachmentInd.equals("true")) {
1999
- convertImageTo64BaseString(callback, pictureFilePath, "compress", attachmentDestPath);
2000
- } else {
2001
- convertImageTo64BaseString(callback, pictureFilePath, "camera", "");
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
+ }
2002
2016
  }
2003
-
2004
2017
  } else if (resultCode == Activity.RESULT_CANCELED) {
2005
2018
  File file = new File(pictureFilePath);
2006
2019
  if (file.exists()) {