mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 23:25:20 +03:00
Fix call chips in edit text
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
c121ffdd5d
commit
bd3eae81d2
5 changed files with 33 additions and 19 deletions
|
@ -45,18 +45,28 @@ import java.util.List;
|
|||
public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
||||
implements IFilterable<String> {
|
||||
|
||||
private String userId;
|
||||
private String objectId;
|
||||
private String displayName;
|
||||
private String source;
|
||||
private UserEntity currentUser;
|
||||
|
||||
public MentionAutocompleteItem(String userId, String displayName, UserEntity currentUser) {
|
||||
this.userId = userId;
|
||||
public MentionAutocompleteItem(String objectId, String displayName, String source, UserEntity currentUser) {
|
||||
this.objectId = objectId;
|
||||
this.displayName = displayName;
|
||||
this.source = source;
|
||||
this.currentUser = currentUser;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
|
@ -67,7 +77,7 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||
public boolean equals(Object o) {
|
||||
if (o instanceof MentionAutocompleteItem) {
|
||||
MentionAutocompleteItem inItem = (MentionAutocompleteItem) o;
|
||||
return (userId.equals(inItem.userId) && displayName.equals(inItem.displayName));
|
||||
return (objectId.equals(inItem.objectId) && displayName.equals(inItem.displayName));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -93,22 +103,22 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||
String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.getSharedApplication()
|
||||
.getResources().getColor(R.color.colorPrimary));
|
||||
if (holder.contactMentionId != null) {
|
||||
FlexibleUtils.highlightText(holder.contactMentionId, "@" + userId,
|
||||
FlexibleUtils.highlightText(holder.contactMentionId, "@" + objectId,
|
||||
String.valueOf(adapter.getFilter(String.class)), NextcloudTalkApplication.getSharedApplication()
|
||||
.getResources().getColor(R.color.colorPrimary));
|
||||
}
|
||||
} else {
|
||||
holder.contactDisplayName.setText(displayName);
|
||||
if (holder.contactMentionId != null) {
|
||||
holder.contactMentionId.setText("@" + userId);
|
||||
holder.contactMentionId.setText("@" + objectId);
|
||||
}
|
||||
}
|
||||
|
||||
if (userId.equals("all")) {
|
||||
if (source.equals("calls")) {
|
||||
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()
|
||||
objectId, R.dimen.avatar_size), new LazyHeaders.Builder()
|
||||
.setHeader("Accept", "image/*")
|
||||
.setHeader("User-Agent", ApiUtils.getUserAgent())
|
||||
.build());
|
||||
|
@ -129,7 +139,7 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||
|
||||
@Override
|
||||
public boolean filter(String constraint) {
|
||||
return userId != null && StringUtils.containsIgnoreCase(userId, constraint) ||
|
||||
return objectId != null && StringUtils.containsIgnoreCase(objectId, constraint) ||
|
||||
displayName != null && StringUtils.containsIgnoreCase(displayName, constraint);
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class MentionAutocompleteCallback implements AutocompleteCallback<Mention
|
|||
editable.replace(start, end, replacement + " ");
|
||||
Spans.MentionChipSpan mentionChipSpan =
|
||||
new Spans.MentionChipSpan(DisplayUtils.getDrawableForMentionChipSpan(context,
|
||||
item.getId(), item.getLabel(), conversationUser, "user",
|
||||
item.getId(), item.getLabel(), conversationUser, item.getSource(),
|
||||
R.xml.chip_accent_background),
|
||||
DynamicDrawableSpan.ALIGN_BASELINE,
|
||||
item.getId(), item.getLabel());
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.nextcloud.talk.models.json.mention;
|
||||
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonIgnore;
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import lombok.Data;
|
||||
import org.parceler.Parcel;
|
||||
|
@ -34,7 +35,7 @@ public class Mention {
|
|||
@JsonField(name = "label")
|
||||
String label;
|
||||
|
||||
// type of user (guests or users)
|
||||
// type of user (guests or users or calls)
|
||||
@JsonField(name = "source")
|
||||
String source;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,8 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||
List<AbstractFlexibleItem> internalAbstractFlexibleItemList = new ArrayList<>();
|
||||
for (Mention mention : mentionsList) {
|
||||
internalAbstractFlexibleItemList.add(
|
||||
new MentionAutocompleteItem(mention.getId(), mention.getLabel(),
|
||||
new MentionAutocompleteItem(mention.getId(),
|
||||
mention.getLabel(), mention.getSource(),
|
||||
currentUser));
|
||||
}
|
||||
|
||||
|
@ -143,9 +144,9 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||
Mention mention = new Mention();
|
||||
MentionAutocompleteItem mentionAutocompleteItem = (MentionAutocompleteItem) adapter.getItem(position);
|
||||
if (mentionAutocompleteItem != null) {
|
||||
mention.setId(mentionAutocompleteItem.getUserId());
|
||||
mention.setId(mentionAutocompleteItem.getObjectId());
|
||||
mention.setLabel(mentionAutocompleteItem.getDisplayName());
|
||||
mention.setSource("users");
|
||||
mention.setSource(mentionAutocompleteItem.getSource());
|
||||
dispatchClick(mention);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -70,6 +70,7 @@ import com.vanniktech.emoji.EmojiTextView;
|
|||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -228,7 +229,9 @@ public class DisplayUtils {
|
|||
|
||||
int drawable;
|
||||
|
||||
if (!"call".equals(type)) {
|
||||
boolean isCall = "call".equals(type) || "calls".equals(type);
|
||||
|
||||
if (!isCall) {
|
||||
if (chipResource == R.xml.chip_accent_background) {
|
||||
drawable = R.drawable.white_circle;
|
||||
} else {
|
||||
|
@ -242,7 +245,7 @@ public class DisplayUtils {
|
|||
|
||||
chip.setBounds(0, 0, chip.getIntrinsicWidth(), chip.getIntrinsicHeight());
|
||||
|
||||
if (!"call".equals(type)) {
|
||||
if (!isCall) {
|
||||
ImageRequest imageRequest =
|
||||
getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(conversationUser.getBaseUrl(), id, R.dimen.avatar_size_big));
|
||||
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
||||
|
@ -255,7 +258,6 @@ public class DisplayUtils {
|
|||
protected void onNewResultImpl(Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
chip.setChipIcon(getRoundedDrawable(new BitmapDrawable(bitmap)));
|
||||
chip.invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue