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
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ class KeyboardEditorViewModel @Inject constructor(
finalTwoStepLongPressMaps.remove(keyId)
}

KeyType.TWO_STEP_FLICK,
KeyType.FLICK_LONG_PRESS -> {
finalFlickMaps.remove(keyId)
finalCircularFlickMaps.remove(keyId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,38 @@ class KeyboardEditorViewModelFlexiblePlacementTest {
assertEquals(beforeLayout.rowCount * 2, afterLayout.rowUnitCount)
}

@Test
fun twoStepKeyEdit_keepsNormalAndLongPressOutputsInLayout() {
val viewModel = viewModel()
viewModel.applyTemplate(singleKeyLayout("key_a", "key_a"))
val key = viewModel.uiState.value.layout.keys.single()
val normalOutputs = mapOf(
TfbiFlickDirection.TAP to mapOf(TfbiFlickDirection.TAP to "あ"),
TfbiFlickDirection.UP to mapOf(
TfbiFlickDirection.TAP to "あ",
TfbiFlickDirection.UP to "い",
TfbiFlickDirection.UP_RIGHT to "う"
)
)
val longPressOutputs = mapOf(
TfbiFlickDirection.UP to mapOf(TfbiFlickDirection.UP_RIGHT to "ぅ")
)

assertTrue(
viewModel.updateKeyAndMappings(
newKeyData = key.copy(keyType = KeyType.TWO_STEP_FLICK, isFlickable = true),
flickMap = emptyMap(),
twoStepMap = normalOutputs,
longPressFlickMap = emptyMap(),
twoStepLongPressMap = longPressOutputs
)
)

val editedLayout = viewModel.uiState.value.layout
assertEquals(normalOutputs, editedLayout.twoStepFlickKeyMaps[key.keyId])
assertEquals(longPressOutputs, editedLayout.twoStepLongPressKeyMaps[key.keyId])
}

@Test
fun legacyLayout_keyResizeStillUsesRowSpanAndColSpanCells() {
val vm = viewModel()
Expand Down
Loading