Skip to content

Commit 2e4bc0e

Browse files
committed
fixed tapping on emojis always producing the first emoji in the list in WhatsApp (#1110)
1 parent c1467ef commit 2e4bc0e

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

app/src/main/java/io/github/sspanak/tt9/hacks/AppHacks.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public void setComposingText(@NonNull String word) {
8181
}
8282

8383

84-
8584
public void setComposingTextWithHighlightedStem(@NonNull String word, @Nullable String stem, boolean isStemFilterFuzzy) {
8685
final HighlightedText highText =
8786
new HighlightedText(word, true, false)
@@ -272,6 +271,15 @@ public int getEditorAction(@NonNull SettingsStore settings) {
272271
}
273272

274273

274+
/**
275+
* Determines whether the composing text in the connected app should be forced to our state,
276+
* before committing or calling finishComposingText().
277+
*/
278+
public boolean shouldRefreshComposingTextBeforeCommit(@NonNull String currentSuggestion) {
279+
return inputType != null && inputType.isWhatsApp() && Text.isGraphic(currentSuggestion);
280+
}
281+
282+
275283
/**
276284
* For Deezer, eBay and other apps' search fields, where the input connection gets restarted on
277285
* every key press. The restart causes initialization of a new TextField object, losing the previous

app/src/main/java/io/github/sspanak/tt9/ime/helpers/SuggestionOps.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ public void commitCurrent(boolean entireSuggestion, boolean clearList) {
225225
// getCurrent() is somewhat resource-intensive, so we want to minimize the calls to it.
226226
// Hence, the more complicated if-else structure
227227
final String current = getCurrent();
228+
229+
if (appHacks != null && appHacks.shouldRefreshComposingTextBeforeCommit(current)) {
230+
textField.replaceComposingText(current);
231+
}
232+
228233
if (textField.getComposingText().equals(current)) {
229234
textField.finishComposingText();
230235
} else {

0 commit comments

Comments
 (0)