diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-11-10 22:03:23 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-11-10 22:03:23 +0100 |
commit | dc98b3dbd5ce9da547fd62ffeaf98650f5586fd5 (patch) | |
tree | daf019950a6e99b5f3fba32ec9a289e881dc063a /src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | |
parent | 8740b55d37ce62e686afbf5d302fb49498ab6ab7 (diff) |
added snackbar to indicate smp. more error handling in verify activity
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/ConversationFragment.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | 125 |
1 files changed, 59 insertions, 66 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 5a536987..11f2c4fc 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -35,7 +35,6 @@ import net.java.otr4j.session.SessionStatus; import java.util.ArrayList; import java.util.List; -import java.util.Set; import java.util.concurrent.ConcurrentLinkedQueue; import eu.siacs.conversations.R; @@ -53,7 +52,6 @@ import eu.siacs.conversations.ui.XmppActivity.OnValueEdited; 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 eu.siacs.conversations.xmpp.jid.Jid; public class ConversationFragment extends Fragment { @@ -146,6 +144,19 @@ public class ConversationFragment extends Fragment { } } }; + protected OnClickListener clickToVerify = new OnClickListener() { + + @Override + public void onClick(View v) { + if (conversation.getOtrFingerprint() != null) { + Intent intent = new Intent(getActivity(), VerifyOTRActivity.class); + intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT); + intent.putExtra("contact", conversation.getContact().getJid().toBareJid().toString()); + intent.putExtra("account", conversation.getAccount().getJid().toBareJid().toString()); + startActivity(intent); + } + } + }; private ConcurrentLinkedQueue<Message> mEncryptedMessages = new ConcurrentLinkedQueue<>(); private boolean mDecryptJobRunning = false; private OnEditorActionListener mEditorActionListener = new OnEditorActionListener() { @@ -296,7 +307,7 @@ public class ConversationFragment extends Fragment { .getConversation()); } } - } else { + } else { Account account = message.getConversation().getAccount(); Intent intent = new Intent(activity, EditAccountActivity.class); intent.putExtra("jid", account.getJid().toBareJid().toString()); @@ -505,6 +516,39 @@ public class ConversationFragment extends Fragment { activity.switchToContactDetails(contact); } }); + } else if (conversation.getMode() == Conversation.MODE_SINGLE) { + makeFingerprintWarning(); + } else if (!conversation.getMucOptions().online() + && conversation.getAccount().getStatus() == Account.STATUS_ONLINE) { + int error = conversation.getMucOptions().getError(); + switch (error) { + case MucOptions.ERROR_NICK_IN_USE: + showSnackbar(R.string.nick_in_use, R.string.edit, + clickToMuc); + break; + case MucOptions.ERROR_ROOM_NOT_FOUND: + showSnackbar(R.string.conference_not_found, + R.string.leave, leaveMuc); + break; + case MucOptions.ERROR_PASSWORD_REQUIRED: + showSnackbar(R.string.conference_requires_password, + R.string.enter_password, enterPassword); + break; + case MucOptions.ERROR_BANNED: + showSnackbar(R.string.conference_banned, + R.string.leave, leaveMuc); + break; + case MucOptions.ERROR_MEMBERS_ONLY: + showSnackbar(R.string.conference_members_only, + R.string.leave, leaveMuc); + break; + case MucOptions.KICKED_FROM_ROOM: + showSnackbar(R.string.conference_kicked, R.string.join, + joinMuc); + break; + default: + break; + } } for (Message message : this.conversation.getMessages()) { if (message.getEncryption() == Message.ENCRYPTION_PGP @@ -526,44 +570,6 @@ public class ConversationFragment extends Fragment { updateStatusMessages(); } this.messageListAdapter.notifyDataSetChanged(); - if (conversation.getMode() == Conversation.MODE_SINGLE) { - if (messageList.size() >= 1) { - makeFingerprintWarning(); - } - } else { - if (!conversation.getMucOptions().online() - && conversation.getAccount().getStatus() == Account.STATUS_ONLINE) { - int error = conversation.getMucOptions().getError(); - switch (error) { - case MucOptions.ERROR_NICK_IN_USE: - showSnackbar(R.string.nick_in_use, R.string.edit, - clickToMuc); - break; - case MucOptions.ERROR_ROOM_NOT_FOUND: - showSnackbar(R.string.conference_not_found, - R.string.leave, leaveMuc); - break; - case MucOptions.ERROR_PASSWORD_REQUIRED: - showSnackbar(R.string.conference_requires_password, - R.string.enter_password, enterPassword); - break; - case MucOptions.ERROR_BANNED: - showSnackbar(R.string.conference_banned, - R.string.leave, leaveMuc); - break; - case MucOptions.ERROR_MEMBERS_ONLY: - showSnackbar(R.string.conference_members_only, - R.string.leave, leaveMuc); - break; - case MucOptions.KICKED_FROM_ROOM: - showSnackbar(R.string.conference_kicked, R.string.join, - joinMuc); - break; - default: - break; - } - } - } updateChatMsgHint(); if (!activity.isConversationsOverviewVisable() || !activity.isConversationsOverviewHideable()) { activity.xmppConnectionService.markRead(conversation, true); @@ -680,24 +686,11 @@ public class ConversationFragment extends Fragment { } protected void makeFingerprintWarning() { - if (conversation.hasValidOtrSession() - && (!conversation.isMuted()) - && (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) + if (conversation.smpRequested()) { + showSnackbar(R.string.smp_requested, R.string.verify, clickToVerify); + } else if (conversation.hasValidOtrSession() && (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!conversation.isOtrFingerprintVerified())) { - showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify, - new OnClickListener() { - - @Override - public void onClick(View v) { - if (conversation.getOtrFingerprint() != null) { - Intent intent = new Intent(getActivity(),VerifyOTRActivity.class); - intent.setAction(VerifyOTRActivity.ACTION_VERIFY_CONTACT); - intent.putExtra("contact",conversation.getContact().getJid().toBareJid().toString()); - intent.putExtra("account",conversation.getAccount().getJid().toBareJid().toString()); - startActivity(intent); - } - } - }); + showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify, clickToVerify); } } @@ -824,15 +817,15 @@ public class ConversationFragment extends Fragment { final ConversationActivity activity = (ConversationActivity) getActivity(); final XmppConnectionService xmppService = activity.xmppConnectionService; activity.selectPresence(message.getConversation(), - new OnPresenceSelected() { + 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) { |