mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 17:08:34 +03:00
parent
b2634a738b
commit
2261c9527c
5 changed files with 44 additions and 14 deletions
|
@ -36,7 +36,6 @@ import com.google.android.flexbox.FlexboxLayout;
|
|||
import com.kevalpatel2106.emoticongifkeyboard.widget.EmoticonTextView;
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.models.database.UserEntity;
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage;
|
||||
import com.nextcloud.talk.utils.DisplayUtils;
|
||||
import com.nextcloud.talk.utils.EmojiDetection;
|
||||
|
@ -72,7 +71,6 @@ public class MagicIncomingTextMessageViewHolder
|
|||
@Inject
|
||||
UserUtils userUtils;
|
||||
|
||||
private UserEntity currentUser;
|
||||
private View itemView;
|
||||
|
||||
public MagicIncomingTextMessageViewHolder(View itemView) {
|
||||
|
@ -81,7 +79,6 @@ public class MagicIncomingTextMessageViewHolder
|
|||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
|
||||
this.itemView = itemView;
|
||||
currentUser = userUtils.getCurrentUser();
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,13 +129,13 @@ public class MagicIncomingTextMessageViewHolder
|
|||
|
||||
Spannable messageString = new SpannableString(message.getText());
|
||||
|
||||
if (messageParameters != null && message.getMessageParameters().size() > 0) {
|
||||
for (String key : message.getMessageParameters().keySet()) {
|
||||
if (messageParameters != null && messageParameters.size() > 0) {
|
||||
for (String key : messageParameters.keySet()) {
|
||||
Map<String, String> individualHashMap = message.getMessageParameters().get(key);
|
||||
if (individualHashMap.get("type").equals("user")) {
|
||||
int color;
|
||||
|
||||
if (individualHashMap.get("id").equals(currentUser.getUserId())) {
|
||||
if (individualHashMap.get("id").equals(message.getActiveUserId())) {
|
||||
color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color
|
||||
.nc_incoming_text_mention_you);
|
||||
} else {
|
||||
|
|
|
@ -34,7 +34,6 @@ import com.google.android.flexbox.FlexboxLayout;
|
|||
import com.kevalpatel2106.emoticongifkeyboard.widget.EmoticonTextView;
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.models.database.UserEntity;
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage;
|
||||
import com.nextcloud.talk.utils.DisplayUtils;
|
||||
import com.nextcloud.talk.utils.EmojiDetection;
|
||||
|
@ -61,8 +60,6 @@ public class MagicOutcomingTextMessageViewHolder extends MessageHolders.Outcomin
|
|||
@Inject
|
||||
UserUtils userUtils;
|
||||
|
||||
private UserEntity currentUser;
|
||||
|
||||
private View itemView;
|
||||
|
||||
public MagicOutcomingTextMessageViewHolder(View itemView) {
|
||||
|
@ -71,7 +68,6 @@ public class MagicOutcomingTextMessageViewHolder extends MessageHolders.Outcomin
|
|||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
|
||||
this.itemView = itemView;
|
||||
currentUser = userUtils.getCurrentUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,11 +85,11 @@ public class MagicOutcomingTextMessageViewHolder extends MessageHolders.Outcomin
|
|||
FlexboxLayout.LayoutParams layoutParams = (FlexboxLayout.LayoutParams) messageTimeView.getLayoutParams();
|
||||
layoutParams.setWrapBefore(false);
|
||||
|
||||
if (messageParameters != null && message.getMessageParameters().size() > 0) {
|
||||
for (String key : message.getMessageParameters().keySet()) {
|
||||
if (messageParameters != null && messageParameters.size() > 0) {
|
||||
for (String key : messageParameters.keySet()) {
|
||||
Map<String, String> individualHashMap = message.getMessageParameters().get(key);
|
||||
if (individualHashMap.get("type").equals("user")) {
|
||||
if (!individualHashMap.get("id").equals(currentUser.getUserId())) {
|
||||
if (!individualHashMap.get("id").equals(message.getActiveUserId())) {
|
||||
messageString = DisplayUtils.searchAndColor(messageText.getText().toString(),
|
||||
messageString, "@" + individualHashMap.get("name"), NextcloudTalkApplication
|
||||
.getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_default));
|
||||
|
|
|
@ -20,11 +20,18 @@
|
|||
|
||||
package com.nextcloud.talk.adapters.messages;
|
||||
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.view.View;
|
||||
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage;
|
||||
import com.nextcloud.talk.utils.DisplayUtils;
|
||||
import com.stfalcon.chatkit.messages.MessageHolders;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class MagicSystemMessageViewHolder extends MessageHolders.IncomingTextMessageViewHolder<ChatMessage> {
|
||||
|
||||
public MagicSystemMessageViewHolder(View itemView) {
|
||||
|
@ -34,6 +41,30 @@ public class MagicSystemMessageViewHolder extends MessageHolders.IncomingTextMes
|
|||
@Override
|
||||
public void onBind(ChatMessage message) {
|
||||
super.onBind(message);
|
||||
text.setText(message.getText());
|
||||
|
||||
Spannable messageString = new SpannableString(message.getText());
|
||||
|
||||
if (message.getMessageParameters() != null && message.getMessageParameters().size() > 0) {
|
||||
for (String key : message.getMessageParameters().keySet()) {
|
||||
Map<String, String> individualHashMap = message.getMessageParameters().get(key);
|
||||
if (individualHashMap.get("type").equals("user")) {
|
||||
int color;
|
||||
|
||||
if (individualHashMap.get("id").equals(message.getActiveUserId())) {
|
||||
color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color
|
||||
.nc_incoming_text_mention_you);
|
||||
} else {
|
||||
color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color
|
||||
.nc_incoming_text_mention_others);
|
||||
}
|
||||
|
||||
messageString = DisplayUtils.searchAndColor(message.getText(),
|
||||
messageString, "@" + individualHashMap.get("name"), color);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
text.setText(messageString);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -813,6 +813,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||
}
|
||||
}
|
||||
chatMessageList.get(i).setBaseUrl(conversationUser.getBaseUrl());
|
||||
chatMessageList.get(i).setActiveUserId(conversationUser.getUserId());
|
||||
if (globalLastKnownPastMessageId == -1 || chatMessageList.get(i).getJsonMessageId() <
|
||||
globalLastKnownPastMessageId) {
|
||||
globalLastKnownPastMessageId = chatMessageList.get(i).getJsonMessageId();
|
||||
|
@ -835,6 +836,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||
chatMessage = chatMessageList.get(i);
|
||||
|
||||
chatMessage.setBaseUrl(conversationUser.getBaseUrl());
|
||||
chatMessageList.get(i).setActiveUserId(conversationUser.getUserId());
|
||||
if (conversationUser.getUserId().equals("?") && !TextUtils.isEmpty(myFirstMessage.toString())) {
|
||||
if (chatMessage.getActorType().equals("guests") &&
|
||||
chatMessage.getActorDisplayName().equals(conversationUser.getDisplayName())) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.nextcloud.talk.models.json.chat;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonIgnore;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.models.json.converters.EnumSystemMessageTypeConverter;
|
||||
|
@ -81,7 +82,10 @@ public class ChatMessage implements IMessage, MessageContentType {
|
|||
@JsonField(name = "systemMessage", typeConverter = EnumSystemMessageTypeConverter.class)
|
||||
SystemMessageType systemMessageType;
|
||||
|
||||
@JsonIgnore
|
||||
boolean isGrouped;
|
||||
@JsonIgnore
|
||||
String activeUserId;
|
||||
|
||||
|
||||
public String getBaseUrl() {
|
||||
|
|
Loading…
Reference in a new issue