mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
parent
03e347bfd9
commit
9bf198bb81
@ -36,13 +36,15 @@ public abstract class MediaConstraints {
|
|||||||
|
|
||||||
public abstract int getAudioMaxSize();
|
public abstract int getAudioMaxSize();
|
||||||
|
|
||||||
|
public abstract int getDocumentMaxSize();
|
||||||
|
|
||||||
public boolean isSatisfied(@NonNull Context context, @NonNull MasterSecret masterSecret, @NonNull Attachment attachment) {
|
public boolean isSatisfied(@NonNull Context context, @NonNull MasterSecret masterSecret, @NonNull Attachment attachment) {
|
||||||
try {
|
try {
|
||||||
return (MediaUtil.isGif(attachment) && attachment.getSize() <= getGifMaxSize() && isWithinBounds(context, masterSecret, attachment.getDataUri())) ||
|
return (MediaUtil.isGif(attachment) && attachment.getSize() <= getGifMaxSize() && isWithinBounds(context, masterSecret, attachment.getDataUri())) ||
|
||||||
(MediaUtil.isImage(attachment) && attachment.getSize() <= getImageMaxSize() && isWithinBounds(context, masterSecret, attachment.getDataUri())) ||
|
(MediaUtil.isImage(attachment) && attachment.getSize() <= getImageMaxSize() && isWithinBounds(context, masterSecret, attachment.getDataUri())) ||
|
||||||
(MediaUtil.isAudio(attachment) && attachment.getSize() <= getAudioMaxSize()) ||
|
(MediaUtil.isAudio(attachment) && attachment.getSize() <= getAudioMaxSize()) ||
|
||||||
(MediaUtil.isVideo(attachment) && attachment.getSize() <= getVideoMaxSize()) ||
|
(MediaUtil.isVideo(attachment) && attachment.getSize() <= getVideoMaxSize()) ||
|
||||||
(!MediaUtil.isImage(attachment) && !MediaUtil.isAudio(attachment) && !MediaUtil.isVideo(attachment));
|
(MediaUtil.isFile(attachment) && attachment.getSize() <= getDocumentMaxSize());
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.w(TAG, "Failed to determine if media's constraints are satisfied.", ioe);
|
Log.w(TAG, "Failed to determine if media's constraints are satisfied.", ioe);
|
||||||
return false;
|
return false;
|
||||||
|
@ -38,4 +38,9 @@ public class MmsMediaConstraints extends MediaConstraints {
|
|||||||
public int getAudioMaxSize() {
|
public int getAudioMaxSize() {
|
||||||
return MAX_MESSAGE_SIZE;
|
return MAX_MESSAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDocumentMaxSize() {
|
||||||
|
return MAX_MESSAGE_SIZE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,4 +39,9 @@ public class PushMediaConstraints extends MediaConstraints {
|
|||||||
public int getAudioMaxSize() {
|
public int getAudioMaxSize() {
|
||||||
return 100 * MB;
|
return 100 * MB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDocumentMaxSize() {
|
||||||
|
return 100 * MB;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,10 @@ public class MediaUtil {
|
|||||||
return !TextUtils.isEmpty(contentType) && contentType.trim().startsWith("video/");
|
return !TextUtils.isEmpty(contentType) && contentType.trim().startsWith("video/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isFile(Attachment attachment) {
|
||||||
|
return !isImage(attachment) && !isAudio(attachment) && !isVideo(attachment);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean hasVideoThumbnail(Uri uri) {
|
public static boolean hasVideoThumbnail(Uri uri) {
|
||||||
Log.w(TAG, "Checking: " + uri);
|
Log.w(TAG, "Checking: " + uri);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user