Skip to content

Commit ad16ccf

Browse files
authored
Update AndroidImplementation.java (#3827)
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/
1 parent 2976ce4 commit ad16ccf

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Ports/Android/src/com/codename1/impl/android/AndroidImplementation.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -6702,11 +6702,15 @@ private String fixAttachmentPath(String attachment) {
67026702

67036703
File newFile = new File(mediaStorageDir.getPath() + File.separator
67046704
+ cn1File.getName());
6705-
if(newFile.exists()) {
6706-
// Create a media file name
6707-
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
6708-
newFile = new File(mediaStorageDir.getPath() + File.separator
6709-
+ "IMG_" + timeStamp + "_" + cn1File.getName());
6705+
if (newFile.exists()) {
6706+
if (Display.getInstance().getProperty("DeleteCachedFileAfterShare", "false").equals("true")) {
6707+
newFile.delete();
6708+
} else {
6709+
// Create a media file name
6710+
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
6711+
newFile = new File(mediaStorageDir.getPath() + File.separator
6712+
+ "IMG_" + timeStamp + "_" + cn1File.getName());
6713+
}
67106714
}
67116715

67126716

0 commit comments

Comments
 (0)