diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-07-18 19:36:29 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-07-18 19:36:29 +0200 |
commit | 9cfb4ee6c3f80e499cd1b4e5d8c6aa9a675cea84 (patch) | |
tree | 0efc988bbb718924b93b879f4b34245265c40c0a /src/eu/siacs/conversations/ui/ConversationFragment.java | |
parent | b561d15720158f12d0fe25ca18534211f9350690 (diff) |
only show muc errors if actually connected
Diffstat (limited to 'src/eu/siacs/conversations/ui/ConversationFragment.java')
-rw-r--r-- | src/eu/siacs/conversations/ui/ConversationFragment.java | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index e33e2cf3..202bab2e 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -8,6 +8,7 @@ import java.util.Set; import net.java.otr4j.session.SessionStatus; import eu.siacs.conversations.R; import eu.siacs.conversations.crypto.PgpEngine; +import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; @@ -61,7 +62,7 @@ public class ConversationFragment extends Fragment { protected ArrayAdapter<Message> messageListAdapter; protected Contact contact; protected BitmapCache mBitmapCache = new BitmapCache(); - + protected int mPrimaryTextColor; protected int mSecondaryTextColor; @@ -113,20 +114,21 @@ public class ConversationFragment extends Fragment { } } }; - + private OnClickListener clickToMuc = new OnClickListener() { @Override public void onClick(View v) { - Intent intent = new Intent(getActivity(), ConferenceDetailsActivity.class); + Intent intent = new Intent(getActivity(), + ConferenceDetailsActivity.class); intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC); intent.putExtra("uuid", conversation.getUuid()); startActivity(intent); } }; - + private OnClickListener leaveMuc = new OnClickListener() { - + @Override public void onClick(View v) { activity.endConversation(conversation); @@ -187,12 +189,12 @@ public class ConversationFragment extends Fragment { mPrimaryTextColor = getResources().getColor(R.color.primarytext); mSecondaryTextColor = getResources().getColor(R.color.secondarytext); - + final View view = inflater.inflate(R.layout.fragment_conversation, container, false); chatMsg = (EditText) view.findViewById(R.id.textinput); chatMsg.setOnClickListener(new OnClickListener() { - + @Override public void onClick(View v) { if (activity.getSlidingPaneLayout().isSlideable()) { @@ -672,7 +674,8 @@ public class ConversationFragment extends Fragment { @Override public void userInputRequried(PendingIntent pi, Message message) { askForPassphraseIntent = pi.getIntentSender(); - showSnackbar(R.string.openpgp_messages_found,R.string.decrypt,clickToDecryptListener); + showSnackbar(R.string.openpgp_messages_found, + R.string.decrypt, clickToDecryptListener); } @Override @@ -724,11 +727,14 @@ public class ConversationFragment extends Fragment { makeFingerprintWarning(conversation.getLatestEncryption()); } } else { - if (!conversation.getMucOptions().online()) { + if (!conversation.getMucOptions().online() + && conversation.getAccount().getStatus() == Account.STATUS_ONLINE) { if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) { - showSnackbar(R.string.nick_in_use, R.string.edit,clickToMuc); + showSnackbar(R.string.nick_in_use, R.string.edit, + clickToMuc); } else if (conversation.getMucOptions().getError() == MucOptions.ERROR_ROOM_NOT_FOUND) { - showSnackbar(R.string.conference_not_found,R.string.leave,leaveMuc); + showSnackbar(R.string.conference_not_found, + R.string.leave, leaveMuc); } } } @@ -783,28 +789,31 @@ public class ConversationFragment extends Fragment { && (conversation.hasValidOtrSession() && (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints .contains(conversation.getOtrFingerprint())))) { - showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify, new OnClickListener() { + showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify, + new OnClickListener() { - @Override - public void onClick(View v) { - if (conversation.getOtrFingerprint() != null) { - AlertDialog dialog = UIHelper.getVerifyFingerprintDialog( - (ConversationActivity) getActivity(), conversation, - snackbar); - dialog.show(); - } - } - }); + @Override + public void onClick(View v) { + if (conversation.getOtrFingerprint() != null) { + AlertDialog dialog = UIHelper + .getVerifyFingerprintDialog( + (ConversationActivity) getActivity(), + conversation, snackbar); + dialog.show(); + } + } + }); } } - - protected void showSnackbar(int message, int action, OnClickListener clickListener) { + + protected void showSnackbar(int message, int action, + OnClickListener clickListener) { snackbar.setVisibility(View.VISIBLE); snackbarMessage.setText(message); snackbarAction.setText(action); snackbarAction.setOnClickListener(clickListener); } - + protected void hideSnackbar() { snackbar.setVisibility(View.GONE); } |