aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-11-10 01:24:35 +0100
committeriNPUTmice <daniel@gultsch.de>2014-11-10 01:24:35 +0100
commit89ee999e1b969a935d5b8ae9d7155ca9afe96389 (patch)
tree3658c68b199eb7e325c0ebd7810381d078a9859f /src/main/java/eu/siacs/conversations/ui
parent26b4788733d9e9e5267bb6b54bb847757c7c25e5 (diff)
more refactoring for presence selection. removed getTo, getFrom and getJid from Element
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java23
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java14
2 files changed, 22 insertions, 15 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index d2ba6f519..63d740c32 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -825,21 +825,16 @@ public class ConversationFragment extends Fragment {
protected void sendOtrMessage(final Message message) {
final ConversationActivity activity = (ConversationActivity) getActivity();
final XmppConnectionService xmppService = activity.xmppConnectionService;
- if (conversation.hasValidOtrSession()) {
- activity.xmppConnectionService.sendMessage(message);
- messageSent();
- } else {
- activity.selectPresence(message.getConversation(),
- new OnPresenceSelected() {
+ activity.selectPresence(message.getConversation(),
+ new OnPresenceSelected() {
- @Override
- public void onPresenceSelected() {
- message.setCounterpart(conversation.getNextCounterpart());
- xmppService.sendMessage(message);
- messageSent();
- }
- });
- }
+ @Override
+ public void onPresenceSelected() {
+ message.setCounterpart(conversation.getNextCounterpart());
+ xmppService.sendMessage(message);
+ messageSent();
+ }
+ });
}
public void appendText(String text) {
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index e8a858c0b..78d7956ae 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -48,6 +48,8 @@ import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import net.java.otr4j.session.SessionID;
+
import java.io.FileNotFoundException;
import java.lang.ref.WeakReference;
import java.util.Hashtable;
@@ -452,7 +454,17 @@ public abstract class XmppActivity extends Activity {
public void selectPresence(final Conversation conversation,
final OnPresenceSelected listener) {
final Contact contact = conversation.getContact();
- if (!contact.showInRoster()) {
+ if (conversation.hasValidOtrSession()) {
+ SessionID id = conversation.getOtrSession().getSessionID();
+ Jid jid;
+ try {
+ jid = Jid.fromString(id.getAccountID() + "/" + id.getUserID());
+ } catch (InvalidJidException e) {
+ jid = null;
+ }
+ conversation.setNextCounterpart(jid);
+ listener.onPresenceSelected();
+ } else if (!contact.showInRoster()) {
showAddToRosterDialog(conversation);
} else {
Presences presences = contact.getPresences();