From 0e68675d8e78c920cac10d4e5fc40f0968734f71 Mon Sep 17 00:00:00 2001 From: Codex Mozc Autonomy Date: Tue, 17 Nov 2026 15:17:24 -0500 Subject: [PATCH] Show the next Free Flick map on switch --- .../res/values-ja/sumire_popup_strings.xml | 6 +-- .../main/res/values/sumire_popup_strings.xml | 6 +-- .../controller/PopupMapInputController.kt | 8 +++- .../custom_keyboard/data/PopupMap.kt | 5 ++- .../data/PopupMapVisibility.kt | 8 +++- .../controller/PopupMapTapSensitivityTest.kt | 40 +++++++++++++++++++ 6 files changed, 62 insertions(+), 11 deletions(-) diff --git a/app/src/main/res/values-ja/sumire_popup_strings.xml b/app/src/main/res/values-ja/sumire_popup_strings.xml index c35d6a4dd..675558ad4 100644 --- a/app/src/main/res/values-ja/sumire_popup_strings.xml +++ b/app/src/main/res/values-ja/sumire_popup_strings.xml @@ -47,7 +47,7 @@ 破棄 入力結果 選択中 - 元キーから動かし、文字で離すと入力。切替枠でマップ切替。上部表示は押した直後から全領域を表示します。周囲表示は長押し表示が有効な場合に長押しで全体を表示します。 + 元キーから動かし、文字で指を離すと入力します。切替枠でマップを切り替えます。キー上部では押した直後から、キー周辺では切替先のマップで全候補を表示します。長押し表示が有効な場合は、長押しでも全候補を表示します。 保存された設定を読み込めないため初期配置を表示しています。保存済みデータは上書きしていません。 このマップを削除しますか? 重複しないマップ名を入力してください。 @@ -68,12 +68,12 @@ popupの表示位置 キー周辺 キー上部のガイド - キーボードの各キーを操作して試せます。上部表示は押した直後から全領域を表示します。周囲表示は長押し表示が有効な場合に長押しで全体を表示します。 + キーボードの各キーを操作して試せます。キー上部では押した直後から、キー周辺では切替先のマップで全候補を表示します。長押し表示が有効な場合は、長押しでも全候補を表示します。 テンプレートを適用 12キーフリック 「%1$s」キーのすべてのマップを、通常の12キーフリックに置き換えます。保存するまで実入力には反映されません。取り消すこともできます。 12キーと同じ通常マップです。枠を追加して文字やマップ切替を設定できます。 - 枠外では有効な最寄りのポップアップを選択。長押し表示が有効なら全体を表示します。変更はフリーフリック設定で行えます。 + 枠外では有効な最寄りのポップアップを選びます。切替先のマップでは全候補を表示します。長押し表示が有効な場合は、長押しでも全候補を表示します。変更はフリーフリック設定で行えます。 2段フリック入力 2段フリック入力のpopupの大きさ、文字サイズ、表示位置を設定します @string/free_flick_around@string/free_flick_above diff --git a/app/src/main/res/values/sumire_popup_strings.xml b/app/src/main/res/values/sumire_popup_strings.xml index 19a159baa..016483843 100644 --- a/app/src/main/res/values/sumire_popup_strings.xml +++ b/app/src/main/res/values/sumire_popup_strings.xml @@ -47,7 +47,7 @@ Discard Output Selection - Start on the key and release on a character to type. Enter a control to switch maps. Above-key guides show all regions immediately; around-key popups reveal all on hold when long-press display is enabled. + Start on the key and release on a character to type. Flick into a switch region to change maps. Above-key guides show all regions on touch. Around-key popups show the full next map as soon as you switch. Holding also reveals all regions when long-press popups are enabled. Saved maps could not be loaded. Showing defaults; the stored data has not been replaced. Delete this map? Enter a unique map name. @@ -68,12 +68,12 @@ Popup position Around the key Guide above the key - Try any key on the keyboard. Above-key guides show all regions immediately; around-key popups reveal all on hold when long-press display is enabled. + Try any key on the keyboard. Above-key guides show all regions on touch. Around-key popups show the full next map as soon as you switch. Holding also reveals all regions when long-press popups are enabled. Apply template 12-key flick Replace all maps for key “%1$s” with standard 12-key flick. This affects input only after saving and can be undone. Standard 12-key map. Add popup regions for text or map transitions. - Outside the regions, the nearest enabled popup is selected. Hold to show all popups when long-press popups are enabled. Options are in Free Flick settings. + Outside the regions, the nearest enabled popup is selected. Switching maps reveals all regions in the next map. Holding also reveals all regions when long-press popups are enabled. Options are in Free Flick settings. Two-step flick input Set two-step popup size, text size, and position @string/free_flick_around@string/free_flick_above diff --git a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/controller/PopupMapInputController.kt b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/controller/PopupMapInputController.kt index bb0804510..cfc13449a 100644 --- a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/controller/PopupMapInputController.kt +++ b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/controller/PopupMapInputController.kt @@ -158,7 +158,13 @@ class PopupMapInputController( val active = session ?: return val policy = visibility ?: return if(!policy.visible) {popup?.dismiss();guideHost?.dismiss();lastDrawing=null;lastPlacement=null;return} - val drawingState=listOf(active.currentMap.id,active.selectedRegionId,active.isTap,policy.expanded,inputOptions.presentation) + val drawingState = listOf( + active.currentMap.id, + active.selectedRegionId, + active.isTap, + policy.showsAllRegions(active), + inputOptions.presentation + ) if(lastDrawing==drawingState && inputOptions.presentation==PopupMapPresentation.AROUND_KEY) return lastDrawing=drawingState val host = windowAnchor() ?: key diff --git a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/data/PopupMap.kt b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/data/PopupMap.kt index ec650075a..09c546d42 100644 --- a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/data/PopupMap.kt +++ b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/data/PopupMap.kt @@ -147,6 +147,7 @@ class PopupMapSession( private val history = mutableListOf(config.startMapId) val currentMap get() = requireNotNull(config.map(history.last())) val mapPath get() = history.toList() + internal val canGoBack get() = history.size > 1 var selectedRegionId: String? = null; private set var selectedText: String? = null; private set var isTap = true; private set @@ -160,7 +161,7 @@ class PopupMapSession( val before = history.toList() when (region.action.type) { PopupActionType.SWITCH -> history += requireNotNull(region.action.targetMapId) - PopupActionType.BACK -> if (history.size > 1) history.removeAt(history.lastIndex) + PopupActionType.BACK -> if (canGoBack) history.removeAt(history.lastIndex) else -> Unit } if (history != before) { @@ -187,7 +188,7 @@ class PopupMapSession( return cardinalRegions[index] } currentMap.regions.firstOrNull { it.contains(x, y, keyWidth, keyHeight) }?.let { return it } - val candidates = currentMap.regions.filter { options.includes(it, history.size > 1) } + val candidates = currentMap.regions.filter { options.includes(it, canGoBack) } // The sensitivity box can leave a gap inside the reserved key. Project that motion // to the key's edge, so a short horizontal flick does not pick a nearer top/bottom // popup simply because the physical key is wider than it is tall. diff --git a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/data/PopupMapVisibility.kt b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/data/PopupMapVisibility.kt index 2d73e6087..0ec2419e7 100644 --- a/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/data/PopupMapVisibility.kt +++ b/custom_keyboard/src/main/java/com/kazumaproject/custom_keyboard/data/PopupMapVisibility.kt @@ -23,6 +23,10 @@ class PopupMapVisibility(val settings: GestureSessionConfig, private val downX: expanded=settings.showLongPressPopup return true } - fun regions(session: PopupMapSession): Set? = if(above || expanded) null else setOfNotNull(session.selectedRegionId) - fun showsTap(session: PopupMapSession) = above || expanded || session.isTap + internal fun showsAllRegions(session: PopupMapSession) = above || expanded || session.canGoBack + + fun regions(session: PopupMapSession): Set? = + if (showsAllRegions(session)) null else setOfNotNull(session.selectedRegionId) + + fun showsTap(session: PopupMapSession) = showsAllRegions(session) || session.isTap } diff --git a/custom_keyboard/src/test/java/com/kazumaproject/custom_keyboard/controller/PopupMapTapSensitivityTest.kt b/custom_keyboard/src/test/java/com/kazumaproject/custom_keyboard/controller/PopupMapTapSensitivityTest.kt index 161188437..23b2686eb 100644 --- a/custom_keyboard/src/test/java/com/kazumaproject/custom_keyboard/controller/PopupMapTapSensitivityTest.kt +++ b/custom_keyboard/src/test/java/com/kazumaproject/custom_keyboard/controller/PopupMapTapSensitivityTest.kt @@ -5,6 +5,7 @@ import android.os.SystemClock import android.view.MotionEvent import android.view.View import android.widget.FrameLayout +import android.widget.PopupWindow import android.widget.TextView import com.kazumaproject.core.domain.flick.GestureSessionConfig import com.kazumaproject.core.domain.flick.GestureSessionConfigSource @@ -17,6 +18,7 @@ import org.junit.runner.RunWith import org.robolectric.Robolectric import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config +import org.robolectric.util.ReflectionHelpers @RunWith(RobolectricTestRunner::class) @Config(sdk=[35]) @@ -88,6 +90,44 @@ class PopupMapTapSensitivityTest { } } } + @Test fun aroundKeyPopupShowsTheDestinationMapOnAQuickSwitch() { + val start = PopupMap("start", "Start", "は", listOf( + PopupRegion("switch", PopupBounds(.5f, -.5f, 1.5f, .5f), + PopupAction(PopupActionType.SWITCH, targetMapId = "next")) + )) + val next = PopupMap("next", "Next", "ば", listOf( + PopupRegion("text", PopupBounds(-1.5f, -.5f, -.5f, .5f), PopupAction(text = "び")), + PopupRegion("back", PopupBounds(-.5f, -1.5f, .5f, -.5f), PopupAction(PopupActionType.BACK)) + )) + verify( + PopupMapPresentation.AROUND_KEY, + config = PopupKeyConfig("は", start.id, listOf(start, next)), + nearestEnabled = false, + tapSizeMode = PopupTapSizeMode.KEY + ) { key, controller, output -> + key.event(MotionEvent.ACTION_DOWN, 100f, 50f) + val view = ReflectionHelpers.getField(controller, "content") + val popup = ReflectionHelpers.getField(controller, "popup") + assertEquals(emptySet(), view.visibleRegionIds) + + key.event(MotionEvent.ACTION_MOVE, 300f, 50f) + assertTrue(popup.isShowing) + assertEquals(next, view.map) + assertNull(view.selectedId) + assertNull("All destination regions should be shown before a long press", view.visibleRegionIds) + assertTrue(view.tapPopupVisible) + + key.event(MotionEvent.ACTION_MOVE, 100f, -50f) + assertEquals(start, view.map) + assertEquals(emptySet(), view.visibleRegionIds) + + key.event(MotionEvent.ACTION_MOVE, 300f, 50f) + key.event(MotionEvent.ACTION_MOVE, -100f, 50f) + key.event(MotionEvent.ACTION_UP, -100f, 50f) + assertEquals(listOf("び"), output) + assertFalse(popup.isShowing) + } + } @Test fun directSelectionUsesDisplayedKeyRelativeRegionsAfterAnOffCenterPress() { val config=PopupKeyConfig("は","normal",listOf(PopupMap("normal","通常","は",listOf( PopupRegion("small",PopupBounds(.7f,-.1f,.9f,.1f),PopupAction(text="へ"))))))