aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/ConversationActivity.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-05-12 14:59:46 +0200
committerDaniel Gultsch <daniel@gultsch.de>2014-05-12 14:59:46 +0200
commit3455d10a4a87916bfe5da52ca9c401dafa8d5155 (patch)
treee7b6cc4520ad0dd64e348d2e9a27ffe7a81db696 /src/eu/siacs/conversations/ui/ConversationActivity.java
parent4d0bf7971ec321a55f180b833b033ceaa6635fdf (diff)
Better error handling if attach file doesnt work (on permission denied)
and unified encrypted and unencrypted file attachment
Diffstat (limited to 'src/eu/siacs/conversations/ui/ConversationActivity.java')
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java54
1 files changed, 35 insertions, 19 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 234730fc..88728245 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -9,7 +9,6 @@ import java.util.List;
import org.openintents.openpgp.OpenPgpError;
import eu.siacs.conversations.R;
-import eu.siacs.conversations.crypto.OnPgpEngineResult;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
@@ -354,7 +353,7 @@ public class ConversationActivity extends XmppActivity {
if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
if (hasPgp()) {
if (conversation.getContact().getPgpKeyId()!=0) {
- xmppConnectionService.getPgpEngine().hasKey(conversation.getContact(), new OnPgpEngineResult() {
+ xmppConnectionService.getPgpEngine().hasKey(conversation.getContact(), new UiCallback() {
@Override
public void userInputRequried(PendingIntent pi) {
@@ -367,7 +366,7 @@ public class ConversationActivity extends XmppActivity {
}
@Override
- public void error(OpenPgpError openPgpError) {
+ public void error(int error) {
// TODO Auto-generated method stub
}
@@ -671,10 +670,26 @@ public class ConversationActivity extends XmppActivity {
} else if (requestCode == REQUEST_ATTACH_FILE_DIALOG) {
prepareImageToast = Toast.makeText(getApplicationContext(), getText(R.string.preparing_image), Toast.LENGTH_LONG);
final Conversation conversation = getSelectedConversation();
- String presence = conversation.getNextPresence();
if (conversation.getNextEncryption() == Message.ENCRYPTION_NONE) {
prepareImageToast.show();
- xmppConnectionService.attachImageToConversation(conversation, presence, data.getData());
+ this.pendingMessage = xmppConnectionService.attachImageToConversation(conversation, data.getData(),new UiCallback() {
+
+ @Override
+ public void userInputRequried(PendingIntent pi) {
+
+ }
+
+ @Override
+ public void success() {
+ sendPendingImageMessage();
+ }
+
+ @Override
+ public void error(int error) {
+ pendingMessage = null;
+ displayErrorDialog(error);
+ }
+ });
} else if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
prepareImageToast.show();
attachPgpFile(conversation,data.getData());
@@ -696,8 +711,7 @@ public class ConversationActivity extends XmppActivity {
}
private void attachPgpFile(Conversation conversation, Uri uri) {
- String presence = conversation.getNextPresence();
- pendingMessage = xmppConnectionService.attachEncryptedImageToConversation(conversation, presence, uri, new OnPgpEngineResult() {
+ pendingMessage = xmppConnectionService.attachImageToConversation(conversation, uri, new UiCallback() {
@Override
public void userInputRequried(PendingIntent pi) {
@@ -706,20 +720,25 @@ public class ConversationActivity extends XmppActivity {
@Override
public void success() {
- pendingMessage.getConversation().getMessages().add(pendingMessage);
- xmppConnectionService.databaseBackend.createMessage(pendingMessage);
- xmppConnectionService.sendMessage(pendingMessage, null);
- xmppConnectionService.updateUi(pendingMessage.getConversation(), false);
- pendingMessage = null;
+ sendPendingImageMessage();
}
@Override
- public void error(OpenPgpError openPgpError) {
- Log.d(LOGTAG,"pgp error"+openPgpError.getMessage());
+ public void error(int error) {
+ pendingMessage = null;
+ displayErrorDialog(error);
}
});
}
+ private void sendPendingImageMessage() {
+ pendingMessage.getConversation().getMessages().add(pendingMessage);
+ xmppConnectionService.databaseBackend.createMessage(pendingMessage);
+ xmppConnectionService.sendMessage(pendingMessage, null);
+ xmppConnectionService.updateUi(pendingMessage.getConversation(), false);
+ pendingMessage = null;
+ }
+
public void updateConversationList() {
conversationList.clear();
conversationList.addAll(xmppConnectionService.getConversations());
@@ -925,7 +944,7 @@ public class ConversationActivity extends XmppActivity {
}
public void encryptTextMessage() {
- xmppConnectionService.getPgpEngine().encrypt(this.pendingMessage, new OnPgpEngineResult() {
+ xmppConnectionService.getPgpEngine().encrypt(this.pendingMessage, new UiCallback() {
@Override
public void userInputRequried(
@@ -947,10 +966,7 @@ public class ConversationActivity extends XmppActivity {
}
@Override
- public void error(
- OpenPgpError openPgpError) {
- // TODO Auto-generated method
- // stub
+ public void error(int error) {
}
});