Skip to content

Commit

Permalink
Update AndroidImplementation.java (#3827)
Browse files Browse the repository at this point in the history
Delete cached file after sharing it to prevent appending IMG_DATE_TIME to the file name when re-sharing it.

https://www.reddit.com/r/cn1/comments/1ed9ngf/share_api_appending_img_date_time_to_file_name/
  • Loading branch information
Eric-Chomba authored Aug 8, 2024
1 parent 2976ce4 commit ad16ccf
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6702,11 +6702,15 @@ private String fixAttachmentPath(String attachment) {

File newFile = new File(mediaStorageDir.getPath() + File.separator
+ cn1File.getName());
if(newFile.exists()) {
// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
newFile = new File(mediaStorageDir.getPath() + File.separator
+ "IMG_" + timeStamp + "_" + cn1File.getName());
if (newFile.exists()) {
if (Display.getInstance().getProperty("DeleteCachedFileAfterShare", "false").equals("true")) {
newFile.delete();
} else {
// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
newFile = new File(mediaStorageDir.getPath() + File.separator
+ "IMG_" + timeStamp + "_" + cn1File.getName());
}
}


Expand Down

0 comments on commit ad16ccf

Please sign in to comment.