aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-15 14:40:43 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-15 14:40:43 +0100
commit989ca229a2d4f32dde5ef4607dfbe96679e69b29 (patch)
treec19717482c217abe7ab8f73b37b5eaa95af4b35d
parent995d1cbf61c2d7bf91afcaff1a0c4ff6a51b1de2 (diff)
fixed description in notifications and conversation overview
-rw-r--r--src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java39
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java12
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java56
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java3
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java12
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java6
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java13
-rw-r--r--src/main/res/values/strings.xml2
8 files changed, 93 insertions, 50 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java b/src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java
new file mode 100644
index 00000000..03fceceb
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java
@@ -0,0 +1,39 @@
+package eu.siacs.conversations.entities;
+
+public class DownloadablePlaceholder implements Downloadable {
+
+ private int status;
+
+ public DownloadablePlaceholder(int status) {
+ this.status = status;
+ }
+ @Override
+ public boolean start() {
+ return false;
+ }
+
+ @Override
+ public int getStatus() {
+ return status;
+ }
+
+ @Override
+ public long getFileSize() {
+ return 0;
+ }
+
+ @Override
+ public int getProgress() {
+ return 0;
+ }
+
+ @Override
+ public String getMimeType() {
+ return "";
+ }
+
+ @Override
+ public void cancel() {
+
+ }
+}
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index 4cb28145..385aab92 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -28,6 +28,7 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.ui.ConversationActivity;
@@ -266,14 +267,21 @@ public class NotificationService {
if (message.getDownloadable() != null
&& (message.getDownloadable().getStatus() == Downloadable.STATUS_OFFER || message
.getDownloadable().getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE)) {
- return mXmppConnectionService.getText(
- R.string.image_offered_for_download).toString();
+ if (message.getType() == Message.TYPE_FILE) {
+ return mXmppConnectionService.getString(R.string.file_offered_for_download);
+ } else {
+ return mXmppConnectionService.getText(
+ R.string.image_offered_for_download).toString();
+ }
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
return mXmppConnectionService.getText(
R.string.encrypted_message_received).toString();
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
return mXmppConnectionService.getText(R.string.decryption_failed)
.toString();
+ } else if (message.getType() == Message.TYPE_FILE) {
+ DownloadableFile file = mXmppConnectionService.getFileBackend().getFile(message);
+ return mXmppConnectionService.getString(R.string.file,file.getMimeType());
} else if (message.getType() == Message.TYPE_IMAGE) {
return mXmppConnectionService.getText(R.string.image_file)
.toString();
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 0383d6ea..2e4341f9 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -57,6 +57,7 @@ import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Downloadable;
import eu.siacs.conversations.entities.DownloadableFile;
+import eu.siacs.conversations.entities.DownloadablePlaceholder;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.MucOptions.OnRenameListener;
@@ -711,11 +712,16 @@ public class XmppConnectionService extends Service {
} else {
if (message.getConversation().getOtrSession()
.getSessionStatus() == SessionStatus.ENCRYPTED) {
- if (message.getType() == Message.TYPE_TEXT) {
- packet = mMessageGenerator.generateOtrChat(message,
- true);
- } else if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE) {
- mJingleConnectionManager.createNewConnection(message);
+ try {
+ message.setCounterpart(Jid.fromSessionID(message.getConversation().getOtrSession().getSessionID()));
+ if (message.getType() == Message.TYPE_TEXT) {
+ packet = mMessageGenerator.generateOtrChat(message,
+ true);
+ } else if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE) {
+ mJingleConnectionManager.createNewConnection(message);
+ }
+ } catch (InvalidJidException e) {
+
}
}
}
@@ -885,10 +891,10 @@ public class XmppConnectionService extends Service {
private void checkDeletedFiles(Conversation conversation) {
for (Message message : conversation.getMessages()) {
- if (message.getType() == Message.TYPE_IMAGE
+ if ((message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE)
&& message.getEncryption() != Message.ENCRYPTION_PGP) {
if (!getFileBackend().isFileAvailable(message)) {
- message.setDownloadable(new DeletedDownloadable());
+ message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_DELETED));
}
}
}
@@ -901,7 +907,7 @@ public class XmppConnectionService extends Service {
&& message.getEncryption() != Message.ENCRYPTION_PGP
&& message.getUuid().equals(uuid)) {
if (!getFileBackend().isFileAvailable(message)) {
- message.setDownloadable(new DeletedDownloadable());
+ message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_DELETED));
updateConversationUi();
}
return;
@@ -2012,38 +2018,4 @@ public class XmppConnectionService extends Service {
return XmppConnectionService.this;
}
}
-
- private class DeletedDownloadable implements Downloadable {
-
- @Override
- public boolean start() {
- return false;
- }
-
- @Override
- public int getStatus() {
- return Downloadable.STATUS_DELETED;
- }
-
- @Override
- public long getFileSize() {
- return 0;
- }
-
- @Override
- public int getProgress() {
- return 0;
- }
-
- @Override
- public String getMimeType() {
- return "";
- }
-
- @Override
- public void cancel() {
-
- }
-
- }
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index e15a6bbc..da788b43 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -44,6 +44,7 @@ import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Downloadable;
+import eu.siacs.conversations.entities.DownloadablePlaceholder;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.Presences;
@@ -367,7 +368,7 @@ public class ConversationFragment extends Fragment {
downloadImage.setVisible(false);
}
if (this.selectedMessage.getDownloadable() == null
- || this.selectedMessage.getDownloadable().getStatus() == Downloadable.STATUS_DELETED) {
+ || this.selectedMessage.getDownloadable() instanceof DownloadablePlaceholder) {
cancelTransmission.setVisible(false);
}
}
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
index b1aea209..b81544e6 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
@@ -104,7 +104,17 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
} else if (d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) {
mLastMessage.setText(R.string.image_offered_for_download);
} else if (d.getStatus() == Downloadable.STATUS_DELETED) {
- mLastMessage.setText(R.string.image_file_deleted);
+ if (message.getType() == Message.TYPE_FILE) {
+ mLastMessage.setText(R.string.file_deleted);
+ } else {
+ mLastMessage.setText(R.string.image_file_deleted);
+ }
+ } else if (d.getStatus() == Downloadable.STATUS_FAILED) {
+ if (message.getType() == Message.TYPE_FILE) {
+ mLastMessage.setText(R.string.file_transmission_failed);
+ } else {
+ mLastMessage.setText(R.string.image_transmission_failed);
+ }
} else if (message.getImageParams().width > 0) {
mLastMessage.setVisibility(View.GONE);
imagePreview.setVisibility(View.VISIBLE);
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 71795e98..c82f5be7 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -505,7 +505,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else if (d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) {
displayDownloadableMessage(viewHolder, item,activity.getString(R.string.check_image_filesize));
} else if (d.getStatus() == Downloadable.STATUS_FAILED) {
- displayInfoMessage(viewHolder, activity.getString(R.string.image_transmission_failed));
+ if (item.getType() == Message.TYPE_FILE) {
+ displayInfoMessage(viewHolder, activity.getString(R.string.file_transmission_failed));
+ } else {
+ displayInfoMessage(viewHolder, activity.getString(R.string.image_transmission_failed));
+ }
}
} else if (item.getType() == Message.TYPE_IMAGE && item.getEncryption() != Message.ENCRYPTION_PGP && item.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
displayImageMessage(viewHolder, item);
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index febd4f57..d6bcf55b 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -18,6 +18,7 @@ import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Downloadable;
import eu.siacs.conversations.entities.DownloadableFile;
+import eu.siacs.conversations.entities.DownloadablePlaceholder;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.xml.Element;
@@ -96,7 +97,6 @@ public class JingleConnection implements Downloadable {
mXmppConnectionService.markMessage(message,
Message.STATUS_RECEIVED);
} else {
- message.setDownloadable(null);
if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
file.delete();
}
@@ -710,6 +710,10 @@ public class JingleConnection implements Downloadable {
this.mXmppConnectionService.markMessage(this.message,
Message.STATUS_SEND);
this.disconnectSocks5Connections();
+ if (this.transport != null && this.transport instanceof JingleInbandTransport) {
+ this.transport.disconnect();
+ }
+ this.message.setDownloadable(null);
this.mJingleConnectionManager.finishConnection(this);
}
@@ -721,7 +725,7 @@ public class JingleConnection implements Downloadable {
this.sendCancel();
this.mJingleConnectionManager.finishConnection(this);
if (this.responder.equals(account.getJid())) {
- this.mStatus = Downloadable.STATUS_FAILED;
+ this.message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_FAILED));
this.mXmppConnectionService.updateConversationUi();
} else {
this.mXmppConnectionService.markMessage(this.message,
@@ -733,9 +737,12 @@ public class JingleConnection implements Downloadable {
private void fail() {
this.mJingleStatus = JINGLE_STATUS_FAILED;
this.disconnectSocks5Connections();
+ if (this.transport != null && this.transport instanceof JingleInbandTransport) {
+ this.transport.disconnect();
+ }
if (this.message != null) {
if (this.responder.equals(account.getJid())) {
- this.mStatus = Downloadable.STATUS_FAILED;
+ this.message.setDownloadable(new DownloadablePlaceholder(Downloadable.STATUS_FAILED));
this.mXmppConnectionService.updateConversationUi();
} else {
this.mXmppConnectionService.markMessage(this.message,
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 00c97a5f..ee2e04f5 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -320,4 +320,6 @@
<string name="file_offered_for_download">File offered for download</string>
<string name="file">%s file</string>
<string name="cancel_transmission">Cancel transmission</string>
+ <string name="file_transmission_failed">file transmission failed</string>
+ <string name="file_deleted">The file has been deleted</string>
</resources>