cordova-plugin-mserviceinterface-2.0 1.0.78 → 1.0.79
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/mInterface.java +64 -0
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.79">
|
|
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>
|
|
@@ -355,6 +355,12 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
355
355
|
} else if (action.equals("CheckLocationPermission")) {
|
|
356
356
|
checkLocationPermission(args, callbackContext);
|
|
357
357
|
return true;
|
|
358
|
+
} else if (action.equals("GetMediaImagePermission")) {
|
|
359
|
+
getMediaImagePermission(args, callbackContext);
|
|
360
|
+
return true;
|
|
361
|
+
} else if (action.equals("CheckMediaImagePermission")) {
|
|
362
|
+
checkMediaImagePermission(args, callbackContext);
|
|
363
|
+
return true;
|
|
358
364
|
} else if (action.equals("AppVersion")) {
|
|
359
365
|
appVersion(callbackContext);
|
|
360
366
|
return true;
|
|
@@ -1238,6 +1244,41 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1238
1244
|
}
|
|
1239
1245
|
}
|
|
1240
1246
|
|
|
1247
|
+
private void checkMediaImagePermission(JSONArray args, CallbackContext callbackContext) {
|
|
1248
|
+
boolean permissionGranted = true, checkPermission = true;
|
|
1249
|
+
List<String> list;
|
|
1250
|
+
try {
|
|
1251
|
+
callback = callbackContext;
|
|
1252
|
+
Context context = cordova.getActivity().getApplicationContext();
|
|
1253
|
+
String[] permissions = args.optJSONObject(0).optString("permissions").split(",");
|
|
1254
|
+
if (permissions[0].equalsIgnoreCase("android.permission.READ_MEDIA_IMAGES")) {
|
|
1255
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
|
1256
|
+
checkPermission = false;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
if (checkPermission) {
|
|
1260
|
+
list = new ArrayList<String>(Arrays.asList(permissions));
|
|
1261
|
+
permissions = list.toArray(new String[0]);
|
|
1262
|
+
|
|
1263
|
+
for (int i = 0; i < permissions.length; i++) {
|
|
1264
|
+
if (ActivityCompat.checkSelfPermission(context, permissions[i]) != PackageManager.PERMISSION_GRANTED) {
|
|
1265
|
+
permissionGranted = false;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
if (!permissionGranted) {
|
|
1269
|
+
callback.error("failure");
|
|
1270
|
+
} else {
|
|
1271
|
+
callback.success("success");
|
|
1272
|
+
}
|
|
1273
|
+
} else {
|
|
1274
|
+
callback.success("success");
|
|
1275
|
+
}
|
|
1276
|
+
} catch (Exception e) {
|
|
1277
|
+
e.printStackTrace();
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
|
|
1241
1282
|
private void getLocationPermission(JSONArray args, CallbackContext callbackContext) {
|
|
1242
1283
|
boolean permissionGranted = true;
|
|
1243
1284
|
List<String> list;
|
|
@@ -1262,7 +1303,30 @@ public class mInterface extends CordovaPlugin implements com.google.android.gms.
|
|
|
1262
1303
|
e.printStackTrace();
|
|
1263
1304
|
}
|
|
1264
1305
|
}
|
|
1306
|
+
private void getMediaImagePermission(JSONArray args, CallbackContext callbackContext) {
|
|
1307
|
+
boolean permissionGranted = true;
|
|
1308
|
+
List<String> list;
|
|
1309
|
+
try {
|
|
1310
|
+
callback = callbackContext;
|
|
1311
|
+
Context context = cordova.getActivity().getApplicationContext();
|
|
1312
|
+
String[] permissions = args.optJSONObject(0).optString("permissions").split(",");
|
|
1313
|
+
list = new ArrayList<String>(Arrays.asList(permissions));
|
|
1314
|
+
permissions = list.toArray(new String[0]);
|
|
1265
1315
|
|
|
1316
|
+
for (int i = 0; i < permissions.length; i++) {
|
|
1317
|
+
if (ActivityCompat.checkSelfPermission(context, permissions[i]) != PackageManager.PERMISSION_GRANTED) {
|
|
1318
|
+
permissionGranted = false;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
if (!permissionGranted) {
|
|
1322
|
+
PermissionHelper.requestPermissions(this, 111, permissions);
|
|
1323
|
+
} else {
|
|
1324
|
+
callback.success("success");
|
|
1325
|
+
}
|
|
1326
|
+
} catch (Exception e) {
|
|
1327
|
+
e.printStackTrace();
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1266
1330
|
private void getPermissions(JSONArray args, CallbackContext callbackContext) {
|
|
1267
1331
|
boolean permissionGranted = true;
|
|
1268
1332
|
List<String> list;
|