1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-11-26 11:50:38 +01:00

fix: ColoredImageSpan icon in invite link

This commit is contained in:
luvletter2333 2023-03-06 14:11:07 +08:00
parent 14e962d30a
commit ed4fdf2fe3
No known key found for this signature in database
GPG Key ID: 9EB7723F3A0ACF92
2 changed files with 11 additions and 2 deletions

View File

@ -51,6 +51,15 @@ public class ColoredImageSpan extends ReplacementSpan {
this.verticalAlignment = verticalAlignment;
}
public ColoredImageSpan(Drawable drawable, int drawableColor, int verticalAlignment) {
this.drawable = drawable;
this.drawableColor = drawableColor;
this.usePaintColor = true;
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.setColorFilter(new PorterDuffColorFilter(drawableColor, PorterDuff.Mode.SRC_IN));
this.verticalAlignment = verticalAlignment;
}
public void setSize(int size) {
this.size = size;
drawable.setBounds(0, 0, size, size);

View File

@ -101,7 +101,7 @@ public class LinkActionView extends LinearLayout {
copyView = new TextView(context);
copyView.setGravity(Gravity.CENTER_HORIZONTAL);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
spannableStringBuilder.append("..").setSpan(new ColoredImageSpan(ContextCompat.getDrawable(context, R.drawable.baseline_content_copy_24), Theme.getColor(Theme.key_chats_actionIcon)), 0, 1, 0);
spannableStringBuilder.append("..").setSpan(new ColoredImageSpan(ContextCompat.getDrawable(context, R.drawable.baseline_content_copy_24), Theme.getColor(Theme.key_chats_actionIcon), ColoredImageSpan.ALIGN_DEFAULT), 0, 1, 0);
spannableStringBuilder.setSpan(new DialogCell.FixedWidthSpan(AndroidUtilities.dp(8)), 1, 2, 0);
spannableStringBuilder.append(LocaleController.getString("LinkActionCopy", R.string.LinkActionCopy));
spannableStringBuilder.append(".").setSpan(new DialogCell.FixedWidthSpan(AndroidUtilities.dp(5)), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), 0);
@ -116,7 +116,7 @@ public class LinkActionView extends LinearLayout {
shareView = new TextView(context);
shareView.setGravity(Gravity.CENTER_HORIZONTAL);
spannableStringBuilder = new SpannableStringBuilder();
spannableStringBuilder.append("..").setSpan(new ColoredImageSpan(ContextCompat.getDrawable(context, R.drawable.baseline_forward_24), Theme.getColor(Theme.key_chats_actionIcon)), 0, 1, 0);
spannableStringBuilder.append("..").setSpan(new ColoredImageSpan(ContextCompat.getDrawable(context, R.drawable.baseline_forward_24), Theme.getColor(Theme.key_chats_actionIcon), ColoredImageSpan.ALIGN_DEFAULT), 0, 1, 0);
spannableStringBuilder.setSpan(new DialogCell.FixedWidthSpan(AndroidUtilities.dp(8)), 1, 2, 0);
spannableStringBuilder.append(LocaleController.getString("LinkActionShare", R.string.LinkActionShare));
spannableStringBuilder.append(".").setSpan(new DialogCell.FixedWidthSpan(AndroidUtilities.dp(5)), spannableStringBuilder.length() - 1, spannableStringBuilder.length(), 0);