diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-09-09 21:13:06 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-09-09 21:13:06 +0200 |
commit | 3334ab7d0a0a394ae5d8fe7d36d7e297859fb30d (patch) | |
tree | 4fd9e7173b01a7c9fc20020665c968866724e7ce /src | |
parent | 9da5429893fa61b495466f4f4da203e46e518925 (diff) |
introduce new file transfer status
Diffstat (limited to '')
5 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Transferable.java b/src/main/java/de/pixart/messenger/entities/Transferable.java index e1deb744d..054841b6e 100644 --- a/src/main/java/de/pixart/messenger/entities/Transferable.java +++ b/src/main/java/de/pixart/messenger/entities/Transferable.java @@ -26,6 +26,7 @@ public interface Transferable { int STATUS_DOWNLOADING = 0x204; int STATUS_OFFER_CHECK_FILESIZE = 0x206; int STATUS_UPLOADING = 0x207; + int STATUS_WAITING = 0x199; boolean start(); diff --git a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java index 7c056bdc1..ac3e8e40c 100644 --- a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java +++ b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java @@ -344,7 +344,7 @@ public class HttpDownloadConnection implements Transferable { @Override public void run() { - changeStatus(STATUS_DOWNLOADING); + changeStatus(STATUS_WAITING); mXmppConnectionService.mDownloadExecutor.execute(() -> { try { changeStatus(STATUS_DOWNLOADING); diff --git a/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java b/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java index f43a94d73..4eedfcf3f 100644 --- a/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java +++ b/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java @@ -47,6 +47,7 @@ public class HttpUploadConnection implements Transferable { private String mime; private SlotRequester.Slot slot; private byte[] key = null; + private int mStatus = Transferable.STATUS_UNKNOWN; private long transmitted = 0; @@ -66,7 +67,7 @@ public class HttpUploadConnection implements Transferable { @Override public int getStatus() { - return STATUS_UPLOADING; + return this.mStatus; } @Override @@ -134,7 +135,9 @@ public class HttpUploadConnection implements Transferable { @Override public void success(SlotRequester.Slot slot) { if (!cancelled) { + changeStatus(STATUS_WAITING); mXmppConnectionService.mUploadExecutor.execute(() -> { + changeStatus(STATUS_UPLOADING); HttpUploadConnection.this.slot = slot; HttpUploadConnection.this.upload(); }); @@ -242,6 +245,11 @@ public class HttpUploadConnection implements Transferable { } } + private void changeStatus(int status) { + this.mStatus = status; + mHttpConnectionManager.updateConversationUi(true); + } + public Message getMessage() { return message; } diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java index 097baa3f6..590085ff5 100644 --- a/src/main/java/de/pixart/messenger/utils/UIHelper.java +++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java @@ -254,6 +254,8 @@ public class UIHelper { final Transferable d = message.getTransferable(); if (d != null) { switch (d.getStatus()) { + case Transferable.STATUS_WAITING: + return new Pair<>(context.getString(R.string.waiting_for_transfer), true); case Transferable.STATUS_CHECKING: return new Pair<>(context.getString(R.string.checking_x, getFileDescriptionString(context, message)), true); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index b6218464d..6a70c8cd4 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -932,4 +932,5 @@ <string name="account_already_setup">This account has already been setup</string> <string name="please_enter_password">Please enter the password for this account</string> <string name="unable_to_perform_this_action">Unable to perform this action</string> + <string name="waiting_for_transfer">Waiting for transfer</string> </resources> |