From d3da4097746ea14811297cc20bd3beee9cbc986f Mon Sep 17 00:00:00 2001 From: rymdhund Date: Thu, 31 Jul 2014 18:50:22 +0200 Subject: [PATCH] Add time to saved media filenames see #1689 // FREEBIE --- .../thoughtcrime/securesms/ConversationFragment.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java index bd79136f44..7d86a1061f 100644 --- a/src/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationFragment.java @@ -486,12 +486,18 @@ public class ConversationFragment extends SherlockListFragment MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton(); String extension = mimeTypeMap.getExtensionFromMimeType(slide.getContentType()); - SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd-HHmmss"); + String base = "textsecure-" + dateFormatter.format(timestamp); if (extension == null) extension = "attach"; - return File.createTempFile("textsecure-" + dateFormatter.format(timestamp), "." + extension, outputDirectory); + int i = 0; + File file = new File(outputDirectory, base+"."+extension); + while (file.exists()) + file = new File(outputDirectory, base+"-"+(++i)+"."+extension); + + return file; } } }