diff --git a/app/src/main/java/com/osfans/trime/data/prefs/AppPrefs.kt b/app/src/main/java/com/osfans/trime/data/prefs/AppPrefs.kt index 28a93df0d9..8cc171bae7 100644 --- a/app/src/main/java/com/osfans/trime/data/prefs/AppPrefs.kt +++ b/app/src/main/java/com/osfans/trime/data/prefs/AppPrefs.kt @@ -10,8 +10,8 @@ import androidx.preference.PreferenceManager import com.osfans.trime.R import com.osfans.trime.data.base.DataManager import com.osfans.trime.ime.candidates.popup.PopupCandidatesMode +import com.osfans.trime.ime.core.ComposingTextMode import com.osfans.trime.ime.enums.FullscreenMode -import com.osfans.trime.ime.enums.InlinePreeditMode import com.osfans.trime.util.appContext import java.lang.ref.WeakReference @@ -37,6 +37,7 @@ class AppPrefs( } val internal = Internal(shared) + val general = General(shared).register() val keyboard = Keyboard(shared) val theme = Theme(shared) val profile = Profile(shared) @@ -91,6 +92,16 @@ class AppPrefs( var pid by int(PID, 0) } + class General( + shared: SharedPreferences, + ) : PreferenceDelegateOwner(shared, R.string.general) { + companion object { + const val COMPOSING_TEXT_MODE = "composing_text_mode" + } + + val composingTextMode = enum(R.string.composing_text_mode, COMPOSING_TEXT_MODE, ComposingTextMode.DISABLE) + } + /** * Wrapper class of keyboard settings. */ @@ -98,7 +109,6 @@ class AppPrefs( shared: SharedPreferences, ) : PreferenceDelegateOwner(shared) { companion object { - const val INLINE_PREEDIT_MODE = "keyboard__inline_preedit" const val SOFT_CURSOR_ENABLED = "keyboard__soft_cursor" const val POPUP_KEY_PRESS_ENABLED = "keyboard__show_key_popup" const val SWITCHES_ENABLED = "keyboard__show_switches" @@ -134,7 +144,6 @@ class AppPrefs( const val REPEAT_INTERVAL = "keyboard__key_repeat_interval" } - var inlinePreedit by enum(INLINE_PREEDIT_MODE, InlinePreeditMode.PREVIEW) var fullscreenMode by enum(FULLSCREEN_MODE, FullscreenMode.AUTO_SHOW) val softCursorEnabled by bool(SOFT_CURSOR_ENABLED, true) val popupKeyPressEnabled by bool(POPUP_KEY_PRESS_ENABLED, false) diff --git a/app/src/main/java/com/osfans/trime/ime/core/ComposingTextMode.kt b/app/src/main/java/com/osfans/trime/ime/core/ComposingTextMode.kt new file mode 100644 index 0000000000..fd928f014f --- /dev/null +++ b/app/src/main/java/com/osfans/trime/ime/core/ComposingTextMode.kt @@ -0,0 +1,19 @@ +/* + * SPDX-FileCopyrightText: 2015 - 2024 Rime community + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package com.osfans.trime.ime.core + +import androidx.annotation.StringRes +import com.osfans.trime.R +import com.osfans.trime.data.prefs.PreferenceDelegateEnum + +enum class ComposingTextMode( + @StringRes override val stringRes: Int, +) : PreferenceDelegateEnum { + DISABLE(R.string.disable), + PREEDIT(R.string.preedit), + COMMIT_TEXT_PREVIEW(R.string.commit_text_preview), + RAW_INPUT(R.string.raw_input), +} diff --git a/app/src/main/java/com/osfans/trime/ime/core/TrimeInputMethodService.kt b/app/src/main/java/com/osfans/trime/ime/core/TrimeInputMethodService.kt index 092bba6fbb..f56fdcc461 100644 --- a/app/src/main/java/com/osfans/trime/ime/core/TrimeInputMethodService.kt +++ b/app/src/main/java/com/osfans/trime/ime/core/TrimeInputMethodService.kt @@ -52,7 +52,6 @@ import com.osfans.trime.data.theme.Theme import com.osfans.trime.data.theme.ThemeManager import com.osfans.trime.ime.broadcast.IntentReceiver import com.osfans.trime.ime.enums.FullscreenMode -import com.osfans.trime.ime.enums.InlinePreeditMode import com.osfans.trime.ime.keyboard.InitializationUi import com.osfans.trime.ime.keyboard.InputFeedbackManager import com.osfans.trime.util.ShortcutUtils @@ -883,14 +882,16 @@ open class TrimeInputMethodService : LifecycleInputMethodService() { return false } + private val composingTextMode by prefs.general.composingTextMode + private fun updateComposingText(ctx: RimeProto.Context) { val ic = currentInputConnection ?: return val text = - when (prefs.keyboard.inlinePreedit) { - InlinePreeditMode.PREVIEW -> ctx.composition.commitTextPreview ?: "" - InlinePreeditMode.COMPOSITION -> ctx.composition.preedit ?: "" - InlinePreeditMode.INPUT -> ctx.input - InlinePreeditMode.NONE -> "" + when (composingTextMode) { + ComposingTextMode.DISABLE -> "" + ComposingTextMode.PREEDIT -> ctx.composition.preedit ?: "" + ComposingTextMode.COMMIT_TEXT_PREVIEW -> ctx.composition.commitTextPreview ?: "" + ComposingTextMode.RAW_INPUT -> ctx.input } if (ic.getSelectedText(0).isNullOrEmpty() || text.isNotEmpty()) { ic.setComposingText(text, 1) diff --git a/app/src/main/java/com/osfans/trime/ime/enums/InlinePreeditMode.kt b/app/src/main/java/com/osfans/trime/ime/enums/InlinePreeditMode.kt deleted file mode 100644 index 70c4d143b3..0000000000 --- a/app/src/main/java/com/osfans/trime/ime/enums/InlinePreeditMode.kt +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-FileCopyrightText: 2015 - 2024 Rime community -// -// SPDX-License-Identifier: GPL-3.0-or-later - -package com.osfans.trime.ime.enums - -/** 嵌入模式枚举 */ -enum class InlinePreeditMode { - NONE, - PREVIEW, - COMPOSITION, - INPUT, -} diff --git a/app/src/main/java/com/osfans/trime/ui/fragments/PrefFragment.kt b/app/src/main/java/com/osfans/trime/ui/fragments/PrefFragment.kt index cf56a3dab3..028e556341 100644 --- a/app/src/main/java/com/osfans/trime/ui/fragments/PrefFragment.kt +++ b/app/src/main/java/com/osfans/trime/ui/fragments/PrefFragment.kt @@ -57,6 +57,10 @@ class PrefFragment : PaddingPreferenceFragment() { findNavController().navigate(R.id.action_prefFragment_to_profileFragment) true } + get("pref_general")?.setOnPreferenceClickListener { + findNavController().navigate(R.id.action_prefFragment_to_generalSettingsFragment) + true + } get("pref_keyboard")?.setOnPreferenceClickListener { findNavController().navigate(R.id.action_prefFragment_to_keyboardFragment) true diff --git a/app/src/main/java/com/osfans/trime/ui/main/settings/GeneralSettingsFragment.kt b/app/src/main/java/com/osfans/trime/ui/main/settings/GeneralSettingsFragment.kt new file mode 100644 index 0000000000..986617cfdb --- /dev/null +++ b/app/src/main/java/com/osfans/trime/ui/main/settings/GeneralSettingsFragment.kt @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2015 - 2024 Rime community + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package com.osfans.trime.ui.main.settings + +import com.osfans.trime.data.prefs.AppPrefs +import com.osfans.trime.data.prefs.PreferenceDelegateFragment + +class GeneralSettingsFragment : PreferenceDelegateFragment(AppPrefs.defaultInstance().general) diff --git a/app/src/main/res/drawable/ic_baseline_tune_24.xml b/app/src/main/res/drawable/ic_baseline_tune_24.xml new file mode 100644 index 0000000000..1bbf29ad2f --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_tune_24.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/app/src/main/res/navigation/pref_nav.xml b/app/src/main/res/navigation/pref_nav.xml index 2ea8649b03..80430d05e8 100644 --- a/app/src/main/res/navigation/pref_nav.xml +++ b/app/src/main/res/navigation/pref_nav.xml @@ -63,6 +63,9 @@ SPDX-License-Identifier: GPL-3.0-or-later + + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 57ccc4e774..f227b36a4c 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -270,4 +270,9 @@ SPDX-License-Identifier: GPL-3.0-or-later 仅预编辑码 候选词窗口 候选词显示模式 + 常规 + 预编辑码 + 首选词预览 + 原始输入码 + 在程序中显示撰写文本 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index c2d27cd00d..8b1551e37b 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -227,7 +227,7 @@ SPDX-License-Identifier: GPL-3.0-or-later 取消置頂 置頂 刪除全部 - 禁用 + 停用 但是我們似乎發現了些問題,請檢查: 收藏夾和草稿箱也在這裡管理 一行一條正則表示式 @@ -271,4 +271,9 @@ SPDX-License-Identifier: GPL-3.0-or-later 僅預編輯碼 候选词窗口 候選詞顯示模式 + 常規 + 預編輯碼 + 首選詞預覽 + 原始輸入碼 + 在程式中顯示撰寫文字 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d403c76333..b37376f7b5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -271,4 +271,9 @@ SPDX-License-Identifier: GPL-3.0-or-later Preedit only Candidates Window Candidates mode + General + Preedit + Commit text preview + Raw input + Show composing text in editor diff --git a/app/src/main/res/xml/keyboard_preference.xml b/app/src/main/res/xml/keyboard_preference.xml index 0f07f40cdf..5bb0ca6e0b 100644 --- a/app/src/main/res/xml/keyboard_preference.xml +++ b/app/src/main/res/xml/keyboard_preference.xml @@ -14,14 +14,6 @@ SPDX-License-Identifier: GPL-3.0-or-later - + +