Add date to saved media filenames

Fixes #1689
Closes #1693
This commit is contained in:
rymdhund 2014-07-11 12:58:21 +02:00 committed by Moxie Marlinspike
parent 23a1c1c8fa
commit d1dd50e31c

View File

@ -411,7 +411,7 @@ public class ConversationFragment extends SherlockListFragment
return FAILURE;
}
File mediaFile = constructOutputFile(slide);
File mediaFile = constructOutputFile(slide, messageRecord[0].getDateReceived());
InputStream inputStream = slide.getPartDataInputStream();
OutputStream outputStream = new FileOutputStream(mediaFile);
@ -470,7 +470,7 @@ public class ConversationFragment extends SherlockListFragment
return null;
}
private File constructOutputFile(Slide slide) throws IOException {
private File constructOutputFile(Slide slide, long timestamp) throws IOException {
File sdCard = Environment.getExternalStorageDirectory();
File outputDirectory;
@ -486,11 +486,12 @@ public class ConversationFragment extends SherlockListFragment
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
String extension = mimeTypeMap.getExtensionFromMimeType(slide.getContentType());
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
if (extension == null)
extension = "attach";
return File.createTempFile("textsecure", "." + extension, outputDirectory);
return File.createTempFile("textsecure-" + dateFormatter.format(timestamp), "." + extension, outputDirectory);
}
}
}