aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java26
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java19
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java24
3 files changed, 34 insertions, 35 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 58e29d300..cc0227287 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -190,7 +190,7 @@ public class ConversationFragment extends Fragment {
}
if (mEditMessage.getText().length() < 1) {
if (this.conversation.getMode() == Conversation.MODE_MULTI) {
- conversation.setNextPresence(null);
+ conversation.setNextCounterpart(null);
updateChatMsgHint();
}
return;
@@ -199,10 +199,10 @@ public class ConversationFragment extends Fragment {
.toString(), conversation.getNextEncryption(activity
.forceEncryption()));
if (conversation.getMode() == Conversation.MODE_MULTI) {
- if (conversation.getNextPresence() != null) {
- message.setPresence(conversation.getNextPresence());
+ if (conversation.getNextCounterpart() != null) {
+ message.setCounterpart(conversation.getNextCounterpart());
message.setType(Message.TYPE_PRIVATE);
- conversation.setNextPresence(null);
+ conversation.setNextCounterpart(null);
}
}
if (conversation.getNextEncryption(activity.forceEncryption()) == Message.ENCRYPTION_OTR) {
@@ -216,10 +216,10 @@ public class ConversationFragment extends Fragment {
public void updateChatMsgHint() {
if (conversation.getMode() == Conversation.MODE_MULTI
- && conversation.getNextPresence() != null) {
+ && conversation.getNextCounterpart() != null) {
this.mEditMessage.setHint(getString(
R.string.send_private_message_to,
- conversation.getNextPresence()));
+ conversation.getNextCounterpart().getResourcepart()));
} else {
switch (conversation.getNextEncryption(activity.forceEncryption())) {
case Message.ENCRYPTION_NONE:
@@ -279,8 +279,8 @@ public class ConversationFragment extends Fragment {
public void onContactPictureClicked(Message message) {
if (message.getStatus() <= Message.STATUS_RECEIVED) {
if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
- if (message.getPresence() != null) {
- highlightInConference(message.getPresence().getResourcepart());
+ if (message.getCounterpart() != null) {
+ highlightInConference(message.getCounterpart().getResourcepart());
} else {
highlightInConference(message
.getContact().getDisplayName());
@@ -310,9 +310,7 @@ public class ConversationFragment extends Fragment {
public void onContactPictureLongClicked(Message message) {
if (message.getStatus() <= Message.STATUS_RECEIVED) {
if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
- if (message.getPresence() != null) {
- privateMessageWith(message.getPresence());
- } else {
+ if (message.getCounterpart() != null) {
privateMessageWith(message.getCounterpart());
}
}
@@ -431,7 +429,7 @@ public class ConversationFragment extends Fragment {
protected void privateMessageWith(final Jid counterpart) {
this.mEditMessage.setText("");
- this.conversation.setNextPresence(counterpart.toString());
+ this.conversation.setNextCounterpart(counterpart);
updateChatMsgHint();
}
@@ -465,7 +463,7 @@ public class ConversationFragment extends Fragment {
this.activity = (ConversationActivity) getActivity();
this.conversation = conversation;
if (this.conversation.getMode() == Conversation.MODE_MULTI) {
- this.conversation.setNextPresence(null);
+ this.conversation.setNextCounterpart(null);
}
this.mEditMessage.setText("");
this.mEditMessage.append(this.conversation.getNextMessage());
@@ -835,7 +833,7 @@ public class ConversationFragment extends Fragment {
@Override
public void onPresenceSelected() {
- message.setPresence(conversation.getNextPresence());
+ message.setCounterpart(conversation.getNextCounterpart());
xmppService.sendMessage(message);
messageSent();
}
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index d2cf582b7..4bd64411d 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -65,6 +65,7 @@ import eu.siacs.conversations.services.AvatarService;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
import eu.siacs.conversations.utils.ExceptionHelper;
+import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
public abstract class XmppActivity extends Activity {
@@ -399,7 +400,7 @@ public abstract class XmppActivity extends Activity {
@Override
public void onClick(DialogInterface dialog, int which) {
- conversation.setNextPresence(null);
+ conversation.setNextCounterpart(null);
if (listener != null) {
listener.onPresenceSelected();
}
@@ -450,7 +451,7 @@ public abstract class XmppActivity extends Activity {
public void selectPresence(final Conversation conversation,
final OnPresenceSelected listener) {
- Contact contact = conversation.getContact();
+ final Contact contact = conversation.getContact();
if (!contact.showInRoster()) {
showAddToRosterDialog(conversation);
} else {
@@ -464,12 +465,16 @@ public abstract class XmppActivity extends Activity {
|| !contact.getOption(Contact.Options.FROM)) {
warnMutalPresenceSubscription(conversation, listener);
} else {
- conversation.setNextPresence(null);
+ conversation.setNextCounterpart(null);
listener.onPresenceSelected();
}
} else if (presences.size() == 1) {
String presence = presences.asStringArray()[0];
- conversation.setNextPresence(presence);
+ try {
+ conversation.setNextCounterpart(Jid.fromParts(contact.getJid().getLocalpart(),contact.getJid().getDomainpart(),presence));
+ } catch (InvalidJidException e) {
+ conversation.setNextCounterpart(null);
+ }
listener.onPresenceSelected();
} else {
final StringBuilder presence = new StringBuilder();
@@ -500,7 +505,11 @@ public abstract class XmppActivity extends Activity {
@Override
public void onClick(DialogInterface dialog, int which) {
- conversation.setNextPresence(presence.toString());
+ try {
+ conversation.setNextCounterpart(Jid.fromParts(contact.getJid().getLocalpart(),contact.getJid().getDomainpart(),presence.toString()));
+ } catch (InvalidJidException e) {
+ conversation.setNextCounterpart(null);
+ }
listener.onPresenceSelected();
}
});
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 465d7bc32..cefe42a77 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -135,16 +135,10 @@ public class MessageAdapter extends ArrayAdapter<Message> {
Contact contact = message.getContact();
if (contact != null) {
info = contact.getDisplayName();
+ } else if (message.getCounterpart() != null) {
+ info = message.getCounterpart().getResourcepart();
} else {
- if (message.getPresence() != null) {
- if (message.getPresence().isBareJid()) {
- info = message.getPresence().toString();
- } else {
- info = message.getPresence().getResourcepart();
- }
- } else {
- info = message.getCounterpart().toString();
- }
+ info = "";
}
}
break;
@@ -232,11 +226,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
privateMarker = activity
.getString(R.string.private_message);
} else {
- final Jid to;
- if (message.getPresence() != null) {
- to = message.getPresence();
+ final String to;
+ if (message.getCounterpart() != null) {
+ to = message.getCounterpart().getResourcepart();
} else {
- to = message.getCounterpart();
+ to = "";
}
privateMarker = activity.getString(R.string.private_message_to, to);
}
@@ -417,9 +411,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
if (contact != null) {
viewHolder.contact_picture.setImageBitmap(activity.avatarService().get(contact, activity.getPixel(48)));
} else if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
- final Jid name = item.getPresence() != null ? item.getPresence() : item.getCounterpart();
- viewHolder.contact_picture.setImageBitmap(activity.avatarService().get(
- name.isBareJid() ? name.toString() : name.getResourcepart(),
+ viewHolder.contact_picture.setImageBitmap(activity.avatarService().get(item.getCounterpart().getResourcepart(),
activity.getPixel(48)));
}
} else if (type == SENT) {