mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-07 22:51:58 +00:00
Fix #318 and better participants list
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
fcc5e30eb6
commit
a4279f28f5
app/src/main
java/com/nextcloud/talk
adapters/items
controllers
models/json/participants
res/layout
@ -24,6 +24,7 @@ import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.model.GlideUrl;
|
||||
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.application.NextcloudTalkApplication;
|
||||
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.utils.ApiUtils;
|
||||
import com.nextcloud.talk.utils.glide.GlideApp;
|
||||
@ -103,7 +105,7 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
||||
if (header != null) {
|
||||
return R.layout.rv_item_contact;
|
||||
} else {
|
||||
return R.layout.rv_item_participant;
|
||||
return R.layout.rv_item_mention;
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,32 +122,41 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
||||
flipView.flipSilently(adapter.isSelected(position));
|
||||
|
||||
if (adapter.hasFilter()) {
|
||||
FlexibleUtils.highlightText(holder.contactDisplayName, participant.getName(),
|
||||
FlexibleUtils.highlightText(holder.contactDisplayName, participant.getDisplayName(),
|
||||
String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.getSharedApplication()
|
||||
.getResources().getColor(R.color.colorPrimary));
|
||||
} 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
|
||||
.getSharedApplication().getResources().getDimension(R.dimen.avatar_size));
|
||||
|
||||
if (TextUtils.isEmpty(participant.getSource()) || participant.getSource().equals("users")) {
|
||||
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||
participant.getUserId(), R.dimen.avatar_size), new LazyHeaders.Builder()
|
||||
.setHeader("Accept", "image/*")
|
||||
.setHeader("User-Agent", ApiUtils.getUserAgent())
|
||||
.build());
|
||||
|
||||
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(),
|
||||
participant.getUserId(), R.dimen.avatar_size), new LazyHeaders.Builder()
|
||||
.setHeader("Accept", "image/*")
|
||||
.setHeader("User-Agent", ApiUtils.getUserAgent())
|
||||
.build());
|
||||
|
||||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||
.asBitmap()
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.load(glideUrl)
|
||||
.centerInside()
|
||||
.override(avatarSize, avatarSize)
|
||||
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||
.into(holder.avatarFlipView.getFrontImageView());
|
||||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||
.asBitmap()
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.load(glideUrl)
|
||||
.centerInside()
|
||||
.override(avatarSize, avatarSize)
|
||||
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||
.into(flipView.getFrontImageView());
|
||||
}
|
||||
} else if (participant.getSource().equals("groups")) {
|
||||
|
||||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||
@ -155,7 +166,7 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
||||
.centerInside()
|
||||
.override(avatarSize, avatarSize)
|
||||
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||
.into(holder.avatarFlipView.getFrontImageView());
|
||||
.into(flipView.getFrontImageView());
|
||||
}
|
||||
|
||||
if (!isEnabled()) {
|
||||
@ -163,12 +174,52 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
||||
} else {
|
||||
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
|
||||
public boolean filter(String constraint) {
|
||||
return participant.getName() != null &&
|
||||
StringUtils.containsIgnoreCase(participant.getName().trim(), constraint);
|
||||
return participant.getDisplayName() != null &&
|
||||
StringUtils.containsIgnoreCase(participant.getDisplayName().trim(), constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -411,7 +411,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
|
||||
InputFilter[] filters = new InputFilter[1];
|
||||
filters[0] = new InputFilter.LengthFilter(1000);
|
||||
messageInputView.getInputEditText() .setFilters(filters);
|
||||
messageInputView.getInputEditText().setFilters(filters);
|
||||
|
||||
messageInputView.getInputEditText().addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
@ -695,16 +695,22 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (e instanceof HttpException && ((HttpException) e).code() == 201) {
|
||||
if (conversationUser.getUserId().equals("?") && TextUtils.isEmpty(myFirstMessage.toString())) {
|
||||
myFirstMessage = message;
|
||||
}
|
||||
if (e instanceof HttpException) {
|
||||
int code = ((HttpException) e).code();
|
||||
if (Integer.toString(code).startsWith("2")) {
|
||||
if (conversationUser.getUserId().equals("?") && TextUtils.isEmpty(myFirstMessage.toString())) {
|
||||
myFirstMessage = message;
|
||||
}
|
||||
|
||||
if (popupBubble != null && popupBubble.isShown()) {
|
||||
popupBubble.hide();
|
||||
}
|
||||
if (popupBubble != null && popupBubble.isShown()) {
|
||||
popupBubble.hide();
|
||||
}
|
||||
|
||||
messagesListView.smoothScrollToPosition(0);
|
||||
messagesListView.smoothScrollToPosition(0);
|
||||
} else {
|
||||
sendMessage(message, attempt + 1);
|
||||
|
||||
}
|
||||
} else {
|
||||
sendMessage(message, attempt + 1);
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ import com.yarolegovich.mp.MaterialPreferenceScreen;
|
||||
import org.parceler.Parcels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@ -172,32 +174,22 @@ public class ConversationInfoController extends BaseController {
|
||||
private void handleParticipants(List<Participant> participants) {
|
||||
UserItem userItem;
|
||||
Participant participant;
|
||||
EnumParticipantTypeConverter enumParticipantTypeConverter = new EnumParticipantTypeConverter();
|
||||
|
||||
recyclerViewItems = new ArrayList<>();
|
||||
HashMap<String, HashMap<String, Object>> conversationParticipants = conversation.getParticipants();
|
||||
HashMap<String, Object> internalHashMap;
|
||||
UserItem ownUserItem = null;
|
||||
|
||||
for (int i = 0; i < participants.size(); 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.setEnabled(!participant.getSessionId().equals("0"));
|
||||
if (!participant.getUserId().equals(conversationUser.getUserId())) {
|
||||
if (!TextUtils.isEmpty(participant.getUserId()) && !participant.getUserId().equals(conversationUser.getUserId())) {
|
||||
ownUserItem = userItem;
|
||||
} else {
|
||||
recyclerViewItems.add(userItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ownUserItem != null) {
|
||||
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.JsonObject;
|
||||
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
@ -34,12 +35,15 @@ public class Participant {
|
||||
@JsonField(name = "userId")
|
||||
String userId;
|
||||
|
||||
@JsonField(name = "type")
|
||||
@JsonField(name = {"type", "participantType"}, typeConverter = EnumParticipantTypeConverter.class)
|
||||
ParticipantType type;
|
||||
|
||||
@JsonField(name = "name")
|
||||
String name;
|
||||
|
||||
@JsonField(name = "displayName")
|
||||
String displayName;
|
||||
|
||||
@JsonField(name = "lastPing")
|
||||
long lastPing;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ @author Mario Danic
|
||||
@ -20,23 +19,22 @@
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/item_height"
|
||||
android:orientation="vertical">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/item_height"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.nextcloud.talk.utils.MagicFlipView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<com.nextcloud.talk.utils.MagicFlipView xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/avatar_flip_view"
|
||||
android:layout_width="@dimen/avatar_size"
|
||||
android:layout_height="@dimen/avatar_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||
app:animationDuration="170"
|
||||
app:enableInitialAnimation="true"
|
||||
app:rearBackgroundColor="@color/colorPrimary"/>
|
||||
app:rearBackgroundColor="@color/colorPrimary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name_text"
|
||||
@ -47,6 +45,6 @@
|
||||
android:layout_toEndOf="@id/avatar_flip_view"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
tools:text="Contact item text"/>
|
||||
tools:text="Contact item text" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user