mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 13:35:33 +03:00
parent
364480ccf4
commit
7cf28e775b
4 changed files with 64 additions and 49 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
package com.nextcloud.talk.adapters.items;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.view.View;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.model.GlideUrl;
|
||||
|
@ -30,6 +31,7 @@ import com.nextcloud.talk.R;
|
|||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.models.database.UserEntity;
|
||||
import com.nextcloud.talk.utils.ApiUtils;
|
||||
import com.nextcloud.talk.utils.DisplayUtils;
|
||||
import com.nextcloud.talk.utils.glide.GlideApp;
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
||||
|
@ -82,6 +84,7 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||
}
|
||||
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, UserItem.UserItemViewHolder holder, int position, List<Object> payloads) {
|
||||
|
||||
|
@ -89,31 +92,39 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||
FlexibleUtils.highlightText(holder.contactDisplayName, displayName,
|
||||
String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.getSharedApplication()
|
||||
.getResources().getColor(R.color.colorPrimary));
|
||||
FlexibleUtils.highlightText(holder.contactMentionId, "@" + userId,
|
||||
String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.getSharedApplication()
|
||||
.getResources().getColor(R.color.colorPrimary));
|
||||
if (holder.contactMentionId != null) {
|
||||
FlexibleUtils.highlightText(holder.contactMentionId, "@" + userId,
|
||||
String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.getSharedApplication()
|
||||
.getResources().getColor(R.color.colorPrimary));
|
||||
}
|
||||
} else {
|
||||
holder.contactDisplayName.setText(displayName);
|
||||
holder.contactMentionId.setText("@" + userId);
|
||||
if (holder.contactMentionId != null) {
|
||||
holder.contactMentionId.setText("@" + userId);
|
||||
}
|
||||
}
|
||||
|
||||
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(currentUser.getBaseUrl(),
|
||||
userId, R.dimen.avatar_size), new LazyHeaders.Builder()
|
||||
.setHeader("Accept", "image/*")
|
||||
.setHeader("User-Agent", ApiUtils.getUserAgent())
|
||||
.build());
|
||||
if (userId.equals("all")) {
|
||||
holder.avatarFlipView.setFrontImageBitmap(DisplayUtils.getRoundedBitmapFromVectorDrawableResource(NextcloudTalkApplication.getSharedApplication().getResources(), R.drawable.ic_people_group_white_24px));
|
||||
} else {
|
||||
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(currentUser.getBaseUrl(),
|
||||
userId, R.dimen.avatar_size), new LazyHeaders.Builder()
|
||||
.setHeader("Accept", "image/*")
|
||||
.setHeader("User-Agent", ApiUtils.getUserAgent())
|
||||
.build());
|
||||
|
||||
int avatarSize = Math.round(NextcloudTalkApplication
|
||||
.getSharedApplication().getResources().getDimension(R.dimen.avatar_size));
|
||||
int avatarSize = Math.round(NextcloudTalkApplication
|
||||
.getSharedApplication().getResources().getDimension(R.dimen.avatar_size));
|
||||
|
||||
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(holder.avatarFlipView.getFrontImageView());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -132,24 +132,26 @@ public class MagicIncomingTextMessageViewHolder
|
|||
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") || individualHashMap.get("type").equals("guest")) {
|
||||
int color;
|
||||
if (individualHashMap != null) {
|
||||
if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest") || individualHashMap.get("type").equals("call")) {
|
||||
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(), "@" + individualHashMap.get("name"), color);
|
||||
} else if (individualHashMap.get("type").equals("file")) {
|
||||
itemView.setOnClickListener(v -> {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link")));
|
||||
context.startActivity(browserIntent);
|
||||
});
|
||||
|
||||
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(), "@" + individualHashMap.get("name"), color);
|
||||
} else if (individualHashMap.get("type").equals("file")) {
|
||||
itemView.setOnClickListener(v -> {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link")));
|
||||
context.startActivity(browserIntent);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,20 +88,22 @@ public class MagicOutcomingTextMessageViewHolder extends MessageHolders.Outcomin
|
|||
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") || individualHashMap.get("type").equals("guest")) {
|
||||
if (!individualHashMap.get("id").equals(message.getActiveUserId())) {
|
||||
messageString =
|
||||
DisplayUtils.searchAndColor(message.getText(),
|
||||
"@" + individualHashMap.get("name"), NextcloudTalkApplication
|
||||
.getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_default));
|
||||
if (individualHashMap != null) {
|
||||
if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest") || individualHashMap.get("type").equals("call")) {
|
||||
if (!individualHashMap.get("id").equals(message.getActiveUserId())) {
|
||||
messageString =
|
||||
DisplayUtils.searchAndColor(message.getText(),
|
||||
"@" + individualHashMap.get("name"), NextcloudTalkApplication
|
||||
.getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_default));
|
||||
}
|
||||
|
||||
} else if (individualHashMap.get("type").equals("file")) {
|
||||
itemView.setOnClickListener(v -> {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link")));
|
||||
context.startActivity(browserIntent);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
} else if (individualHashMap.get("type").equals("file")) {
|
||||
itemView.setOnClickListener(v -> {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link")));
|
||||
context.startActivity(browserIntent);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class MagicSystemMessageViewHolder extends MessageHolders.IncomingTextMes
|
|||
for (String key : message.getMessageParameters().keySet()) {
|
||||
Map<String, String> individualHashMap = message.getMessageParameters().get(key);
|
||||
int color;
|
||||
if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest")) {
|
||||
if (individualHashMap != null && (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest") || individualHashMap.get("type").equals("call"))) {
|
||||
|
||||
if (individualHashMap.get("id").equals(message.getActiveUserId())) {
|
||||
color = context.getResources().getColor(R.color.nc_incoming_text_mention_you);
|
||||
|
|
Loading…
Reference in a new issue