fix 'checking file size' status display

This commit is contained in:
Daniel Gultsch 2021-03-20 11:21:48 +01:00
parent 38ef69a926
commit 72828c6c4e
1 changed files with 4 additions and 7 deletions

View File

@ -13,7 +13,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.CancellationException;
import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLHandshakeException;
@ -39,7 +38,6 @@ import static eu.siacs.conversations.http.HttpConnectionManager.EXECUTOR;
public class HttpDownloadConnection implements Transferable { public class HttpDownloadConnection implements Transferable {
private final Message message; private final Message message;
private final boolean mUseTor;
private final HttpConnectionManager mHttpConnectionManager; private final HttpConnectionManager mHttpConnectionManager;
private final XmppConnectionService mXmppConnectionService; private final XmppConnectionService mXmppConnectionService;
private HttpUrl mUrl; private HttpUrl mUrl;
@ -47,14 +45,12 @@ public class HttpDownloadConnection implements Transferable {
private int mStatus = Transferable.STATUS_UNKNOWN; private int mStatus = Transferable.STATUS_UNKNOWN;
private boolean acceptedAutomatically = false; private boolean acceptedAutomatically = false;
private int mProgress = 0; private int mProgress = 0;
private boolean canceled = false;
private Call mostRecentCall; private Call mostRecentCall;
HttpDownloadConnection(Message message, HttpConnectionManager manager) { HttpDownloadConnection(Message message, HttpConnectionManager manager) {
this.message = message; this.message = message;
this.mHttpConnectionManager = manager; this.mHttpConnectionManager = manager;
this.mXmppConnectionService = manager.getXmppConnectionService(); this.mXmppConnectionService = manager.getXmppConnectionService();
this.mUseTor = mXmppConnectionService.useTorToConnect();
} }
@Override @Override
@ -143,7 +139,6 @@ public class HttpDownloadConnection implements Transferable {
@Override @Override
public void cancel() { public void cancel() {
this.canceled = true;
final Call call = this.mostRecentCall; final Call call = this.mostRecentCall;
if (call != null && !call.isCanceled()) { if (call != null && !call.isCanceled()) {
call.cancel(); call.cancel();
@ -270,7 +265,7 @@ public class HttpDownloadConnection implements Transferable {
check(); check();
} }
private void retrieveFailed(@Nullable Exception e) { private void retrieveFailed(@Nullable final Exception e) {
changeStatus(STATUS_OFFER_CHECK_FILESIZE); changeStatus(STATUS_OFFER_CHECK_FILESIZE);
if (interactive) { if (interactive) {
showToastForException(e); showToastForException(e);
@ -285,7 +280,7 @@ public class HttpDownloadConnection implements Transferable {
long size; long size;
try { try {
size = retrieveFileSize(); size = retrieveFileSize();
} catch (Exception e) { } catch (final Exception e) {
Log.d(Config.LOGTAG, "io exception in http file size checker: " + e.getMessage()); Log.d(Config.LOGTAG, "io exception in http file size checker: " + e.getMessage());
retrieveFailed(e); retrieveFailed(e);
return; return;
@ -309,6 +304,8 @@ public class HttpDownloadConnection implements Transferable {
} }
private long retrieveFileSize() throws IOException { private long retrieveFileSize() throws IOException {
Log.d(Config.LOGTAG, "retrieve file size. interactive:" + interactive);
changeStatus(STATUS_CHECKING);
final OkHttpClient client = mHttpConnectionManager.buildHttpClient( final OkHttpClient client = mHttpConnectionManager.buildHttpClient(
mUrl, mUrl,
message.getConversation().getAccount(), message.getConversation().getAccount(),