Implement file size limit

This commit is contained in:
Niels Andriesse 2020-02-11 11:00:00 +11:00
parent 98d4ee1724
commit cb1553631e

View File

@ -3,13 +3,12 @@ package org.thoughtcrime.securesms.mms;
import android.content.Context; import android.content.Context;
import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.signalservice.loki.api.LokiFileServerAPI;
public class PushMediaConstraints extends MediaConstraints { public class PushMediaConstraints extends MediaConstraints {
private static final int MAX_IMAGE_DIMEN_LOWMEM = 768; private static final int MAX_IMAGE_DIMEN_LOWMEM = 768;
private static final int MAX_IMAGE_DIMEN = 4096; private static final int MAX_IMAGE_DIMEN = 4096;
private static final int KB = 1024;
private static final int MB = 1024 * KB;
@Override @Override
public int getImageMaxWidth(Context context) { public int getImageMaxWidth(Context context) {
@ -23,26 +22,26 @@ public class PushMediaConstraints extends MediaConstraints {
@Override @Override
public int getImageMaxSize(Context context) { public int getImageMaxSize(Context context) {
return 6 * MB; return LokiFileServerAPI.Companion.getMaxFileSize();
} }
@Override @Override
public int getGifMaxSize(Context context) { public int getGifMaxSize(Context context) {
return 25 * MB; return LokiFileServerAPI.Companion.getMaxFileSize();
} }
@Override @Override
public int getVideoMaxSize(Context context) { public int getVideoMaxSize(Context context) {
return 100 * MB; return LokiFileServerAPI.Companion.getMaxFileSize();
} }
@Override @Override
public int getAudioMaxSize(Context context) { public int getAudioMaxSize(Context context) {
return 100 * MB; return LokiFileServerAPI.Companion.getMaxFileSize();
} }
@Override @Override
public int getDocumentMaxSize(Context context) { public int getDocumentMaxSize(Context context) {
return 100 * MB; return LokiFileServerAPI.Companion.getMaxFileSize();
} }
} }