mirror of
https://codeberg.org/monocles/monocles_chat.git
synced 2025-01-29 00:14:12 +01:00
Show banned users to admins
(cherry picked from commit dbe40f8ee92fa29178c9729e884f7ba381265c7f)
This commit is contained in:
parent
4aab8c67fc
commit
4c8e550f03
3 changed files with 47 additions and 27 deletions
|
@ -400,10 +400,14 @@ public class MucOptions {
|
|||
}
|
||||
|
||||
public ArrayList<User> getUsers(boolean includeOffline) {
|
||||
return getUsers(true, false);
|
||||
}
|
||||
|
||||
public ArrayList<User> getUsers(boolean includeOffline, boolean includeOutcast) {
|
||||
synchronized (users) {
|
||||
ArrayList<User> users = new ArrayList<>();
|
||||
for (User user : this.users) {
|
||||
if (!user.isDomain() && (includeOffline ? user.getAffiliation().ranks(Affiliation.NONE) : user.getRole().ranks(Role.PARTICIPANT))) {
|
||||
if (!user.isDomain() && (includeOffline ? (includeOutcast || user.getAffiliation().ranks(Affiliation.NONE)) : user.getRole().ranks(Role.PARTICIPANT))) {
|
||||
users.add(user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,28 +158,39 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
}
|
||||
};
|
||||
|
||||
private final OnClickListener mChangeConferenceSettings = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final MucOptions mucOptions = mConversation.getMucOptions();
|
||||
final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(ConferenceDetailsActivity.this);
|
||||
MucConfiguration configuration = MucConfiguration.get(ConferenceDetailsActivity.this, mAdvancedMode, mucOptions);
|
||||
builder.setTitle(configuration.title);
|
||||
final boolean[] values = configuration.values;
|
||||
builder.setMultiChoiceItems(configuration.names, values, (dialog, which, isChecked) -> values[which] = isChecked);
|
||||
builder.setNegativeButton(R.string.cancel, null);
|
||||
builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
|
||||
final Bundle options = configuration.toBundle(values);
|
||||
options.putString("muc#roomconfig_persistentroom", "1");
|
||||
options.putString("{http://prosody.im/protocol/muc}roomconfig_allowmemberinvites", options.getString("muc#roomconfig_allowinvites"));
|
||||
xmppConnectionService.pushConferenceConfiguration(mConversation,
|
||||
options,
|
||||
ConferenceDetailsActivity.this);
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
};
|
||||
|
||||
private final OnClickListener mChangeConferenceSettings =
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final MucOptions mucOptions = mConversation.getMucOptions();
|
||||
final MaterialAlertDialogBuilder builder =
|
||||
new MaterialAlertDialogBuilder(ConferenceDetailsActivity.this);
|
||||
MucConfiguration configuration =
|
||||
MucConfiguration.get(
|
||||
ConferenceDetailsActivity.this, mAdvancedMode, mucOptions);
|
||||
builder.setTitle(configuration.title);
|
||||
final boolean[] values = configuration.values;
|
||||
builder.setMultiChoiceItems(
|
||||
configuration.names,
|
||||
values,
|
||||
(dialog, which, isChecked) -> values[which] = isChecked);
|
||||
builder.setNegativeButton(R.string.cancel, null);
|
||||
builder.setPositiveButton(
|
||||
R.string.confirm,
|
||||
(dialog, which) -> {
|
||||
final Bundle options = configuration.toBundle(values);
|
||||
options.putString("muc#roomconfig_persistentroom", "1");
|
||||
if (options.containsKey("muc#roomconfig_allowinvites")) {
|
||||
options.putString(
|
||||
"{http://prosody.im/protocol/muc}roomconfig_allowmemberinvites",
|
||||
options.getString("muc#roomconfig_allowinvites"));
|
||||
}
|
||||
xmppConnectionService.pushConferenceConfiguration(
|
||||
mConversation, options, ConferenceDetailsActivity.this);
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onConversationUpdate() {
|
||||
|
@ -259,6 +270,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
popupMenu.show();
|
||||
return true;
|
||||
});
|
||||
this.binding.editMucNameButton.setContentDescription(getString(R.string.edit_name_and_topic));
|
||||
this.binding.editMucNameButton.setOnClickListener(this::onMucEditButtonClicked);
|
||||
this.binding.mucEditTitle.addTextChangedListener(this);
|
||||
this.binding.mucEditSubject.addTextChangedListener(this);
|
||||
|
@ -346,6 +358,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
this.binding.mucEditor.setVisibility(View.VISIBLE);
|
||||
this.binding.mucDisplay.setVisibility(View.GONE);
|
||||
this.binding.editMucNameButton.setImageResource(R.drawable.ic_cancel_24dp);
|
||||
this.binding.editMucNameButton.setContentDescription(getString(R.string.cancel));
|
||||
final String name = mucOptions.getName();
|
||||
this.binding.mucEditTitle.setText("");
|
||||
final boolean owner = mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER);
|
||||
|
@ -420,6 +433,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
this.binding.mucEditor.setVisibility(View.GONE);
|
||||
this.binding.mucDisplay.setVisibility(View.VISIBLE);
|
||||
this.binding.editMucNameButton.setImageResource(R.drawable.ic_edit_24dp);
|
||||
this.binding.editMucNameButton.setContentDescription(getString(R.string.edit_name_and_topic));
|
||||
}
|
||||
|
||||
private void onMucInfoUpdated(String subject, String name) {
|
||||
|
@ -657,10 +671,10 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
});
|
||||
this.mUserPreviewAdapter.submitList(MucOptions.sub(users, GridManager.getCurrentColumnCount(binding.users)));
|
||||
this.binding.invite.setVisibility(mucOptions.canInvite() ? View.VISIBLE : View.GONE);
|
||||
this.binding.showUsers.setVisibility(!users.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
this.binding.showUsers.setVisibility(mucOptions.getUsers(true, mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.ADMIN)).size() > 0 ? View.VISIBLE : View.GONE);
|
||||
this.binding.showUsers.setText(getResources().getQuantityString(R.plurals.view_users, users.size(), users.size()));
|
||||
this.binding.usersWrapper.setVisibility(!users.isEmpty() || mucOptions.canInvite() ? View.VISIBLE : View.GONE);
|
||||
if (users.isEmpty()) {
|
||||
this.binding.usersWrapper.setVisibility(users.size() > 0 || mucOptions.canInvite() ? View.VISIBLE : View.GONE);
|
||||
if (users.size() == 0) {
|
||||
this.binding.noUsersHints.setText(mucOptions.isPrivateAndNonAnonymous() ? R.string.no_users_hint_group_chat : R.string.no_users_hint_channel);
|
||||
this.binding.noUsersHints.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
@ -779,8 +793,10 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
final Bookmark bookmark = mConversation.getBookmark();
|
||||
if (subjectChanged || nameChanged || (bookmark != null && mConversation.getAccount().getXmppConnection().getFeatures().bookmarks2())) {
|
||||
this.binding.editMucNameButton.setImageResource(R.drawable.ic_save_24dp);
|
||||
this.binding.editMucNameButton.setContentDescription(getString(R.string.save));
|
||||
} else {
|
||||
this.binding.editMucNameButton.setImageResource(R.drawable.ic_cancel_24dp);
|
||||
this.binding.editMucNameButton.setContentDescription(getString(R.string.cancel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class MucUsersActivity extends XmppActivity implements XmppConnectionServ
|
|||
|
||||
private void loadAndSubmitUsers() {
|
||||
if (mConversation != null) {
|
||||
allUsers = mConversation.getMucOptions().getUsers();
|
||||
allUsers = mConversation.getMucOptions().getUsers(true, mConversation.getMucOptions().getSelf().getAffiliation().ranks(MucOptions.Affiliation.ADMIN));
|
||||
submitFilteredList(mSearchEditText != null ? mSearchEditText.getText().toString() : null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue