mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Add Edit Actions submenu in settings
This commit is contained in:
parent
52084de79b
commit
8a13804faf
@ -71,7 +71,9 @@ fun ActionItem(action: Action, modifier: Modifier = Modifier, dragIcon: Boolean
|
|||||||
Icon(
|
Icon(
|
||||||
painterResource(id = R.drawable.move),
|
painterResource(id = R.drawable.move),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = dragIconModifier.size(16.dp).align(Alignment.TopEnd),
|
modifier = dragIconModifier
|
||||||
|
.size(16.dp)
|
||||||
|
.align(Alignment.TopEnd),
|
||||||
tint = LocalContentColor.current.copy(alpha = 0.6f)
|
tint = LocalContentColor.current.copy(alpha = 0.6f)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -125,7 +127,9 @@ fun MoreActionsView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LazyVerticalGrid(
|
LazyVerticalGrid(
|
||||||
modifier = Modifier.fillMaxWidth().padding(8.dp),
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(8.dp),
|
||||||
columns = GridCells.Adaptive(98.dp),
|
columns = GridCells.Adaptive(98.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||||
@ -143,14 +147,18 @@ val CategoryTitleStyle = Typography.titleMedium.copy(fontWeight = FontWeight.W50
|
|||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun ActionsEditor() {
|
fun ActionsEditor(header: @Composable () -> Unit) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val view = LocalView.current
|
val view = LocalView.current
|
||||||
|
|
||||||
val initialList: List<ActionEditorItem> = remember {
|
val initialList: List<ActionEditorItem> = if(!LocalInspectionMode.current) {
|
||||||
context.getSettingBlocking(ActionsSettings).toActionEditorItems().ensureWellFormed().filter {
|
remember {
|
||||||
it !is ActionEditorItem.Item || it.action.shownInEditor
|
context.getSettingBlocking(ActionsSettings).toActionEditorItems().ensureWellFormed().filter {
|
||||||
|
it !is ActionEditorItem.Item || it.action.shownInEditor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
DefaultActionSettings.flattenToActionEditorItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
val list = remember { initialList.toMutableStateList() }
|
val list = remember { initialList.toMutableStateList() }
|
||||||
@ -162,10 +170,12 @@ fun ActionsEditor() {
|
|||||||
view.performHapticFeedback(HapticFeedbackConstants.SEGMENT_FREQUENT_TICK)
|
view.performHapticFeedback(HapticFeedbackConstants.SEGMENT_FREQUENT_TICK)
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposableEffect(Unit) {
|
if(!LocalInspectionMode.current) {
|
||||||
onDispose {
|
DisposableEffect(Unit) {
|
||||||
val map = list.toActionMap()
|
onDispose {
|
||||||
context.updateSettingsWithNewActions(map)
|
val map = list.toActionMap()
|
||||||
|
context.updateSettingsWithNewActions(map)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,12 +214,12 @@ fun ActionsEditor() {
|
|||||||
ReorderableItem(reorderableLazyListState, key = it.toKey(), enabled = it.category != ActionCategory.entries[0]) { _ ->
|
ReorderableItem(reorderableLazyListState, key = it.toKey(), enabled = it.category != ActionCategory.entries[0]) { _ ->
|
||||||
Column {
|
Column {
|
||||||
if (it.category == ActionCategory.entries[0]) {
|
if (it.category == ActionCategory.entries[0]) {
|
||||||
Box(Modifier.defaultMinSize(minHeight = 72.dp), contentAlignment = Alignment.BottomStart) {
|
header()
|
||||||
if (actionMap[ActionCategory.ActionKey]?.let { it.size > 1 } == true) {
|
|
||||||
Tip("Only one Action Key can be set, anything after the first is ignored")
|
if (actionMap[ActionCategory.ActionKey]?.let { it.size > 1 } == true) {
|
||||||
} else if (actionMap[ActionCategory.PinnedKey]?.let { it.size > 4 } == true) {
|
Tip("Only one Action Key can be set, anything after the first is ignored")
|
||||||
Tip("You have more pinned actions than seems reasonable. Consider moving some to favorites")
|
} else if (actionMap[ActionCategory.PinnedKey]?.let { it.size > 4 } == true) {
|
||||||
}
|
Tip("You have more pinned actions than seems reasonable. Consider moving some to favorites")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text(it.category.name(context), modifier = Modifier.padding(top = 24.dp), style = CategoryTitleStyle, color = LocalContentColor.current.copy(alpha = 0.6f))
|
Text(it.category.name(context), modifier = Modifier.padding(top = 24.dp), style = CategoryTitleStyle, color = LocalContentColor.current.copy(alpha = 0.6f))
|
||||||
@ -231,7 +241,9 @@ fun ActionEditor() {
|
|||||||
color = MaterialTheme.colorScheme.background,
|
color = MaterialTheme.colorScheme.background,
|
||||||
shape = RoundedCornerShape(32.dp, 32.dp, 0.dp, 0.dp)
|
shape = RoundedCornerShape(32.dp, 32.dp, 0.dp, 0.dp)
|
||||||
) {
|
) {
|
||||||
ActionsEditor()
|
ActionsEditor {
|
||||||
|
ScreenTitle(title = "Edit actions")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
|||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
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.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.lazy.LazyItemScope
|
import androidx.compose.foundation.lazy.LazyItemScope
|
||||||
import androidx.compose.foundation.lazy.LazyListScope
|
import androidx.compose.foundation.lazy.LazyListScope
|
||||||
@ -60,6 +61,8 @@ 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.ActionEditor
|
||||||
|
import org.futo.inputmethod.latin.uix.actions.ActionsEditor
|
||||||
import org.futo.inputmethod.latin.uix.actions.ClipboardHistoryEnabled
|
import org.futo.inputmethod.latin.uix.actions.ClipboardHistoryEnabled
|
||||||
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
|
||||||
@ -96,6 +99,16 @@ fun NavGraphBuilder.addTypingNavigation(
|
|||||||
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("actionEdit") { ActionEditorScreen(navController) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview(showBackground = true)
|
||||||
|
@Composable
|
||||||
|
fun ActionEditorScreen(navController: NavHostController = rememberNavController()) {
|
||||||
|
Column {
|
||||||
|
ScreenTitle("Edit Actions", showBack = true, navController)
|
||||||
|
ActionsEditor { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preview(showBackground = true)
|
@Preview(showBackground = true)
|
||||||
@ -328,13 +341,6 @@ fun LongPressScreen(navController: NavHostController = rememberNavController())
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
SettingToggleDataStore(
|
|
||||||
title = "Spacebar language switcher",
|
|
||||||
subtitle = "Show the language switching menu when long-pressing the space",
|
|
||||||
setting = KeyHintsSetting
|
|
||||||
)*/
|
|
||||||
|
|
||||||
longPressKeyLayoutEditor(
|
longPressKeyLayoutEditor(
|
||||||
context = context,
|
context = context,
|
||||||
setting = setting,
|
setting = setting,
|
||||||
@ -444,6 +450,14 @@ fun TypingScreen(navController: NavHostController = rememberNavController()) {
|
|||||||
icon = painterResource(id = R.drawable.keyboard)
|
icon = painterResource(id = R.drawable.keyboard)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
NavigationItem(
|
||||||
|
title = "Edit Actions",
|
||||||
|
subtitle = "Edit favorite actions, pinned actions, and the action key next to the spacebar",
|
||||||
|
style = NavigationItemStyle.Misc,
|
||||||
|
navigate = { navController.navigate("actionEdit") },
|
||||||
|
icon = painterResource(id = R.drawable.smile)
|
||||||
|
)
|
||||||
|
|
||||||
SettingToggleDataStore(
|
SettingToggleDataStore(
|
||||||
title = "Show action/suggestions bar",
|
title = "Show action/suggestions bar",
|
||||||
subtitle = "Show the bar containing suggestions. Recommended to keep enabled",
|
subtitle = "Show the bar containing suggestions. Recommended to keep enabled",
|
||||||
|
Loading…
Reference in New Issue
Block a user