aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-01-21 14:32:22 +0100
committerChristian Schneppe <christian@pix-art.de>2018-01-21 14:32:22 +0100
commit64bee71d95b2e700938c97dbf4a7daf4ee139e1f (patch)
tree4ddb668c5ac36756a798ff75886b92a2474b68cf /src/main/java/de/pixart/messenger
parent6e63c99120f556c541e5a41b727866ee3123c911 (diff)
show warning toast if PM is disabled in MUC
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/entities/MucOptions.java5
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java6
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java41
3 files changed, 27 insertions, 25 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java
index e64f78648..12987cfc9 100644
--- a/src/main/java/de/pixart/messenger/entities/MucOptions.java
+++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java
@@ -397,6 +397,11 @@ public class MucOptions {
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() {
return !online()
|| self.getRole().ranks(Role.PARTICIPANT)
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
index d7f022d3e..55a7ad85e 100644
--- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
@@ -477,7 +477,11 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
return true;
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;
case R.id.invite:
xmppConnectionService.directInvite(mConversation, jid);
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 90a3057ba..72ab218e2 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -77,7 +77,6 @@ import de.pixart.messenger.ui.XmppActivity.OnPresenceSelected;
import de.pixart.messenger.ui.XmppActivity.OnValueEdited;
import de.pixart.messenger.ui.adapter.MessageAdapter;
import de.pixart.messenger.ui.adapter.MessageAdapter.OnContactPictureClicked;
-import de.pixart.messenger.ui.adapter.MessageAdapter.OnContactPictureLongClicked;
import de.pixart.messenger.ui.widget.EditMessage;
import de.pixart.messenger.utils.MessageUtils;
import de.pixart.messenger.utils.NickValidityChecker;
@@ -638,34 +637,28 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
}
}
});
- messageListAdapter
- .setOnContactPictureLongClicked(new OnContactPictureLongClicked() {
-
- @Override
- public void onContactPictureLongClicked(Message message) {
- if (message.getStatus() <= Message.STATUS_RECEIVED) {
- if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
- Jid user = message.getCounterpart();
- if (user != null && !user.isBareJid()) {
- if (message.getConversation().getMucOptions().isUserInRoom(user)) {
- privateMessageWith(user);
- } else {
- Toast.makeText(activity, activity.getString(R.string.user_has_left_conference, user.getResourcepart()), Toast.LENGTH_SHORT).show();
- }
- }
- }
+ messageListAdapter.setOnContactPictureLongClicked(message -> {
+ if (message.getStatus() <= Message.STATUS_RECEIVED) {
+ if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
+ final MucOptions mucOptions = conversation.getMucOptions();
+ if (!mucOptions.allowPm()) {
+ Toast.makeText(activity, R.string.private_messages_are_disabled, Toast.LENGTH_SHORT).show();
+ return;
+ }
+ Jid user = message.getCounterpart();
+ if (user != null && !user.isBareJid()) {
+ if (mucOptions.isUserInRoom(user)) {
+ privateMessageWith(user);
} 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() {
-
- @Override
- public void onQuote(String text) {
- quoteText(text);
+ }
+ } else {
+ activity.showQrCode();
}
});
+ messageListAdapter.setOnQuoteListener(text -> quoteText(text));
messagesView.setAdapter(messageListAdapter);
registerForContextMenu(messagesView);