From e306c29ccd69bf1d139c14c869ff808a181c7967 Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Sat, 20 Jul 2024 22:38:06 +0300 Subject: [PATCH] Show a toast when language switching occurs with only one language active --- java/src/org/futo/inputmethod/latin/Subtypes.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/src/org/futo/inputmethod/latin/Subtypes.kt b/java/src/org/futo/inputmethod/latin/Subtypes.kt index 3e12734d3..41d6ace88 100644 --- a/java/src/org/futo/inputmethod/latin/Subtypes.kt +++ b/java/src/org/futo/inputmethod/latin/Subtypes.kt @@ -7,6 +7,7 @@ import android.util.Log import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodSubtype import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder +import android.widget.Toast import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -258,6 +259,13 @@ object Subtypes { val enabledSubtypes = context.getSettingBlocking(SubtypesSetting).toList() val currentSubtype = context.getSettingBlocking(ActiveSubtype) + if(enabledSubtypes.isEmpty()) return + + if(enabledSubtypes.size == 1) { + Toast.makeText(context, "Only one language is enabled, can't switch to next", Toast.LENGTH_SHORT).show() + return + } + val index = enabledSubtypes.indexOf(currentSubtype) val nextIndex = if(index == -1) { 0 @@ -265,8 +273,6 @@ object Subtypes { (index + direction.sign).mod(enabledSubtypes.size) } - if(enabledSubtypes.isEmpty()) return - context.setSettingBlocking(ActiveSubtype.key, enabledSubtypes[nextIndex]) } }