some clean ups for affiliation change context menu

This commit is contained in:
Daniel Gultsch 2015-01-08 00:23:26 +01:00
parent cff9a937f2
commit 061de5205e
3 changed files with 16 additions and 6 deletions

View file

@ -245,6 +245,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
MenuItem giveAdminPrivileges = menu.findItem(R.id.give_admin_privileges); MenuItem giveAdminPrivileges = menu.findItem(R.id.give_admin_privileges);
MenuItem removeAdminPrivileges = menu.findItem(R.id.remove_admin_privileges); MenuItem removeAdminPrivileges = menu.findItem(R.id.remove_admin_privileges);
MenuItem removeFromRoom = menu.findItem(R.id.remove_from_room); MenuItem removeFromRoom = menu.findItem(R.id.remove_from_room);
MenuItem banFromConference = menu.findItem(R.id.ban_from_conference);
startConversation.setVisible(true); startConversation.setVisible(true);
if (self.getAffiliation().ranks(MucOptions.Affiliation.ADMIN) && if (self.getAffiliation().ranks(MucOptions.Affiliation.ADMIN) &&
self.getAffiliation().outranks(user.getAffiliation())) { self.getAffiliation().outranks(user.getAffiliation())) {
@ -254,13 +255,15 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
} else { } else {
removeMembership.setVisible(true); removeMembership.setVisible(true);
} }
banFromConference.setVisible(true);
} else {
removeFromRoom.setVisible(true);
} }
if (user.getAffiliation() != MucOptions.Affiliation.ADMIN) { if (user.getAffiliation() != MucOptions.Affiliation.ADMIN) {
giveAdminPrivileges.setVisible(true); giveAdminPrivileges.setVisible(true);
} else { } else {
removeAdminPrivileges.setVisible(true); removeAdminPrivileges.setVisible(true);
} }
removeFromRoom.setVisible(true);
} }
} }
@ -289,6 +292,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
case R.id.remove_from_room: case R.id.remove_from_room:
removeFromRoom(mSelectedUser); removeFromRoom(mSelectedUser);
return true; return true;
case R.id.ban_from_conference:
xmppConnectionService.changeAffiliationInConference(mConversation,mSelectedUser.getJid(), MucOptions.Affiliation.OUTCAST,this);
return true;
default: default:
return super.onContextItemSelected(item); return super.onContextItemSelected(item);
} }
@ -299,7 +305,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
xmppConnectionService.changeAffiliationInConference(mConversation,user.getJid(), MucOptions.Affiliation.NONE,this); xmppConnectionService.changeAffiliationInConference(mConversation,user.getJid(), MucOptions.Affiliation.NONE,this);
} else { } else {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.ban_user_from_conference); builder.setTitle(R.string.ban_from_conference);
builder.setMessage(getString(R.string.removing_from_public_conference,user.getName())); builder.setMessage(getString(R.string.removing_from_public_conference,user.getName()));
builder.setNegativeButton(R.string.cancel,null); builder.setNegativeButton(R.string.cancel,null);
builder.setPositiveButton(R.string.ban_now,new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.ban_now,new DialogInterface.OnClickListener() {

View file

@ -21,6 +21,10 @@
android:id="@+id/remove_membership" android:id="@+id/remove_membership"
android:title="@string/remove_membership" android:title="@string/remove_membership"
android:visible="false"/> android:visible="false"/>
<item
android:id="@+id/ban_from_conference"
android:title="@string/ban_from_conference"
android:visible="false" />
<item <item
android:id="@+id/remove_from_room" android:id="@+id/remove_from_room"
android:title="@string/remove_from_room" android:title="@string/remove_from_room"

View file

@ -412,12 +412,12 @@
<string name="member">Member</string> <string name="member">Member</string>
<string name="advanced_mode">Advanced mode</string> <string name="advanced_mode">Advanced mode</string>
<string name="grant_membership">Grant membership</string> <string name="grant_membership">Grant membership</string>
<string name="remove_membership">Remove membership</string> <string name="remove_membership">Revoke membership</string>
<string name="grant_admin_privileges">Grant admin privileges</string> <string name="grant_admin_privileges">Grant admin privileges</string>
<string name="remove_admin_privileges">Remove admin privileges</string> <string name="remove_admin_privileges">Revoke admin privileges</string>
<string name="remove_from_room">Remove from room</string> <string name="remove_from_room">Remove from conference</string>
<string name="could_not_change_affiliation">Could not change affiliation</string> <string name="could_not_change_affiliation">Could not change affiliation</string>
<string name="ban_user_from_conference">Ban user from conference</string> <string name="ban_from_conference">Ban from conference</string>
<string name="removing_from_public_conference">You are trying to remove %s from a public conference. The only way to do that is to ban that user for ever.</string> <string name="removing_from_public_conference">You are trying to remove %s from a public conference. The only way to do that is to ban that user for ever.</string>
<string name="ban_now">Ban now</string> <string name="ban_now">Ban now</string>
</resources> </resources>