fix the warning when attaching multiple files: images are recoded, only videos are not

This commit is contained in:
B. Petersen 2024-10-10 15:45:19 +02:00 committed by bjoern
parent aa78c607ce
commit 5f77f791d0
4 changed files with 22 additions and 4 deletions

View file

@ -93,12 +93,16 @@ public abstract class BaseConversationListFragment extends Fragment implements A
if (isForwarding(getActivity())) { if (isForwarding(getActivity())) {
message = String.format(Util.getLocale(), getString(R.string.ask_forward_multiple), selectedChats.size()); message = String.format(Util.getLocale(), getString(R.string.ask_forward_multiple), selectedChats.size());
} else if (!uris.isEmpty()) { } else if (!uris.isEmpty()) {
message = String.format(Util.getLocale(), getString(R.string.share_multiple_attachments_multiple_chats), uris.size(), selectedChats.size()); message = String.format(Util.getLocale(), getString(R.string.ask_send_files_to_selected_chats), uris.size(), selectedChats.size());
} else { } else {
message = String.format(Util.getLocale(), getString(R.string.share_text_multiple_chats), selectedChats.size(), getSharedText(getActivity())); message = String.format(Util.getLocale(), getString(R.string.share_text_multiple_chats), selectedChats.size(), getSharedText(getActivity()));
} }
Context context = getContext(); Context context = getContext();
if (context != null) { if (context != null) {
if (SendRelayedMessageUtil.containsVideoType(context, uris)) {
message += "\n\n" + getString(R.string.videos_sent_without_recoding);
}
new AlertDialog.Builder(context) new AlertDialog.Builder(context)
.setMessage(message) .setMessage(message)
.setCancelable(false) .setCancelable(false)

View file

@ -669,7 +669,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
ArrayList<Uri> uriList = RelayUtil.getSharedUris(this); ArrayList<Uri> uriList = RelayUtil.getSharedUris(this);
int sharedContactId = RelayUtil.getSharedContactId(this); int sharedContactId = RelayUtil.getSharedContactId(this);
if (uriList.size() > 1) { if (uriList.size() > 1) {
String message = String.format(getString(R.string.share_multiple_attachments), uriList.size()); String message = String.format(getString(R.string.ask_send_files_to_selected_chat), uriList.size());
if (SendRelayedMessageUtil.containsVideoType(context, uriList)) {
message += "\n\n" + getString(R.string.videos_sent_without_recoding);
}
new AlertDialog.Builder(this) new AlertDialog.Builder(this)
.setMessage(message) .setMessage(message)
.setCancelable(false) .setCancelable(false)

View file

@ -74,6 +74,16 @@ public class SendRelayedMessageUtil {
} }
} }
public static boolean containsVideoType(Context context, ArrayList<Uri> uris) {
for (final Uri uri : uris) {
final String mimeType = MediaUtil.getMimeType(context, uri);
if (MediaUtil.isVideoType(mimeType)) {
return true;
}
}
return false;
}
public static DcMsg createMessage(Context context, Uri uri, String text) throws NullPointerException { public static DcMsg createMessage(Context context, Uri uri, String text) throws NullPointerException {
DcContext dcContext = DcHelper.getContext(context); DcContext dcContext = DcHelper.getContext(context);
DcMsg message; DcMsg message;

View file

@ -656,8 +656,9 @@
<!-- share and forward messages --> <!-- share and forward messages -->
<!-- Translators: shown above a chat/contact list when selecting recipients to forward messages --> <!-- Translators: shown above a chat/contact list when selecting recipients to forward messages -->
<string name="forward_to">Forward to…</string> <string name="forward_to">Forward to…</string>
<string name="share_multiple_attachments">Send %1$d files to the selected chat?\n\nThe files are sent unmodified in their original size (eg. images and videos are not re-encoded).</string> <string name="ask_send_files_to_selected_chat">Send %1$d files to the selected chat?</string>
<string name="share_multiple_attachments_multiple_chats">Send %1$d file(s) to %2$d chats?\n\nThe files are sent unmodified in their original size (eg. images and videos are not re-encoded).</string> <string name="ask_send_files_to_selected_chats">Send %1$d file(s) to %2$d chats?</string>
<string name="videos_sent_without_recoding">(Videos are sent as original, big files. To send videos as smaller files, attach them separately).</string>
<string name="share_text_multiple_chats">Send this text to %1$d chats?\n\n\"%2$s\"</string> <string name="share_text_multiple_chats">Send this text to %1$d chats?\n\n\"%2$s\"</string>
<string name="share_abort">Sharing aborted due to missing permissions.</string> <string name="share_abort">Sharing aborted due to missing permissions.</string>