From d1c2ad0a39369e6e9d41f34f9eafb29d59f2e58a Mon Sep 17 00:00:00 2001 From: Helium314 Date: Thu, 13 Jun 2024 20:36:04 +0200 Subject: [PATCH] fix system sometimes enabling wrong subtype --- app/src/main/java/helium314/keyboard/latin/LatinIME.java | 5 +++++ app/src/main/res/xml/method_dummy.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/app/src/main/java/helium314/keyboard/latin/LatinIME.java b/app/src/main/java/helium314/keyboard/latin/LatinIME.java index bafd0f3f0..589fabc67 100644 --- a/app/src/main/java/helium314/keyboard/latin/LatinIME.java +++ b/app/src/main/java/helium314/keyboard/latin/LatinIME.java @@ -853,6 +853,11 @@ public class LatinIME extends InputMethodService implements public void onCurrentInputMethodSubtypeChanged(final InputMethodSubtype subtype) { // Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged() // is not guaranteed. It may even be called at the same time on a different thread. + if (subtype.hashCode() == 0xf000000f) { + // For some reason sometimes the system wants to set the dummy subtype, which messes with the currently enabled subtype. + // Now that the dummy subtype has a fixed id, we can easily avoid enabling it. + return; + } InputMethodSubtype oldSubtype = mRichImm.getCurrentSubtype().getRawSubtype(); StatsUtils.onSubtypeChanged(oldSubtype, subtype); mRichImm.onSubtypeChanged(subtype); diff --git a/app/src/main/res/xml/method_dummy.xml b/app/src/main/res/xml/method_dummy.xml index ee1a48031..9f6471c33 100644 --- a/app/src/main/res/xml/method_dummy.xml +++ b/app/src/main/res/xml/method_dummy.xml @@ -24,6 +24,7 @@ the system picker crashes on some devices for unknown reasons.