only show muc errors if actually connected

This commit is contained in:
iNPUTmice 2014-07-18 19:36:29 +02:00
parent b561d15720
commit 9cfb4ee6c3

View file

@ -8,6 +8,7 @@ import java.util.Set;
import net.java.otr4j.session.SessionStatus; import net.java.otr4j.session.SessionStatus;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.PgpEngine; import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message;
@ -118,7 +119,8 @@ public class ConversationFragment extends Fragment {
@Override @Override
public void onClick(View v) { 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.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid()); intent.putExtra("uuid", conversation.getUuid());
startActivity(intent); startActivity(intent);
@ -672,7 +674,8 @@ public class ConversationFragment extends Fragment {
@Override @Override
public void userInputRequried(PendingIntent pi, Message message) { public void userInputRequried(PendingIntent pi, Message message) {
askForPassphraseIntent = pi.getIntentSender(); askForPassphraseIntent = pi.getIntentSender();
showSnackbar(R.string.openpgp_messages_found,R.string.decrypt,clickToDecryptListener); showSnackbar(R.string.openpgp_messages_found,
R.string.decrypt, clickToDecryptListener);
} }
@Override @Override
@ -724,11 +727,14 @@ public class ConversationFragment extends Fragment {
makeFingerprintWarning(conversation.getLatestEncryption()); makeFingerprintWarning(conversation.getLatestEncryption());
} }
} else { } else {
if (!conversation.getMucOptions().online()) { if (!conversation.getMucOptions().online()
&& conversation.getAccount().getStatus() == Account.STATUS_ONLINE) {
if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) { 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) { } 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,22 +789,25 @@ public class ConversationFragment extends Fragment {
&& (conversation.hasValidOtrSession() && (conversation.hasValidOtrSession()
&& (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints && (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints
.contains(conversation.getOtrFingerprint())))) { .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 @Override
public void onClick(View v) { public void onClick(View v) {
if (conversation.getOtrFingerprint() != null) { if (conversation.getOtrFingerprint() != null) {
AlertDialog dialog = UIHelper.getVerifyFingerprintDialog( AlertDialog dialog = UIHelper
(ConversationActivity) getActivity(), conversation, .getVerifyFingerprintDialog(
snackbar); (ConversationActivity) getActivity(),
dialog.show(); 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); snackbar.setVisibility(View.VISIBLE);
snackbarMessage.setText(message); snackbarMessage.setText(message);
snackbarAction.setText(action); snackbarAction.setText(action);