mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-10 17:40:03 +00:00
parent
026db931c2
commit
d6457bc997
@ -156,7 +156,7 @@ dependencies {
|
||||
|
||||
implementation 'com.github.wooplr:Spotlight:1.2.3'
|
||||
|
||||
implementation 'com.github.stfalcon:chatkit:0.3.0'
|
||||
implementation 'com.github.mario:ChatKit:master-SNAPSHOT'
|
||||
implementation 'com.otaliastudios:autocomplete:1.1.0'
|
||||
|
||||
implementation 'com.github.Kennyc1012:BottomSheet:2.4.0'
|
||||
|
@ -21,6 +21,9 @@
|
||||
package com.nextcloud.talk.adapters.messages;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
@ -92,7 +95,7 @@ public class MagicIncomingTextMessageViewHolder
|
||||
messageAuthor.setText(R.string.nc_nick_guest);
|
||||
}
|
||||
|
||||
if (message.getActorType().equals("guests")) {
|
||||
if (message.getActorType().equals("guests") && !message.isGrouped()) {
|
||||
TextDrawable drawable = TextDrawable.builder().beginConfig().bold()
|
||||
.endConfig().buildRound(String.valueOf(messageAuthor.getText().charAt(0)), NextcloudTalkApplication
|
||||
.getSharedApplication().getResources().getColor(R.color.nc_grey));
|
||||
@ -100,6 +103,23 @@ public class MagicIncomingTextMessageViewHolder
|
||||
messageUserAvatarView.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
Resources resources = NextcloudTalkApplication.getSharedApplication().getResources();
|
||||
if (message.isGrouped()) {
|
||||
messageUserAvatarView.setVisibility(View.INVISIBLE);
|
||||
Drawable bubbleDrawable = DisplayUtils.getMessageSelector(resources.getColor(R.color.white_two),
|
||||
resources.getColor(R.color.transparent),
|
||||
resources.getColor(R.color.white_two), R.drawable.shape_grouped_incoming_message);
|
||||
ViewCompat.setBackground(bubble, bubbleDrawable);
|
||||
messageAuthor.setVisibility(View.GONE);
|
||||
} else {
|
||||
messageUserAvatarView.setVisibility(View.VISIBLE);
|
||||
Drawable bubbleDrawable = DisplayUtils.getMessageSelector(resources.getColor(R.color.white_two),
|
||||
resources.getColor(R.color.transparent),
|
||||
resources.getColor(R.color.white_two), R.drawable.shape_incoming_message);
|
||||
ViewCompat.setBackground(bubble, bubbleDrawable);
|
||||
messageAuthor.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
HashMap<String, HashMap<String, String>> messageParameters = message.getMessageParameters();
|
||||
|
||||
Context context = NextcloudTalkApplication.getSharedApplication().getApplicationContext();
|
||||
|
@ -21,6 +21,9 @@
|
||||
package com.nextcloud.talk.adapters.messages;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
@ -106,6 +109,19 @@ public class MagicOutcomingTextMessageViewHolder extends MessageHolders.Outcomin
|
||||
itemView.setSelected(true);
|
||||
}
|
||||
|
||||
Resources resources = NextcloudTalkApplication.getSharedApplication().getResources();
|
||||
if (message.isGrouped()) {
|
||||
Drawable bubbleDrawable = DisplayUtils.getMessageSelector(resources.getColor(R.color.colorPrimary),
|
||||
resources.getColor(R.color.transparent),
|
||||
resources.getColor(R.color.colorPrimary), R.drawable.shape_grouped_outcoming_message);
|
||||
ViewCompat.setBackground(bubble, bubbleDrawable);
|
||||
} else {
|
||||
Drawable bubbleDrawable = DisplayUtils.getMessageSelector(resources.getColor(R.color.colorPrimary),
|
||||
resources.getColor(R.color.transparent),
|
||||
resources.getColor(R.color.colorPrimary), R.drawable.shape_outcoming_message);
|
||||
ViewCompat.setBackground(bubble, bubbleDrawable);
|
||||
}
|
||||
|
||||
messageTimeView.setLayoutParams(layoutParams);
|
||||
messageText.setText(messageString);
|
||||
}
|
||||
|
@ -172,6 +172,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
private boolean isFirstMessagesProcessing = true;
|
||||
private boolean isHelloClicked;
|
||||
|
||||
private final short VIEW_TYPE_DATE_HEADER = 130;
|
||||
public ChatController(Bundle args) {
|
||||
super(args);
|
||||
setHasOptionsMenu(true);
|
||||
@ -748,7 +749,17 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
|
||||
if (!isFromTheFuture) {
|
||||
|
||||
int countGroupedMessages = 0;
|
||||
for (int i = 0; i < chatMessageList.size(); i++) {
|
||||
if (chatMessageList.size() > i + 1) {
|
||||
if (chatMessageList.get(i + 1).getActorId().equals(chatMessageList.get(i).getActorId()) &&
|
||||
countGroupedMessages < 4) {
|
||||
chatMessageList.get(i).setGrouped(true);
|
||||
countGroupedMessages++;
|
||||
} else {
|
||||
countGroupedMessages = 0;
|
||||
}
|
||||
}
|
||||
chatMessageList.get(i).setBaseUrl(conversationUser.getBaseUrl());
|
||||
if (globalLastKnownPastMessageId == -1 || chatMessageList.get(i).getJsonMessageId() <
|
||||
globalLastKnownPastMessageId) {
|
||||
@ -762,15 +773,17 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
adapter.addToEnd(chatMessageList, false);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
ChatMessage chatMessage;
|
||||
|
||||
for (int i = 0; i < chatMessageList.size(); i++) {
|
||||
chatMessageList.get(i).setBaseUrl(conversationUser.getBaseUrl());
|
||||
chatMessage = chatMessageList.get(i);
|
||||
|
||||
chatMessage.setBaseUrl(conversationUser.getBaseUrl());
|
||||
if (conversationUser.getUserId().equals("?") && !TextUtils.isEmpty(myFirstMessage.toString())) {
|
||||
ChatMessage chatMessage = chatMessageList.get(i);
|
||||
if (chatMessage.getActorType().equals("guests") &&
|
||||
chatMessage.getActorDisplayName().equals(conversationUser.getDisplayName())) {
|
||||
conversationUser.setUserId(chatMessage.getActorId());
|
||||
@ -792,7 +805,15 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
newMessagesCount = 0;
|
||||
}
|
||||
|
||||
adapter.addToStart(chatMessageList.get(i), shouldScroll);
|
||||
if (i == 0) {
|
||||
if (adapter.isPreviousSameAuthor(chatMessage.getActorId(), 0)) {
|
||||
chatMessage.setGrouped(true);
|
||||
}
|
||||
} else if (chatMessage.getActorId().equals(chatMessageList.get(i - 1).getActorId())) {
|
||||
chatMessage.setGrouped(true);
|
||||
}
|
||||
|
||||
adapter.addToStart(chatMessage, shouldScroll);
|
||||
}
|
||||
|
||||
String xChatLastGivenHeader;
|
||||
|
@ -57,6 +57,7 @@ public class ChatMessage implements IMessage {
|
||||
String message;
|
||||
@JsonField(name = "messageParameters")
|
||||
HashMap<String, HashMap<String, String>> messageParameters;
|
||||
boolean isGrouped;
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
|
@ -22,6 +22,7 @@ package com.nextcloud.talk.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@ -29,6 +30,8 @@ import android.os.Build;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v7.widget.AppCompatDrawableManager;
|
||||
import android.text.Spannable;
|
||||
import android.text.TextUtils;
|
||||
@ -111,4 +114,25 @@ public class DisplayUtils {
|
||||
|
||||
return spannable;
|
||||
}
|
||||
|
||||
public static Drawable getMessageSelector(@ColorInt int normalColor, @ColorInt int selectedColor,
|
||||
@ColorInt int pressedColor, @DrawableRes int shape) {
|
||||
|
||||
Drawable vectorDrawable = ContextCompat.getDrawable(NextcloudTalkApplication.getSharedApplication()
|
||||
.getApplicationContext(),
|
||||
shape);
|
||||
Drawable drawable = DrawableCompat.wrap(vectorDrawable).mutate();
|
||||
DrawableCompat.setTintList(
|
||||
drawable,
|
||||
new ColorStateList(
|
||||
new int[][]{
|
||||
new int[]{android.R.attr.state_selected},
|
||||
new int[]{android.R.attr.state_pressed},
|
||||
new int[]{-android.R.attr.state_pressed, -android.R.attr.state_selected}
|
||||
},
|
||||
new int[]{selectedColor, pressedColor, normalColor}
|
||||
));
|
||||
return drawable;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user