diff --git a/java/src/org/futo/inputmethod/latin/uix/settings/SettingsNavigator.kt b/java/src/org/futo/inputmethod/latin/uix/settings/SettingsNavigator.kt index 1edb1b791..4255d431c 100644 --- a/java/src/org/futo/inputmethod/latin/uix/settings/SettingsNavigator.kt +++ b/java/src/org/futo/inputmethod/latin/uix/settings/SettingsNavigator.kt @@ -13,6 +13,7 @@ import org.futo.inputmethod.latin.uix.InfoDialog import org.futo.inputmethod.latin.uix.settings.pages.AdvancedParametersScreen import org.futo.inputmethod.latin.uix.settings.pages.BlacklistScreen import org.futo.inputmethod.latin.uix.settings.pages.HomeScreen +import org.futo.inputmethod.latin.uix.settings.pages.LanguagesScreen import org.futo.inputmethod.latin.uix.settings.pages.PredictiveTextScreen import org.futo.inputmethod.latin.uix.settings.pages.ThemeScreen import org.futo.inputmethod.latin.uix.settings.pages.TypingScreen @@ -39,6 +40,7 @@ fun SettingsNavigator( startDestination = "home" ) { composable("home") { HomeScreen(navController) } + composable("languages") { LanguagesScreen(navController) } composable("predictiveText") { PredictiveTextScreen(navController) } composable("advancedparams") { AdvancedParametersScreen(navController) } composable("typing") { TypingScreen(navController) } diff --git a/java/src/org/futo/inputmethod/latin/uix/settings/pages/Home.kt b/java/src/org/futo/inputmethod/latin/uix/settings/pages/Home.kt index 0e932fd37..bbe9af72c 100644 --- a/java/src/org/futo/inputmethod/latin/uix/settings/pages/Home.kt +++ b/java/src/org/futo/inputmethod/latin/uix/settings/pages/Home.kt @@ -70,7 +70,7 @@ fun HomeScreen(navController: NavHostController = rememberNavController()) { NavigationItem( title = "Languages", style = NavigationItemStyle.HomePrimary, - navigate = { context.openLanguageSettings() }, + navigate = { navController.navigate("languages") }, icon = painterResource(id = R.drawable.globe) ) diff --git a/java/src/org/futo/inputmethod/latin/uix/settings/pages/Languages.kt b/java/src/org/futo/inputmethod/latin/uix/settings/pages/Languages.kt new file mode 100644 index 000000000..852157f16 --- /dev/null +++ b/java/src/org/futo/inputmethod/latin/uix/settings/pages/Languages.kt @@ -0,0 +1,79 @@ +package org.futo.inputmethod.latin.uix.settings.pages + +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.navigation.NavHostController +import androidx.navigation.compose.rememberNavController +import org.futo.inputmethod.latin.R +import org.futo.inputmethod.latin.RichInputMethodManager +import org.futo.inputmethod.latin.uix.settings.NavigationItem +import org.futo.inputmethod.latin.uix.settings.NavigationItemStyle +import org.futo.inputmethod.latin.uix.settings.ScreenTitle +import org.futo.inputmethod.latin.uix.settings.ScrollableList +import org.futo.inputmethod.latin.uix.settings.Tip +import org.futo.inputmethod.latin.uix.settings.openLanguageSettings +import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils +import org.futo.inputmethod.updates.openURI + +data class LanguageOptions( + val voiceInputModel: String?, + val dictionary: String?, + val transformerModel: String? +) + + +@Preview +@Composable +fun LanguagesScreen(navController: NavHostController = rememberNavController()) { + val context = LocalContext.current + ScrollableList { + ScreenTitle("Languages", showBack = true, navController) + + NavigationItem( + title = "Enable/disable languages", + style = NavigationItemStyle.Misc, + navigate = { context.openLanguageSettings() }, + ) + + Tip("Note: The list below will only update after opening the keyboard") + + RichInputMethodManager.getInstance().getMyEnabledInputMethodSubtypeList(true).forEach { + val name = SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(it) + + val dummyOptions = LanguageOptions( + voiceInputModel = "Built-in English-39", + dictionary = "main.dict", + transformerModel = null + ) + + ScreenTitle(name) + NavigationItem( + title = dummyOptions.voiceInputModel ?: "None", + style = dummyOptions.voiceInputModel?.let { NavigationItemStyle.HomeTertiary } ?: NavigationItemStyle.MiscNoArrow, + navigate = { + context.openURI("https://keyboard.futo.org/voice-input-models", true) + }, + icon = painterResource(id = R.drawable.mic_fill) + ) + NavigationItem( + title = dummyOptions.dictionary ?: "None", + style = dummyOptions.dictionary?.let { NavigationItemStyle.HomeTertiary } ?: NavigationItemStyle.MiscNoArrow, + navigate = { + context.openURI("https://codeberg.org/Helium314/aosp-dictionaries#dictionaries", true) + }, + icon = painterResource(id = R.drawable.book) + ) + NavigationItem( + title = dummyOptions.transformerModel ?: "None", + style = dummyOptions.transformerModel?.let { NavigationItemStyle.HomeTertiary } ?: NavigationItemStyle.MiscNoArrow, + navigate = { + context.openURI("https://keyboard.futo.org/models", true) + }, + icon = painterResource(id = R.drawable.cpu) + ) + } + } +} \ No newline at end of file