aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/ConversationFragment.java
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-08-10 15:27:44 +0200
committeriNPUTmice <daniel@gultsch.de>2014-08-10 15:27:44 +0200
commitb35aa3ed0720f195ec341a1188591052909bdf18 (patch)
treea15759ef8c4006c30bcae497baa7841ee792dd3f /src/eu/siacs/conversations/ui/ConversationFragment.java
parent6de53791b5db4513f662dabbdfe83db29eb4d666 (diff)
added limited private muc chat feature (messages are now properly marked) - long press on user icon will sent private messages. fixed #259
Diffstat (limited to 'src/eu/siacs/conversations/ui/ConversationFragment.java')
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index e0733291..fced1e38 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -17,6 +17,7 @@ import eu.siacs.conversations.ui.EditMessage.OnEnterPressed;
import eu.siacs.conversations.ui.XmppActivity.OnPresenceSelected;
import eu.siacs.conversations.ui.adapter.MessageAdapter;
import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureClicked;
+import eu.siacs.conversations.ui.adapter.MessageAdapter.OnContactPictureLongClicked;
import eu.siacs.conversations.utils.UIHelper;
import android.app.AlertDialog;
import android.app.Fragment;
@@ -160,10 +161,22 @@ public class ConversationFragment extends Fragment {
private void sendMessage() {
- if (mEditMessage.getText().length() < 1)
+ if (mEditMessage.getText().length() < 1) {
+ if (this.conversation.getMode() == Conversation.MODE_MULTI) {
+ conversation.setNextPresence(null);
+ updateChatMsgHint();
+ }
return;
+ }
Message message = new Message(conversation, mEditMessage.getText()
.toString(), conversation.getNextEncryption());
+ if (conversation.getMode() == Conversation.MODE_MULTI) {
+ if (conversation.getNextPresence() != null) {
+ message.setPresence(conversation.getNextPresence());
+ message.setType(Message.TYPE_PRIVATE);
+ conversation.setNextPresence(null);
+ }
+ }
if (conversation.getNextEncryption() == Message.ENCRYPTION_OTR) {
sendOtrMessage(message);
} else if (conversation.getNextEncryption() == Message.ENCRYPTION_PGP) {
@@ -230,7 +243,24 @@ public class ConversationFragment extends Fragment {
@Override
public void onContactPictureClicked(Message message) {
if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
- highlightInConference(message.getCounterpart());
+ if (message.getPresence() != null) {
+ highlightInConference(message.getPresence());
+ } else {
+ highlightInConference(message.getCounterpart());
+ }
+ }
+ }
+ });
+ messageListAdapter.setOnContactPictureLongClicked(new OnContactPictureLongClicked() {
+
+ @Override
+ public void onContactPictureLongClicked(Message message) {
+ if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
+ if (message.getPresence() != null) {
+ privateMessageWith(message.getPresence());
+ } else {
+ privateMessageWith(message.getCounterpart());
+ }
}
}
});
@@ -238,6 +268,12 @@ public class ConversationFragment extends Fragment {
return view;
}
+
+ protected void privateMessageWith(String counterpart) {
+ this.mEditMessage.setHint(getString(R.string.send_private_message_to,counterpart));
+ this.mEditMessage.setText("");
+ this.conversation.setNextPresence(counterpart);
+ }
protected void highlightInConference(String nick) {
String oldString = mEditMessage.getText().toString().trim();
@@ -303,6 +339,9 @@ public class ConversationFragment extends Fragment {
activity.invalidateOptionsMenu();
}
}
+ if (this.conversation.getMode() == Conversation.MODE_MULTI) {
+ conversation.setNextPresence(null);
+ }
}
private void decryptMessage(Message message) {
@@ -406,6 +445,7 @@ public class ConversationFragment extends Fragment {
messagesView.setSelection(size - 1);
}
mEditMessage.setText("");
+ updateChatMsgHint();
}
protected void updateStatusMessages() {