count muc participants correctly

This commit is contained in:
Christian Schneppe 2019-01-24 20:24:37 +01:00
parent 141a37a7c8
commit 6d5c7fd4d6
3 changed files with 64 additions and 95 deletions

View file

@ -569,19 +569,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
}
public String getParticipants() {
if (getMode() == MODE_MULTI) {
String generatedName = getMucOptions().createNameFromParticipants();
if (generatedName != null) {
return generatedName;
} else {
return null;
}
} else {
return null;
}
}
public String getAccountUuid() {
return this.accountUuid;
}

View file

@ -766,65 +766,49 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
}
}
} else {
if (conversation.getParticipants() != null) {
ChatState state = ChatState.COMPOSING;
List<MucOptions.User> userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
if (userWithChatStates.size() == 0) {
state = ChatState.PAUSED;
userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
}
List<MucOptions.User> users = conversation.getMucOptions().getUsers(true);
if (state == ChatState.COMPOSING) {
if (userWithChatStates.size() > 0) {
if (userWithChatStates.size() == 1) {
MucOptions.User user = userWithChatStates.get(0);
absubtitle.setText(EmojiWrapper.transform(getString(R.string.contact_is_typing, UIHelper.getDisplayName(user))));
} else {
StringBuilder builder = new StringBuilder();
for (MucOptions.User user : userWithChatStates) {
if (builder.length() != 0) {
builder.append(", ");
}
builder.append(UIHelper.getDisplayName(user));
}
absubtitle.setText(EmojiWrapper.transform(getString(R.string.contacts_are_typing, builder.toString())));
}
}
} else {
if (users.size() == 0) {
absubtitle.setText(getString(R.string.one_participant));
} else {
int size = users.size() + 1;
absubtitle.setText(getString(R.string.more_participants, size));
}
}
absubtitle.setSelected(true);
absubtitle.setOnClickListener(view15 -> {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
switchToContactDetails(conversation.getContact());
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
Intent intent = new Intent(ConversationsActivity.this, ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
}
});
} else {
absubtitle.setText(R.string.no_participants);
abtitle.setSelected(true);
absubtitle.setOnClickListener(view16 -> {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
switchToContactDetails(conversation.getContact());
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
Intent intent = new Intent(ConversationsActivity.this, ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
}
});
ChatState state = ChatState.COMPOSING;
List<MucOptions.User> userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
if (userWithChatStates.size() == 0) {
state = ChatState.PAUSED;
userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
}
List<MucOptions.User> users = conversation.getMucOptions().getUsers(true);
if (state == ChatState.COMPOSING) {
if (userWithChatStates.size() > 0) {
if (userWithChatStates.size() == 1) {
MucOptions.User user = userWithChatStates.get(0);
absubtitle.setText(EmojiWrapper.transform(getString(R.string.contact_is_typing, UIHelper.getDisplayName(user))));
} else {
StringBuilder builder = new StringBuilder();
for (MucOptions.User user : userWithChatStates) {
if (builder.length() != 0) {
builder.append(", ");
}
builder.append(UIHelper.getDisplayName(user));
}
absubtitle.setText(EmojiWrapper.transform(getString(R.string.contacts_are_typing, builder.toString())));
}
}
} else {
if (users.size() == 0) {
absubtitle.setText(getString(R.string.one_participant));
} else {
int size = users.size() + 1;
absubtitle.setText(getString(R.string.more_participants, size));
}
}
absubtitle.setSelected(true);
absubtitle.setOnClickListener(view15 -> {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
switchToContactDetails(conversation.getContact());
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
Intent intent = new Intent(ConversationsActivity.this, ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
}
});
}
return;
}

View file

@ -276,32 +276,30 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
viewHolder.sender.setVisibility(View.GONE);
}
} else {
if (conversation.getParticipants() != null) {
ChatState state = ChatState.COMPOSING;
List<MucOptions.User> userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
if (userWithChatStates.size() == 0) {
state = ChatState.PAUSED;
userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
}
if (state == ChatState.COMPOSING) {
if (userWithChatStates.size() > 0) {
if (userWithChatStates.size() == 1) {
MucOptions.User user = userWithChatStates.get(0);
viewHolder.lastMessage.setText(activity.getString(R.string.contact_is_typing, UIHelper.getDisplayName(user)));
viewHolder.lastMessage.setTypeface(null, Typeface.BOLD_ITALIC);
viewHolder.sender.setVisibility(View.GONE);
} else {
StringBuilder builder = new StringBuilder();
for (MucOptions.User user : userWithChatStates) {
if (builder.length() != 0) {
builder.append(", ");
}
builder.append(UIHelper.getDisplayName(user));
ChatState state = ChatState.COMPOSING;
List<MucOptions.User> userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
if (userWithChatStates.size() == 0) {
state = ChatState.PAUSED;
userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
}
if (state == ChatState.COMPOSING) {
if (userWithChatStates.size() > 0) {
if (userWithChatStates.size() == 1) {
MucOptions.User user = userWithChatStates.get(0);
viewHolder.lastMessage.setText(activity.getString(R.string.contact_is_typing, UIHelper.getDisplayName(user)));
viewHolder.lastMessage.setTypeface(null, Typeface.BOLD_ITALIC);
viewHolder.sender.setVisibility(View.GONE);
} else {
StringBuilder builder = new StringBuilder();
for (MucOptions.User user : userWithChatStates) {
if (builder.length() != 0) {
builder.append(", ");
}
viewHolder.lastMessage.setText(activity.getString(R.string.contacts_are_typing, builder.toString()));
viewHolder.lastMessage.setTypeface(null, Typeface.BOLD_ITALIC);
viewHolder.sender.setVisibility(View.GONE);
builder.append(UIHelper.getDisplayName(user));
}
viewHolder.lastMessage.setText(activity.getString(R.string.contacts_are_typing, builder.toString()));
viewHolder.lastMessage.setTypeface(null, Typeface.BOLD_ITALIC);
viewHolder.sender.setVisibility(View.GONE);
}
}
}