Skip to content

Commit

Permalink
refactor: polish (virtual) keyboard settings wording
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiredPlanck committed Jan 27, 2025
1 parent a513da3 commit 9850e71
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 41 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/com/osfans/trime/data/prefs/AppPrefs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ class AppPrefs(
companion object {
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"
const val SHOW_SCHEMA_SWITCHES = "show_schema_switches_in_idle"
const val SHOW_ARROW_IN_SWITCHES = "show_arrow_in_switches"
const val LANDSCAPE_MODE = "keyboard__landscape_mode"
const val SPLIT_SPACE_PERCENT = "keyboard__split_space"
const val SWITCH_ARROW_ENABLED = "keyboard__show_switch_arrow"

const val HOOK_CTRL_A = "keyboard__hook_ctrl_a"
const val HOOK_CTRL_CV = "keyboard__hook_ctrl_cv"
Expand Down Expand Up @@ -146,8 +146,8 @@ class AppPrefs(

val softCursorEnabled by bool(SOFT_CURSOR_ENABLED, true)
val popupKeyPressEnabled = bool(POPUP_KEY_PRESS_ENABLED, false)
val switchesEnabled = bool(SWITCHES_ENABLED, true)
val switchArrowEnabled = bool(SWITCH_ARROW_ENABLED, true)
val showSchemaSwitches = bool(SHOW_SCHEMA_SWITCHES, true)
val showArrowInSwitches = bool(SHOW_ARROW_IN_SWITCHES, true)

enum class LandscapeModeOption {
NEVER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
package com.osfans.trime.data.schema

import com.osfans.trime.core.Rime
import com.osfans.trime.data.prefs.AppPrefs
import kotlinx.serialization.builtins.ListSerializer

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

private val arrow get() = AppPrefs.defaultInstance().keyboard.switchArrowEnabled

private val defaultSchema = Schema()

@JvmStatic
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/osfans/trime/ime/bar/QuickBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class QuickBar(

private val prefs = AppPrefs.defaultInstance()

private val showSwitchers by prefs.keyboard.switchesEnabled
private val showSwitches by prefs.keyboard.showSchemaSwitches

val themedHeight =
theme.generalStyle.candidateViewHeight + theme.generalStyle.commentHeight

private fun evalAlwaysUiState() {
val newState =
when {
showSwitchers -> AlwaysUi.State.Switchers
showSwitches -> AlwaysUi.State.Switches
else -> AlwaysUi.State.Empty
}
if (newState == alwaysUi.currentState) return
Expand Down Expand Up @@ -211,7 +211,7 @@ class QuickBar(
}

override fun onRimeSchemaUpdated(schema: SchemaItem) {
if (alwaysUi.currentState == AlwaysUi.State.Switchers) {
if (alwaysUi.currentState == AlwaysUi.State.Switches) {
service.lifecycleScope.launch {
alwaysUi.switchesUi.setSwitches(SchemaManager.visibleSwitches)
}
Expand All @@ -227,7 +227,7 @@ class QuickBar(
view.visibility = if (value.value) View.GONE else View.VISIBLE
}
}
if (alwaysUi.currentState == AlwaysUi.State.Switchers) {
if (alwaysUi.currentState == AlwaysUi.State.Switches) {
service.lifecycleScope.launch {
alwaysUi.switchesUi.setSwitches(SchemaManager.visibleSwitches)
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/osfans/trime/ime/bar/ui/AlwaysUi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AlwaysUi(
) : Ui {
enum class State {
Empty,
Switchers,
Switches,
}

var currentState = State.Empty
Expand Down Expand Up @@ -55,7 +55,7 @@ class AlwaysUi(
Timber.d("Switch always ui to $state")
when (state) {
State.Empty -> animator.displayedChild = 0
State.Switchers -> animator.displayedChild = 1
State.Switches -> animator.displayedChild = 1
}
currentState = state
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.osfans.trime.data.theme.Theme
class SwitchesAdapter(
private val theme: Theme,
) : BaseQuickAdapter<Schema.Switch, SwitchesAdapter.Holder>() {
private val showArrow by AppPrefs.defaultInstance().keyboard.switchArrowEnabled
private val showArrow by AppPrefs.defaultInstance().keyboard.showArrowInSwitches

inner class Holder(
val ui: SwitchUi,
Expand All @@ -37,13 +37,7 @@ class SwitchesAdapter(
setFirstText(item.states[enabled])
val altText =
if (item.options.isEmpty()) {
item.states[1 - enabled].let {
if (showArrow) {
"$it"
} else {
it
}
}
"${if (showArrow) "" else ""}${item.states[1 - enabled]}"
} else {
""
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/navigation/pref_nav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<fragment
android:id="@+id/keyboardFragment"
android:name="com.osfans.trime.ui.fragments.KeyboardFragment"
android:label="@string/keyboard" />
android:label="@string/virtual_keyboard" />
<fragment
android:id="@+id/themeFragment"
android:name="com.osfans.trime.ui.fragments.ThemeFragment"
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="keyboard__speak_key_commit_title">上屏时朗读字符</string>
<string name="keyboard__long_press_timeout_title">长按按键的延迟时间</string>
<string name="keyboard__key_repeat_interval_title">重复按键的重复间隔</string>
<string name="keyboard__show_switches_title">在候选栏中显示状态</string>
<string name="show_schema_switches_in_idle">空闲时显示方案开关</string>
<string name="keyboard__show_key_popup_title">按键时弹出显示字符</string>
<string-array name="keyboard__landscape_mode_entries">
<item>永不</item>
Expand Down Expand Up @@ -82,7 +82,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="clipboard_clipboard_limit">剪贴板历史记录上限</string>
<string name="clipboard_clipboard_compare_title">剪贴板去重规则</string>
<string name="clipboard_clipboard_output_title">剪贴板过滤规则</string>
<string name="keyboard__show_switche_arrow_title">为开关显示箭头符号(→)</string>
<string name="show_arrow_in_switches">方案开关显示箭头符号(→)</string>
<string name="keyboard__fullscreen_mode_title">横屏时全屏编辑</string>
<string name="deploy_finish">部署完成</string>
<string-array name="keyboard__fullscreen_mode_entries">
Expand Down Expand Up @@ -131,7 +131,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="about__build_info">构建信息</string>
<string name="keyboard__use_mini_keyboard_title">连接实体键盘时,显示迷你软键盘</string>
<string name="pref_trime_telegram">Telegram群组</string>
<string name="pref_keyboard__candidate">候选栏</string>
<string name="quick_bar">快捷栏</string>
<string name="copy_done">已复制</string>
<string name="keyboard__hook_shift_space">点击空格时,忽略Shift的锁定状态</string>
<string name="keyboard__hook_shift_num">点击0-9时,忽略Shift的锁定状态</string>
Expand All @@ -148,7 +148,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="app_crash">应用程序崩溃了</string>
<string name="exception_logcat_created">Logcat 进程已创建</string>
<string name="app_crash_message">抱歉,但我们提供了日志以供调查。</string>
<string name="keyboard">键盘</string>
<string name="virtual_keyboard">虚拟键盘</string>
<string name="about">关于</string>
<string name="theme">主题</string>
<string name="profile">配置</string>
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="keyboard__speak_key_commit_title">上屏時朗讀字符</string>
<string name="keyboard__long_press_timeout_title">長按按鍵的延遲時間</string>
<string name="keyboard__key_repeat_interval_title">重複按鍵的重複間隔</string>
<string name="keyboard__show_switches_title">在候選欄中顯示狀態</string>
<string name="show_schema_switches_in_idle">空閒時顯示方案開關</string>
<string name="keyboard__show_key_popup_title">按鍵時彈出顯示字符</string>
<string-array name="keyboard__landscape_mode_entries">
<item>永不</item>
Expand Down Expand Up @@ -85,7 +85,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="pref__default">預設</string>
<string name="clipboard_clipboard_compare_title">剪貼板去重規則</string>
<string name="clipboard_clipboard_output_title">剪貼板過濾規則</string>
<string name="keyboard__show_switche_arrow_title">爲開關顯示箭頭符號(→)</string>
<string name="show_arrow_in_switches">方案開關顯示箭頭符號(→)</string>
<string name="keyboard__fullscreen_mode_title">橫屏時全屏編輯</string>
<string name="deploy_finish">部署完成</string>
<string-array name="keyboard__fullscreen_mode_entries">
Expand Down Expand Up @@ -134,7 +134,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="about__build_info">建構資訊</string>
<string name="keyboard__use_mini_keyboard_title">連接實體鍵盤時,顯示迷你軟鍵盤</string>
<string name="pref_trime_telegram">Telegram群組</string>
<string name="pref_keyboard__candidate">候選欄</string>
<string name="quick_bar">快捷欄</string>
<string name="copy_done">已複製</string>
<string name="keyboard__hook_shift_space">點擊空格時,忽略Shift的鎖定狀態</string>
<string name="keyboard__hook_shift_num">點擊0-9時,忽略Shift的鎖定狀態</string>
Expand All @@ -155,7 +155,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="theme">主題</string>
<string name="profile">配置</string>
<string name="profile_summary">設定儲存位置和修改同步設定等</string>
<string name="keyboard">鍵盤</string>
<string name="virtual_keyboard">虛擬鍵盤</string>
<string name="storage">儲存</string>
<string name="maintenance">維護</string>
<string name="loading">正在載入</string>
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="keyboard__speak_key_commit_title">Voice on commit</string>
<string name="keyboard__long_press_timeout_title">Long key press delay</string>
<string name="keyboard__key_repeat_interval_title">Key repeat interval</string>
<string name="keyboard__show_switches_title">Show switches in candidate bar</string>
<string name="show_schema_switches_in_idle">Show schema switches in idle</string>
<string name="keyboard__show_key_popup_title">Popup on key press</string>
<string-array name="keyboard__landscape_mode_entries">
<item>Never</item>
Expand Down Expand Up @@ -86,7 +86,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="clipboard_clipboard_limit">Clipboard History Limit</string>
<string name="clipboard_clipboard_compare_title">Clipboard Compare Rules</string>
<string name="clipboard_clipboard_output_title">Clipboard Output Rules</string>
<string name="keyboard__show_switche_arrow_title">Show arrow for switch (→)</string>
<string name="show_arrow_in_switches">Add arrow (→) for schema switches</string>
<string name="keyboard__fullscreen_mode_title">Landscape fullscreen input</string>
<string name="deploy_finish">Deploy finish</string>
<string-array name="keyboard__fullscreen_mode_entries">
Expand Down Expand Up @@ -136,7 +136,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="about__build_info">Build Info</string>
<string name="keyboard__use_mini_keyboard_title">Show mini keyboard with real keyboard attached</string>
<string name="pref_trime_telegram">Telegram Group</string>
<string name="pref_keyboard__candidate">Candidate</string>
<string name="quick_bar">Quick bar</string>
<string name="copy_done">Copied to clipboard!</string>
<string name="keyboard__hook_shift_space">Ignore Shift locked for Space</string>
<string name="keyboard__hook_shift_num">Ignore Shift locked for 0-9</string>
Expand All @@ -154,7 +154,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<string name="scroll_to_bottom">Jump to Bottom</string>
<string name="toolkit">Toolkit</string>
<string name="profile">Profile</string>
<string name="keyboard">Keyboard</string>
<string name="virtual_keyboard">Virtual Keyboard</string>
<string name="theme">Theme</string>
<string name="about">About</string>
<string name="storage">Storage</string>
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/res/xml/keyboard_preference.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:key="pref_keyboard"
android:title="@string/keyboard">
android:title="@string/virtual_keyboard">

<PreferenceCategory
app:iconSpaceReserved="false"
Expand Down Expand Up @@ -56,7 +56,7 @@ SPDX-License-Identifier: GPL-3.0-or-later

<PreferenceCategory
app:iconSpaceReserved="false"
app:title="@string/pref_keyboard__candidate">
app:title="@string/quick_bar">
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="keyboard__soft_cursor"
Expand All @@ -65,13 +65,14 @@ SPDX-License-Identifier: GPL-3.0-or-later

<SwitchPreferenceCompat
android:defaultValue="true"
android:key="keyboard__show_switches"
android:title="@string/keyboard__show_switches_title"
android:key="show_schema_switches_in_idle"
android:title="@string/show_schema_switches_in_idle"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="keyboard__show_switch_arrow"
android:title="@string/keyboard__show_switche_arrow_title"
android:key="show_arrow_in_switches"
android:title="@string/show_arrow_in_switches"
app:dependency="show_schema_switches_in_idle"
app:iconSpaceReserved="false" />
</PreferenceCategory>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
app:icon="@drawable/ic_baseline_tune_24" />

<Preference android:key="pref_keyboard"
android:title="@string/keyboard"
android:title="@string/virtual_keyboard"
app:icon="@drawable/ic_baseline_keyboard_24" />

<Preference android:key="pref_candidates"
Expand Down

0 comments on commit 9850e71

Please sign in to comment.