2015-01-02 23:43:28 +00:00
|
|
|
package org.thoughtcrime.securesms.mms;
|
|
|
|
|
2015-06-04 21:19:10 +00:00
|
|
|
import android.content.Context;
|
|
|
|
|
2017-05-08 22:32:59 +00:00
|
|
|
import com.android.mms.service_alt.MmsConfig;
|
2015-06-04 21:19:10 +00:00
|
|
|
|
2019-03-28 18:14:06 +00:00
|
|
|
final class MmsMediaConstraints extends MediaConstraints {
|
2017-05-08 22:32:59 +00:00
|
|
|
|
|
|
|
private final int subscriptionId;
|
|
|
|
|
2019-03-28 18:14:06 +00:00
|
|
|
private static final int MIN_IMAGE_DIMEN = 1024;
|
|
|
|
|
2017-05-08 22:32:59 +00:00
|
|
|
MmsMediaConstraints(int subscriptionId) {
|
|
|
|
this.subscriptionId = subscriptionId;
|
|
|
|
}
|
2015-01-02 23:43:28 +00:00
|
|
|
|
|
|
|
@Override
|
2015-06-04 21:19:10 +00:00
|
|
|
public int getImageMaxWidth(Context context) {
|
2019-03-28 18:14:06 +00:00
|
|
|
return Math.max(MIN_IMAGE_DIMEN, getOverriddenMmsConfig(context).getMaxImageWidth());
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-06-04 21:19:10 +00:00
|
|
|
public int getImageMaxHeight(Context context) {
|
2019-03-28 18:14:06 +00:00
|
|
|
return Math.max(MIN_IMAGE_DIMEN, getOverriddenMmsConfig(context).getMaxImageHeight());
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-05-08 22:32:59 +00:00
|
|
|
public int getImageMaxSize(Context context) {
|
|
|
|
return getMaxMessageSize(context);
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|
|
|
|
|
2015-07-15 20:42:59 +00:00
|
|
|
@Override
|
2017-05-08 22:32:59 +00:00
|
|
|
public int getGifMaxSize(Context context) {
|
|
|
|
return getMaxMessageSize(context);
|
2015-07-15 20:42:59 +00:00
|
|
|
}
|
|
|
|
|
2015-01-02 23:43:28 +00:00
|
|
|
@Override
|
2017-05-08 22:32:59 +00:00
|
|
|
public int getVideoMaxSize(Context context) {
|
|
|
|
return getMaxMessageSize(context);
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-05-08 22:32:59 +00:00
|
|
|
public int getAudioMaxSize(Context context) {
|
|
|
|
return getMaxMessageSize(context);
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|
2017-04-24 22:52:48 +00:00
|
|
|
|
|
|
|
@Override
|
2017-05-08 22:32:59 +00:00
|
|
|
public int getDocumentMaxSize(Context context) {
|
|
|
|
return getMaxMessageSize(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
private int getMaxMessageSize(Context context) {
|
2019-03-28 18:14:06 +00:00
|
|
|
return getOverriddenMmsConfig(context).getMaxMessageSize();
|
|
|
|
}
|
2017-05-08 22:32:59 +00:00
|
|
|
|
2019-03-28 18:14:06 +00:00
|
|
|
private MmsConfig.Overridden getOverriddenMmsConfig(Context context) {
|
|
|
|
MmsConfig mmsConfig = MmsConfigManager.getMmsConfig(context, subscriptionId);
|
2017-05-08 22:32:59 +00:00
|
|
|
|
2019-03-28 18:14:06 +00:00
|
|
|
return new MmsConfig.Overridden(mmsConfig, null);
|
2017-04-24 22:52:48 +00:00
|
|
|
}
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|