diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapter.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapter.kt index abdbc00c66..82bf3f33c2 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapter.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockAdapter.kt @@ -474,16 +474,6 @@ class BlockAdapter( ItemBlockDescriptionBinding.inflate(inflater, parent, false) ).apply { with(content) { - enableEnterKeyDetector( - onEnterClicked = { range -> - onDescriptionEnterKeyListener( - views = views, - textView = content, - range = range, - onKeyPressedEvent = onKeyPressedEvent - ) - } - ) addTextChangedListener( DefaultTextWatcher { editable -> val pos = bindingAdapterPosition diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/text/Description.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/text/Description.kt index e55ffb9aa2..b910aebf2e 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/text/Description.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/text/Description.kt @@ -2,7 +2,6 @@ package com.anytypeio.anytype.core_ui.features.editor.holders.text import android.view.Gravity import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView import com.anytypeio.anytype.core_ui.R import com.anytypeio.anytype.core_ui.databinding.ItemBlockDescriptionBinding import com.anytypeio.anytype.core_ui.features.editor.BlockViewDiffUtil @@ -115,27 +114,6 @@ class Description(val binding: ItemBlockDescriptionBinding) : BlockViewHolder(bi binding.tvBlockDescription.enableEditMode() } - fun onDescriptionEnterKeyListener( - views: List, - textView: TextView, - range: IntRange, - onKeyPressedEvent: (KeyPressedEvent) -> Unit - ) { - val pos = bindingAdapterPosition - val text = textView.text.toString() - if (pos != RecyclerView.NO_POSITION) { - val view = views[pos] - check(view is BlockView.Title) - onKeyPressedEvent.invoke( - KeyPressedEvent.OnDescriptionBlockEnterKeyEvent( - target = view.id, - text = text, - range = range - ) - ) - } - } - private fun setupContentPadding(isTodoLayout: Boolean) { if (isTodoLayout) { val lr = itemView.context.dimen(R.dimen.dp_40).toInt() diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt index 7a0f2d166d..3d99d4d5b5 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt @@ -1366,12 +1366,14 @@ class EditorViewModel( text: String, range: IntRange ) { + Timber.d("onSplitObjectDescription, target:[$target] text:[$text] range:[$range]") proceedWithSplitEvent( target = target, text = text, range = range, marks = emptyList() ) + viewModelScope.sendAnalyticsSetDescriptionEvent(analytics, analyticsContext) } private fun proceedWithEnterEvent( @@ -5333,14 +5335,6 @@ class EditorViewModel( ) viewModelScope.sendAnalyticsSetTitleEvent(analytics, analyticsContext) } - is KeyPressedEvent.OnDescriptionBlockEnterKeyEvent -> { - proceedWithDescriptionEnterClicked( - description = event.target, - text = event.text, - range = event.range - ) - viewModelScope.sendAnalyticsSetDescriptionEvent(analytics, analyticsContext) - } } } @@ -5376,14 +5370,6 @@ class EditorViewModel( ) } } - - private fun proceedWithDescriptionEnterClicked( - description: Id, - text: String, - range: IntRange - ) { - proceedWithSplitEvent(description, range, text, emptyList()) - } //endregion //region MULTI-SELECT diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/editor/KeyPressedEvent.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/editor/KeyPressedEvent.kt index 4690055bbb..54b70d05ef 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/editor/KeyPressedEvent.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/editor/KeyPressedEvent.kt @@ -1,6 +1,5 @@ package com.anytypeio.anytype.presentation.editor.editor -import android.text.Editable import com.anytypeio.anytype.core_models.Id sealed class KeyPressedEvent { @@ -10,11 +9,4 @@ sealed class KeyPressedEvent { val text: String, val range: IntRange ) : KeyPressedEvent() - - data class OnDescriptionBlockEnterKeyEvent( - val target: Id, - val text: String, - val range: IntRange - ) : KeyPressedEvent() - } \ No newline at end of file diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSplitTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSplitTest.kt index 636dd68ab1..967c605e2d 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSplitTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorSplitTest.kt @@ -1391,12 +1391,10 @@ class EditorSplitTest : EditorPresentationTestSetup() { hasFocus = true ) - vm.onKeyPressedEvent( - KeyPressedEvent.OnDescriptionBlockEnterKeyEvent( - target = description.id, - text = description.content().text, - range = range - ) + vm.onSplitObjectDescription( + target = description.id, + text = description.content().text, + range = range ) coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION) @@ -1467,12 +1465,10 @@ class EditorSplitTest : EditorPresentationTestSetup() { hasFocus = true ) - vm.onKeyPressedEvent( - KeyPressedEvent.OnDescriptionBlockEnterKeyEvent( - target = description.id, - text = description.content().text, - range = range - ) + vm.onSplitObjectDescription( + target = description.id, + text = description.content().text, + range = range ) coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION) @@ -1543,12 +1539,10 @@ class EditorSplitTest : EditorPresentationTestSetup() { hasFocus = true ) - vm.onKeyPressedEvent( - KeyPressedEvent.OnDescriptionBlockEnterKeyEvent( - target = description.id, - text = description.content().text, - range = range - ) + vm.onSplitObjectDescription( + target = description.id, + text = description.content().text, + range = range ) coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION) @@ -1621,12 +1615,10 @@ class EditorSplitTest : EditorPresentationTestSetup() { hasFocus = true ) - vm.onKeyPressedEvent( - KeyPressedEvent.OnDescriptionBlockEnterKeyEvent( - target = description.id, - text = description.content().text, - range = range - ) + vm.onSplitObjectDescription( + target = description.id, + text = description.content().text, + range = range ) coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION) @@ -1696,12 +1688,10 @@ class EditorSplitTest : EditorPresentationTestSetup() { hasFocus = true ) - vm.onKeyPressedEvent( - KeyPressedEvent.OnDescriptionBlockEnterKeyEvent( - target = description.id, - text = description.content().text, - range = range - ) + vm.onSplitObjectDescription( + target = description.id, + text = description.content().text, + range = range ) coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION) @@ -1771,12 +1761,10 @@ class EditorSplitTest : EditorPresentationTestSetup() { hasFocus = true ) - vm.onKeyPressedEvent( - KeyPressedEvent.OnDescriptionBlockEnterKeyEvent( - target = description.id, - text = description.content().text, - range = range - ) + vm.onSplitObjectDescription( + target = description.id, + text = description.content().text, + range = range ) coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION)