kopia lustrzana https://github.com/ryukoposting/Signal-Android
Use custom emoji for avatars.
rodzic
d0827eb48e
commit
7e4396ae3f
|
@ -30,6 +30,7 @@ class TextAvatarDrawable(
|
||||||
textView.text = avatar.text
|
textView.text = avatar.text
|
||||||
textView.gravity = Gravity.CENTER
|
textView.gravity = Gravity.CENTER
|
||||||
textView.setTextColor(if (inverted) avatar.color.backgroundColor else avatar.color.foregroundColor)
|
textView.setTextColor(if (inverted) avatar.color.backgroundColor else avatar.color.foregroundColor)
|
||||||
|
textView.setForceCustomEmoji(true)
|
||||||
|
|
||||||
layout.addView(textView)
|
layout.addView(textView)
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,10 @@ import java.util.List;
|
||||||
public class EmojiTextView extends AppCompatTextView {
|
public class EmojiTextView extends AppCompatTextView {
|
||||||
|
|
||||||
private final boolean scaleEmojis;
|
private final boolean scaleEmojis;
|
||||||
private final boolean forceCustom;
|
|
||||||
|
|
||||||
private static final char ELLIPSIS = '…';
|
private static final char ELLIPSIS = '…';
|
||||||
|
|
||||||
|
private boolean forceCustom;
|
||||||
private CharSequence previousText;
|
private CharSequence previousText;
|
||||||
private BufferType previousBufferType;
|
private BufferType previousBufferType;
|
||||||
private float originalFontSize;
|
private float originalFontSize;
|
||||||
|
@ -144,6 +144,13 @@ public class EmojiTextView extends AppCompatTextView {
|
||||||
setText(previousText, BufferType.SPANNABLE);
|
setText(previousText, BufferType.SPANNABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setForceCustomEmoji(boolean forceCustom) {
|
||||||
|
if (this.forceCustom != forceCustom) {
|
||||||
|
this.forceCustom = forceCustom;
|
||||||
|
setText(previousText, BufferType.SPANNABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ellipsizeAnyTextForMaxLength() {
|
private void ellipsizeAnyTextForMaxLength() {
|
||||||
if (maxLength > 0 && getText().length() > maxLength + 1) {
|
if (maxLength > 0 && getText().length() > maxLength + 1) {
|
||||||
SpannableStringBuilder newContent = new SpannableStringBuilder();
|
SpannableStringBuilder newContent = new SpannableStringBuilder();
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
app:layout_constraintEnd_toEndOf="@id/avatar_picker_item_image"
|
app:layout_constraintEnd_toEndOf="@id/avatar_picker_item_image"
|
||||||
app:layout_constraintStart_toStartOf="@id/avatar_picker_item_image"
|
app:layout_constraintStart_toStartOf="@id/avatar_picker_item_image"
|
||||||
app:layout_constraintTop_toTopOf="@id/avatar_picker_item_image"
|
app:layout_constraintTop_toTopOf="@id/avatar_picker_item_image"
|
||||||
|
app:emoji_forceCustom="true"
|
||||||
tools:ignore="SpUsage"
|
tools:ignore="SpUsage"
|
||||||
tools:text="AF" />
|
tools:text="AF" />
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fontFamily="sans-serif-medium"
|
android:fontFamily="sans-serif-medium"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
tools:text="AF" />
|
tools:text="AF"
|
||||||
|
app:emoji_forceCustom="true"/>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/avatar_picker_item_fader"
|
android:id="@+id/avatar_picker_item_fader"
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
app:layout_constraintEnd_toEndOf="@id/avatar_picker_item_image"
|
app:layout_constraintEnd_toEndOf="@id/avatar_picker_item_image"
|
||||||
app:layout_constraintStart_toStartOf="@id/avatar_picker_item_image"
|
app:layout_constraintStart_toStartOf="@id/avatar_picker_item_image"
|
||||||
app:layout_constraintTop_toTopOf="@id/avatar_picker_item_image"
|
app:layout_constraintTop_toTopOf="@id/avatar_picker_item_image"
|
||||||
|
app:emoji_forceCustom="true"
|
||||||
tools:ignore="SpUsage"
|
tools:ignore="SpUsage"
|
||||||
tools:text="AF" />
|
tools:text="AF" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
Ładowanie…
Reference in New Issue