show max file upload size in server info

This commit is contained in:
Daniel Gultsch 2019-03-23 07:27:03 +01:00
parent 6322d4c077
commit d390345073
3 changed files with 12 additions and 8 deletions

View file

@ -1023,7 +1023,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.binding.serverInfoPep.setText(R.string.server_info_unavailable); this.binding.serverInfoPep.setText(R.string.server_info_unavailable);
} }
if (features.httpUpload(0)) { if (features.httpUpload(0)) {
this.binding.serverInfoHttpUpload.setText(R.string.server_info_available); this.binding.serverInfoHttpUpload.setText(UIHelper.filesizeToString(features.getMaxHttpUploadSize()));
} else if (features.p1S3FileTransfer()) { } else if (features.p1S3FileTransfer()) {
this.binding.serverInfoHttpUploadDescription.setText(R.string.p1_s3_filetransfer); this.binding.serverInfoHttpUploadDescription.setText(R.string.p1_s3_filetransfer);
this.binding.serverInfoHttpUpload.setText(R.string.server_info_available); this.binding.serverInfoHttpUpload.setText(R.string.server_info_available);

View file

@ -183,13 +183,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
&& message.getMergedStatus() <= Message.STATUS_RECEIVED; && message.getMergedStatus() <= Message.STATUS_RECEIVED;
if (message.isFileOrImage() || transferable != null) { if (message.isFileOrImage() || transferable != null) {
FileParams params = message.getFileParams(); FileParams params = message.getFileParams();
if (params.size > (1.5 * 1024 * 1024)) { filesize = params.size > 0 ? UIHelper.filesizeToString(params.size) : null;
filesize = Math.round(params.size * 1f / (1024 * 1024)) + " MiB";
} else if (params.size >= 1024) {
filesize = Math.round(params.size * 1f / 1024) + " KiB";
} else if (params.size > 0) {
filesize = params.size + " B";
}
if (transferable != null && transferable.getStatus() == Transferable.STATUS_FAILED) { if (transferable != null && transferable.getStatus() == Transferable.STATUS_FAILED) {
error = true; error = true;
} }

View file

@ -572,4 +572,14 @@ public class UIHelper {
return new ListItem.Tag(context.getString(R.string.presence_online), 0xff259b24); return new ListItem.Tag(context.getString(R.string.presence_online), 0xff259b24);
} }
} }
public static String filesizeToString(long size) {
if (size > (1.5 * 1024 * 1024)) {
return Math.round(size * 1f / (1024 * 1024)) + " MiB";
} else if (size >= 1024) {
return Math.round(size * 1f / 1024) + " KiB";
} else {
return size + " B";
}
}
} }