You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by no...@apache.org on 2024/12/28 19:22:34 UTC

(cordova-plugin-media-capture) branch master updated: fix(android): Remove usage of Media Store queries (#307)

This is an automated email from the ASF dual-hosted git repository.

normanbreau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-media-capture.git


The following commit(s) were added to refs/heads/master by this push:
     new 38a8cca  fix(android): Remove usage of Media Store queries (#307)
38a8cca is described below

commit 38a8cca493d67217b7314cdfcabc8bb18bf51b8f
Author: Norman Breau <no...@breautek.com>
AuthorDate: Sat Dec 28 15:22:29 2024 -0400

    fix(android): Remove usage of Media Store queries (#307)
---
 src/android/Capture.java | 38 --------------------------------------
 1 file changed, 38 deletions(-)

diff --git a/src/android/Capture.java b/src/android/Capture.java
index f589615..fd2b56c 100644
--- a/src/android/Capture.java
+++ b/src/android/Capture.java
@@ -94,7 +94,6 @@ public class Capture extends CordovaPlugin {
 
     private final PendingRequests pendingRequests = new PendingRequests();
 
-    private int numPics;                            // Number of pictures before capture activity
     private String audioAbsolutePath;
     private String imageAbsolutePath;
     private String videoAbsolutePath;
@@ -295,9 +294,6 @@ public class Capture extends CordovaPlugin {
     private void captureImage(Request req) {
         if (isMissingCameraPermissions(req)) return;
 
-        // Save the number of images currently on disk for later
-        this.numPics = queryImgDB(whichContentStore()).getCount();
-
         Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
 
         String timeStamp = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
@@ -428,8 +424,6 @@ public class Capture extends CordovaPlugin {
 
         req.results.put(mediaFile);
 
-        checkForDuplicateImage();
-
         if (req.results.length() >= req.limit) {
             // Send Uri back to JavaScript for viewing image
             pendingRequests.resolveWithSuccess(req);
@@ -529,38 +523,6 @@ public class Capture extends CordovaPlugin {
         return obj;
     }
 
-    /**
-     * Creates a cursor that can be used to determine how many images we have.
-     *
-     * @return a cursor
-     */
-    private Cursor queryImgDB(Uri contentStore) {
-        return this.cordova.getActivity().getContentResolver().query(
-            contentStore,
-            new String[] { MediaStore.Images.Media._ID },
-            null,
-            null,
-            null);
-    }
-
-    /**
-     * Used to find out if we are in a situation where the Camera Intent adds to images
-     * to the content store.
-     */
-    private void checkForDuplicateImage() {
-        Uri contentStore = whichContentStore();
-        Cursor cursor = queryImgDB(contentStore);
-        int currentNumOfImages = cursor.getCount();
-
-        // delete the duplicate file if the difference is 2
-        if ((currentNumOfImages - numPics) == 2) {
-            cursor.moveToLast();
-            int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID))) - 1;
-            Uri uri = Uri.parse(contentStore + "/" + id);
-            this.cordova.getActivity().getContentResolver().delete(uri, null, null);
-        }
-    }
-
     /**
      * Determine if we are storing the images in internal or external storage
      * @return Uri


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org