Fix message in chat room

This commit is contained in:
Erwan Croze 2018-09-11 11:22:18 +02:00
parent e52cce611a
commit e544dc5d37
4 changed files with 21 additions and 2 deletions

View file

@ -195,6 +195,8 @@ Vos amis pourront vous joindre plus facilement si vous associez votre compte à
<string name="participant_removed">%s a quitté le groupe</string>
<string name="subject_changed">Nouveau sujet : %s</string>
<string name="admin_set">%s est devenu(e) admin</string>
<string name="admin_set_us">Vous etes devenu(e) admin</string>
<string name="admin_unset_us">Vous n\'êtes plus admin</string>
<string name="admin_unset">%s n\'est plus admin</string>
<string name="chat_room_you_are_now_admin">Vous êtes maintenant admin</string>
<string name="chat_room_you_are_no_longer_admin">Vous n\'êtes plus admin</string>

View file

@ -222,7 +222,9 @@
<string name="security_alert_from">Security alert from %s</string>
<string name="subject_changed">new subject: %s</string>
<string name="admin_set">%s is admin</string>
<string name="admin_set_us">Now, you are admin</string>
<string name="admin_unset">%s is no longer admin</string>
<string name="admin_unset_us">You are no longer admin</string>
<string name="group_chat_notif" formatted="false">%1: %2</string>
<string name="chat_room_you_are_now_admin">You are now admin</string>
<string name="chat_room_you_are_no_longer_admin">You are no longer admin</string>

View file

@ -829,5 +829,11 @@ public final class LinphoneUtils {
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
public static boolean isUs(ProxyConfig proxy, String username) {
if (proxy == null || username == null || username.isEmpty()) return false;
Address proxyConfigContact = proxy.getContact();
return proxyConfigContact.getUsername().equalsIgnoreCase(username);
}
}

View file

@ -73,6 +73,7 @@ import java.util.Arrays;
import java.util.List;
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
import static org.linphone.LinphoneUtils.isUs;
public class ChatEventsAdapter extends ListSelectionAdapter {
private static int MARGIN_BETWEEN_MESSAGES = 10;
@ -431,10 +432,18 @@ public class ChatEventsAdapter extends ListSelectionAdapter {
holder.eventMessage.setText(mContext.getString(R.string.subject_changed).replace("%s", event.getSubject()));
break;
case ConferenceParticipantSetAdmin:
holder.eventMessage.setText(mContext.getString(R.string.admin_set).replace("%s", displayName));
if (isUs(LinphoneManager.getLc().getDefaultProxyConfig(), address.getUsername())) {
holder.eventMessage.setText(mContext.getString(R.string.admin_set_us));
} else {
holder.eventMessage.setText(mContext.getString(R.string.admin_set).replace("%s", displayName));
}
break;
case ConferenceParticipantUnsetAdmin:
holder.eventMessage.setText(mContext.getString(R.string.admin_unset).replace("%s", displayName));
if (isUs(LinphoneManager.getLc().getDefaultProxyConfig(), address.getUsername())) {
holder.eventMessage.setText(mContext.getString(R.string.admin_unset_us));
} else {
holder.eventMessage.setText(mContext.getString(R.string.admin_unset).replace("%s", displayName));
}
break;
case ConferenceParticipantDeviceAdded:
holder.eventMessage.setText(mContext.getString(R.string.device_added).replace("%s", displayName));