mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
recode videos when multiple are shared/attached, show progress dialog
Agent-Logs-Url: https://github.com/ArcaneChat/android/sessions/46f23f6d-d5a5-48b9-8b1d-4aa5cfdda115 Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
60ab7f2826
commit
e6fd96bf35
@@ -122,9 +122,6 @@ public abstract class BaseConversationListFragment extends Fragment implements A
|
||||
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
if (SendRelayedMessageUtil.containsVideoType(context, uris)) {
|
||||
message += "\n\n" + getString(R.string.videos_sent_without_recoding);
|
||||
}
|
||||
new AlertDialog.Builder(context)
|
||||
.setMessage(message)
|
||||
.setCancelable(false)
|
||||
|
||||
@@ -860,9 +860,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
private void askSendingFiles(ArrayList<Uri> uriList, Runnable onConfirm) {
|
||||
String message =
|
||||
String.format(getString(R.string.ask_send_files_to_chat), uriList.size(), dcChat.getName());
|
||||
if (SendRelayedMessageUtil.containsVideoType(context, uriList)) {
|
||||
message += "\n\n" + getString(R.string.videos_sent_without_recoding);
|
||||
}
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(message)
|
||||
.setCancelable(false)
|
||||
|
||||
@@ -9,6 +9,7 @@ import static org.thoughtcrime.securesms.util.ShareUtil.isSharing;
|
||||
import static org.thoughtcrime.securesms.util.ShareUtil.resetRelayingMessageContent;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
@@ -27,9 +28,11 @@ import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.thoughtcrime.securesms.ConversationListRelayingActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
|
||||
import org.thoughtcrime.securesms.video.recode.VideoRecoder;
|
||||
|
||||
public class SendRelayedMessageUtil {
|
||||
private static final String TAG = SendRelayedMessageUtil.class.getSimpleName();
|
||||
@@ -118,17 +121,58 @@ public class SendRelayedMessageUtil {
|
||||
ArrayList<Uri> uris = sharedUris;
|
||||
String text = sharedText;
|
||||
|
||||
boolean hasVideos = containsVideoType(context, uris);
|
||||
final ProgressDialog[] progressDialog = {null};
|
||||
if (hasVideos && context instanceof Activity) {
|
||||
Activity activity = (Activity) context;
|
||||
Util.runOnMain(
|
||||
() -> {
|
||||
if (!activity.isFinishing()) {
|
||||
progressDialog[0] =
|
||||
ProgressDialog.show(
|
||||
activity, "", context.getString(R.string.one_moment), true, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (uris.size() == 1) {
|
||||
dcContext.sendMsg(
|
||||
chatId, createMessage(context, uris.get(0), msgType, sharedHtml, subject, text));
|
||||
DcMsg msg = createMessage(context, uris.get(0), msgType, sharedHtml, subject, text);
|
||||
if (msg.getType() == DcMsg.DC_MSG_VIDEO) {
|
||||
if (!VideoRecoder.prepareVideo(context, chatId, msg)) {
|
||||
dismissProgressDialog(progressDialog);
|
||||
return;
|
||||
}
|
||||
}
|
||||
dcContext.sendMsg(chatId, msg);
|
||||
} else {
|
||||
if (text != null || sharedHtml != null) {
|
||||
dcContext.sendMsg(chatId, createMessage(context, null, null, sharedHtml, subject, text));
|
||||
}
|
||||
for (Uri uri : uris) {
|
||||
dcContext.sendMsg(chatId, createMessage(context, uri, null, null, subject, null));
|
||||
DcMsg msg = createMessage(context, uri, null, null, subject, null);
|
||||
if (msg.getType() == DcMsg.DC_MSG_VIDEO) {
|
||||
if (!VideoRecoder.prepareVideo(context, chatId, msg)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
dcContext.sendMsg(chatId, msg);
|
||||
}
|
||||
}
|
||||
|
||||
dismissProgressDialog(progressDialog);
|
||||
}
|
||||
|
||||
private static void dismissProgressDialog(ProgressDialog[] progressDialog) {
|
||||
if (progressDialog[0] != null) {
|
||||
Util.runOnMain(
|
||||
() -> {
|
||||
try {
|
||||
if (progressDialog[0] != null) progressDialog[0].dismiss();
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// The activity is finishing/destroyed, do nothing.
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean containsVideoType(Context context, ArrayList<Uri> uris) {
|
||||
|
||||
Reference in New Issue
Block a user