show warning snackbar before joining anon-non-private room. fixes #3306

This commit is contained in:
Daniel Gultsch 2018-12-09 18:25:11 +01:00
parent 5b681553df
commit 1a1bfb3246
4 changed files with 23 additions and 1 deletions

View File

@ -676,7 +676,8 @@ public class MucOptions {
SHUTDOWN,
DESTROYED,
INVALID_NICK,
UNKNOWN
UNKNOWN,
NON_ANONYMOUS
}
private interface OnEventListener {

View File

@ -2298,6 +2298,13 @@ public class XmppConnectionService extends Service {
private void join(Conversation conversation) {
Account account = conversation.getAccount();
final MucOptions mucOptions = conversation.getMucOptions();
if (mucOptions.nonanonymous() && !mucOptions.membersOnly() && !conversation.getBooleanAttribute("accept_non_anonymous", false)) {
mucOptions.setError(MucOptions.Error.NON_ANONYMOUS);
updateConversationUi();
return;
}
final Jid joinJid = mucOptions.getSelf().getFullJid();
Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": joining conversation " + joinJid.toString());
PresencePacket packet = mPresenceGenerator.selfPresence(account, Presence.Status.ONLINE, mucOptions.nonanonymous() || onConferenceJoined != null);

View File

@ -187,6 +187,16 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
activity.xmppConnectionService.joinMuc(conversation);
}
};
private OnClickListener acceptJoin = new OnClickListener() {
@Override
public void onClick(View v) {
conversation.setAttribute("accept_non_anonymous",true);
activity.xmppConnectionService.updateConversation(conversation);
activity.xmppConnectionService.joinMuc(conversation);
}
};
private OnClickListener enterPassword = new OnClickListener() {
@Override
@ -2119,6 +2129,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
case DESTROYED:
showSnackbar(R.string.conference_destroyed, R.string.leave, leaveMuc);
break;
case NON_ANONYMOUS:
showSnackbar(R.string.group_chat_will_make_your_jabber_id_public, R.string.join, acceptJoin);
break;
default:
hideSnackbar();
break;

View File

@ -803,4 +803,5 @@
<string name="install_orbot">Install Orbot</string>
<string name="start_orbot">Start Orbot</string>
<string name="no_market_app_installed">No market app installed.</string>
<string name="group_chat_will_make_your_jabber_id_public">This group chat will make your Jabber ID public</string>
</resources>