mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Add option to hide action bar
This commit is contained in:
parent
8bd334e919
commit
9985f2a715
java/src/org/futo/inputmethod/latin/uix
@ -78,6 +78,8 @@ import org.futo.inputmethod.latin.uix.actions.ActionRegistry
|
|||||||
import org.futo.inputmethod.latin.uix.actions.AllActions
|
import org.futo.inputmethod.latin.uix.actions.AllActions
|
||||||
import org.futo.inputmethod.latin.uix.actions.EmojiAction
|
import org.futo.inputmethod.latin.uix.actions.EmojiAction
|
||||||
import org.futo.inputmethod.latin.uix.settings.SettingsActivity
|
import org.futo.inputmethod.latin.uix.settings.SettingsActivity
|
||||||
|
import org.futo.inputmethod.latin.uix.settings.pages.ActionBarDisplayedSetting
|
||||||
|
import org.futo.inputmethod.latin.uix.settings.useDataStore
|
||||||
import org.futo.inputmethod.latin.uix.theme.ThemeOption
|
import org.futo.inputmethod.latin.uix.theme.ThemeOption
|
||||||
import org.futo.inputmethod.latin.uix.theme.Typography
|
import org.futo.inputmethod.latin.uix.theme.Typography
|
||||||
import org.futo.inputmethod.latin.uix.theme.UixThemeAuto
|
import org.futo.inputmethod.latin.uix.theme.UixThemeAuto
|
||||||
@ -348,6 +350,8 @@ class UixManager(private val latinIME: LatinIME) {
|
|||||||
private fun MainKeyboardViewWithActionBar() {
|
private fun MainKeyboardViewWithActionBar() {
|
||||||
val view = LocalView.current
|
val view = LocalView.current
|
||||||
|
|
||||||
|
val actionBarShown = useDataStore(ActionBarDisplayedSetting)
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
// Don't show suggested words when it's not meant to be shown
|
// Don't show suggested words when it's not meant to be shown
|
||||||
val suggestedWordsOrNull = if(shouldShowSuggestionStrip) {
|
val suggestedWordsOrNull = if(shouldShowSuggestionStrip) {
|
||||||
@ -356,25 +360,33 @@ class UixManager(private val latinIME: LatinIME) {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionBar(
|
if(actionBarShown.value) {
|
||||||
suggestedWordsOrNull,
|
ActionBar(
|
||||||
latinIME.latinIMELegacy as SuggestionStripView.Listener,
|
suggestedWordsOrNull,
|
||||||
inlineSuggestions = inlineSuggestions,
|
latinIME.latinIMELegacy as SuggestionStripView.Listener,
|
||||||
onActionActivated = {
|
inlineSuggestions = inlineSuggestions,
|
||||||
keyboardManagerForAction.performHapticAndAudioFeedback(Constants.CODE_TAB, view)
|
onActionActivated = {
|
||||||
onActionActivated(it)
|
keyboardManagerForAction.performHapticAndAudioFeedback(
|
||||||
},
|
Constants.CODE_TAB,
|
||||||
onActionAltActivated = {
|
view
|
||||||
if(it.altPressImpl != null) {
|
)
|
||||||
keyboardManagerForAction.performHapticAndAudioFeedback(Constants.CODE_TAB, view)
|
onActionActivated(it)
|
||||||
}
|
},
|
||||||
onActionAltActivated(it)
|
onActionAltActivated = {
|
||||||
},
|
if (it.altPressImpl != null) {
|
||||||
importantNotice = currentNotice.value,
|
keyboardManagerForAction.performHapticAndAudioFeedback(
|
||||||
keyboardManagerForAction = keyboardManagerForAction,
|
Constants.CODE_TAB,
|
||||||
isActionsExpanded = isActionsExpanded.value,
|
view
|
||||||
toggleActionsExpanded = { toggleActionsExpanded() },
|
)
|
||||||
)
|
}
|
||||||
|
onActionAltActivated(it)
|
||||||
|
},
|
||||||
|
importantNotice = currentNotice.value,
|
||||||
|
keyboardManagerForAction = keyboardManagerForAction,
|
||||||
|
isActionsExpanded = isActionsExpanded.value,
|
||||||
|
toggleActionsExpanded = { toggleActionsExpanded() },
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import androidx.compose.foundation.ExperimentalFoundationApi
|
|||||||
import androidx.compose.foundation.gestures.detectDragGestures
|
import androidx.compose.foundation.gestures.detectDragGestures
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.width
|
|
||||||
import androidx.compose.foundation.lazy.LazyItemScope
|
import androidx.compose.foundation.lazy.LazyItemScope
|
||||||
import androidx.compose.foundation.lazy.LazyListScope
|
import androidx.compose.foundation.lazy.LazyListScope
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
@ -35,9 +34,9 @@ import androidx.compose.ui.res.painterResource
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.compose.ui.zIndex
|
import androidx.compose.ui.zIndex
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
|
import androidx.datastore.preferences.core.booleanPreferencesKey
|
||||||
import androidx.datastore.preferences.core.intPreferencesKey
|
import androidx.datastore.preferences.core.intPreferencesKey
|
||||||
import androidx.navigation.NavGraphBuilder
|
import androidx.navigation.NavGraphBuilder
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
@ -61,22 +60,9 @@ import org.futo.inputmethod.latin.uix.KeyboardHeightMultiplierSetting
|
|||||||
import org.futo.inputmethod.latin.uix.PreferenceUtils
|
import org.futo.inputmethod.latin.uix.PreferenceUtils
|
||||||
import org.futo.inputmethod.latin.uix.SHOW_EMOJI_SUGGESTIONS
|
import org.futo.inputmethod.latin.uix.SHOW_EMOJI_SUGGESTIONS
|
||||||
import org.futo.inputmethod.latin.uix.SettingsKey
|
import org.futo.inputmethod.latin.uix.SettingsKey
|
||||||
import org.futo.inputmethod.latin.uix.actions.AllActions
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.ClipboardHistoryAction
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.ClipboardHistoryEnabled
|
import org.futo.inputmethod.latin.uix.actions.ClipboardHistoryEnabled
|
||||||
import org.futo.inputmethod.latin.uix.actions.CopyAction
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.CutAction
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.EmojiAction
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.PasteAction
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.RedoAction
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.SelectAllAction
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.SwitchLanguageAction
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.TextEditAction
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.UndoAction
|
|
||||||
import org.futo.inputmethod.latin.uix.actions.VoiceInputAction
|
|
||||||
import org.futo.inputmethod.latin.uix.getSettingBlocking
|
import org.futo.inputmethod.latin.uix.getSettingBlocking
|
||||||
import org.futo.inputmethod.latin.uix.settings.DataStoreItem
|
import org.futo.inputmethod.latin.uix.settings.DataStoreItem
|
||||||
import org.futo.inputmethod.latin.uix.settings.DropDownPicker
|
|
||||||
import org.futo.inputmethod.latin.uix.settings.NavigationItem
|
import org.futo.inputmethod.latin.uix.settings.NavigationItem
|
||||||
import org.futo.inputmethod.latin.uix.settings.NavigationItemStyle
|
import org.futo.inputmethod.latin.uix.settings.NavigationItemStyle
|
||||||
import org.futo.inputmethod.latin.uix.settings.ScreenTitle
|
import org.futo.inputmethod.latin.uix.settings.ScreenTitle
|
||||||
@ -89,7 +75,6 @@ import org.futo.inputmethod.latin.uix.settings.SettingSliderSharedPrefsInt
|
|||||||
import org.futo.inputmethod.latin.uix.settings.SettingToggleDataStore
|
import org.futo.inputmethod.latin.uix.settings.SettingToggleDataStore
|
||||||
import org.futo.inputmethod.latin.uix.settings.SettingToggleSharedPrefs
|
import org.futo.inputmethod.latin.uix.settings.SettingToggleSharedPrefs
|
||||||
import org.futo.inputmethod.latin.uix.settings.useDataStore
|
import org.futo.inputmethod.latin.uix.settings.useDataStore
|
||||||
import org.futo.inputmethod.latin.uix.settings.useSharedPrefsBool
|
|
||||||
import org.futo.inputmethod.latin.uix.settings.useSharedPrefsInt
|
import org.futo.inputmethod.latin.uix.settings.useSharedPrefsInt
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
@ -100,13 +85,17 @@ val vibrationDurationSetting = SettingsKey(
|
|||||||
-1
|
-1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val ActionBarDisplayedSetting = SettingsKey(
|
||||||
|
booleanPreferencesKey("enable_action_bar"),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
fun NavGraphBuilder.addTypingNavigation(
|
fun NavGraphBuilder.addTypingNavigation(
|
||||||
navController: NavHostController
|
navController: NavHostController
|
||||||
) {
|
) {
|
||||||
composable("typing") { TypingScreen(navController) }
|
composable("typing") { TypingScreen(navController) }
|
||||||
composable("resize") { ResizeScreen(navController) }
|
composable("resize") { ResizeScreen(navController) }
|
||||||
composable("longPress") { LongPressScreen(navController) }
|
composable("longPress") { LongPressScreen(navController) }
|
||||||
composable("actionKey") { ActionKeyScreen(navController) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview(showBackground = true)
|
@Preview(showBackground = true)
|
||||||
@ -405,58 +394,6 @@ fun LongPressScreen(navController: NavHostController = rememberNavController())
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview(showBackground = true)
|
|
||||||
@Composable
|
|
||||||
fun ActionKeyScreen(navController: NavHostController = rememberNavController()) {
|
|
||||||
val context = LocalContext.current
|
|
||||||
val isActionKeyActive = useSharedPrefsBool(key = Settings.PREF_SHOW_ACTION_KEY, default = true)
|
|
||||||
val emojiKey = useSharedPrefsInt(key = Settings.PREF_ACTION_KEY_ID, default = 0)
|
|
||||||
|
|
||||||
val permittedOptions = listOf(
|
|
||||||
EmojiAction,
|
|
||||||
SwitchLanguageAction,
|
|
||||||
VoiceInputAction,
|
|
||||||
ClipboardHistoryAction,
|
|
||||||
TextEditAction,
|
|
||||||
UndoAction,
|
|
||||||
RedoAction,
|
|
||||||
CutAction,
|
|
||||||
CopyAction,
|
|
||||||
PasteAction,
|
|
||||||
SelectAllAction,
|
|
||||||
)
|
|
||||||
|
|
||||||
ScrollableList {
|
|
||||||
ScreenTitle("Action Key", showBack = true, navController)
|
|
||||||
|
|
||||||
|
|
||||||
SettingToggleSharedPrefs(
|
|
||||||
title = "Action key enabled",
|
|
||||||
subtitle = "Show the action key on the bottom row",
|
|
||||||
key = Settings.PREF_SHOW_ACTION_KEY,
|
|
||||||
default = true
|
|
||||||
)
|
|
||||||
|
|
||||||
if(isActionKeyActive.value) {
|
|
||||||
SettingItem(title = "Action key") {
|
|
||||||
DropDownPicker(
|
|
||||||
label = "",
|
|
||||||
options = permittedOptions,
|
|
||||||
selection = AllActions[emojiKey.value],
|
|
||||||
onSet = {
|
|
||||||
emojiKey.setValue(AllActions.indexOf(it))
|
|
||||||
},
|
|
||||||
getDisplayName = {
|
|
||||||
context.getString(it.name)
|
|
||||||
},
|
|
||||||
modifier = Modifier.width(180.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Preview(showBackground = true)
|
@Preview(showBackground = true)
|
||||||
@Composable
|
@Composable
|
||||||
fun TypingScreen(navController: NavHostController = rememberNavController()) {
|
fun TypingScreen(navController: NavHostController = rememberNavController()) {
|
||||||
@ -475,7 +412,6 @@ fun TypingScreen(navController: NavHostController = rememberNavController()) {
|
|||||||
ScrollableList {
|
ScrollableList {
|
||||||
ScreenTitle("Keyboard", showBack = true, navController)
|
ScreenTitle("Keyboard", showBack = true, navController)
|
||||||
|
|
||||||
|
|
||||||
NavigationItem(
|
NavigationItem(
|
||||||
title = "Resize Keyboard",
|
title = "Resize Keyboard",
|
||||||
subtitle = "Change the height and offset of the keyboard",
|
subtitle = "Change the height and offset of the keyboard",
|
||||||
@ -500,14 +436,6 @@ fun TypingScreen(navController: NavHostController = rememberNavController()) {
|
|||||||
icon = painterResource(id = R.drawable.arrow_up)
|
icon = painterResource(id = R.drawable.arrow_up)
|
||||||
)
|
)
|
||||||
|
|
||||||
NavigationItem(
|
|
||||||
title = "Action Key",
|
|
||||||
subtitle = "Change the action key into an emoji key, language switch key, or disable it altogether.",
|
|
||||||
style = NavigationItemStyle.Misc,
|
|
||||||
navigate = { navController.navigate("actionKey") },
|
|
||||||
icon = painterResource(id = R.drawable.smile)
|
|
||||||
)
|
|
||||||
|
|
||||||
NavigationItem(
|
NavigationItem(
|
||||||
title = "Additional Layouts",
|
title = "Additional Layouts",
|
||||||
subtitle = "Configure additional layouts in the languages screen",
|
subtitle = "Configure additional layouts in the languages screen",
|
||||||
@ -516,6 +444,15 @@ fun TypingScreen(navController: NavHostController = rememberNavController()) {
|
|||||||
icon = painterResource(id = R.drawable.keyboard)
|
icon = painterResource(id = R.drawable.keyboard)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SettingToggleDataStore(
|
||||||
|
title = "Show action/suggestions bar",
|
||||||
|
subtitle = "Show the bar containing suggestions. Recommended to keep enabled",
|
||||||
|
setting = ActionBarDisplayedSetting,
|
||||||
|
icon = {
|
||||||
|
Icon(painterResource(id = R.drawable.more_horizontal), contentDescription = null)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
ScreenTitle(title = "Typing preferences")
|
ScreenTitle(title = "Typing preferences")
|
||||||
|
|
||||||
SettingToggleSharedPrefs(
|
SettingToggleSharedPrefs(
|
||||||
|
Loading…
Reference in New Issue
Block a user