diff --git a/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModuleImpl.kt b/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModuleImpl.kt index 53a92f3..8d0cb56 100644 --- a/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModuleImpl.kt +++ b/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModuleImpl.kt @@ -423,6 +423,11 @@ class ImageEditorModuleImpl(private val reactContext: ReactApplicationContext) { ) private const val TEMP_FILE_PREFIX = "ReactNative_cropped_image_" + /** + * Copied onto the cropped JPEG. Geolocation tags are deliberately absent: a crop is a new + * picture the user may share on its own, and it should not carry where the original + * happened to be taken. + */ @SuppressLint("InlinedApi") private val EXIF_ATTRIBUTES = arrayOf( @@ -461,38 +466,6 @@ class ImageEditorModuleImpl(private val reactContext: ReactApplicationContext) { ExifInterface.TAG_F_NUMBER, ExifInterface.TAG_GAIN_CONTROL, ExifInterface.TAG_GAMMA, - ExifInterface.TAG_GPS_ALTITUDE, - ExifInterface.TAG_GPS_ALTITUDE_REF, - ExifInterface.TAG_GPS_AREA_INFORMATION, - ExifInterface.TAG_GPS_DATESTAMP, - ExifInterface.TAG_GPS_DOP, - ExifInterface.TAG_GPS_LATITUDE, - ExifInterface.TAG_GPS_LATITUDE_REF, - ExifInterface.TAG_GPS_LONGITUDE, - ExifInterface.TAG_GPS_LONGITUDE_REF, - ExifInterface.TAG_GPS_STATUS, - ExifInterface.TAG_GPS_DEST_BEARING, - ExifInterface.TAG_GPS_DEST_BEARING_REF, - ExifInterface.TAG_GPS_DEST_DISTANCE, - ExifInterface.TAG_GPS_DEST_DISTANCE_REF, - ExifInterface.TAG_GPS_DEST_LATITUDE, - ExifInterface.TAG_GPS_DEST_LATITUDE_REF, - ExifInterface.TAG_GPS_DEST_LONGITUDE, - ExifInterface.TAG_GPS_DEST_LONGITUDE_REF, - ExifInterface.TAG_GPS_DIFFERENTIAL, - ExifInterface.TAG_GPS_IMG_DIRECTION, - ExifInterface.TAG_GPS_IMG_DIRECTION_REF, - ExifInterface.TAG_GPS_MAP_DATUM, - ExifInterface.TAG_GPS_MEASURE_MODE, - ExifInterface.TAG_GPS_PROCESSING_METHOD, - ExifInterface.TAG_GPS_SATELLITES, - ExifInterface.TAG_GPS_SPEED, - ExifInterface.TAG_GPS_SPEED_REF, - ExifInterface.TAG_GPS_STATUS, - ExifInterface.TAG_GPS_TIMESTAMP, - ExifInterface.TAG_GPS_TRACK, - ExifInterface.TAG_GPS_TRACK_REF, - ExifInterface.TAG_GPS_VERSION_ID, ExifInterface.TAG_IMAGE_DESCRIPTION, ExifInterface.TAG_IMAGE_UNIQUE_ID, ExifInterface.TAG_ISO_SPEED, @@ -664,27 +637,18 @@ class ImageEditorModuleImpl(private val reactContext: ReactApplicationContext) { } /** - * Create a temporary file in the cache directory on either internal or external storage, - * whichever is available and has more free space. + * Create a temporary file in the app's internal cache directory. External storage is only a + * fallback for the rare case where there is no internal cache dir: a crop inherits the + * original's Exif data, and external storage is readable by other apps on API <= 29. * * @param mimeType the MIME type of the file to create (image/ *) */ @Throws(IOException::class) private fun createTempFile(context: Context, mimeType: String?): File { - val externalCacheDir = context.externalCacheDir - val internalCacheDir = context.cacheDir - if (externalCacheDir == null && internalCacheDir == null) { + val cacheDir = context.cacheDir ?: context.externalCacheDir + if (cacheDir == null) { throw IOException("No cache directory available") } - val cacheDir: File? = - if (externalCacheDir == null) { - internalCacheDir - } else if (internalCacheDir == null) { - externalCacheDir - } else { - if (externalCacheDir.freeSpace > internalCacheDir.freeSpace) externalCacheDir - else internalCacheDir - } return File.createTempFile( TEMP_FILE_PREFIX, getFileExtensionForType(mimeType),