Hide some special actions from editor

This commit is contained in:
Aleksandras Kostarevas 2024-07-20 23:27:52 +03:00
parent d2f1b1e358
commit cee9548995
4 changed files with 11 additions and 4 deletions

View File

@ -110,4 +110,6 @@ data class Action(
val persistentState: ((KeyboardManagerForAction) -> PersistentActionState)? = null,
val persistentStateInitialization: PersistentStateInitialization = PersistentStateInitialization.OnActionTrigger,
val altPressImpl: ((KeyboardManagerForAction, PersistentActionState?) -> Unit)? = null,
val shownInEditor: Boolean = true
)

View File

@ -122,7 +122,9 @@ fun ActionsEditor() {
val view = LocalView.current
val initialList: List<ActionEditorItem> = remember {
context.getSettingBlocking(ActionsSettings).toActionEditorItems().ensureWellFormed()
context.getSettingBlocking(ActionsSettings).toActionEditorItems().ensureWellFormed().filter {
it !is ActionEditorItem.Item || it.action.shownInEditor
}
}
val list = remember { initialList.toMutableStateList() }
@ -212,6 +214,7 @@ val MoreActionsAction = Action(
icon = R.drawable.more_horizontal,
name = R.string.more_actions_action_title,
simplePressImpl = null,
shownInEditor = false,
windowImpl = { manager, _ ->
object : ActionWindow {
@Composable

View File

@ -171,7 +171,8 @@ fun Map<ActionCategory, List<Action>>.ensureAllActionsPresent(): Map<ActionCateg
val actionsMissing = actionsRequired.subtract(actionsPresent)
if(actionsMissing.isNotEmpty()) {
map[ActionCategory.More] = map[ActionCategory.More]!! + actionsMissing
map[ActionCategory.More] = map[ActionCategory.More]!! + actionsMissing.filter { it.shownInEditor }
map[ActionCategory.Disabled] = map[ActionCategory.Disabled]!! + actionsMissing.filter { !it.shownInEditor }
}
return map
@ -220,7 +221,7 @@ val DefaultActionSettings = mapOf(
ActionCategory.PinnedKey to listOf(VoiceInputAction),
ActionCategory.Favorites to listOf(SwitchLanguageAction, UndoAction, RedoAction, TextEditAction, ClipboardHistoryAction, ThemeAction),
ActionCategory.More to listOf(), // Remaining actions get populated automatically by ensureWellFormed
ActionCategory.Disabled to listOf(MemoryDebugAction)
ActionCategory.Disabled to listOf(MemoryDebugAction, SystemVoiceInputAction)
)
val ActionsSettings = SettingsKey(

View File

@ -64,7 +64,8 @@ val SystemVoiceInputAction = Action(
it.triggerSystemVoiceInput()
},
persistentState = null,
windowImpl = null
windowImpl = null,
shownInEditor = false
)