mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Improvements to call chip
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
ad3b440e88
commit
4feb46f40a
@ -98,6 +98,7 @@ public class MagicOutcomingTextMessageViewHolder extends MessageHolders.Outcomin
|
|||||||
messageString,
|
messageString,
|
||||||
individualHashMap.get("id"),
|
individualHashMap.get("id"),
|
||||||
individualHashMap.get("name"),
|
individualHashMap.get("name"),
|
||||||
|
individualHashMap.get("type"),
|
||||||
userUtils.getUserById(message.getActiveUserId()),
|
userUtils.getUserById(message.getActiveUserId()),
|
||||||
R.xml.chip_simple_background);
|
R.xml.chip_simple_background);
|
||||||
} else {
|
} else {
|
||||||
@ -106,6 +107,7 @@ public class MagicOutcomingTextMessageViewHolder extends MessageHolders.Outcomin
|
|||||||
messageString,
|
messageString,
|
||||||
individualHashMap.get("id"),
|
individualHashMap.get("id"),
|
||||||
individualHashMap.get("name"),
|
individualHashMap.get("name"),
|
||||||
|
individualHashMap.get("type"),
|
||||||
userUtils.getUserById(message.getActiveUserId()),
|
userUtils.getUserById(message.getActiveUserId()),
|
||||||
R.xml.chip_outgoing_own_mention);
|
R.xml.chip_outgoing_own_mention);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class MentionAutocompleteCallback implements AutocompleteCallback<Mention
|
|||||||
editable.replace(start, end, replacement + " ");
|
editable.replace(start, end, replacement + " ");
|
||||||
Spans.MentionChipSpan mentionChipSpan =
|
Spans.MentionChipSpan mentionChipSpan =
|
||||||
new Spans.MentionChipSpan(DisplayUtils.getDrawableForMentionChipSpan(context,
|
new Spans.MentionChipSpan(DisplayUtils.getDrawableForMentionChipSpan(context,
|
||||||
item.getId(), item.getLabel(), conversationUser,
|
item.getId(), item.getLabel(), conversationUser, "user",
|
||||||
R.xml.chip_accent_background),
|
R.xml.chip_accent_background),
|
||||||
DynamicDrawableSpan.ALIGN_BASELINE,
|
DynamicDrawableSpan.ALIGN_BASELINE,
|
||||||
item.getId(), item.getLabel());
|
item.getId(), item.getLabel());
|
||||||
|
@ -24,6 +24,7 @@ import android.annotation.SuppressLint;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
@ -215,50 +216,62 @@ public class DisplayUtils {
|
|||||||
|
|
||||||
|
|
||||||
public static Drawable getDrawableForMentionChipSpan(Context context, String id, String label,
|
public static Drawable getDrawableForMentionChipSpan(Context context, String id, String label,
|
||||||
UserEntity conversationUser,
|
UserEntity conversationUser, String type,
|
||||||
@XmlRes int chipResource) {
|
@XmlRes int chipResource) {
|
||||||
ChipDrawable chip = ChipDrawable.createFromResource(context, chipResource);
|
ChipDrawable chip = ChipDrawable.createFromResource(context, chipResource);
|
||||||
chip.setText(label);
|
chip.setText(label);
|
||||||
int drawable;
|
|
||||||
|
|
||||||
if (chipResource == R.xml.chip_accent_background) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
drawable = R.drawable.white_circle;
|
Configuration config = context.getResources().getConfiguration();
|
||||||
} else {
|
chip.setLayoutDirection(config.getLayoutDirection());
|
||||||
drawable = R.drawable.accent_circle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
chip.setChipIcon(context.getDrawable(drawable));
|
int drawable;
|
||||||
|
|
||||||
|
if (!"call".equals(type)) {
|
||||||
|
if (chipResource == R.xml.chip_accent_background) {
|
||||||
|
drawable = R.drawable.white_circle;
|
||||||
|
} else {
|
||||||
|
drawable = R.drawable.accent_circle;
|
||||||
|
}
|
||||||
|
|
||||||
|
chip.setChipIcon(context.getDrawable(drawable));
|
||||||
|
} else {
|
||||||
|
chip.setChipIcon(getRoundedDrawable(context.getDrawable(R.drawable.ic_people_group_white_24px)));
|
||||||
|
}
|
||||||
|
|
||||||
chip.setBounds(0, 0, chip.getIntrinsicWidth(), chip.getIntrinsicHeight());
|
chip.setBounds(0, 0, chip.getIntrinsicWidth(), chip.getIntrinsicHeight());
|
||||||
|
|
||||||
ImageRequest imageRequest =
|
if (!"call".equals(type)) {
|
||||||
getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(conversationUser.getBaseUrl(), id, R.dimen.avatar_size_big));
|
ImageRequest imageRequest =
|
||||||
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(conversationUser.getBaseUrl(), id, R.dimen.avatar_size_big));
|
||||||
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
|
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
||||||
|
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
|
||||||
|
|
||||||
dataSource.subscribe(
|
dataSource.subscribe(
|
||||||
new BaseBitmapDataSubscriber() {
|
new BaseBitmapDataSubscriber() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewResultImpl(Bitmap bitmap) {
|
protected void onNewResultImpl(Bitmap bitmap) {
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
chip.setChipIcon(getRoundedDrawable(new BitmapDrawable(bitmap)));
|
chip.setChipIcon(getRoundedDrawable(new BitmapDrawable(bitmap)));
|
||||||
chip.invalidateSelf();
|
chip.invalidateSelf();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
|
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UiThreadImmediateExecutorService.getInstance());
|
UiThreadImmediateExecutorService.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
return chip;
|
return chip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Spannable searchAndReplaceWithMentionSpan(Context context, Spannable text,
|
public static Spannable searchAndReplaceWithMentionSpan(Context context, Spannable text,
|
||||||
String id, String label,
|
String id, String label, String type,
|
||||||
UserEntity conversationUser,
|
UserEntity conversationUser,
|
||||||
@XmlRes int chipXmlRes) {
|
@XmlRes int chipXmlRes) {
|
||||||
|
|
||||||
@ -276,7 +289,7 @@ public class DisplayUtils {
|
|||||||
int end = start + m.group().length();
|
int end = start + m.group().length();
|
||||||
lastStartIndex = end;
|
lastStartIndex = end;
|
||||||
mentionChipSpan = new Spans.MentionChipSpan(DisplayUtils.getDrawableForMentionChipSpan(context,
|
mentionChipSpan = new Spans.MentionChipSpan(DisplayUtils.getDrawableForMentionChipSpan(context,
|
||||||
id, label, conversationUser, chipXmlRes),
|
id, label, conversationUser, type, chipXmlRes),
|
||||||
DynamicDrawableSpan.ALIGN_BASELINE, id,
|
DynamicDrawableSpan.ALIGN_BASELINE, id,
|
||||||
label);
|
label);
|
||||||
spannableString.setSpan(mentionChipSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
spannableString.setSpan(mentionChipSpan, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
Loading…
Reference in New Issue
Block a user