mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 04:29:45 +01:00
Fix #318 and better participants list
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
fcc5e30eb6
commit
a4279f28f5
@ -24,6 +24,7 @@ import android.text.TextUtils;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
import com.bumptech.glide.load.model.GlideUrl;
|
import com.bumptech.glide.load.model.GlideUrl;
|
||||||
import com.bumptech.glide.load.model.LazyHeaders;
|
import com.bumptech.glide.load.model.LazyHeaders;
|
||||||
@ -32,6 +33,7 @@ import com.bumptech.glide.request.RequestOptions;
|
|||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
import com.nextcloud.talk.models.database.UserEntity;
|
||||||
|
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
||||||
import com.nextcloud.talk.models.json.participants.Participant;
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
import com.nextcloud.talk.utils.glide.GlideApp;
|
import com.nextcloud.talk.utils.glide.GlideApp;
|
||||||
@ -103,7 +105,7 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
if (header != null) {
|
if (header != null) {
|
||||||
return R.layout.rv_item_contact;
|
return R.layout.rv_item_contact;
|
||||||
} else {
|
} else {
|
||||||
return R.layout.rv_item_participant;
|
return R.layout.rv_item_mention;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,24 +122,32 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
flipView.flipSilently(adapter.isSelected(position));
|
flipView.flipSilently(adapter.isSelected(position));
|
||||||
|
|
||||||
if (adapter.hasFilter()) {
|
if (adapter.hasFilter()) {
|
||||||
FlexibleUtils.highlightText(holder.contactDisplayName, participant.getName(),
|
FlexibleUtils.highlightText(holder.contactDisplayName, participant.getDisplayName(),
|
||||||
String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.getSharedApplication()
|
String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.getSharedApplication()
|
||||||
.getResources().getColor(R.color.colorPrimary));
|
.getResources().getColor(R.color.colorPrimary));
|
||||||
} else {
|
} else {
|
||||||
holder.contactDisplayName.setText(participant.getName());
|
holder.contactDisplayName.setText(participant.getDisplayName());
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(participant.getDisplayName()) &&
|
||||||
|
(participant.getType().equals(Participant.ParticipantType.GUEST) || participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {
|
||||||
|
holder.contactDisplayName.setText(NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_guest));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int avatarSize = Math.round(NextcloudTalkApplication
|
int avatarSize = Math.round(NextcloudTalkApplication
|
||||||
.getSharedApplication().getResources().getDimension(R.dimen.avatar_size));
|
.getSharedApplication().getResources().getDimension(R.dimen.avatar_size));
|
||||||
|
|
||||||
if (TextUtils.isEmpty(participant.getSource()) || participant.getSource().equals("users")) {
|
if (TextUtils.isEmpty(participant.getSource()) || participant.getSource().equals("users")) {
|
||||||
|
|
||||||
|
if (participant.getType().equals(Participant.ParticipantType.GUEST) || participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK)) {
|
||||||
|
// TODO: Show generated avatar for guests
|
||||||
|
} else {
|
||||||
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||||
participant.getUserId(), R.dimen.avatar_size), new LazyHeaders.Builder()
|
participant.getUserId(), R.dimen.avatar_size), new LazyHeaders.Builder()
|
||||||
.setHeader("Accept", "image/*")
|
.setHeader("Accept", "image/*")
|
||||||
.setHeader("User-Agent", ApiUtils.getUserAgent())
|
.setHeader("User-Agent", ApiUtils.getUserAgent())
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
|
||||||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
@ -145,7 +155,8 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
.centerInside()
|
.centerInside()
|
||||||
.override(avatarSize, avatarSize)
|
.override(avatarSize, avatarSize)
|
||||||
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||||
.into(holder.avatarFlipView.getFrontImageView());
|
.into(flipView.getFrontImageView());
|
||||||
|
}
|
||||||
} else if (participant.getSource().equals("groups")) {
|
} else if (participant.getSource().equals("groups")) {
|
||||||
|
|
||||||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||||
@ -155,7 +166,7 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
.centerInside()
|
.centerInside()
|
||||||
.override(avatarSize, avatarSize)
|
.override(avatarSize, avatarSize)
|
||||||
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||||
.into(holder.avatarFlipView.getFrontImageView());
|
.into(flipView.getFrontImageView());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
@ -163,12 +174,52 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
} else {
|
} else {
|
||||||
holder.itemView.setAlpha(1.0f);
|
holder.itemView.setAlpha(1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: show what the user is doing currently
|
||||||
|
long participantFlags = participant.getParticipantFlags();
|
||||||
|
if (participantFlags == 0) {
|
||||||
|
} else if (participantFlags == 1) {
|
||||||
|
// do nothing, just in call
|
||||||
|
} else if (participantFlags == 2) {
|
||||||
|
// with audio
|
||||||
|
} else if (participantFlags == 4) {
|
||||||
|
// with video
|
||||||
|
} else if (participantFlags == 7) {
|
||||||
|
// video and audio
|
||||||
|
}
|
||||||
|
|
||||||
|
String userType = "";
|
||||||
|
|
||||||
|
if (header == null) {
|
||||||
|
switch (new EnumParticipantTypeConverter().convertToInt(participant.getType())) {
|
||||||
|
case 1:
|
||||||
|
userType = NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_owner);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
userType = NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_moderator);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
userType = NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_user);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
userType = NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_guest);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
userType = NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_following_link);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.contactMentionId.setText(userType);
|
||||||
|
holder.contactMentionId.setTextColor(NextcloudTalkApplication.getSharedApplication().getColor(R.color.colorPrimary));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filter(String constraint) {
|
public boolean filter(String constraint) {
|
||||||
return participant.getName() != null &&
|
return participant.getDisplayName() != null &&
|
||||||
StringUtils.containsIgnoreCase(participant.getName().trim(), constraint);
|
StringUtils.containsIgnoreCase(participant.getDisplayName().trim(), constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -411,7 +411,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
|
|
||||||
InputFilter[] filters = new InputFilter[1];
|
InputFilter[] filters = new InputFilter[1];
|
||||||
filters[0] = new InputFilter.LengthFilter(1000);
|
filters[0] = new InputFilter.LengthFilter(1000);
|
||||||
messageInputView.getInputEditText() .setFilters(filters);
|
messageInputView.getInputEditText().setFilters(filters);
|
||||||
|
|
||||||
messageInputView.getInputEditText().addTextChangedListener(new TextWatcher() {
|
messageInputView.getInputEditText().addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
@ -695,7 +695,9 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
if (e instanceof HttpException && ((HttpException) e).code() == 201) {
|
if (e instanceof HttpException) {
|
||||||
|
int code = ((HttpException) e).code();
|
||||||
|
if (Integer.toString(code).startsWith("2")) {
|
||||||
if (conversationUser.getUserId().equals("?") && TextUtils.isEmpty(myFirstMessage.toString())) {
|
if (conversationUser.getUserId().equals("?") && TextUtils.isEmpty(myFirstMessage.toString())) {
|
||||||
myFirstMessage = message;
|
myFirstMessage = message;
|
||||||
}
|
}
|
||||||
@ -707,6 +709,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
messagesListView.smoothScrollToPosition(0);
|
messagesListView.smoothScrollToPosition(0);
|
||||||
} else {
|
} else {
|
||||||
sendMessage(message, attempt + 1);
|
sendMessage(message, attempt + 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sendMessage(message, attempt + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,8 @@ import com.yarolegovich.mp.MaterialPreferenceScreen;
|
|||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -172,32 +174,22 @@ public class ConversationInfoController extends BaseController {
|
|||||||
private void handleParticipants(List<Participant> participants) {
|
private void handleParticipants(List<Participant> participants) {
|
||||||
UserItem userItem;
|
UserItem userItem;
|
||||||
Participant participant;
|
Participant participant;
|
||||||
EnumParticipantTypeConverter enumParticipantTypeConverter = new EnumParticipantTypeConverter();
|
|
||||||
|
|
||||||
recyclerViewItems = new ArrayList<>();
|
recyclerViewItems = new ArrayList<>();
|
||||||
HashMap<String, HashMap<String, Object>> conversationParticipants = conversation.getParticipants();
|
|
||||||
HashMap<String, Object> internalHashMap;
|
|
||||||
UserItem ownUserItem = null;
|
UserItem ownUserItem = null;
|
||||||
|
|
||||||
for (int i = 0; i < participants.size(); i++) {
|
for (int i = 0; i < participants.size(); i++) {
|
||||||
participant = participants.get(i);
|
participant = participants.get(i);
|
||||||
internalHashMap = conversationParticipants.get(participant.getUserId());
|
|
||||||
participant.setInCall((long)internalHashMap.get("call") != 0);
|
|
||||||
if (!participant.getUserId().equals(conversationUser.getUserId())) {
|
|
||||||
participant.setName((String) internalHashMap.get("name"));
|
|
||||||
} else {
|
|
||||||
participant.setName(getResources().getString(R.string.nc_chat_you) + " (" + internalHashMap.get("name") + ")");
|
|
||||||
}
|
|
||||||
participant.setType(enumParticipantTypeConverter.getFromInt((int)(long) internalHashMap.get("type")));
|
|
||||||
|
|
||||||
userItem = new UserItem(participant, conversationUser, null);
|
userItem = new UserItem(participant, conversationUser, null);
|
||||||
userItem.setEnabled(!participant.getSessionId().equals("0"));
|
userItem.setEnabled(!participant.getSessionId().equals("0"));
|
||||||
if (!participant.getUserId().equals(conversationUser.getUserId())) {
|
if (!TextUtils.isEmpty(participant.getUserId()) && !participant.getUserId().equals(conversationUser.getUserId())) {
|
||||||
ownUserItem = userItem;
|
ownUserItem = userItem;
|
||||||
} else {
|
} else {
|
||||||
recyclerViewItems.add(userItem);
|
recyclerViewItems.add(userItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ownUserItem != null) {
|
if (ownUserItem != null) {
|
||||||
recyclerViewItems.add(ownUserItem);
|
recyclerViewItems.add(ownUserItem);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ package com.nextcloud.talk.models.json.participants;
|
|||||||
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||||
|
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
||||||
|
|
||||||
import org.parceler.Parcel;
|
import org.parceler.Parcel;
|
||||||
|
|
||||||
@ -34,12 +35,15 @@ public class Participant {
|
|||||||
@JsonField(name = "userId")
|
@JsonField(name = "userId")
|
||||||
String userId;
|
String userId;
|
||||||
|
|
||||||
@JsonField(name = "type")
|
@JsonField(name = {"type", "participantType"}, typeConverter = EnumParticipantTypeConverter.class)
|
||||||
ParticipantType type;
|
ParticipantType type;
|
||||||
|
|
||||||
@JsonField(name = "name")
|
@JsonField(name = "name")
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
|
@JsonField(name = "displayName")
|
||||||
|
String displayName;
|
||||||
|
|
||||||
@JsonField(name = "lastPing")
|
@JsonField(name = "lastPing")
|
||||||
long lastPing;
|
long lastPing;
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
<!--
|
|
||||||
~ Nextcloud Talk application
|
~ Nextcloud Talk application
|
||||||
~
|
~
|
||||||
~ @author Mario Danic
|
~ @author Mario Danic
|
||||||
@ -26,17 +25,16 @@
|
|||||||
android:layout_height="@dimen/item_height"
|
android:layout_height="@dimen/item_height"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.nextcloud.talk.utils.MagicFlipView
|
<com.nextcloud.talk.utils.MagicFlipView xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/avatar_flip_view"
|
android:id="@+id/avatar_flip_view"
|
||||||
android:layout_width="@dimen/avatar_size"
|
android:layout_width="@dimen/avatar_size"
|
||||||
android:layout_height="@dimen/avatar_size"
|
android:layout_height="@dimen/avatar_size"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||||
app:animationDuration="170"
|
app:animationDuration="170"
|
||||||
app:enableInitialAnimation="true"
|
app:enableInitialAnimation="true"
|
||||||
app:rearBackgroundColor="@color/colorPrimary"/>
|
app:rearBackgroundColor="@color/colorPrimary" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/name_text"
|
android:id="@+id/name_text"
|
||||||
@ -47,6 +45,6 @@
|
|||||||
android:layout_toEndOf="@id/avatar_flip_view"
|
android:layout_toEndOf="@id/avatar_flip_view"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
tools:text="Contact item text"/>
|
tools:text="Contact item text" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user