@@ -127,7 +127,6 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
127
127
private boolean allowEdit ; // Should we allow the user to crop the image.
128
128
129
129
public CallbackContext callbackContext ;
130
- private int numPics ;
131
130
132
131
private MediaScannerConnection conn ; // Used to update gallery app with newly-written files
133
132
private Uri scanMe ; // Uri of image to be added to content store
@@ -307,9 +306,6 @@ public void callTakePicture(int returnType, int encodingType) {
307
306
308
307
public void takePicture (int returnType , int encodingType )
309
308
{
310
- // Save the number of images currently on disk for later
311
- this .numPics = queryImgDB (whichContentStore ()).getCount ();
312
-
313
309
// Let's use the intent and see what happens
314
310
Intent intent = new Intent (MediaStore .ACTION_IMAGE_CAPTURE );
315
311
@@ -336,8 +332,6 @@ public void takePicture(int returnType, int encodingType)
336
332
LOG .d (LOG_TAG , "Error: You don't have a default camera. Your device may not be CTS complaint." );
337
333
}
338
334
}
339
- // else
340
- // LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity");
341
335
}
342
336
343
337
/**
@@ -559,12 +553,7 @@ private void processResultFromCamera(int destType, Intent intent) throws IOExcep
559
553
return ;
560
554
}
561
555
562
-
563
556
this .processPicture (bitmap , this .encodingType );
564
-
565
- if (!this .saveToPhotoAlbum ) {
566
- checkForDuplicateImage (DATA_URL );
567
- }
568
557
}
569
558
570
559
// If sending filename back
@@ -626,7 +615,7 @@ else if (destType == FILE_URI) {
626
615
throw new IllegalStateException ();
627
616
}
628
617
629
- this .cleanup (FILE_URI , this .imageUri , galleryUri , bitmap );
618
+ this .cleanup (this .imageUri , galleryUri , bitmap );
630
619
bitmap = null ;
631
620
input .close ();
632
621
}
@@ -1207,34 +1196,19 @@ public static int calculateSampleSize(int srcWidth, int srcHeight, int dstWidth,
1207
1196
}
1208
1197
}
1209
1198
1210
- /**
1211
- * Creates a cursor that can be used to determine how many images we have.
1212
- *
1213
- * @return a cursor
1214
- */
1215
- private Cursor queryImgDB (Uri contentStore ) {
1216
- return this .cordova .getActivity ().getContentResolver ().query (
1217
- contentStore ,
1218
- new String []{MediaStore .Images .Media ._ID },
1219
- null ,
1220
- null ,
1221
- null );
1222
- }
1223
-
1224
1199
/**
1225
1200
* Cleans up after picture taking. Checking for duplicates and that kind of stuff.
1226
1201
*
1227
1202
* @param newImage
1228
1203
*/
1229
- private void cleanup (int imageType , Uri oldImage , Uri newImage , Bitmap bitmap ) {
1204
+ private void cleanup (Uri oldImage , Uri newImage , Bitmap bitmap ) {
1230
1205
if (bitmap != null ) {
1231
1206
bitmap .recycle ();
1232
1207
}
1233
1208
1234
1209
// Clean up initial camera-written image file.
1235
1210
(new File (FileHelper .stripFileProtocol (oldImage .toString ()))).delete ();
1236
1211
1237
- checkForDuplicateImage (imageType );
1238
1212
// Scan for the gallery to update pic refs in gallery
1239
1213
if (this .saveToPhotoAlbum && newImage != null ) {
1240
1214
this .scanForGallery (newImage );
@@ -1243,37 +1217,6 @@ private void cleanup(int imageType, Uri oldImage, Uri newImage, Bitmap bitmap) {
1243
1217
System .gc ();
1244
1218
}
1245
1219
1246
- /**
1247
- * Used to find out if we are in a situation where the Camera Intent adds to images
1248
- * to the content store. If we are using a FILE_URI and the number of images in the DB
1249
- * increases by 2 we have a duplicate, when using a DATA_URL the number is 1.
1250
- *
1251
- * @param type FILE_URI or DATA_URL
1252
- */
1253
- private void checkForDuplicateImage (int type ) {
1254
- int diff = 1 ;
1255
- Uri contentStore = whichContentStore ();
1256
- Cursor cursor = queryImgDB (contentStore );
1257
- int currentNumOfImages = cursor .getCount ();
1258
-
1259
- if (type == FILE_URI && this .saveToPhotoAlbum ) {
1260
- diff = 2 ;
1261
- }
1262
-
1263
- // delete the duplicate file if the difference is 2 for file URI or 1 for Data URL
1264
- if ((currentNumOfImages - numPics ) == diff ) {
1265
- cursor .moveToLast ();
1266
- @ SuppressLint ("Range" )
1267
- int id = Integer .valueOf (cursor .getString (cursor .getColumnIndex (MediaStore .Images .Media ._ID )));
1268
- if (diff == 2 ) {
1269
- id --;
1270
- }
1271
- Uri uri = Uri .parse (contentStore + "/" + id );
1272
- this .cordova .getActivity ().getContentResolver ().delete (uri , null , null );
1273
- cursor .close ();
1274
- }
1275
- }
1276
-
1277
1220
/**
1278
1221
* Determine if we are storing the images in internal or external storage
1279
1222
*
@@ -1377,7 +1320,6 @@ public Bundle onSaveInstanceState() {
1377
1320
state .putInt ("targetHeight" , this .targetHeight );
1378
1321
state .putInt ("encodingType" , this .encodingType );
1379
1322
state .putInt ("mediaType" , this .mediaType );
1380
- state .putInt ("numPics" , this .numPics );
1381
1323
state .putBoolean ("allowEdit" , this .allowEdit );
1382
1324
state .putBoolean ("correctOrientation" , this .correctOrientation );
1383
1325
state .putBoolean ("saveToPhotoAlbum" , this .saveToPhotoAlbum );
@@ -1401,7 +1343,6 @@ public void onRestoreStateForActivityResult(Bundle state, CallbackContext callba
1401
1343
this .targetHeight = state .getInt ("targetHeight" );
1402
1344
this .encodingType = state .getInt ("encodingType" );
1403
1345
this .mediaType = state .getInt ("mediaType" );
1404
- this .numPics = state .getInt ("numPics" );
1405
1346
this .allowEdit = state .getBoolean ("allowEdit" );
1406
1347
this .correctOrientation = state .getBoolean ("correctOrientation" );
1407
1348
this .saveToPhotoAlbum = state .getBoolean ("saveToPhotoAlbum" );
0 commit comments