Skip to content

Commit

Permalink
Merge pull request signalapp#376 from meskio/extension_saving_attachment
Browse files Browse the repository at this point in the history
Set the right extension on saving an attachment
  • Loading branch information
moxie0 committed Oct 15, 2013
2 parents f49c627 + 73b1e3f commit f3fdde6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/org/thoughtcrime/securesms/ConversationItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
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;
Expand Down Expand Up @@ -387,9 +388,14 @@ else if (slide.hasAudio())
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() {
Expand Down

0 comments on commit f3fdde6

Please sign in to comment.