mirror of
https://github.com/fcitx5-android/fcitx5-android.git
synced 2026-08-02 20:16:06 +08:00
Restore InputView state when switching between virtual/physical keyboard
This commit is contained in:
parent
23c4d318b6
commit
2ad65bd234
@ -442,6 +442,11 @@ void AndroidFrontend::showToast(const std::string &s) {
|
||||
|
||||
void AndroidFrontend::setCandidatePagingMode(const int mode) {
|
||||
pagingMode_ = mode;
|
||||
if (mode == 0) {
|
||||
activeIC_->updateCandidatesBulk();
|
||||
} else {
|
||||
activeIC_->updateCandidatesPaged();
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidFrontend::updatePagedCandidate(const PagedCandidateEntity &paged) {
|
||||
|
||||
@ -37,6 +37,19 @@ abstract class BaseInputView(
|
||||
}
|
||||
}
|
||||
|
||||
open fun refreshWithCachedEvents() {
|
||||
val inputPanelData = fcitx.runImmediately { inputPanelCached }
|
||||
val inputMethodEntry = fcitx.runImmediately { inputMethodEntryCached }
|
||||
val statusAreaActions = fcitx.runImmediately { statusAreaActionsCached }
|
||||
arrayOf(
|
||||
FcitxEvent.InputPanelEvent(inputPanelData),
|
||||
FcitxEvent.IMChangeEvent(inputMethodEntry),
|
||||
FcitxEvent.StatusAreaEvent(
|
||||
FcitxEvent.StatusAreaEvent.Data(statusAreaActions, inputMethodEntry)
|
||||
)
|
||||
).forEach { handleFcitxEvent(it) }
|
||||
}
|
||||
|
||||
var handleEvents = false
|
||||
set(value) {
|
||||
field = value
|
||||
|
||||
@ -20,16 +20,25 @@ class InputDeviceManager(private val onChange: (Boolean) -> Unit) {
|
||||
private var candidatesView: CandidatesView? = null
|
||||
|
||||
private fun setupInputViewEvents(isVirtual: Boolean) {
|
||||
inputView?.handleEvents = isVirtual
|
||||
inputView?.visibility = if (isVirtual) View.VISIBLE else View.GONE
|
||||
val iv = inputView ?: return
|
||||
iv.handleEvents = isVirtual
|
||||
if (isVirtual) {
|
||||
iv.visibility = View.VISIBLE
|
||||
} else {
|
||||
iv.visibility = View.GONE
|
||||
iv.refreshWithCachedEvents()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCandidatesViewEvents(isVirtual: Boolean) {
|
||||
candidatesView?.handleEvents = !isVirtual
|
||||
val cv = candidatesView ?: return
|
||||
cv.handleEvents = !isVirtual
|
||||
// hide CandidatesView when entering virtual keyboard mode,
|
||||
// but preserve the visibility when entering physical keyboard mode (in case it's empty)
|
||||
if (isVirtual) {
|
||||
candidatesView?.visibility = View.GONE
|
||||
cv.visibility = View.GONE
|
||||
} else {
|
||||
cv.refreshWithCachedEvents()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user