@Override
        public void onClick(View v) {
          MucOptions muc = conversation.getMucOptions();
          String password = muc.getPassword();
          if (password == null) {
            password = "";
          }
          activity.quickPasswordEdit(
              password,
              new OnValueEdited() {

                @Override
                public void onValueEdited(String value) {
                  activity.xmppConnectionService.providePasswordForMuc(conversation, value);
                }
              });
        }
 private String key(MucOptions options, int size) {
   synchronized (this.sizes) {
     if (!this.sizes.contains(size)) {
       this.sizes.add(size);
     }
   }
   return PREFIX_CONVERSATION
       + "_"
       + options.getConversation().getUuid()
       + "_"
       + String.valueOf(size);
 }
  public Bitmap get(MucOptions mucOptions, int size) {
    final String KEY = key(mucOptions, size);
    Bitmap bitmap = this.mXmppConnectionService.getBitmapCache().get(KEY);
    if (bitmap != null) {
      return bitmap;
    }
    List<MucOptions.User> users = mucOptions.getUsers();
    int count = users.size();
    bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    bitmap.eraseColor(TRANSPARENT);

    if (count == 0) {
      String name = mucOptions.getConversation().getName();
      String letter = name.substring(0, 1);
      int color = this.getColorForName(name);
      drawTile(canvas, letter, color, 0, 0, size, size);
    } else if (count == 1) {
      drawTile(canvas, users.get(0), 0, 0, size, size);
    } else if (count == 2) {
      drawTile(canvas, users.get(0), 0, 0, size / 2 - 1, size);
      drawTile(canvas, users.get(1), size / 2 + 1, 0, size, size);
    } else if (count == 3) {
      drawTile(canvas, users.get(0), 0, 0, size / 2 - 1, size);
      drawTile(canvas, users.get(1), size / 2 + 1, 0, size, size / 2 - 1);
      drawTile(canvas, users.get(2), size / 2 + 1, size / 2 + 1, size, size);
    } else if (count == 4) {
      drawTile(canvas, users.get(0), 0, 0, size / 2 - 1, size / 2 - 1);
      drawTile(canvas, users.get(1), 0, size / 2 + 1, size / 2 - 1, size);
      drawTile(canvas, users.get(2), size / 2 + 1, 0, size, size / 2 - 1);
      drawTile(canvas, users.get(3), size / 2 + 1, size / 2 + 1, size, size);
    } else {
      drawTile(canvas, users.get(0), 0, 0, size / 2 - 1, size / 2 - 1);
      drawTile(canvas, users.get(1), 0, size / 2 + 1, size / 2 - 1, size);
      drawTile(canvas, users.get(2), size / 2 + 1, 0, size, size / 2 - 1);
      drawTile(canvas, "\u2026", PLACEHOLDER_COLOR, size / 2 + 1, size / 2 + 1, size, size);
    }
    this.mXmppConnectionService.getBitmapCache().put(KEY, bitmap);
    return bitmap;
  }
 public void parseConferencePresence(PresencePacket packet, Account account) {
   final Conversation conversation =
       packet.getFrom() == null
           ? null
           : mXmppConnectionService.find(account, packet.getFrom().toBareJid());
   if (conversation != null) {
     final MucOptions mucOptions = conversation.getMucOptions();
     boolean before = mucOptions.online();
     int count = mucOptions.getUserCount();
     final List<MucOptions.User> tileUserBefore = mucOptions.getUsers(5);
     processConferencePresence(packet, mucOptions);
     final List<MucOptions.User> tileUserAfter = mucOptions.getUsers(5);
     if (!tileUserAfter.equals(tileUserBefore)) {
       mXmppConnectionService.getAvatarService().clear(mucOptions);
     }
     if (before != mucOptions.online()
         || (mucOptions.online() && count != mucOptions.getUserCount())) {
       mXmppConnectionService.updateConversationUi();
     } else if (mucOptions.online()) {
       mXmppConnectionService.updateMucRosterUi();
     }
   }
 }
 private void processConferencePresence(PresencePacket packet, MucOptions mucOptions) {
   final Jid from = packet.getFrom();
   if (!from.isBareJid()) {
     final String type = packet.getAttribute("type");
     final Element x = packet.findChild("x", "http://jabber.org/protocol/muc#user");
     Avatar avatar = Avatar.parsePresence(packet.findChild("x", "vcard-temp:x:update"));
     final List<String> codes = getStatusCodes(x);
     if (type == null) {
       if (x != null) {
         Element item = x.findChild("item");
         if (item != null && !from.isBareJid()) {
           mucOptions.setError(MucOptions.ERROR_NO_ERROR);
           MucOptions.User user = new MucOptions.User(mucOptions, from);
           user.setAffiliation(item.getAttribute("affiliation"));
           user.setRole(item.getAttribute("role"));
           user.setJid(item.getAttributeAsJid("jid"));
           if (codes.contains(MucOptions.STATUS_CODE_SELF_PRESENCE)
               || packet.getFrom().equals(mucOptions.getConversation().getJid())) {
             mucOptions.setOnline();
             mucOptions.setSelf(user);
             if (mucOptions.mNickChangingInProgress) {
               if (mucOptions.onRenameListener != null) {
                 mucOptions.onRenameListener.onSuccess();
               }
               mucOptions.mNickChangingInProgress = false;
             }
           } else {
             mucOptions.addUser(user);
           }
           if (mXmppConnectionService.getPgpEngine() != null) {
             Element signed = packet.findChild("x", "jabber:x:signed");
             if (signed != null) {
               Element status = packet.findChild("status");
               String msg = status == null ? "" : status.getContent();
               long keyId =
                   mXmppConnectionService
                       .getPgpEngine()
                       .fetchKeyId(mucOptions.getAccount(), msg, signed.getContent());
               if (keyId != 0) {
                 user.setPgpKeyId(keyId);
               }
             }
           }
           if (avatar != null) {
             avatar.owner = from;
             if (mXmppConnectionService.getFileBackend().isAvatarCached(avatar)) {
               if (user.setAvatar(avatar)) {
                 mXmppConnectionService.getAvatarService().clear(user);
               }
             } else {
               mXmppConnectionService.fetchAvatar(mucOptions.getAccount(), avatar);
             }
           }
         }
       }
     } else if (type.equals("unavailable")) {
       if (codes.contains(MucOptions.STATUS_CODE_SELF_PRESENCE)
           || packet.getFrom().equals(mucOptions.getConversation().getJid())) {
         if (codes.contains(MucOptions.STATUS_CODE_CHANGED_NICK)) {
           mucOptions.mNickChangingInProgress = true;
         } else if (codes.contains(MucOptions.STATUS_CODE_KICKED)) {
           mucOptions.setError(MucOptions.KICKED_FROM_ROOM);
         } else if (codes.contains(MucOptions.STATUS_CODE_BANNED)) {
           mucOptions.setError(MucOptions.ERROR_BANNED);
         } else if (codes.contains(MucOptions.STATUS_CODE_LOST_MEMBERSHIP)) {
           mucOptions.setError(MucOptions.ERROR_MEMBERS_ONLY);
         } else {
           mucOptions.setError(MucOptions.ERROR_UNKNOWN);
           Log.d(Config.LOGTAG, "unknown error in conference: " + packet);
         }
       } else if (!from.isBareJid()) {
         MucOptions.User user = mucOptions.deleteUser(from.getResourcepart());
         if (user != null) {
           mXmppConnectionService.getAvatarService().clear(user);
         }
       }
     } else if (type.equals("error")) {
       Element error = packet.findChild("error");
       if (error != null && error.hasChild("conflict")) {
         if (mucOptions.online()) {
           if (mucOptions.onRenameListener != null) {
             mucOptions.onRenameListener.onFailure();
           }
         } else {
           mucOptions.setError(MucOptions.ERROR_NICK_IN_USE);
         }
       } else if (error != null && error.hasChild("not-authorized")) {
         mucOptions.setError(MucOptions.ERROR_PASSWORD_REQUIRED);
       } else if (error != null && error.hasChild("forbidden")) {
         mucOptions.setError(MucOptions.ERROR_BANNED);
       } else if (error != null && error.hasChild("registration-required")) {
         mucOptions.setError(MucOptions.ERROR_MEMBERS_ONLY);
       }
     }
   }
 }