Adjust how preferred variation is handled for reaction customization.
This commit is contained in:
parent
a4a4665aaa
commit
5ed6a05eb9
4 changed files with 14 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
android:id="@+id/conversation_reaction_scrubber"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toTopOf="@+id/status_bar_guideline"
|
||||
app:layout_constraintStart_toStartOf="@+id/parent_start_guideline"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/parent_end_guideline"
|
||||
android:elevation="1000dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/parent_end_guideline"
|
||||
app:layout_constraintStart_toStartOf="@+id/parent_start_guideline"
|
||||
app:layout_constraintTop_toTopOf="@+id/status_bar_guideline"
|
||||
tools:visibility="visible">
|
||||
|
||||
<Space
|
||||
|
@ -159,6 +159,7 @@
|
|||
android:layout_height="48dp"
|
||||
android:alpha="0"
|
||||
android:translationY="@dimen/reaction_scrubber_anim_start_translation_y"
|
||||
app:forceJumbo="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/reaction_6"
|
||||
|
|
Loading…
Add table
Reference in a new issue