show snackbar if conference was not found

This commit is contained in:
iNPUTmice 2014-07-18 12:44:33 +02:00
parent 38a9242955
commit 6b74c0594e
4 changed files with 19 additions and 5 deletions

View file

@ -270,4 +270,6 @@
<string name="you">You</string> <string name="you">You</string>
<string name="action_edit_subject">Edit conference subject</string> <string name="action_edit_subject">Edit conference subject</string>
<string name="title_activity_choose_contact">Choose contact</string> <string name="title_activity_choose_contact">Choose contact</string>
<string name="conference_not_found">Conference not found</string>
<string name="leave">Leave</string>
</resources> </resources>

View file

@ -10,7 +10,9 @@ import android.annotation.SuppressLint;
@SuppressLint("DefaultLocale") @SuppressLint("DefaultLocale")
public class MucOptions { 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_NICK_IN_USE = 1;
public static final int ERROR_ROOM_NOT_FOUND = 2;
public interface OnRenameListener { public interface OnRenameListener {
public void onRename(boolean success); public void onRename(boolean success);
@ -82,7 +84,7 @@ public class MucOptions {
private ArrayList<User> users = new ArrayList<User>(); private ArrayList<User> users = new ArrayList<User>();
private Conversation conversation; private Conversation conversation;
private boolean isOnline = false; private boolean isOnline = false;
private int error = 0; private int error = ERROR_ROOM_NOT_FOUND;
private OnRenameListener renameListener = null; private OnRenameListener renameListener = null;
private boolean aboutToRename = false; private boolean aboutToRename = false;
private User self = new User(); private User self = new User();
@ -126,7 +128,7 @@ public class MucOptions {
user.setName(name); user.setName(name);
if (name.equals(this.joinnick)) { if (name.equals(this.joinnick)) {
this.isOnline = true; this.isOnline = true;
this.error = 0; this.error = ERROR_NO_ERROR;
self = user; self = user;
if (aboutToRename) { if (aboutToRename) {
if (renameListener!=null) { if (renameListener!=null) {

View file

@ -568,7 +568,7 @@ public class ConversationActivity extends XmppActivity {
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
private void endConversation(Conversation conversation) { public void endConversation(Conversation conversation) {
conversation.setStatus(Conversation.STATUS_ARCHIVED); conversation.setStatus(Conversation.STATUS_ARCHIVED);
paneShouldBeOpen = true; paneShouldBeOpen = true;
spl.openPane(); spl.openPane();

View file

@ -124,6 +124,14 @@ public class ConversationFragment extends Fragment {
startActivity(intent); startActivity(intent);
} }
}; };
private OnClickListener leaveMuc = new OnClickListener() {
@Override
public void onClick(View v) {
activity.endConversation(conversation);
}
};
private OnScrollListener mOnScrollListener = new OnScrollListener() { private OnScrollListener mOnScrollListener = new OnScrollListener() {
@ -687,6 +695,7 @@ public class ConversationFragment extends Fragment {
if (getView() == null) { if (getView() == null) {
return; return;
} }
hideSnackbar();
ConversationActivity activity = (ConversationActivity) getActivity(); ConversationActivity activity = (ConversationActivity) getActivity();
if (this.conversation != null) { if (this.conversation != null) {
for (Message message : this.conversation.getMessages()) { for (Message message : this.conversation.getMessages()) {
@ -715,10 +724,11 @@ public class ConversationFragment extends Fragment {
makeFingerprintWarning(conversation.getLatestEncryption()); makeFingerprintWarning(conversation.getLatestEncryption());
} }
} else { } else {
if (conversation.getMucOptions().getError() != 0) { if (!conversation.getMucOptions().online()) {
showSnackbar(R.string.nick_in_use, R.string.edit,clickToMuc);
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) {
showSnackbar(R.string.conference_not_found,R.string.leave,leaveMuc);
} }
} }
} }