fixed description in notifications and conversation overview
This commit is contained in:
parent
e0f012dba1
commit
47d44448f3
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
|
@ -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)) {
|
||||
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();
|
||||
|
|
|
@ -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,12 +712,17 @@ public class XmppConnectionService extends Service {
|
|||
} else {
|
||||
if (message.getConversation().getOtrSession()
|
||||
.getSessionStatus() == SessionStatus.ENCRYPTED) {
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (message.getType() == Message.TYPE_TEXT) {
|
||||
|
@ -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() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
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);
|
||||
|
|
|
@ -505,8 +505,12 @@ 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) {
|
||||
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);
|
||||
} else if (item.getType() == Message.TYPE_FILE && item.getEncryption() != Message.ENCRYPTION_PGP && item.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue