Skip to content
Merged
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: 3 additions & 3 deletions app/src/main/res/values-ja/sumire_popup_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<string name="popup_discard">破棄</string>
<string name="popup_result">入力結果</string>
<string name="popup_selection">選択中</string>
<string name="popup_try_hint">元キーから動かし、文字で離すと入力。切替枠でマップ切替。上部表示は押した直後から全領域を表示します。周囲表示は長押し表示が有効な場合に長押しで全体を表示します。</string>
<string name="popup_try_hint">元キーから動かし、文字で指を離すと入力します。切替枠でマップを切り替えます。キー上部では押した直後から、キー周辺では切替先のマップで全候補を表示します。長押し表示が有効な場合は、長押しでも全候補を表示します。</string>
<string name="popup_invalid_saved">保存された設定を読み込めないため初期配置を表示しています。保存済みデータは上書きしていません。</string>
<string name="popup_delete_confirm">このマップを削除しますか?</string>
<string name="popup_name_required">重複しないマップ名を入力してください。</string>
Expand All @@ -68,12 +68,12 @@
<string name="free_flick_presentation">popupの表示位置</string>
<string name="free_flick_around">キー周辺</string>
<string name="free_flick_above">キー上部のガイド</string>
<string name="free_flick_preview_hint">キーボードの各キーを操作して試せます。上部表示は押した直後から全領域を表示します。周囲表示は長押し表示が有効な場合に長押しで全体を表示します。</string>
<string name="free_flick_preview_hint">キーボードの各キーを操作して試せます。キー上部では押した直後から、キー周辺では切替先のマップで全候補を表示します。長押し表示が有効な場合は、長押しでも全候補を表示します。</string>
<string name="free_flick_template">テンプレートを適用</string>
<string name="free_flick_template_12">12キーフリック</string>
<string name="free_flick_template_confirm">「%1$s」キーのすべてのマップを、通常の12キーフリックに置き換えます。保存するまで実入力には反映されません。取り消すこともできます。</string>
<string name="free_flick_template_hint">12キーと同じ通常マップです。枠を追加して文字やマップ切替を設定できます。</string>
<string name="free_flick_try_nearest">枠外では有効な最寄りのポップアップを選択。長押し表示が有効なら全体を表示します。変更はフリーフリック設定で行えます。</string>
<string name="free_flick_try_nearest">枠外では有効な最寄りのポップアップを選びます。切替先のマップでは全候補を表示します。長押し表示が有効な場合は、長押しでも全候補を表示します。変更はフリーフリック設定で行えます。</string>
<string name="two_step_popup_title">2段フリック入力</string>
<string name="two_step_popup_summary">2段フリック入力のpopupの大きさ、文字サイズ、表示位置を設定します</string>
<string-array name="free_flick_presentation_entries"><item>@string/free_flick_around</item><item>@string/free_flick_above</item></string-array>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values/sumire_popup_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<string name="popup_discard">Discard</string>
<string name="popup_result">Output</string>
<string name="popup_selection">Selection</string>
<string name="popup_try_hint">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.</string>
<string name="popup_try_hint">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.</string>
<string name="popup_invalid_saved">Saved maps could not be loaded. Showing defaults; the stored data has not been replaced.</string>
<string name="popup_delete_confirm">Delete this map?</string>
<string name="popup_name_required">Enter a unique map name.</string>
Expand All @@ -68,12 +68,12 @@
<string name="free_flick_presentation">Popup position</string>
<string name="free_flick_around">Around the key</string>
<string name="free_flick_above">Guide above the key</string>
<string name="free_flick_preview_hint">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.</string>
<string name="free_flick_preview_hint">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.</string>
<string name="free_flick_template">Apply template</string>
<string name="free_flick_template_12">12-key flick</string>
<string name="free_flick_template_confirm">Replace all maps for key “%1$s” with standard 12-key flick. This affects input only after saving and can be undone.</string>
<string name="free_flick_template_hint">Standard 12-key map. Add popup regions for text or map transitions.</string>
<string name="free_flick_try_nearest">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.</string>
<string name="free_flick_try_nearest">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.</string>
<string name="two_step_popup_title">Two-step flick input</string>
<string name="two_step_popup_summary">Set two-step popup size, text size, and position</string>
<string-array name="free_flick_presentation_entries"><item>@string/free_flick_around</item><item>@string/free_flick_above</item></string-array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class PopupMapVisibility(val settings: GestureSessionConfig, private val downX:
expanded=settings.showLongPressPopup
return true
}
fun regions(session: PopupMapSession): Set<String>? = 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<String>? =
if (showsAllRegions(session)) null else setOfNotNull(session.selectedRegionId)

fun showsTap(session: PopupMapSession) = showsAllRegions(session) || session.isTap
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
Expand Down Expand Up @@ -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<PopupMapView>(controller, "content")
val popup = ReflectionHelpers.getField<PopupWindow>(controller, "popup")
assertEquals(emptySet<String>(), 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<String>(), 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="へ"))))))
Expand Down
Loading