From 0b86f65bdc8dfd979be752798b7cbc3c28317c53 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sat, 20 Sep 2014 16:02:49 +0200 Subject: fixed #470 --- .../conversations/ui/ConversationFragment.java | 32 ++++++++---- .../conversations/ui/ManageAccountActivity.java | 8 +-- src/eu/siacs/conversations/ui/XmppActivity.java | 6 +++ .../conversations/ui/adapter/MessageAdapter.java | 57 ++++++++++++---------- 4 files changed, 60 insertions(+), 43 deletions(-) (limited to 'src/eu/siacs/conversations') diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index ea0a6f14..299bf281 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -275,11 +275,23 @@ public class ConversationFragment extends Fragment { @Override public void onContactPictureClicked(Message message) { - if (message.getConversation().getMode() == Conversation.MODE_MULTI) { - if (message.getPresence() != null) { - highlightInConference(message.getPresence()); + if (message.getStatus() <= Message.STATUS_RECEIVED) { + if (message.getConversation().getMode() == Conversation.MODE_MULTI) { + if (message.getPresence() != null) { + highlightInConference(message.getPresence()); + } else { + highlightInConference(message + .getCounterpart()); + } } else { - highlightInConference(message.getCounterpart()); + Contact contact = message.getConversation() + .getContact(); + if (contact.showInRoster()) { + activity.switchToContactDetails(contact); + } else { + activity.showAddToRosterDialog(message + .getConversation()); + } } } } @@ -289,11 +301,13 @@ public class ConversationFragment extends Fragment { @Override public void onContactPictureLongClicked(Message message) { - if (message.getConversation().getMode() == Conversation.MODE_MULTI) { - if (message.getPresence() != null) { - privateMessageWith(message.getPresence()); - } else { - privateMessageWith(message.getCounterpart()); + if (message.getStatus() <= Message.STATUS_RECEIVED) { + if (message.getConversation().getMode() == Conversation.MODE_MULTI) { + if (message.getPresence() != null) { + privateMessageWith(message.getPresence()); + } else { + privateMessageWith(message.getCounterpart()); + } } } } diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java index c57121da..ca17eb0d 100644 --- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java +++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java @@ -62,7 +62,7 @@ public class ManageAccountActivity extends XmppActivity { @Override public void onItemClick(AdapterView arg0, View view, int position, long arg3) { - editAccount(accountList.get(position)); + switchToAccount(accountList.get(position)); } }); registerForContextMenu(accountListView); @@ -163,12 +163,6 @@ public class ManageAccountActivity extends XmppActivity { } } - private void editAccount(Account account) { - Intent intent = new Intent(this, EditAccountActivity.class); - intent.putExtra("jid", account.getJid()); - startActivity(intent); - } - private void publishAvatar(Account account) { Intent intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java index 4ee51580..351462ae 100644 --- a/src/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/eu/siacs/conversations/ui/XmppActivity.java @@ -247,6 +247,12 @@ public abstract class XmppActivity extends Activity { intent.putExtra("contact", contact.getJid()); startActivity(intent); } + + public void switchToAccount(Account account) { + Intent intent = new Intent(this, EditAccountActivity.class); + intent.putExtra("jid", account.getJid()); + startActivity(intent); + } protected void inviteToConversation(Conversation conversation) { Intent intent = new Intent(getApplicationContext(), diff --git a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 876fbfe7..acf6ac3f 100644 --- a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -406,6 +406,36 @@ public class MessageAdapter extends ArrayAdapter { return view; } + if (viewHolder.contact_picture != null) { + viewHolder.contact_picture + .setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + if (MessageAdapter.this.mOnContactPictureClickedListener != null) { + MessageAdapter.this.mOnContactPictureClickedListener + .onContactPictureClicked(item); + ; + } + + } + }); + viewHolder.contact_picture + .setOnLongClickListener(new OnLongClickListener() { + + @Override + public boolean onLongClick(View v) { + if (MessageAdapter.this.mOnContactPictureLongClickedListener != null) { + MessageAdapter.this.mOnContactPictureLongClickedListener + .onContactPictureLongClicked(item); + return true; + } else { + return false; + } + } + }); + } + if (type == RECEIVED) { if (item.getConversation().getMode() == Conversation.MODE_MULTI) { Contact contact = item.getContact(); @@ -420,33 +450,6 @@ public class MessageAdapter extends ArrayAdapter { viewHolder.contact_picture.setImageBitmap(mBitmapCache.get( name, getContext())); } - viewHolder.contact_picture - .setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - if (MessageAdapter.this.mOnContactPictureClickedListener != null) { - MessageAdapter.this.mOnContactPictureClickedListener - .onContactPictureClicked(item); - ; - } - - } - }); - viewHolder.contact_picture - .setOnLongClickListener(new OnLongClickListener() { - - @Override - public boolean onLongClick(View v) { - if (MessageAdapter.this.mOnContactPictureLongClickedListener != null) { - MessageAdapter.this.mOnContactPictureLongClickedListener - .onContactPictureLongClicked(item); - return true; - } else { - return false; - } - } - }); } } -- cgit v1.2.3