do not switch for hintLocales if we have a matching secondary locale

fixes #1181
This commit is contained in:
Helium314 2025-01-04 08:52:27 +01:00
parent 6e50d6e208
commit 32a37eaddf

View file

@ -89,6 +89,7 @@ import helium314.keyboard.latin.utils.StatsUtilsManager;
import helium314.keyboard.latin.utils.SubtypeLocaleUtils; import helium314.keyboard.latin.utils.SubtypeLocaleUtils;
import helium314.keyboard.latin.utils.SubtypeSettingsKt; import helium314.keyboard.latin.utils.SubtypeSettingsKt;
import helium314.keyboard.latin.utils.ViewLayoutUtils; import helium314.keyboard.latin.utils.ViewLayoutUtils;
import kotlin.collections.CollectionsKt;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.PrintWriter; import java.io.PrintWriter;
@ -884,8 +885,9 @@ public class LatinIME extends InputMethodService implements
} }
// Try switching to a subtype matching the hint language. // Try switching to a subtype matching the hint language.
for (final Locale hintLocale : hintLocales) { for (final Locale hintLocale : hintLocales) {
if (LocaleUtils.INSTANCE.getMatchLevel(hintLocale, mRichImm.getCurrentSubtypeLocale()) >= 3) if (LocaleUtils.INSTANCE.getMatchLevel(hintLocale, mRichImm.getCurrentSubtypeLocale()) >= 3
return; // current locale is already a good match, and we want to avoid unnecessary layout switches || CollectionsKt.any(mSettings.getCurrent().mSecondaryLocales, (secLocale) -> LocaleUtils.INSTANCE.getMatchLevel(hintLocale, secLocale) >= 3))
return; // current locales are already a good match, and we want to avoid unnecessary layout switches
final InputMethodSubtype newSubtype = mRichImm.findSubtypeForHintLocale(hintLocale); final InputMethodSubtype newSubtype = mRichImm.findSubtypeForHintLocale(hintLocale);
if (newSubtype == null) continue; if (newSubtype == null) continue;
if (newSubtype.equals(mRichImm.getCurrentSubtype().getRawSubtype())) if (newSubtype.equals(mRichImm.getCurrentSubtype().getRawSubtype()))