mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 17:59:39 +02:00
Remove prepareMsg (and OUT_PREPARING message state) (#3468)
This PR removes prepareMsg, which put messages into the OUT_PREPARING state and was used while videos were recoded. It also removes the now-unused method isIncreation(). - It was buggy because when you forwarded a message while it was InPreparation, or when the app was killed while a message is InPreparation, the message would stay InPreparation forever. - Android is the only UI using this InPreparation (according to @r10s, I didn't check this myself), so we can simplify some things in core, which will also make it easier to deduplicate blob files.
This commit is contained in:
parent
a3a6919b08
commit
963327dd64
5 changed files with 14 additions and 18 deletions
|
@ -702,12 +702,6 @@ JNIEXPORT jboolean Java_com_b44t_messenger_DcContext_resendMsgs(JNIEnv *env, job
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT jint Java_com_b44t_messenger_DcContext_prepareMsg(JNIEnv *env, jobject obj, jint chat_id, jobject msg)
|
|
||||||
{
|
|
||||||
return dc_prepare_msg(get_dc_context(env, obj), chat_id, get_dc_msg(env, msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT jint Java_com_b44t_messenger_DcContext_sendMsg(JNIEnv *env, jobject obj, jint chat_id, jobject msg)
|
JNIEXPORT jint Java_com_b44t_messenger_DcContext_sendMsg(JNIEnv *env, jobject obj, jint chat_id, jobject msg)
|
||||||
{
|
{
|
||||||
return dc_send_msg(get_dc_context(env, obj), chat_id, get_dc_msg(env, msg));
|
return dc_send_msg(get_dc_context(env, obj), chat_id, get_dc_msg(env, msg));
|
||||||
|
@ -1578,12 +1572,6 @@ JNIEXPORT jboolean Java_com_b44t_messenger_DcMsg_isForwarded(JNIEnv *env, jobjec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT jboolean Java_com_b44t_messenger_DcMsg_isIncreation(JNIEnv *env, jobject obj)
|
|
||||||
{
|
|
||||||
return dc_msg_is_increation(get_dc_msg(env, obj))!=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT jboolean Java_com_b44t_messenger_DcMsg_isInfo(JNIEnv *env, jobject obj)
|
JNIEXPORT jboolean Java_com_b44t_messenger_DcMsg_isInfo(JNIEnv *env, jobject obj)
|
||||||
{
|
{
|
||||||
return dc_msg_is_info(get_dc_msg(env, obj))!=0;
|
return dc_msg_is_info(get_dc_msg(env, obj))!=0;
|
||||||
|
|
|
@ -194,7 +194,6 @@ public class DcContext {
|
||||||
public native void deleteMsgs (int msg_ids[]);
|
public native void deleteMsgs (int msg_ids[]);
|
||||||
public native void forwardMsgs (int msg_ids[], int chat_id);
|
public native void forwardMsgs (int msg_ids[], int chat_id);
|
||||||
public native boolean resendMsgs (int msg_ids[]);
|
public native boolean resendMsgs (int msg_ids[]);
|
||||||
public native int prepareMsg (int chat_id, DcMsg msg);
|
|
||||||
public native int sendMsg (int chat_id, DcMsg msg);
|
public native int sendMsg (int chat_id, DcMsg msg);
|
||||||
public native int sendTextMsg (int chat_id, String text);
|
public native int sendTextMsg (int chat_id, String text);
|
||||||
public native int sendVideochatInvitation(int chat_id);
|
public native int sendVideochatInvitation(int chat_id);
|
||||||
|
|
|
@ -155,7 +155,6 @@ public class DcMsg {
|
||||||
public native String getSetupCodeBegin ();
|
public native String getSetupCodeBegin ();
|
||||||
public native String getVideochatUrl ();
|
public native String getVideochatUrl ();
|
||||||
public native int getVideochatType ();
|
public native int getVideochatType ();
|
||||||
public native boolean isIncreation ();
|
|
||||||
public native void setText (String text);
|
public native void setText (String text);
|
||||||
public native void setFile (String file, String filemime);
|
public native void setFile (String file, String filemime);
|
||||||
public native void setDimension (int width, int height);
|
public native void setDimension (int width, int height);
|
||||||
|
|
|
@ -117,6 +117,7 @@ import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener;
|
import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener;
|
||||||
import org.thoughtcrime.securesms.util.guava.Optional;
|
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.util.views.Stub;
|
||||||
import org.thoughtcrime.securesms.video.recode.VideoRecoder;
|
import org.thoughtcrime.securesms.video.recode.VideoRecoder;
|
||||||
import org.thoughtcrime.securesms.videochat.VideochatUtil;
|
import org.thoughtcrime.securesms.videochat.VideochatUtil;
|
||||||
|
@ -171,6 +172,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
private View composePanel;
|
private View composePanel;
|
||||||
private ScaleStableImageView backgroundView;
|
private ScaleStableImageView backgroundView;
|
||||||
private MessageRequestsBottomView messageRequestBottomView;
|
private MessageRequestsBottomView messageRequestBottomView;
|
||||||
|
private ProgressDialog progressDialog;
|
||||||
|
|
||||||
private AttachmentTypeSelector attachmentTypeSelector;
|
private AttachmentTypeSelector attachmentTypeSelector;
|
||||||
private AttachmentManager attachmentManager;
|
private AttachmentManager attachmentManager;
|
||||||
|
@ -1072,7 +1074,17 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
{
|
{
|
||||||
boolean doSend = true;
|
boolean doSend = true;
|
||||||
if (recompress==DcMsg.DC_MSG_VIDEO) {
|
if (recompress==DcMsg.DC_MSG_VIDEO) {
|
||||||
|
Util.runOnMain(() -> {
|
||||||
|
progressDialog = ProgressDialog.show(
|
||||||
|
ConversationActivity.this,
|
||||||
|
"",
|
||||||
|
getString(R.string.one_moment),
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
doSend = VideoRecoder.prepareVideo(ConversationActivity.this, dcChat.getId(), msg);
|
doSend = VideoRecoder.prepareVideo(ConversationActivity.this, dcChat.getId(), msg);
|
||||||
|
Util.runOnMain(() -> progressDialog.dismiss());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doSend) {
|
if (doSend) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import com.googlecode.mp4parser.util.Path;
|
||||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||||
import org.thoughtcrime.securesms.util.Prefs;
|
import org.thoughtcrime.securesms.util.Prefs;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
import org.thoughtcrime.securesms.util.views.ProgressDialog;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -551,11 +552,9 @@ public class VideoRecoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepareVideo() assumes the msg object is set up properly to being sent;
|
// prepareVideo() assumes the msg object is set up properly to being sent;
|
||||||
// the function fills out missing information and also recodes the video as needed;
|
// the function fills out missing information and also recodes the video as needed.
|
||||||
// to get a responsive ui, DcChat.prepareMsg() may be called.
|
|
||||||
// return: true=video might be prepared, can be sent, false=error
|
// return: true=video might be prepared, can be sent, false=error
|
||||||
public static boolean prepareVideo(Context context, int chatId, DcMsg msg) {
|
public static boolean prepareVideo(Context context, int chatId, DcMsg msg) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String inPath = msg.getFile();
|
String inPath = msg.getFile();
|
||||||
Log.i(TAG, "Preparing video: " + inPath);
|
Log.i(TAG, "Preparing video: " + inPath);
|
||||||
|
@ -623,7 +622,6 @@ public class VideoRecoder {
|
||||||
msg.setDimension(vei.resultWidth, vei.resultHeight);
|
msg.setDimension(vei.resultWidth, vei.resultHeight);
|
||||||
}
|
}
|
||||||
msg.setDuration((int) resultDurationMs);
|
msg.setDuration((int) resultDurationMs);
|
||||||
DcHelper.getContext(context).prepareMsg(chatId, msg);
|
|
||||||
|
|
||||||
// calculate bytes
|
// calculate bytes
|
||||||
vei.estimatedBytes = VideoRecoder.calculateEstimatedSize((float) resultDurationMs / vei.originalDurationMs,
|
vei.estimatedBytes = VideoRecoder.calculateEstimatedSize((float) resultDurationMs / vei.originalDurationMs,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue