cordova-plugin-mserviceinterface-2.0 1.0.55 → 1.0.57

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.55",
3
+ "version": "1.0.57",
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
@@ -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.55">
5
+ version="1.0.57">
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>
@@ -47,6 +47,7 @@
47
47
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
48
48
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
49
49
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
50
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
50
51
  </config-file>
51
52
  <config-file target="AndroidManifest.xml" parent="/manifest/application">
52
53
  <service android:name="com.selfservit.util.mInterfaceService" android:foregroundServiceType="location" android:enabled="true" android:exported="true"/>
@@ -25,7 +25,6 @@ import android.graphics.Canvas;
25
25
  import android.graphics.Matrix;
26
26
  import android.graphics.Paint;
27
27
  import android.location.Location;
28
- import androidx.exifinterface.media.ExifInterface;
29
28
  import android.media.MediaMetadataRetriever;
30
29
  import android.media.ThumbnailUtils;
31
30
  import android.net.ConnectivityManager;
@@ -35,7 +34,6 @@ import android.os.AsyncTask;
35
34
  import android.os.Build;
36
35
  import android.os.Bundle;
37
36
  import android.os.Environment;
38
- import android.os.PowerManager;
39
37
  import android.provider.DocumentsContract;
40
38
  import android.provider.MediaStore;
41
39
  import android.provider.OpenableColumns;
@@ -52,6 +50,7 @@ import androidx.annotation.NonNull;
52
50
  import androidx.annotation.Nullable;
53
51
  import androidx.annotation.RequiresApi;
54
52
  import androidx.core.app.ActivityCompat;
53
+ import androidx.exifinterface.media.ExifInterface;
55
54
 
56
55
  import com.google.android.gms.common.ConnectionResult;
57
56
  import com.google.android.gms.common.api.GoogleApiClient;
@@ -150,7 +149,6 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
150
149
  @RequiresApi(api = Build.VERSION_CODES.O)
151
150
  @Override
152
151
  public boolean execute(final String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
153
- callback = callbackContext;
154
152
  mInterfaceUtil.rootDirectory = new File(cordova.getActivity().getExternalFilesDir(""), "");
155
153
  if (mInterfaceUtil.packageName.equals("")) {
156
154
  mInterfaceUtil.packageName = cordova.getActivity().getApplicationContext().getPackageName().split("\\.")[2];
@@ -721,7 +719,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
721
719
  }
722
720
  } else if (action.equals("DownloadFile")) {
723
721
  callback = callbackContext;
724
- final DownloadTask downloadTask = new DownloadTask(cordova.getActivity());
722
+ final DownloadTask downloadTask = new DownloadTask(cordova.getActivity(),callback);
725
723
  downloadTask.execute(args.optJSONObject(0).optString("url"), args.optJSONObject(0).optString("filePath"), args.optJSONObject(0).optString("thumbnailInd"));
726
724
  return true;
727
725
  } else if ("QueueProcessor".equals(action)) {
@@ -1051,6 +1049,12 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
1051
1049
  if (Build.VERSION.SDK_INT != Build.VERSION_CODES.Q) {
1052
1050
  list = new ArrayList<String>(Arrays.asList(permissions));
1053
1051
  list.remove("android.permission.ACCESS_BACKGROUND_LOCATION");
1052
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
1053
+ list.remove("android.permission.POST_NOTIFICATIONS");
1054
+ }else{
1055
+ list.remove("android.permission.WRITE_EXTERNAL_STORAGE");
1056
+ list.remove("android.permission.READ_EXTERNAL_STORAGE");
1057
+ }
1054
1058
  permissions = list.toArray(new String[0]);
1055
1059
  }
1056
1060
  for (int i = 0; i < permissions.length; i++) {
@@ -1128,19 +1132,26 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
1128
1132
  selectFile;
1129
1133
  PluginResult pluginResult;
1130
1134
  callback = callbackContext;
1131
- if (Build.MANUFACTURER.equals("samsung")) {
1132
- /* SELECT FILE FOR SAMSUNG DEVICES */
1133
- openFile = new Intent("com.sec.android.app.myfiles.PICK_DATA");
1134
- openFile.putExtra("CONTENT_TYPE", "*/*");
1135
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
1136
+ // Use the ACTION_OPEN_DOCUMENT intent for Android 13 and higher
1137
+ openFile = new Intent(MediaStore.ACTION_PICK_IMAGES);
1138
+ openFile.setType("image/*");
1135
1139
  } else {
1136
- /* SELECT FILE FOR EXCEPT SAMSUNG DEVICES */
1137
- openFile = new Intent(Intent.ACTION_GET_CONTENT);
1138
- openFile.setType("*/*");
1139
- openFile.addCategory(Intent.CATEGORY_OPENABLE);
1140
- openFile.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
1140
+ if (Build.MANUFACTURER.equals("samsung")) {
1141
+ /* SELECT FILE FOR SAMSUNG DEVICES */
1142
+ openFile = new Intent("com.sec.android.app.myfiles.PICK_DATA");
1143
+ openFile.putExtra("CONTENT_TYPE", "*/*");
1144
+ } else {
1145
+ /* SELECT FILE FOR EXCEPT SAMSUNG DEVICES */
1146
+ openFile = new Intent(Intent.ACTION_GET_CONTENT);
1147
+ openFile.setType("*/*");
1148
+ openFile.addCategory(Intent.CATEGORY_OPENABLE);
1149
+ openFile.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
1150
+ }
1141
1151
  }
1152
+
1142
1153
  selectFile = Intent.createChooser(openFile, "Select File");
1143
- cordova.startActivityForResult(this, selectFile, PICK_IMAGE_FROM_GALLERY);
1154
+ cordova.startActivityForResult(this,selectFile, PICK_IMAGE_FROM_GALLERY);
1144
1155
  pluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
1145
1156
  pluginResult.setKeepCallback(true);
1146
1157
  callbackContext.sendPluginResult(pluginResult);
@@ -1714,7 +1725,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
1714
1725
  fileName = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DISPLAY_NAME));
1715
1726
  }
1716
1727
  cursor.close();
1717
- // API LEVEL 19 BELOW AND SAMSUNG (TO GET FILEPROPERTIES OF NORMAL FILES(EX:txt,.pdf,etc..,))
1728
+ // API LEVEL 19 BELOW AND SAMSUNG (TO GET FILE PROPERTIES OF NORMAL FILES(EX:txt,.pdf,etc..,))
1718
1729
  } else {
1719
1730
  getfilePath = data.getData().getPath();
1720
1731
  filePath = getfilePath.substring(0, getfilePath.lastIndexOf(File.separator));
@@ -1764,7 +1775,6 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
1764
1775
  Cursor cursor = null;
1765
1776
  if (uri.getScheme().equals("file")) {
1766
1777
  fileName = uri.getLastPathSegment();
1767
-
1768
1778
  if (fileName.indexOf(".") > 0) {
1769
1779
  fileName = fileName.substring(0, fileName.lastIndexOf("."));
1770
1780
  String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
@@ -2176,9 +2186,11 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
2176
2186
  private class DownloadTask extends AsyncTask<String, Integer, String> {
2177
2187
 
2178
2188
  private final Context context;
2189
+ private final CallbackContext downloadFileCallback;
2179
2190
 
2180
- public DownloadTask(Context context) {
2191
+ public DownloadTask(Context context, CallbackContext callback) {
2181
2192
  this.context = context;
2193
+ this.downloadFileCallback = callback;
2182
2194
  }
2183
2195
 
2184
2196
  @Override
@@ -2223,7 +2235,7 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
2223
2235
  output.write(data, 0, count);
2224
2236
  }
2225
2237
  } catch (Exception e) {
2226
- callback.error("Failure..." + e.getMessage());
2238
+ downloadFileCallback.error("Failure..." + e.getMessage());
2227
2239
  }
2228
2240
  if (sUrl[2].equalsIgnoreCase("true")) {
2229
2241
  return sUrl[1];
@@ -2240,13 +2252,13 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
2240
2252
  String extension = "." + result.substring(result.lastIndexOf(".") + 1).toLowerCase(),
2241
2253
  filePath = mInterfaceUtil.rootDirectory + "/" + result;
2242
2254
  String thumbnail = getFileThumbnail(filePath, extension);
2243
- callback.success(thumbnail);
2255
+ downloadFileCallback.success(thumbnail);
2244
2256
  } else {
2245
- callback.error("Failure...");
2257
+ downloadFileCallback.error("Failure...");
2246
2258
  }
2247
2259
  } else {
2248
2260
  System.out.println("success");
2249
- callback.success("");
2261
+ downloadFileCallback.success("");
2250
2262
  }
2251
2263
  } catch (Exception e) {
2252
2264
  e.printStackTrace();