From 185c3283a728fbb989dbc20b2b48010763b335ae Mon Sep 17 00:00:00 2001 From: WhiredPlanck Date: Mon, 11 Nov 2024 23:40:00 +0800 Subject: [PATCH] fix: only the candidates of the first page could be selected in popup window feat: add `selectPagedCandidate` and `deletePagedCanidate` to new api implementation --- app/src/main/java/com/osfans/trime/core/Rime.kt | 10 ++++++++++ app/src/main/java/com/osfans/trime/core/RimeApi.kt | 4 ++++ .../trime/ime/composition/CompositionPopupWindow.kt | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/osfans/trime/core/Rime.kt b/app/src/main/java/com/osfans/trime/core/Rime.kt index 3b136ebcad..6d270599e9 100644 --- a/app/src/main/java/com/osfans/trime/core/Rime.kt +++ b/app/src/main/java/com/osfans/trime/core/Rime.kt @@ -116,6 +116,16 @@ class Rime : forgetRimeCandidate(idx).also { if (it) ipcResponseCallback() } } + override suspend fun selectPagedCandidate(idx: Int): Boolean = + withRimeContext { + selectRimeCandidateOnCurrentPage(idx).also { if (it) ipcResponseCallback() } + } + + override suspend fun deletedPagedCandidate(idx: Int): Boolean = + withRimeContext { + deleteRimeCandidateOnCurrentPage(idx).also { if (it) ipcResponseCallback() } + } + override suspend fun availableSchemata(): Array = withRimeContext { getAvailableRimeSchemaList() } override suspend fun enabledSchemata(): Array = withRimeContext { getSelectedRimeSchemaList() } diff --git a/app/src/main/java/com/osfans/trime/core/RimeApi.kt b/app/src/main/java/com/osfans/trime/core/RimeApi.kt index 7f8051cd65..a50acbbfce 100644 --- a/app/src/main/java/com/osfans/trime/core/RimeApi.kt +++ b/app/src/main/java/com/osfans/trime/core/RimeApi.kt @@ -37,6 +37,10 @@ interface RimeApi { suspend fun forgetCandidate(idx: Int): Boolean + suspend fun selectPagedCandidate(idx: Int): Boolean + + suspend fun deletedPagedCandidate(idx: Int): Boolean + suspend fun availableSchemata(): Array suspend fun enabledSchemata(): Array diff --git a/app/src/main/java/com/osfans/trime/ime/composition/CompositionPopupWindow.kt b/app/src/main/java/com/osfans/trime/ime/composition/CompositionPopupWindow.kt index afb992e4a0..f2afac069d 100644 --- a/app/src/main/java/com/osfans/trime/ime/composition/CompositionPopupWindow.kt +++ b/app/src/main/java/com/osfans/trime/ime/composition/CompositionPopupWindow.kt @@ -56,7 +56,7 @@ class CompositionPopupWindow( updatePopupWindow(x.toInt(), y.toInt()) } setOnSelectCandidateListener { idx -> - rime.launchOnReady { it.selectCandidate(idx) } + rime.launchOnReady { it.selectPagedCandidate(idx) } } }