From 94dfebca21279fdc790ffec45e495f2b740a8066 Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas Date: Fri, 15 Mar 2024 10:59:13 -0500 Subject: [PATCH] Add settings action to more easily access settings --- java/res/drawable/settings.xml | 20 +++++++++++++++++ .../futo/inputmethod/latin/uix/ActionBar.kt | 2 ++ .../latin/uix/actions/SettingsAction.kt | 22 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 java/res/drawable/settings.xml create mode 100644 java/src/org/futo/inputmethod/latin/uix/actions/SettingsAction.kt diff --git a/java/res/drawable/settings.xml b/java/res/drawable/settings.xml new file mode 100644 index 000000000..fd91a9246 --- /dev/null +++ b/java/res/drawable/settings.xml @@ -0,0 +1,20 @@ + + + + diff --git a/java/src/org/futo/inputmethod/latin/uix/ActionBar.kt b/java/src/org/futo/inputmethod/latin/uix/ActionBar.kt index a400a9b20..8b786c375 100644 --- a/java/src/org/futo/inputmethod/latin/uix/ActionBar.kt +++ b/java/src/org/futo/inputmethod/latin/uix/ActionBar.kt @@ -73,6 +73,7 @@ import org.futo.inputmethod.latin.suggestions.SuggestionStripView import org.futo.inputmethod.latin.uix.actions.ClipboardAction import org.futo.inputmethod.latin.uix.actions.EmojiAction import org.futo.inputmethod.latin.uix.actions.RedoAction +import org.futo.inputmethod.latin.uix.actions.SettingsAction import org.futo.inputmethod.latin.uix.actions.SystemVoiceInputAction import org.futo.inputmethod.latin.uix.actions.TextEditAction import org.futo.inputmethod.latin.uix.actions.ThemeAction @@ -370,6 +371,7 @@ fun ActionItemSmall(action: Action, onSelect: (Action) -> Unit) { fun RowScope.ActionItems(onSelect: (Action) -> Unit) { val systemVoiceInput = useDataStore(key = USE_SYSTEM_VOICE_INPUT.key, default = USE_SYSTEM_VOICE_INPUT.default) + ActionItem(SettingsAction, onSelect) ActionItem(EmojiAction, onSelect) ActionItem(if(systemVoiceInput.value) { SystemVoiceInputAction } else { VoiceInputAction }, onSelect) ActionItem(ThemeAction, onSelect) diff --git a/java/src/org/futo/inputmethod/latin/uix/actions/SettingsAction.kt b/java/src/org/futo/inputmethod/latin/uix/actions/SettingsAction.kt new file mode 100644 index 000000000..8f230daca --- /dev/null +++ b/java/src/org/futo/inputmethod/latin/uix/actions/SettingsAction.kt @@ -0,0 +1,22 @@ +package org.futo.inputmethod.latin.uix.actions + +import android.content.Intent +import org.futo.inputmethod.latin.R +import org.futo.inputmethod.latin.uix.Action +import org.futo.inputmethod.latin.uix.settings.SettingsActivity + +val SettingsAction = Action( + icon = R.drawable.settings, + name = R.string.go_to_settings, + simplePressImpl = { manager, _ -> + val intent = Intent() + intent.setClass(manager.getContext(), SettingsActivity::class.java) + intent.setFlags( + Intent.FLAG_ACTIVITY_NEW_TASK + or Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED + or Intent.FLAG_ACTIVITY_CLEAR_TOP + ) + manager.getContext().startActivity(intent) + }, + windowImpl = null, +) \ No newline at end of file