ConferenceDetailsActivity.java

  1package eu.siacs.conversations.ui;
  2
  3import android.app.AlertDialog;
  4import android.app.PendingIntent;
  5import android.content.Context;
  6import android.content.DialogInterface;
  7import android.content.IntentSender.SendIntentException;
  8import android.os.Bundle;
  9import android.view.ContextMenu;
 10import android.view.LayoutInflater;
 11import android.view.Menu;
 12import android.view.MenuItem;
 13import android.view.View;
 14import android.view.View.OnClickListener;
 15import android.widget.Button;
 16import android.widget.ImageButton;
 17import android.widget.ImageView;
 18import android.widget.LinearLayout;
 19import android.widget.RelativeLayout;
 20import android.widget.TableLayout;
 21import android.widget.TextView;
 22import android.widget.Toast;
 23
 24import org.openintents.openpgp.util.OpenPgpUtils;
 25
 26import java.util.ArrayList;
 27import java.util.Collections;
 28import java.util.concurrent.atomic.AtomicInteger;
 29
 30import eu.siacs.conversations.Config;
 31import eu.siacs.conversations.R;
 32import eu.siacs.conversations.crypto.PgpEngine;
 33import eu.siacs.conversations.entities.Account;
 34import eu.siacs.conversations.entities.Bookmark;
 35import eu.siacs.conversations.entities.Contact;
 36import eu.siacs.conversations.entities.Conversation;
 37import eu.siacs.conversations.entities.MucOptions;
 38import eu.siacs.conversations.entities.MucOptions.User;
 39import eu.siacs.conversations.services.XmppConnectionService;
 40import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate;
 41import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate;
 42import eu.siacs.conversations.xmpp.jid.Jid;
 43
 44public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed {
 45	public static final String ACTION_VIEW_MUC = "view_muc";
 46
 47	private static final float INACTIVE_ALPHA = 0.4684f; //compromise between dark and light theme
 48
 49	private Conversation mConversation;
 50	private OnClickListener inviteListener = new OnClickListener() {
 51
 52		@Override
 53		public void onClick(View v) {
 54			inviteToConversation(mConversation);
 55		}
 56	};
 57	private TextView mYourNick;
 58	private ImageView mYourPhoto;
 59	private TextView mFullJid;
 60	private TextView mAccountJid;
 61	private LinearLayout membersView;
 62	private LinearLayout mMoreDetails;
 63	private RelativeLayout mMucSettings;
 64	private TextView mConferenceType;
 65	private TableLayout mConferenceInfoTable;
 66	private TextView mConferenceInfoMam;
 67	private TextView mNotifyStatusText;
 68	private ImageButton mChangeConferenceSettingsButton;
 69	private ImageButton mNotifyStatusButton;
 70	private Button mInviteButton;
 71	private String uuid = null;
 72	private User mSelectedUser = null;
 73
 74	private boolean mAdvancedMode = false;
 75
 76	private UiCallback<Conversation> renameCallback = new UiCallback<Conversation>() {
 77		@Override
 78		public void success(Conversation object) {
 79			runOnUiThread(new Runnable() {
 80				@Override
 81				public void run() {
 82					Toast.makeText(ConferenceDetailsActivity.this,getString(R.string.your_nick_has_been_changed),Toast.LENGTH_SHORT).show();
 83					updateView();
 84				}
 85			});
 86
 87		}
 88
 89		@Override
 90		public void error(final int errorCode, Conversation object) {
 91			runOnUiThread(new Runnable() {
 92				@Override
 93				public void run() {
 94					Toast.makeText(ConferenceDetailsActivity.this,getString(errorCode),Toast.LENGTH_SHORT).show();
 95				}
 96			});
 97		}
 98
 99		@Override
100		public void userInputRequried(PendingIntent pi, Conversation object) {
101
102		}
103	};
104
105	private OnClickListener mNotifyStatusClickListener = new OnClickListener() {
106		@Override
107		public void onClick(View v) {
108			AlertDialog.Builder builder = new AlertDialog.Builder(ConferenceDetailsActivity.this);
109			builder.setTitle(R.string.pref_notification_settings);
110			String[] choices = {
111					getString(R.string.notify_on_all_messages),
112					getString(R.string.notify_only_when_highlighted),
113					getString(R.string.notify_never)
114			};
115			final AtomicInteger choice;
116			if (mConversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0) == Long.MAX_VALUE) {
117				choice = new AtomicInteger(2);
118			} else {
119				choice = new AtomicInteger(mConversation.alwaysNotify() ? 0 : 1);
120			}
121			builder.setSingleChoiceItems(choices, choice.get(), new DialogInterface.OnClickListener() {
122				@Override
123				public void onClick(DialogInterface dialog, int which) {
124					choice.set(which);
125				}
126			});
127			builder.setNegativeButton(R.string.cancel, null);
128			builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
129				@Override
130				public void onClick(DialogInterface dialog, int which) {
131					if (choice.get() == 2) {
132						mConversation.setMutedTill(Long.MAX_VALUE);
133					} else {
134						mConversation.setMutedTill(0);
135						mConversation.setAttribute(Conversation.ATTRIBUTE_ALWAYS_NOTIFY,String.valueOf(choice.get() == 0));
136					}
137					xmppConnectionService.updateConversation(mConversation);
138					updateView();
139				}
140			});
141			builder.create().show();
142		}
143	};
144
145	private OnClickListener mChangeConferenceSettings = new OnClickListener() {
146		@Override
147		public void onClick(View v) {
148			final MucOptions mucOptions = mConversation.getMucOptions();
149			AlertDialog.Builder builder = new AlertDialog.Builder(ConferenceDetailsActivity.this);
150			builder.setTitle(R.string.conference_options);
151			final String[] options;
152			final boolean[] values;
153			if (mAdvancedMode) {
154				options = new String[]{
155						getString(R.string.members_only),
156						getString(R.string.moderated),
157						getString(R.string.non_anonymous)
158				};
159				values = new boolean[]{
160						mucOptions.membersOnly(),
161						mucOptions.moderated(),
162						mucOptions.nonanonymous()
163				};
164			} else {
165				options = new String[]{
166						getString(R.string.members_only),
167						getString(R.string.non_anonymous)
168				};
169				values = new boolean[]{
170						mucOptions.membersOnly(),
171						mucOptions.nonanonymous()
172				};
173			}
174			builder.setMultiChoiceItems(options,values,new DialogInterface.OnMultiChoiceClickListener() {
175				@Override
176				public void onClick(DialogInterface dialog, int which, boolean isChecked) {
177					values[which] = isChecked;
178				}
179			});
180			builder.setNegativeButton(R.string.cancel, null);
181			builder.setPositiveButton(R.string.confirm,new DialogInterface.OnClickListener() {
182				@Override
183				public void onClick(DialogInterface dialog, int which) {
184					if (!mucOptions.membersOnly() && values[0]) {
185						xmppConnectionService.changeAffiliationsInConference(mConversation,
186								MucOptions.Affiliation.NONE,
187								MucOptions.Affiliation.MEMBER);
188					}
189					Bundle options = new Bundle();
190					options.putString("muc#roomconfig_membersonly", values[0] ? "1" : "0");
191					if (values.length == 2) {
192						options.putString("muc#roomconfig_whois", values[1] ? "anyone" : "moderators");
193					} else if (values.length == 3) {
194						options.putString("muc#roomconfig_moderatedroom", values[1] ? "1" : "0");
195						options.putString("muc#roomconfig_whois", values[2] ? "anyone" : "moderators");
196					}
197					options.putString("muc#roomconfig_persistentroom", "1");
198					xmppConnectionService.pushConferenceConfiguration(mConversation,
199							options,
200							ConferenceDetailsActivity.this);
201				}
202			});
203			builder.create().show();
204		}
205	};
206	private OnValueEdited onSubjectEdited = new OnValueEdited() {
207
208		@Override
209		public String onValueEdited(String value) {
210			xmppConnectionService.pushSubjectToConference(mConversation,value);
211			return null;
212		}
213	};
214
215	@Override
216	public void onConversationUpdate() {
217		refreshUi();
218	}
219
220	@Override
221	public void onMucRosterUpdate() {
222		refreshUi();
223	}
224
225	@Override
226	protected void refreshUiReal() {
227		updateView();
228	}
229
230	@Override
231	protected void onCreate(Bundle savedInstanceState) {
232		super.onCreate(savedInstanceState);
233		setContentView(R.layout.activity_muc_details);
234		mYourNick = (TextView) findViewById(R.id.muc_your_nick);
235		mYourPhoto = (ImageView) findViewById(R.id.your_photo);
236		ImageButton mEditNickButton = (ImageButton) findViewById(R.id.edit_nick_button);
237		mFullJid = (TextView) findViewById(R.id.muc_jabberid);
238		membersView = (LinearLayout) findViewById(R.id.muc_members);
239		mAccountJid = (TextView) findViewById(R.id.details_account);
240		mMucSettings = findViewById(R.id.muc_settings);
241		mMoreDetails = (LinearLayout) findViewById(R.id.muc_more_details);
242		mMoreDetails.setVisibility(View.GONE);
243		mChangeConferenceSettingsButton = (ImageButton) findViewById(R.id.change_conference_button);
244		mChangeConferenceSettingsButton.setOnClickListener(this.mChangeConferenceSettings);
245		mInviteButton = (Button) findViewById(R.id.invite);
246		mInviteButton.setOnClickListener(inviteListener);
247		mConferenceType = (TextView) findViewById(R.id.muc_conference_type);
248		if (getActionBar() != null) {
249			getActionBar().setHomeButtonEnabled(true);
250			getActionBar().setDisplayHomeAsUpEnabled(true);
251		}
252		mEditNickButton.setOnClickListener(new OnClickListener() {
253
254			@Override
255			public void onClick(View v) {
256				quickEdit(mConversation.getMucOptions().getActualNick(),
257						0,
258						new OnValueEdited() {
259
260							@Override
261							public String onValueEdited(String value) {
262								if (xmppConnectionService.renameInMuc(mConversation,value,renameCallback)) {
263									return null;
264								} else {
265									return getString(R.string.invalid_username);
266								}
267							}
268						});
269			}
270		});
271		this.mAdvancedMode = getPreferences().getBoolean("advanced_muc_mode", false);
272		this.mConferenceInfoTable = (TableLayout) findViewById(R.id.muc_info_more);
273		this.mConferenceInfoTable.setVisibility(this.mAdvancedMode ? View.VISIBLE : View.GONE);
274		this.mConferenceInfoMam = (TextView) findViewById(R.id.muc_info_mam);
275		this.mNotifyStatusButton = (ImageButton) findViewById(R.id.notification_status_button);
276		this.mNotifyStatusButton.setOnClickListener(this.mNotifyStatusClickListener);
277		this.mNotifyStatusText = (TextView) findViewById(R.id.notification_status_text);
278	}
279
280	@Override
281	protected void onStart() {
282		super.onStart();
283		final int theme = findTheme();
284		if (this.mTheme != theme) {
285			recreate();
286		}
287	}
288
289	@Override
290	public boolean onOptionsItemSelected(MenuItem menuItem) {
291		switch (menuItem.getItemId()) {
292			case android.R.id.home:
293				finish();
294				break;
295			case R.id.action_edit_subject:
296				if (mConversation != null) {
297					quickEdit(mConversation.getMucOptions().getSubject(),
298							R.string.edit_subject_hint,
299							this.onSubjectEdited);
300				}
301				break;
302			case R.id.action_share_http:
303				shareLink(true);
304				break;
305			case R.id.action_share_uri:
306				shareLink(false);
307				break;
308			case R.id.action_save_as_bookmark:
309				saveAsBookmark();
310				break;
311			case R.id.action_delete_bookmark:
312				deleteBookmark();
313				break;
314			case R.id.action_advanced_mode:
315				this.mAdvancedMode = !menuItem.isChecked();
316				menuItem.setChecked(this.mAdvancedMode);
317				getPreferences().edit().putBoolean("advanced_muc_mode", mAdvancedMode).apply();
318				final boolean online = mConversation != null && mConversation.getMucOptions().online();
319				mConferenceInfoTable.setVisibility(this.mAdvancedMode && online ? View.VISIBLE : View.GONE);
320				invalidateOptionsMenu();
321				updateView();
322				break;
323		}
324		return super.onOptionsItemSelected(menuItem);
325	}
326
327	@Override
328	protected String getShareableUri(boolean http) {
329		if (mConversation != null) {
330			if (http) {
331				return "https://conversations.im/j/"+ mConversation.getJid().toBareJid();
332			} else {
333				return "xmpp:"+mConversation.getJid().toBareJid()+"?join";
334			}
335		} else {
336			return null;
337		}
338	}
339
340	@Override
341	public boolean onPrepareOptionsMenu(Menu menu) {
342		MenuItem menuItemSaveBookmark = menu.findItem(R.id.action_save_as_bookmark);
343		MenuItem menuItemDeleteBookmark = menu.findItem(R.id.action_delete_bookmark);
344		MenuItem menuItemAdvancedMode = menu.findItem(R.id.action_advanced_mode);
345		MenuItem menuItemChangeSubject = menu.findItem(R.id.action_edit_subject);
346		menuItemAdvancedMode.setChecked(mAdvancedMode);
347		if (mConversation == null) {
348			return true;
349		}
350		Account account = mConversation.getAccount();
351		if (account.hasBookmarkFor(mConversation.getJid().toBareJid())) {
352			menuItemSaveBookmark.setVisible(false);
353			menuItemDeleteBookmark.setVisible(true);
354		} else {
355			menuItemDeleteBookmark.setVisible(false);
356			menuItemSaveBookmark.setVisible(true);
357		}
358		menuItemChangeSubject.setVisible(mConversation.getMucOptions().canChangeSubject());
359		return true;
360	}
361
362	@Override
363	public boolean onCreateOptionsMenu(Menu menu) {
364		getMenuInflater().inflate(R.menu.muc_details, menu);
365		return super.onCreateOptionsMenu(menu);
366	}
367
368	@Override
369	public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
370		Object tag = v.getTag();
371		if (tag instanceof User) {
372			getMenuInflater().inflate(R.menu.muc_details_context,menu);
373			final User user = (User) tag;
374			final User self = mConversation.getMucOptions().getSelf();
375			this.mSelectedUser = user;
376			String name;
377			final Contact contact = user.getContact();
378			if (contact != null && contact.showInRoster()) {
379				name = contact.getDisplayName();
380			} else if (user.getRealJid() != null){
381				name = user.getRealJid().toBareJid().toString();
382			} else {
383				name = user.getName();
384			}
385			menu.setHeaderTitle(name);
386			if (user.getRealJid() != null) {
387				MenuItem showContactDetails = menu.findItem(R.id.action_contact_details);
388				MenuItem startConversation = menu.findItem(R.id.start_conversation);
389				MenuItem giveMembership = menu.findItem(R.id.give_membership);
390				MenuItem removeMembership = menu.findItem(R.id.remove_membership);
391				MenuItem giveAdminPrivileges = menu.findItem(R.id.give_admin_privileges);
392				MenuItem removeAdminPrivileges = menu.findItem(R.id.remove_admin_privileges);
393				MenuItem removeFromRoom = menu.findItem(R.id.remove_from_room);
394				MenuItem banFromConference = menu.findItem(R.id.ban_from_conference);
395				MenuItem invite = menu.findItem(R.id.invite);
396				startConversation.setVisible(true);
397				if (contact != null && contact.showInRoster()) {
398					showContactDetails.setVisible(!contact.isSelf());
399				}
400				if (user.getRole() == MucOptions.Role.NONE) {
401					invite.setVisible(true);
402				}
403				if (self.getAffiliation().ranks(MucOptions.Affiliation.ADMIN) &&
404						self.getAffiliation().outranks(user.getAffiliation())) {
405					if (mAdvancedMode) {
406						if (user.getAffiliation() == MucOptions.Affiliation.NONE) {
407							giveMembership.setVisible(true);
408						} else {
409							removeMembership.setVisible(true);
410						}
411						banFromConference.setVisible(true);
412					} else {
413						removeFromRoom.setVisible(true);
414					}
415					if (user.getAffiliation() != MucOptions.Affiliation.ADMIN) {
416						giveAdminPrivileges.setVisible(true);
417					} else {
418						removeAdminPrivileges.setVisible(true);
419					}
420				}
421			} else {
422				MenuItem sendPrivateMessage = menu.findItem(R.id.send_private_message);
423				sendPrivateMessage.setVisible(user.getRole().ranks(MucOptions.Role.PARTICIPANT));
424			}
425
426		}
427		super.onCreateContextMenu(menu, v, menuInfo);
428	}
429
430	@Override
431	public boolean onContextItemSelected(MenuItem item) {
432		Jid jid = mSelectedUser.getRealJid();
433		switch (item.getItemId()) {
434			case R.id.action_contact_details:
435				Contact contact = mSelectedUser.getContact();
436				if (contact != null) {
437					switchToContactDetails(contact);
438				}
439				return true;
440			case R.id.start_conversation:
441				startConversation(mSelectedUser);
442				return true;
443			case R.id.give_admin_privileges:
444				xmppConnectionService.changeAffiliationInConference(mConversation, jid, MucOptions.Affiliation.ADMIN,this);
445				return true;
446			case R.id.give_membership:
447				xmppConnectionService.changeAffiliationInConference(mConversation, jid, MucOptions.Affiliation.MEMBER,this);
448				return true;
449			case R.id.remove_membership:
450				xmppConnectionService.changeAffiliationInConference(mConversation, jid, MucOptions.Affiliation.NONE,this);
451				return true;
452			case R.id.remove_admin_privileges:
453				xmppConnectionService.changeAffiliationInConference(mConversation, jid, MucOptions.Affiliation.MEMBER,this);
454				return true;
455			case R.id.remove_from_room:
456				removeFromRoom(mSelectedUser);
457				return true;
458			case R.id.ban_from_conference:
459				xmppConnectionService.changeAffiliationInConference(mConversation,jid, MucOptions.Affiliation.OUTCAST,this);
460				if (mSelectedUser.getRole() != MucOptions.Role.NONE) {
461					xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, this);
462				}
463				return true;
464			case R.id.send_private_message:
465				privateMsgInMuc(mConversation,mSelectedUser.getName());
466				return true;
467			case R.id.invite:
468				xmppConnectionService.directInvite(mConversation, jid);
469				return true;
470			default:
471				return super.onContextItemSelected(item);
472		}
473	}
474
475	private void removeFromRoom(final User user) {
476		if (mConversation.getMucOptions().membersOnly()) {
477			xmppConnectionService.changeAffiliationInConference(mConversation,user.getRealJid(), MucOptions.Affiliation.NONE,this);
478			if (user.getRole() != MucOptions.Role.NONE) {
479				xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, ConferenceDetailsActivity.this);
480			}
481		} else {
482			AlertDialog.Builder builder = new AlertDialog.Builder(this);
483			builder.setTitle(R.string.ban_from_conference);
484			builder.setMessage(getString(R.string.removing_from_public_conference,user.getName()));
485			builder.setNegativeButton(R.string.cancel,null);
486			builder.setPositiveButton(R.string.ban_now,new DialogInterface.OnClickListener() {
487				@Override
488				public void onClick(DialogInterface dialog, int which) {
489					xmppConnectionService.changeAffiliationInConference(mConversation,user.getRealJid(), MucOptions.Affiliation.OUTCAST,ConferenceDetailsActivity.this);
490					if (user.getRole() != MucOptions.Role.NONE) {
491						xmppConnectionService.changeRoleInConference(mConversation, mSelectedUser.getName(), MucOptions.Role.NONE, ConferenceDetailsActivity.this);
492					}
493				}
494			});
495			builder.create().show();
496		}
497	}
498
499	protected void startConversation(User user) {
500		if (user.getRealJid() != null) {
501			Conversation conversation = xmppConnectionService.findOrCreateConversation(this.mConversation.getAccount(),user.getRealJid().toBareJid(),false,true);
502			switchToConversation(conversation);
503		}
504	}
505
506	protected void saveAsBookmark() {
507		xmppConnectionService.saveConversationAsBookmark(mConversation,
508				mConversation.getMucOptions().getSubject());
509	}
510
511	protected void deleteBookmark() {
512		Account account = mConversation.getAccount();
513		Bookmark bookmark = mConversation.getBookmark();
514		mConversation.deregisterWithBookmark();
515		account.getBookmarks().remove(bookmark);
516		xmppConnectionService.pushBookmarks(account);
517		updateView();
518	}
519
520	@Override
521	void onBackendConnected() {
522		if (mPendingConferenceInvite != null) {
523			mPendingConferenceInvite.execute(this);
524			mPendingConferenceInvite = null;
525		}
526		if (getIntent().getAction().equals(ACTION_VIEW_MUC)) {
527			this.uuid = getIntent().getExtras().getString("uuid");
528		}
529		if (uuid != null) {
530			this.mConversation = xmppConnectionService.findConversationByUuid(uuid);
531			if (this.mConversation != null) {
532				updateView();
533			}
534		}
535	}
536
537	private void updateView() {
538		invalidateOptionsMenu();
539		final MucOptions mucOptions = mConversation.getMucOptions();
540		final User self = mucOptions.getSelf();
541		String account;
542		if (Config.DOMAIN_LOCK != null) {
543			account = mConversation.getAccount().getJid().getLocalpart();
544		} else {
545			account = mConversation.getAccount().getJid().toBareJid().toString();
546		}
547		mAccountJid.setText(getString(R.string.using_account, account));
548		mYourPhoto.setImageBitmap(avatarService().get(mConversation.getAccount(), getPixel(48)));
549		setTitle(mConversation.getName());
550		mFullJid.setText(mConversation.getJid().toBareJid().toString());
551		mYourNick.setText(mucOptions.getActualNick());
552		TextView mRoleAffiliaton = (TextView) findViewById(R.id.muc_role);
553		if (mucOptions.online()) {
554			mMoreDetails.setVisibility(View.VISIBLE);
555			mMucSettings.setVisibility(View.VISIBLE);
556			mConferenceInfoTable.setVisibility(this.mAdvancedMode ? View.VISIBLE : View.GONE);
557			final String status = getStatus(self);
558			if (status != null) {
559				mRoleAffiliaton.setVisibility(View.VISIBLE);
560				mRoleAffiliaton.setText(status);
561			} else {
562				mRoleAffiliaton.setVisibility(View.GONE);
563			}
564			if (mucOptions.membersOnly()) {
565				mConferenceType.setText(R.string.private_conference);
566			} else {
567				mConferenceType.setText(R.string.public_conference);
568			}
569			if (mucOptions.mamSupport()) {
570				mConferenceInfoMam.setText(R.string.server_info_available);
571			} else {
572				mConferenceInfoMam.setText(R.string.server_info_unavailable);
573			}
574			if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) {
575				mChangeConferenceSettingsButton.setVisibility(View.VISIBLE);
576			} else {
577				mChangeConferenceSettingsButton.setVisibility(View.GONE);
578			}
579		} else {
580			mMoreDetails.setVisibility(View.GONE);
581			mMucSettings.setVisibility(View.GONE);
582			mConferenceInfoTable.setVisibility(View.GONE);
583		}
584
585		int ic_notifications = 		  getThemeResource(R.attr.icon_notifications, R.drawable.ic_notifications_black_24dp);
586		int ic_notifications_off = 	  getThemeResource(R.attr.icon_notifications_off, R.drawable.ic_notifications_off_black_24dp);
587		int ic_notifications_paused = getThemeResource(R.attr.icon_notifications_paused, R.drawable.ic_notifications_paused_black_24dp);
588		int ic_notifications_none =	  getThemeResource(R.attr.icon_notifications_none, R.drawable.ic_notifications_none_black_24dp);
589
590		long mutedTill = mConversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL,0);
591		if (mutedTill == Long.MAX_VALUE) {
592			mNotifyStatusText.setText(R.string.notify_never);
593			mNotifyStatusButton.setImageResource(ic_notifications_off);
594		} else if (System.currentTimeMillis() < mutedTill) {
595			mNotifyStatusText.setText(R.string.notify_paused);
596			mNotifyStatusButton.setImageResource(ic_notifications_paused);
597		} else if (mConversation.alwaysNotify()) {
598			mNotifyStatusButton.setImageResource(ic_notifications);
599			mNotifyStatusText.setText(R.string.notify_on_all_messages);
600		} else {
601			mNotifyStatusButton.setImageResource(ic_notifications_none);
602			mNotifyStatusText.setText(R.string.notify_only_when_highlighted);
603		}
604
605		LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
606		membersView.removeAllViews();
607		final ArrayList<User> users = mucOptions.getUsers();
608		Collections.sort(users);
609		for (final User user : users) {
610			View view = inflater.inflate(R.layout.contact, membersView,false);
611			this.setListItemBackgroundOnView(view);
612			view.setOnClickListener(new OnClickListener() {
613				@Override
614				public void onClick(View view) {
615					highlightInMuc(mConversation, user.getName());
616				}
617			});
618			registerForContextMenu(view);
619			view.setTag(user);
620			TextView tvDisplayName = (TextView) view.findViewById(R.id.contact_display_name);
621			TextView tvKey = (TextView) view.findViewById(R.id.key);
622			TextView tvStatus = (TextView) view.findViewById(R.id.contact_jid);
623			if (mAdvancedMode && user.getPgpKeyId() != 0) {
624				tvKey.setVisibility(View.VISIBLE);
625				tvKey.setOnClickListener(new OnClickListener() {
626
627					@Override
628					public void onClick(View v) {
629						viewPgpKey(user);
630					}
631				});
632				tvKey.setText(OpenPgpUtils.convertKeyIdToHex(user.getPgpKeyId()));
633			}
634			Contact contact = user.getContact();
635			String name = user.getName();
636			if (contact != null) {
637				tvDisplayName.setText(contact.getDisplayName());
638				tvStatus.setText((name != null ? name+ " \u2022 " : "") + getStatus(user));
639			} else {
640				tvDisplayName.setText(name == null ? "" : name);
641				tvStatus.setText(getStatus(user));
642
643			}
644			ImageView iv = (ImageView) view.findViewById(R.id.contact_photo);
645			iv.setImageBitmap(avatarService().get(user, getPixel(48), false));
646			if (user.getRole() == MucOptions.Role.NONE) {
647				tvDisplayName.setAlpha(INACTIVE_ALPHA);
648				tvKey.setAlpha(INACTIVE_ALPHA);
649				tvStatus.setAlpha(INACTIVE_ALPHA);
650				iv.setAlpha(INACTIVE_ALPHA);
651			}
652			membersView.addView(view);
653			if (mConversation.getMucOptions().canInvite()) {
654				mInviteButton.setVisibility(View.VISIBLE);
655			} else {
656				mInviteButton.setVisibility(View.GONE);
657			}
658		}
659	}
660
661	private String getStatus(User user) {
662		if (mAdvancedMode) {
663			return getString(user.getAffiliation().getResId()) +
664					" (" + getString(user.getRole().getResId()) + ')';
665		} else {
666			return getString(user.getAffiliation().getResId());
667		}
668	}
669
670	private void viewPgpKey(User user) {
671		PgpEngine pgp = xmppConnectionService.getPgpEngine();
672		if (pgp != null) {
673			PendingIntent intent = pgp.getIntentForKey(user.getPgpKeyId());
674			if (intent != null) {
675				try {
676					startIntentSenderForResult(intent.getIntentSender(), 0, null, 0, 0, 0);
677				} catch (SendIntentException ignored) {
678
679				}
680			}
681		}
682	}
683
684	@Override
685	public void onAffiliationChangedSuccessful(Jid jid) {
686		refreshUi();
687	}
688
689	@Override
690	public void onAffiliationChangeFailed(Jid jid, int resId) {
691		displayToast(getString(resId,jid.toBareJid().toString()));
692	}
693
694	@Override
695	public void onRoleChangedSuccessful(String nick) {
696
697	}
698
699	@Override
700	public void onRoleChangeFailed(String nick, int resId) {
701		displayToast(getString(resId,nick));
702	}
703
704	@Override
705	public void onPushSucceeded() {
706		displayToast(getString(R.string.modified_conference_options));
707	}
708
709	@Override
710	public void onPushFailed() {
711		displayToast(getString(R.string.could_not_modify_conference_options));
712	}
713
714	private void displayToast(final String msg) {
715		runOnUiThread(new Runnable() {
716			@Override
717			public void run() {
718				Toast.makeText(ConferenceDetailsActivity.this,msg,Toast.LENGTH_SHORT).show();
719			}
720		});
721	}
722}