mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Add languages menu
This commit is contained in:
parent
a9b8e9de22
commit
14fa302f1f
@ -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) }
|
||||
|
@ -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)
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user