show warning toast if PM is disabled in MUC
This commit is contained in:
parent
5d11fe7dc6
commit
6663eb0a12
|
@ -397,6 +397,11 @@ public class MucOptions {
|
||||||
return self.getRole().ranks(Role.MODERATOR) || (field != null && "1".equals(field.getValue()));
|
return self.getRole().ranks(Role.MODERATOR) || (field != null && "1".equals(field.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean allowPm() {
|
||||||
|
Field field = this.form.getFieldByName("muc#roomconfig_allowpm");
|
||||||
|
return field == null || "1".equals(field.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean participating() {
|
public boolean participating() {
|
||||||
return !online()
|
return !online()
|
||||||
|| self.getRole().ranks(Role.PARTICIPANT)
|
|| self.getRole().ranks(Role.PARTICIPANT)
|
||||||
|
|
|
@ -462,7 +462,11 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.send_private_message:
|
case R.id.send_private_message:
|
||||||
privateMsgInMuc(mConversation,mSelectedUser.getName());
|
if (mConversation.getMucOptions().allowPm()) {
|
||||||
|
privateMsgInMuc(mConversation,mSelectedUser.getName());
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, R.string.private_messages_are_disabled, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.invite:
|
case R.id.invite:
|
||||||
xmppConnectionService.directInvite(mConversation, jid);
|
xmppConnectionService.directInvite(mConversation, jid);
|
||||||
|
|
|
@ -609,34 +609,28 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
messageListAdapter
|
messageListAdapter.setOnContactPictureLongClicked(message -> {
|
||||||
.setOnContactPictureLongClicked(new OnContactPictureLongClicked() {
|
if (message.getStatus() <= Message.STATUS_RECEIVED) {
|
||||||
|
if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
|
||||||
@Override
|
final MucOptions mucOptions = conversation.getMucOptions();
|
||||||
public void onContactPictureLongClicked(Message message) {
|
if (!mucOptions.allowPm()) {
|
||||||
if (message.getStatus() <= Message.STATUS_RECEIVED) {
|
Toast.makeText(activity, R.string.private_messages_are_disabled, Toast.LENGTH_SHORT).show();
|
||||||
if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
|
return;
|
||||||
Jid user = message.getCounterpart();
|
}
|
||||||
if (user != null && !user.isBareJid()) {
|
Jid user = message.getCounterpart();
|
||||||
if (message.getConversation().getMucOptions().isUserInRoom(user)) {
|
if (user != null && !user.isBareJid()) {
|
||||||
privateMessageWith(user);
|
if (mucOptions.isUserInRoom(user)) {
|
||||||
} else {
|
privateMessageWith(user);
|
||||||
Toast.makeText(activity, activity.getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
activity.showQrCode();
|
Toast.makeText(activity, activity.getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
messageListAdapter.setOnQuoteListener(new MessageAdapter.OnQuoteListener() {
|
} else {
|
||||||
|
activity.showQrCode();
|
||||||
@Override
|
|
||||||
public void onQuote(String text) {
|
|
||||||
quoteText(text);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
messageListAdapter.setOnQuoteListener(text -> quoteText(text));
|
||||||
messagesView.setAdapter(messageListAdapter);
|
messagesView.setAdapter(messageListAdapter);
|
||||||
|
|
||||||
registerForContextMenu(messagesView);
|
registerForContextMenu(messagesView);
|
||||||
|
|
|
@ -729,4 +729,5 @@
|
||||||
<string name="copy_to_clipboard">Copy to clipboard</string>
|
<string name="copy_to_clipboard">Copy to clipboard</string>
|
||||||
<string name="message_copied_to_clipboard">Message copied to clipboard</string>
|
<string name="message_copied_to_clipboard">Message copied to clipboard</string>
|
||||||
<string name="message">Message</string>
|
<string name="message">Message</string>
|
||||||
|
<string name="private_messages_are_disabled">Private messages are disabled</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue