mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-23 11:15:44 +00:00
Adjust how preferred variation is handled for reaction customization.
This commit is contained in:
committed by
Greyson Parrelli
parent
a4a4665aaa
commit
5ed6a05eb9
@@ -54,6 +54,10 @@ public final class EmojiUtil {
|
||||
return canonical != null ? canonical : emoji;
|
||||
}
|
||||
|
||||
public static boolean isCanonicallyEqual(@NonNull String left, @NonNull String right) {
|
||||
return getCanonicalRepresentation(left).equals(getCanonicalRepresentation(right));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the provided emoji string into a single drawable, if possible.
|
||||
*/
|
||||
|
||||
@@ -612,7 +612,7 @@ public final class ConversationReactionOverlay extends FrameLayout {
|
||||
view.setTranslationY(0);
|
||||
|
||||
boolean isAtCustomIndex = i == customEmojiIndex;
|
||||
boolean isNotAtCustomIndexAndOldEmojiMatches = !isAtCustomIndex && oldEmoji != null && emojis.get(i).equals(EmojiUtil.getCanonicalRepresentation(oldEmoji));
|
||||
boolean isNotAtCustomIndexAndOldEmojiMatches = !isAtCustomIndex && oldEmoji != null && EmojiUtil.isCanonicallyEqual(emojis.get(i), oldEmoji);
|
||||
boolean isAtCustomIndexAndOldEmojiExists = isAtCustomIndex && oldEmoji != null;
|
||||
|
||||
if (!foundSelected &&
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.reactions.edit
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import org.signal.core.util.concurrent.SignalExecutors
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiUtil
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.keyvalue.EmojiValues
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
@@ -26,6 +27,9 @@ class EditReactionsViewModel : ViewModel() {
|
||||
fun onEmojiSelected(emoji: String) {
|
||||
store.update { state ->
|
||||
if (state.selection != NO_SELECTION && state.selection in state.reactions.indices) {
|
||||
if (emoji != EmojiUtil.getCanonicalRepresentation(emoji)) {
|
||||
emojiValues.setPreferredVariation(emoji)
|
||||
}
|
||||
val preferredEmoji: String = emojiValues.getPreferredVariation(emoji)
|
||||
val newReactions: List<String> = state.reactions.toMutableList().apply { set(state.selection, preferredEmoji) }
|
||||
state.copy(reactions = newReactions)
|
||||
|
||||
Reference in New Issue
Block a user