Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/main/java/com/osfans/trime/data/prefs/AppPrefs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ class AppPrefs(
const val USE_SOFT_CURSOR = "use_soft_cursor"
const val HIDE_INPUT_BAR = "hide_input_bar"

// Distinct key (not "hide_virtual_keyboard") to avoid a type clash with the
// String value some experimental builds stored under that key.
const val HIDE_VIRTUAL_KEYBOARD = "hide_virtual_keyboard_keep_toolbar"

const val SOUND_ON_KEYPRESS = "sound_on_keypress"
const val KEY_SOUND_VOLUME = "sound_volume"
const val USE_CUSTOM_SOUND_EFFECT = "custom_sound_effect_enabled"
Expand Down Expand Up @@ -180,6 +184,8 @@ class AppPrefs(

val hideInputBar = switch(R.string.hide_input_bar, HIDE_INPUT_BAR, false)

val hideVirtualKeyboard = switch(R.string.hide_virtual_keyboard, HIDE_VIRTUAL_KEYBOARD, false)

val soundOnKeyPress = switch(R.string.sound_on_keypress, SOUND_ON_KEYPRESS, false)
val soundVolume = int(
R.string.sound_volume,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
private var cursorUpdateIndex = 0

private val recreateInputViewPrefs: Array<PreferenceDelegate<*>> =
arrayOf(prefs.keyboard.hideInputBar)
arrayOf(
prefs.keyboard.hideInputBar,
prefs.keyboard.hideVirtualKeyboard,
)

@Keep
private val recreateInputViewListener =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class KeyboardWindow :
override val key: ResidentWindow.Key
get() = KeyboardWindow

override val isKeyboardArea: Boolean = true

private val presetKeyboardIds = theme.presetKeyboards.keys.toList()
private var currentKeyboardId = ""
private var lastKeyboardId = ""
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/osfans/trime/ime/window/BoardWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ sealed class BoardWindow {

protected val context: Context by di.instance()

/**
* Whether this window represents the virtual keyboard area. When the user enables
* "hide virtual keyboard", only windows for which this is `true` are hidden, so that
* non-keyboard panels (option switcher, unrolled candidates, liquid keyboard, ...)
* remain visible when opened from the toolbar.
*/
open val isKeyboardArea: Boolean = false

/**
* Animation when the window is added to the layout
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.transition.Transition
import androidx.transition.TransitionManager
import androidx.transition.TransitionSet
import com.osfans.trime.R
import com.osfans.trime.data.prefs.AppPrefs
import com.osfans.trime.ime.broadcast.InputBroadcaster
import com.osfans.trime.ime.dependency.InputDependencyManager
import org.kodein.di.instance
Expand All @@ -29,6 +30,8 @@ class BoardWindowManager {
private var currentWindow: BoardWindow? = null
private var currentView: View? = null

private val hideVirtualKeyboard by AppPrefs.defaultInstance().keyboard.hideVirtualKeyboard

private fun prepareAnimation(
exitAnimation: Transition?,
enterAnimation: Transition?,
Expand Down Expand Up @@ -108,6 +111,10 @@ class BoardWindowManager {
Timber.d("Attach $window")
window.onAttached()
currentWindow = window
// Toolbar-only mode: hide the window host only while the keyboard area is shown, so that
// non-keyboard panels (option switcher, unrolled candidates, liquid keyboard, ...) opened
// from the toolbar remain visible. Returning to the keyboard hides the host again.
view.visibility = if (hideVirtualKeyboard && window.isKeyboardArea) View.GONE else View.VISIBLE
broadcaster.onWindowAttached(window)
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
<string name="deploy_failure">部署失败</string>
<string name="view_deploy_failure_log">部署失败。点此查看错误日志。</string>
<string name="hide_input_bar">隐藏输入工具栏</string>
<string name="hide_virtual_keyboard">隐藏虚拟键盘(保留工具栏)</string>
<string name="navbar_bkg_none">无背景</string>
<string name="navbar_bkg_color_only">跟随键盘背景色</string>
<string name="navbar_bkg_full">键盘背景图片</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
<string name="deploy_failure">部署失敗</string>
<string name="view_deploy_failure_log">部署失敗。點此檢視錯誤日誌。</string>
<string name="hide_input_bar">隱藏輸入工具欄</string>
<string name="hide_virtual_keyboard">隱藏虛擬鍵盤(保留工具欄)</string>
<string name="navbar_bkg_none">無背景</string>
<string name="navbar_bkg_color_only">跟隨鍵盤背景色</string>
<string name="navbar_bkg_full">鍵盤背景圖片</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
<string name="deploy_failure">Deploy failure</string>
<string name="view_deploy_failure_log">Deploy failure. Click here to view error log.</string>
<string name="hide_input_bar">Hide input bar</string>
<string name="hide_virtual_keyboard">Hide virtual keyboard (keep toolbar)</string>
<string name="navbar_bkg_none">No background</string>
<string name="navbar_bkg_color_only">Follow keyboard color</string>
<string name="navbar_bkg_full">Keyboard background image</string>
Expand Down