From f79d92ab67206254df1c0c348898d60c3a741e0e Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 20 May 2014 11:44:43 +0200 Subject: highlight people in conferences by clicken on their picture --- .../conversations/ui/ConversationFragment.java | 41 ++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'src/eu/siacs') diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index b551e6ad..7ab01936 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -392,20 +392,17 @@ public class ConversationFragment extends Fragment { if (type == RECIEVED) { if (item.getConversation().getMode() == Conversation.MODE_MULTI) { - if (item.getCounterpart() != null) { - viewHolder.contact_picture - .setImageBitmap(mBitmapCache.get(item - .getCounterpart(), null, - getActivity() - .getApplicationContext())); - } else { - viewHolder.contact_picture - .setImageBitmap(mBitmapCache.get( - item.getConversation().getName( - useSubject), null, - getActivity() - .getApplicationContext())); - } + viewHolder.contact_picture.setImageBitmap(mBitmapCache + .get(item.getCounterpart(), null, getActivity() + .getApplicationContext())); + viewHolder.contact_picture + .setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + highlightInConference(item.getCounterpart()); + } + }); } } @@ -461,6 +458,22 @@ public class ConversationFragment extends Fragment { return view; } + protected void highlightInConference(String nick) { + if (chatMsg.getText().toString().isEmpty()) { + chatMsg.setText(nick+": "); + } else { + String oldString = chatMsg.getText().toString(); + if (oldString.endsWith(" ")) { + chatMsg.setText(oldString+nick+" "); + } else { + chatMsg.setText(oldString+" "+nick+" "); + } + } + int position = chatMsg.length(); + Editable etext = chatMsg.getText(); + Selection.setSelection(etext, position); + } + protected Bitmap findSelfPicture() { SharedPreferences sharedPref = PreferenceManager .getDefaultSharedPreferences(getActivity() -- cgit v1.2.3