Simplify to one download size

This commit is contained in:
M66B 2020-07-13 15:34:31 +02:00
parent 83d849f10a
commit d23ca3a03b
4 changed files with 8 additions and 10 deletions

View File

@ -2636,12 +2636,11 @@ class Core {
if (download && message.size != null && !message.ui_hide) {
long maxSize;
if (state == null || state.networkState.isUnmetered())
maxSize = MessageHelper.SMALL_MESSAGE_SIZE;
maxSize = MessageHelper.DEFAULT_DOWNLOAD_SIZE;
else {
int downloadSize = prefs.getInt("download", 0);
maxSize = (downloadSize == 0
? MessageHelper.SMALL_MESSAGE_SIZE
: Math.min(downloadSize, MessageHelper.SMALL_MESSAGE_SIZE));
maxSize = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
if (maxSize == 0)
maxSize = MessageHelper.DEFAULT_DOWNLOAD_SIZE;
}
if (message.size < maxSize) {
@ -2988,7 +2987,7 @@ class Core {
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
long maxSize = prefs.getInt("download", MessageHelper.DEFAULT_ATTACHMENT_DOWNLOAD_SIZE);
long maxSize = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
if (maxSize == 0)
maxSize = Long.MAX_VALUE;

View File

@ -4213,7 +4213,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
autoExpanded = false;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
long download = prefs.getInt("download", MessageHelper.DEFAULT_ATTACHMENT_DOWNLOAD_SIZE);
long download = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
if (download == 0)
download = Long.MAX_VALUE;

View File

@ -31,7 +31,6 @@ import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.Menu;
@ -253,7 +252,7 @@ public class FragmentOptionsConnection extends FragmentBase implements SharedPre
swMetered.setChecked(prefs.getBoolean("metered", true));
int download = prefs.getInt("download", MessageHelper.DEFAULT_ATTACHMENT_DOWNLOAD_SIZE);
int download = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
int[] downloadValues = getResources().getIntArray(R.array.downloadValues);
for (int pos = 0; pos < downloadValues.length; pos++)
if (downloadValues[pos] == download) {

View File

@ -108,7 +108,7 @@ public class MessageHelper {
private static File cacheDir = null;
static final int SMALL_MESSAGE_SIZE = 64 * 1024; // bytes
static final int DEFAULT_ATTACHMENT_DOWNLOAD_SIZE = 256 * 1024; // bytes
static final int DEFAULT_DOWNLOAD_SIZE = 256 * 1024; // bytes
static final String HEADER_CORRELATION_ID = "X-Correlation-ID";
private static final int MAX_MESSAGE_SIZE = 10 * 1024 * 1024; // bytes