Skip to content

Commit 9850e71

Browse files
committed
refactor: polish (virtual) keyboard settings wording
1 parent a513da3 commit 9850e71

File tree

11 files changed

+33
-41
lines changed

11 files changed

+33
-41
lines changed

app/src/main/java/com/osfans/trime/data/prefs/AppPrefs.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ class AppPrefs(
111111
companion object {
112112
const val SOFT_CURSOR_ENABLED = "keyboard__soft_cursor"
113113
const val POPUP_KEY_PRESS_ENABLED = "keyboard__show_key_popup"
114-
const val SWITCHES_ENABLED = "keyboard__show_switches"
114+
const val SHOW_SCHEMA_SWITCHES = "show_schema_switches_in_idle"
115+
const val SHOW_ARROW_IN_SWITCHES = "show_arrow_in_switches"
115116
const val LANDSCAPE_MODE = "keyboard__landscape_mode"
116117
const val SPLIT_SPACE_PERCENT = "keyboard__split_space"
117-
const val SWITCH_ARROW_ENABLED = "keyboard__show_switch_arrow"
118118

119119
const val HOOK_CTRL_A = "keyboard__hook_ctrl_a"
120120
const val HOOK_CTRL_CV = "keyboard__hook_ctrl_cv"
@@ -146,8 +146,8 @@ class AppPrefs(
146146

147147
val softCursorEnabled by bool(SOFT_CURSOR_ENABLED, true)
148148
val popupKeyPressEnabled = bool(POPUP_KEY_PRESS_ENABLED, false)
149-
val switchesEnabled = bool(SWITCHES_ENABLED, true)
150-
val switchArrowEnabled = bool(SWITCH_ARROW_ENABLED, true)
149+
val showSchemaSwitches = bool(SHOW_SCHEMA_SWITCHES, true)
150+
val showArrowInSwitches = bool(SHOW_ARROW_IN_SWITCHES, true)
151151

152152
enum class LandscapeModeOption {
153153
NEVER,

app/src/main/java/com/osfans/trime/data/schema/SchemaManager.kt

-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
package com.osfans.trime.data.schema
66

77
import com.osfans.trime.core.Rime
8-
import com.osfans.trime.data.prefs.AppPrefs
98
import kotlinx.serialization.builtins.ListSerializer
109

1110
object SchemaManager {
1211
private lateinit var currentSchema: Schema
1312
var visibleSwitches: List<Schema.Switch> = listOf()
1413

15-
private val arrow get() = AppPrefs.defaultInstance().keyboard.switchArrowEnabled
16-
1714
private val defaultSchema = Schema()
1815

1916
@JvmStatic

app/src/main/java/com/osfans/trime/ime/bar/QuickBar.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ class QuickBar(
5353

5454
private val prefs = AppPrefs.defaultInstance()
5555

56-
private val showSwitchers by prefs.keyboard.switchesEnabled
56+
private val showSwitches by prefs.keyboard.showSchemaSwitches
5757

5858
val themedHeight =
5959
theme.generalStyle.candidateViewHeight + theme.generalStyle.commentHeight
6060

6161
private fun evalAlwaysUiState() {
6262
val newState =
6363
when {
64-
showSwitchers -> AlwaysUi.State.Switchers
64+
showSwitches -> AlwaysUi.State.Switches
6565
else -> AlwaysUi.State.Empty
6666
}
6767
if (newState == alwaysUi.currentState) return
@@ -211,7 +211,7 @@ class QuickBar(
211211
}
212212

213213
override fun onRimeSchemaUpdated(schema: SchemaItem) {
214-
if (alwaysUi.currentState == AlwaysUi.State.Switchers) {
214+
if (alwaysUi.currentState == AlwaysUi.State.Switches) {
215215
service.lifecycleScope.launch {
216216
alwaysUi.switchesUi.setSwitches(SchemaManager.visibleSwitches)
217217
}
@@ -227,7 +227,7 @@ class QuickBar(
227227
view.visibility = if (value.value) View.GONE else View.VISIBLE
228228
}
229229
}
230-
if (alwaysUi.currentState == AlwaysUi.State.Switchers) {
230+
if (alwaysUi.currentState == AlwaysUi.State.Switches) {
231231
service.lifecycleScope.launch {
232232
alwaysUi.switchesUi.setSwitches(SchemaManager.visibleSwitches)
233233
}

app/src/main/java/com/osfans/trime/ime/bar/ui/AlwaysUi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AlwaysUi(
2525
) : Ui {
2626
enum class State {
2727
Empty,
28-
Switchers,
28+
Switches,
2929
}
3030

3131
var currentState = State.Empty
@@ -55,7 +55,7 @@ class AlwaysUi(
5555
Timber.d("Switch always ui to $state")
5656
when (state) {
5757
State.Empty -> animator.displayedChild = 0
58-
State.Switchers -> animator.displayedChild = 1
58+
State.Switches -> animator.displayedChild = 1
5959
}
6060
currentState = state
6161
}

app/src/main/java/com/osfans/trime/ime/bar/ui/always/switches/SwitchesAdapter.kt

+2-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import com.osfans.trime.data.theme.Theme
1515
class SwitchesAdapter(
1616
private val theme: Theme,
1717
) : BaseQuickAdapter<Schema.Switch, SwitchesAdapter.Holder>() {
18-
private val showArrow by AppPrefs.defaultInstance().keyboard.switchArrowEnabled
18+
private val showArrow by AppPrefs.defaultInstance().keyboard.showArrowInSwitches
1919

2020
inner class Holder(
2121
val ui: SwitchUi,
@@ -37,13 +37,7 @@ class SwitchesAdapter(
3737
setFirstText(item.states[enabled])
3838
val altText =
3939
if (item.options.isEmpty()) {
40-
item.states[1 - enabled].let {
41-
if (showArrow) {
42-
"$it"
43-
} else {
44-
it
45-
}
46-
}
40+
"${if (showArrow) "" else ""}${item.states[1 - enabled]}"
4741
} else {
4842
""
4943
}

app/src/main/res/navigation/pref_nav.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
7474
<fragment
7575
android:id="@+id/keyboardFragment"
7676
android:name="com.osfans.trime.ui.fragments.KeyboardFragment"
77-
android:label="@string/keyboard" />
77+
android:label="@string/virtual_keyboard" />
7878
<fragment
7979
android:id="@+id/themeFragment"
8080
android:name="com.osfans.trime.ui.fragments.ThemeFragment"

app/src/main/res/values-zh-rCN/strings.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
4242
<string name="keyboard__speak_key_commit_title">上屏时朗读字符</string>
4343
<string name="keyboard__long_press_timeout_title">长按按键的延迟时间</string>
4444
<string name="keyboard__key_repeat_interval_title">重复按键的重复间隔</string>
45-
<string name="keyboard__show_switches_title">在候选栏中显示状态</string>
45+
<string name="show_schema_switches_in_idle">空闲时显示方案开关</string>
4646
<string name="keyboard__show_key_popup_title">按键时弹出显示字符</string>
4747
<string-array name="keyboard__landscape_mode_entries">
4848
<item>永不</item>
@@ -82,7 +82,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
8282
<string name="clipboard_clipboard_limit">剪贴板历史记录上限</string>
8383
<string name="clipboard_clipboard_compare_title">剪贴板去重规则</string>
8484
<string name="clipboard_clipboard_output_title">剪贴板过滤规则</string>
85-
<string name="keyboard__show_switche_arrow_title">为开关显示箭头符号(→)</string>
85+
<string name="show_arrow_in_switches">方案开关显示箭头符号(→)</string>
8686
<string name="keyboard__fullscreen_mode_title">横屏时全屏编辑</string>
8787
<string name="deploy_finish">部署完成</string>
8888
<string-array name="keyboard__fullscreen_mode_entries">
@@ -131,7 +131,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
131131
<string name="about__build_info">构建信息</string>
132132
<string name="keyboard__use_mini_keyboard_title">连接实体键盘时,显示迷你软键盘</string>
133133
<string name="pref_trime_telegram">Telegram群组</string>
134-
<string name="pref_keyboard__candidate">候选栏</string>
134+
<string name="quick_bar">快捷栏</string>
135135
<string name="copy_done">已复制</string>
136136
<string name="keyboard__hook_shift_space">点击空格时,忽略Shift的锁定状态</string>
137137
<string name="keyboard__hook_shift_num">点击0-9时,忽略Shift的锁定状态</string>
@@ -148,7 +148,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
148148
<string name="app_crash">应用程序崩溃了</string>
149149
<string name="exception_logcat_created">Logcat 进程已创建</string>
150150
<string name="app_crash_message">抱歉,但我们提供了日志以供调查。</string>
151-
<string name="keyboard">键盘</string>
151+
<string name="virtual_keyboard">虚拟键盘</string>
152152
<string name="about">关于</string>
153153
<string name="theme">主题</string>
154154
<string name="profile">配置</string>

app/src/main/res/values-zh-rTW/strings.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
4545
<string name="keyboard__speak_key_commit_title">上屏時朗讀字符</string>
4646
<string name="keyboard__long_press_timeout_title">長按按鍵的延遲時間</string>
4747
<string name="keyboard__key_repeat_interval_title">重複按鍵的重複間隔</string>
48-
<string name="keyboard__show_switches_title">在候選欄中顯示狀態</string>
48+
<string name="show_schema_switches_in_idle">空閒時顯示方案開關</string>
4949
<string name="keyboard__show_key_popup_title">按鍵時彈出顯示字符</string>
5050
<string-array name="keyboard__landscape_mode_entries">
5151
<item>永不</item>
@@ -85,7 +85,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
8585
<string name="pref__default">預設</string>
8686
<string name="clipboard_clipboard_compare_title">剪貼板去重規則</string>
8787
<string name="clipboard_clipboard_output_title">剪貼板過濾規則</string>
88-
<string name="keyboard__show_switche_arrow_title">爲開關顯示箭頭符號(→)</string>
88+
<string name="show_arrow_in_switches">方案開關顯示箭頭符號(→)</string>
8989
<string name="keyboard__fullscreen_mode_title">橫屏時全屏編輯</string>
9090
<string name="deploy_finish">部署完成</string>
9191
<string-array name="keyboard__fullscreen_mode_entries">
@@ -134,7 +134,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
134134
<string name="about__build_info">建構資訊</string>
135135
<string name="keyboard__use_mini_keyboard_title">連接實體鍵盤時,顯示迷你軟鍵盤</string>
136136
<string name="pref_trime_telegram">Telegram群組</string>
137-
<string name="pref_keyboard__candidate">候選欄</string>
137+
<string name="quick_bar">快捷欄</string>
138138
<string name="copy_done">已複製</string>
139139
<string name="keyboard__hook_shift_space">點擊空格時,忽略Shift的鎖定狀態</string>
140140
<string name="keyboard__hook_shift_num">點擊0-9時,忽略Shift的鎖定狀態</string>
@@ -155,7 +155,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
155155
<string name="theme">主題</string>
156156
<string name="profile">配置</string>
157157
<string name="profile_summary">設定儲存位置和修改同步設定等</string>
158-
<string name="keyboard">鍵盤</string>
158+
<string name="virtual_keyboard">虛擬鍵盤</string>
159159
<string name="storage">儲存</string>
160160
<string name="maintenance">維護</string>
161161
<string name="loading">正在載入</string>

app/src/main/res/values/strings.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
4545
<string name="keyboard__speak_key_commit_title">Voice on commit</string>
4646
<string name="keyboard__long_press_timeout_title">Long key press delay</string>
4747
<string name="keyboard__key_repeat_interval_title">Key repeat interval</string>
48-
<string name="keyboard__show_switches_title">Show switches in candidate bar</string>
48+
<string name="show_schema_switches_in_idle">Show schema switches in idle</string>
4949
<string name="keyboard__show_key_popup_title">Popup on key press</string>
5050
<string-array name="keyboard__landscape_mode_entries">
5151
<item>Never</item>
@@ -86,7 +86,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
8686
<string name="clipboard_clipboard_limit">Clipboard History Limit</string>
8787
<string name="clipboard_clipboard_compare_title">Clipboard Compare Rules</string>
8888
<string name="clipboard_clipboard_output_title">Clipboard Output Rules</string>
89-
<string name="keyboard__show_switche_arrow_title">Show arrow for switch (→)</string>
89+
<string name="show_arrow_in_switches">Add arrow (→) for schema switches</string>
9090
<string name="keyboard__fullscreen_mode_title">Landscape fullscreen input</string>
9191
<string name="deploy_finish">Deploy finish</string>
9292
<string-array name="keyboard__fullscreen_mode_entries">
@@ -136,7 +136,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
136136
<string name="about__build_info">Build Info</string>
137137
<string name="keyboard__use_mini_keyboard_title">Show mini keyboard with real keyboard attached</string>
138138
<string name="pref_trime_telegram">Telegram Group</string>
139-
<string name="pref_keyboard__candidate">Candidate</string>
139+
<string name="quick_bar">Quick bar</string>
140140
<string name="copy_done">Copied to clipboard!</string>
141141
<string name="keyboard__hook_shift_space">Ignore Shift locked for Space</string>
142142
<string name="keyboard__hook_shift_num">Ignore Shift locked for 0-9</string>
@@ -154,7 +154,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
154154
<string name="scroll_to_bottom">Jump to Bottom</string>
155155
<string name="toolkit">Toolkit</string>
156156
<string name="profile">Profile</string>
157-
<string name="keyboard">Keyboard</string>
157+
<string name="virtual_keyboard">Virtual Keyboard</string>
158158
<string name="theme">Theme</string>
159159
<string name="about">About</string>
160160
<string name="storage">Storage</string>

app/src/main/res/xml/keyboard_preference.xml

+7-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
99
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
1010
xmlns:app="http://schemas.android.com/apk/res-auto"
1111
android:key="pref_keyboard"
12-
android:title="@string/keyboard">
12+
android:title="@string/virtual_keyboard">
1313

1414
<PreferenceCategory
1515
app:iconSpaceReserved="false"
@@ -56,7 +56,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
5656

5757
<PreferenceCategory
5858
app:iconSpaceReserved="false"
59-
app:title="@string/pref_keyboard__candidate">
59+
app:title="@string/quick_bar">
6060
<SwitchPreferenceCompat
6161
android:defaultValue="true"
6262
android:key="keyboard__soft_cursor"
@@ -65,13 +65,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
6565

6666
<SwitchPreferenceCompat
6767
android:defaultValue="true"
68-
android:key="keyboard__show_switches"
69-
android:title="@string/keyboard__show_switches_title"
68+
android:key="show_schema_switches_in_idle"
69+
android:title="@string/show_schema_switches_in_idle"
7070
app:iconSpaceReserved="false" />
7171
<SwitchPreferenceCompat
7272
android:defaultValue="true"
73-
android:key="keyboard__show_switch_arrow"
74-
android:title="@string/keyboard__show_switche_arrow_title"
73+
android:key="show_arrow_in_switches"
74+
android:title="@string/show_arrow_in_switches"
75+
app:dependency="show_schema_switches_in_idle"
7576
app:iconSpaceReserved="false" />
7677
</PreferenceCategory>
7778

app/src/main/res/xml/prefs.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
2525
app:icon="@drawable/ic_baseline_tune_24" />
2626

2727
<Preference android:key="pref_keyboard"
28-
android:title="@string/keyboard"
28+
android:title="@string/virtual_keyboard"
2929
app:icon="@drawable/ic_baseline_keyboard_24" />
3030

3131
<Preference android:key="pref_candidates"

0 commit comments

Comments
 (0)