aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/ui')
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java38
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java35
2 files changed, 45 insertions, 28 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index a6d1be4e..646eb3c0 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -2,6 +2,7 @@ package eu.siacs.conversations.ui;
import java.io.FileNotFoundException;
import java.lang.ref.WeakReference;
+import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
@@ -67,6 +68,7 @@ public class ConversationActivity extends XmppActivity {
private static final int REQUEST_ATTACH_FILE_DIALOG = 0x48502;
private static final int REQUEST_SEND_PGP_IMAGE = 0x53883;
private static final int REQUEST_ATTACH_FILE = 0x73824;
+ public static final int REQUEST_ENCRYPT_MESSAGE = 0x378018;
protected SlidingPaneLayout spl;
@@ -652,6 +654,10 @@ public class ConversationActivity extends XmppActivity {
attachFile();
} else if (requestCode == REQUEST_ANNOUNCE_PGP) {
announcePgp(getSelectedConversation().getAccount(),getSelectedConversation());
+ } else if (requestCode == REQUEST_ENCRYPT_MESSAGE) {
+ encryptTextMessage();
+ } else {
+ Log.d(LOGTAG,"unknown result code:"+requestCode);
}
}
}
@@ -884,4 +890,36 @@ public class ConversationActivity extends XmppActivity {
return bitmapWorkerTaskReference.get();
}
}
+
+ public void encryptTextMessage() {
+ xmppConnectionService.getPgpEngine().encrypt(this.pendingMessage, new OnPgpEngineResult() {
+
+ @Override
+ public void userInputRequried(
+ PendingIntent pi) {
+ activity.runIntent(
+ pi,
+ ConversationActivity.REQUEST_SEND_MESSAGE);
+ }
+
+ @Override
+ public void success() {
+ xmppConnectionService.sendMessage(pendingMessage, null);
+ pendingMessage = null;
+ ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager()
+ .findFragmentByTag("conversation");
+ if (selectedFragment != null) {
+ selectedFragment.clearInputField();
+ }
+ }
+
+ @Override
+ public void error(
+ OpenPgpError openPgpError) {
+ // TODO Auto-generated method
+ // stub
+
+ }
+ });
+ }
}
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index e370deb0..e06c9eeb 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -664,10 +664,10 @@ public class ConversationFragment extends Fragment {
}
protected void sendPgpMessage(final Message message) {
+ activity.pendingMessage = message;
final ConversationActivity activity = (ConversationActivity) getActivity();
final XmppConnectionService xmppService = activity.xmppConnectionService;
final Contact contact = message.getConversation().getContact();
- final Account account = message.getConversation().getAccount();
if (activity.hasPgp()) {
if (contact.getPgpKeyId() != 0) {
xmppService.getPgpEngine().hasKey(contact,
@@ -677,37 +677,12 @@ public class ConversationFragment extends Fragment {
public void userInputRequried(PendingIntent pi) {
activity.runIntent(
pi,
- ConversationActivity.REQUEST_SEND_MESSAGE);
+ ConversationActivity.REQUEST_ENCRYPT_MESSAGE);
}
@Override
public void success() {
- xmppService.getPgpEngine().encrypt(account,
- message, new OnPgpEngineResult() {
-
- @Override
- public void userInputRequried(
- PendingIntent pi) {
- activity.runIntent(
- pi,
- ConversationActivity.REQUEST_SEND_MESSAGE);
- }
-
- @Override
- public void success() {
- xmppService.sendMessage(
- message, null);
- chatMsg.setText("");
- }
-
- @Override
- public void error(
- OpenPgpError openPgpError) {
- // TODO Auto-generated method
- // stub
-
- }
- });
+ activity.encryptTextMessage();
}
@Override
@@ -809,4 +784,8 @@ public class ConversationFragment extends Fragment {
public void setText(String text) {
this.pastedText = text;
}
+
+ public void clearInputField() {
+ this.chatMsg.setText("");
+ }
}