mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
SES-1571 Large messages show warning toast
This commit is contained in:
parent
27ca77d5c4
commit
acc8d47c68
@ -1840,6 +1840,22 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
val mediaPreppedListener = object : ListenableFuture.Listener<Boolean> {
|
||||
|
||||
override fun onSuccess(result: Boolean?) {
|
||||
if (result == null) {
|
||||
Log.w(TAG, "Media prepper returned a null result - bailing.")
|
||||
return
|
||||
}
|
||||
|
||||
// If the attachment was too large or MediaConstraints.isSatisfied failed for some
|
||||
// other reason then we reset the attachment manager & shown buttons then bail..
|
||||
if (!result) {
|
||||
attachmentManager.clear()
|
||||
if (isShowingAttachmentOptions) { toggleAttachmentOptions() }
|
||||
return
|
||||
}
|
||||
|
||||
// ..otherwise we can attempt to send the attachment(s).
|
||||
// Note: The only multi-attachment message type is when sending images - all others
|
||||
// attempt send on initial attachment selection.
|
||||
sendAttachments(attachmentManager.buildSlideDeck().asAttachments(), null)
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,9 @@ public class AttachmentManager {
|
||||
|
||||
private final static String TAG = AttachmentManager.class.getSimpleName();
|
||||
|
||||
// Max attachment size is 10MB, above which we display a warning toast rather than sending the msg
|
||||
private final long MAX_ATTACHMENTS_FILE_SIZE_BYTES = 10 * 1024 * 1024;
|
||||
|
||||
private final @NonNull Context context;
|
||||
private final @NonNull AttachmentListener attachmentListener;
|
||||
|
||||
@ -360,9 +363,18 @@ public class AttachmentManager {
|
||||
final @Nullable Slide slide,
|
||||
final @NonNull MediaConstraints constraints)
|
||||
{
|
||||
return slide == null ||
|
||||
constraints.isSatisfied(context, slide.asAttachment()) ||
|
||||
constraints.canResize(slide.asAttachment());
|
||||
// Null attachment? Not satisfied.
|
||||
if (slide == null) return false;
|
||||
|
||||
// Attachments are excessively large? Not satisfied.
|
||||
if (slide.asAttachment().getSize() > MAX_ATTACHMENTS_FILE_SIZE_BYTES) {
|
||||
Toast.makeText(context, R.string.attachmentsErrorSize, Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise our constraints-satisfied condition becomes whether we can resize it (obviously
|
||||
// this will only work on images).
|
||||
return constraints.canResize(slide.asAttachment());
|
||||
}
|
||||
|
||||
public interface AttachmentListener {
|
||||
|
Loading…
x
Reference in New Issue
Block a user