session-android/src/org/thoughtcrime/securesms/mms/MmsMediaConstraints.java

79 lines
2.0 KiB
Java
Raw Normal View History

2015-01-02 23:43:28 +00:00
package org.thoughtcrime.securesms.mms;
import android.content.Context;
import android.os.Bundle;
import com.android.mms.service_alt.MmsConfig;
class MmsMediaConstraints extends MediaConstraints {
private static final int DEFAULT_MAX_IMAGE_DIMEN = 1024;
private static final int DEFAULT_MAX_MESSAGE_SIZE = 280 * 1024;
private final int subscriptionId;
MmsMediaConstraints(int subscriptionId) {
this.subscriptionId = subscriptionId;
}
2015-01-02 23:43:28 +00:00
@Override
public int getImageMaxWidth(Context context) {
MmsConfig mmsConfig = MmsConfigManager.getMmsConfig(context, subscriptionId);
if (mmsConfig != null) {
MmsConfig.Overridden overridden = new MmsConfig.Overridden(mmsConfig, new Bundle());
return overridden.getMaxImageWidth();
}
return DEFAULT_MAX_IMAGE_DIMEN;
2015-01-02 23:43:28 +00:00
}
@Override
public int getImageMaxHeight(Context context) {
MmsConfig mmsConfig = MmsConfigManager.getMmsConfig(context, subscriptionId);
if (mmsConfig != null) {
MmsConfig.Overridden overridden = new MmsConfig.Overridden(mmsConfig, new Bundle());
return overridden.getMaxImageHeight();
}
return DEFAULT_MAX_IMAGE_DIMEN;
2015-01-02 23:43:28 +00:00
}
@Override
public int getImageMaxSize(Context context) {
return getMaxMessageSize(context);
2015-01-02 23:43:28 +00:00
}
@Override
public int getGifMaxSize(Context context) {
return getMaxMessageSize(context);
}
2015-01-02 23:43:28 +00:00
@Override
public int getVideoMaxSize(Context context) {
return getMaxMessageSize(context);
2015-01-02 23:43:28 +00:00
}
@Override
public int getAudioMaxSize(Context context) {
return getMaxMessageSize(context);
2015-01-02 23:43:28 +00:00
}
@Override
public int getDocumentMaxSize(Context context) {
return getMaxMessageSize(context);
}
private int getMaxMessageSize(Context context) {
MmsConfig mmsConfig = MmsConfigManager.getMmsConfig(context, subscriptionId);
if (mmsConfig != null) {
MmsConfig.Overridden overridden = new MmsConfig.Overridden(mmsConfig, new Bundle());
return overridden.getMaxMessageSize();
}
return DEFAULT_MAX_MESSAGE_SIZE;
}
2015-01-02 23:43:28 +00:00
}