From 6b74c0594e95dcedfdbeeb33ef7bdd8b52c1093e Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Fri, 18 Jul 2014 12:44:33 +0200 Subject: [PATCH] show snackbar if conference was not found --- res/values/strings.xml | 2 ++ .../siacs/conversations/entities/MucOptions.java | 6 ++++-- .../conversations/ui/ConversationActivity.java | 2 +- .../conversations/ui/ConversationFragment.java | 14 ++++++++++++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 8cfff3684..af655f678 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -270,4 +270,6 @@ You Edit conference subject Choose contact + Conference not found + Leave diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java index 766300ffd..0bb9b295e 100644 --- a/src/eu/siacs/conversations/entities/MucOptions.java +++ b/src/eu/siacs/conversations/entities/MucOptions.java @@ -10,7 +10,9 @@ import android.annotation.SuppressLint; @SuppressLint("DefaultLocale") public class MucOptions { + public static final int ERROR_NO_ERROR = 0; public static final int ERROR_NICK_IN_USE = 1; + public static final int ERROR_ROOM_NOT_FOUND = 2; public interface OnRenameListener { public void onRename(boolean success); @@ -82,7 +84,7 @@ public class MucOptions { private ArrayList users = new ArrayList(); private Conversation conversation; private boolean isOnline = false; - private int error = 0; + private int error = ERROR_ROOM_NOT_FOUND; private OnRenameListener renameListener = null; private boolean aboutToRename = false; private User self = new User(); @@ -126,7 +128,7 @@ public class MucOptions { user.setName(name); if (name.equals(this.joinnick)) { this.isOnline = true; - this.error = 0; + this.error = ERROR_NO_ERROR; self = user; if (aboutToRename) { if (renameListener!=null) { diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index ae1d218ae..05b7cb4aa 100644 --- a/src/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/eu/siacs/conversations/ui/ConversationActivity.java @@ -568,7 +568,7 @@ public class ConversationActivity extends XmppActivity { return super.onOptionsItemSelected(item); } - private void endConversation(Conversation conversation) { + public void endConversation(Conversation conversation) { conversation.setStatus(Conversation.STATUS_ARCHIVED); paneShouldBeOpen = true; spl.openPane(); diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index 206e40a09..e33e2cf38 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -124,6 +124,14 @@ public class ConversationFragment extends Fragment { startActivity(intent); } }; + + private OnClickListener leaveMuc = new OnClickListener() { + + @Override + public void onClick(View v) { + activity.endConversation(conversation); + } + }; private OnScrollListener mOnScrollListener = new OnScrollListener() { @@ -687,6 +695,7 @@ public class ConversationFragment extends Fragment { if (getView() == null) { return; } + hideSnackbar(); ConversationActivity activity = (ConversationActivity) getActivity(); if (this.conversation != null) { for (Message message : this.conversation.getMessages()) { @@ -715,10 +724,11 @@ public class ConversationFragment extends Fragment { makeFingerprintWarning(conversation.getLatestEncryption()); } } else { - if (conversation.getMucOptions().getError() != 0) { - showSnackbar(R.string.nick_in_use, R.string.edit,clickToMuc); + if (!conversation.getMucOptions().online()) { if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) { 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); } } }