mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-06 03:49:58 +02:00
fix: Use getFilename() instead of the actual filename on disk (#3521)
* fix: Use msg.getFilename() instead of the file's name in some cases * fix: Use msg.getFilename() instead of the file's name in initializeDraft() * fix: Use msg.getFilename() instead of the file's name in MediaItem * fix: Use the correct file name in MediaView * refactor: `msg` param of `getManuallyCalculatedSlideInfo()` was always null * Improve comment * Revert "refactor: `msg` param of `getManuallyCalculatedSlideInfo()` was always null" We will unfortunately need getManuallyCalculatedSlideInfo() with `msg` param This reverts commit60e8248db3
. * fix: Fix drafting images This fixes a bug introduced in14f69f87e8
: When you drafted an image, pressed Back, and opened the chat again, then the height of the drafted image was wrong and tapping the image opened a preview for the wrong image. I do think that theoretically it would be nicer to use getSlideForMsg here, because we already have a DcMsg, but this didn't work because a) the width and height wasn't gotten from the msg and instead 0 was passed and b) the code tries to save a msgId instead of the message instead, and loading the message from the database fails later since it's just a draft. I didn't want to try and fix these things, because they might be bigger refactorings and I don't know the code. * fix: Use the original message's filemime if there is one ...instead of trying to guess the mimetype from the uri
This commit is contained in:
parent
923227a0e8
commit
8e55a3dbf3
10 changed files with 60 additions and 46 deletions
|
@ -120,7 +120,6 @@ import org.thoughtcrime.securesms.util.ViewUtil;
|
|||
import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener;
|
||||
import org.thoughtcrime.securesms.util.guava.Optional;
|
||||
import org.thoughtcrime.securesms.util.views.ProgressDialog;
|
||||
import org.thoughtcrime.securesms.util.views.Stub;
|
||||
import org.thoughtcrime.securesms.video.recode.VideoRecoder;
|
||||
import org.thoughtcrime.securesms.videochat.VideochatUtil;
|
||||
|
||||
|
@ -746,8 +745,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
handleReplyMessage(quote);
|
||||
}
|
||||
|
||||
String filename = draft.getFile();
|
||||
if (filename.isEmpty() || !new File(filename).exists()) {
|
||||
String file = draft.getFile();
|
||||
if (file.isEmpty() || !new File(file).exists()) {
|
||||
future.set(!text.isEmpty());
|
||||
updateToggleButtonState();
|
||||
return future;
|
||||
|
@ -767,26 +766,21 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
};
|
||||
|
||||
File file = new File(filename);
|
||||
Uri uri = Uri.fromFile(file);
|
||||
switch (draft.getType()) {
|
||||
case DcMsg.DC_MSG_IMAGE:
|
||||
setMedia(uri, MediaType.IMAGE).addListener(listener);
|
||||
setMedia(draft, MediaType.IMAGE).addListener(listener);
|
||||
break;
|
||||
case DcMsg.DC_MSG_GIF:
|
||||
setMedia(uri, MediaType.GIF).addListener(listener);
|
||||
setMedia(draft, MediaType.GIF).addListener(listener);
|
||||
break;
|
||||
case DcMsg.DC_MSG_AUDIO:
|
||||
setMedia(uri, MediaType.AUDIO).addListener(listener);
|
||||
setMedia(draft, MediaType.AUDIO).addListener(listener);
|
||||
break;
|
||||
case DcMsg.DC_MSG_VIDEO:
|
||||
setMedia(uri, MediaType.VIDEO).addListener(listener);
|
||||
break;
|
||||
case DcMsg.DC_MSG_WEBXDC:
|
||||
setMedia(draft, MediaType.DOCUMENT).addListener(listener);
|
||||
setMedia(draft, MediaType.VIDEO).addListener(listener);
|
||||
break;
|
||||
default:
|
||||
setMedia(uri, MediaType.DOCUMENT).addListener(listener);
|
||||
setMedia(draft, MediaType.DOCUMENT).addListener(listener);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue