From 73b1e3f3d4db4ed390d4a0fee85c936603ea17cd Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Sun, 13 Oct 2013 14:45:04 +0200 Subject: [PATCH] Set the right extension on saving an attachment --- src/org/thoughtcrime/securesms/ConversationItem.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index 7243f4e0f5..536c4ffc3b 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -39,6 +39,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; +import android.webkit.MimeTypeMap; import org.thoughtcrime.securesms.contacts.ContactIdentityManager; import org.thoughtcrime.securesms.contacts.ContactPhotoFactory; @@ -387,9 +388,14 @@ public class ConversationItem extends LinearLayout { outputDirectory = new File(sdCard.getAbsolutePath() + File.separator + "Music"); else outputDirectory = new File(sdCard.getAbsolutePath() + File.separator + "Pictures"); - outputDirectory.mkdirs(); - return File.createTempFile("textsecure", ".attach", outputDirectory); + + MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton(); + String extension = mimeTypeMap.getExtensionFromMimeType(slide.getContentType()); + if (extension == null) + extension = "attach"; + + return File.createTempFile("textsecure", "." + extension, outputDirectory); } private void saveToSdCard() {