1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

Editor | Fix | Disable link appearance menu (#2355) (#2356)

This commit is contained in:
Sergey Boishtyan 2022-06-16 14:01:48 +03:00 committed by GitHub
parent b69bb21f0d
commit ba7a328624
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 33 deletions

View file

@ -12,6 +12,7 @@ android {
targetSdkVersion config["target_sdk"]
testInstrumentationRunner config["test_runner"]
buildConfigField "boolean", "NESTED_DECORATION_ENABLED", "false"
buildConfigField "boolean", "ENABLE_LINK_APPERANCE_MENU", "false"
}
testOptions.unitTests.includeAndroidResources = true

View file

@ -356,7 +356,7 @@ class EditorViewModel(
viewModelScope.launch {
templateDelegateState.collect { state ->
Timber.d("Template delegate state: $state")
Timber.v("Template delegate state: $state")
when (state) {
is SelectTemplateState.Accepted -> {
commands.postValue(EventWrapper(Command.CloseKeyboard))
@ -370,6 +370,8 @@ class EditorViewModel(
)
)
}
is SelectTemplateState.Available -> {}
SelectTemplateState.Idle -> {}
}
}
}
@ -1655,10 +1657,12 @@ class EditorViewModel(
}
is Content.Link -> {
excludedActions.add(ActionItemType.Download)
if (!isMultiMode) {
var copyIndex = targetActions.indexOf(ActionItemType.Style)
if (copyIndex == NO_POSITION) copyIndex = PREVIEW_POSITION
targetActions.addIfNotExists(ActionItemType.Preview, copyIndex)
if (BuildConfig.ENABLE_LINK_APPERANCE_MENU) {
if (!isMultiMode) {
var copyIndex = targetActions.indexOf(ActionItemType.Style)
if (copyIndex == NO_POSITION) copyIndex = PREVIEW_POSITION
targetActions.addIfNotExists(ActionItemType.Preview, copyIndex)
}
}
}
is Content.Page -> {
@ -1693,7 +1697,7 @@ class EditorViewModel(
item: ActionItemType,
position: Int = NO_POSITION
) {
if (indexOf(item) != NO_POSITION) {
if (contains(item)) {
return
}

View file

@ -124,7 +124,6 @@ class SplashViewModel(
}
private fun retryLaunchingWallet() {
val startTime = System.currentTimeMillis()
viewModelScope.launch {
launchWallet(BaseUseCase.None).process(
failure = { e ->

View file

@ -2,6 +2,7 @@ package com.anytypeio.anytype.presentation.editor.editor
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.anytypeio.anytype.core_models.Block
import com.anytypeio.anytype.presentation.BuildConfig
import com.anytypeio.anytype.presentation.MockBlockFactory
import com.anytypeio.anytype.presentation.editor.editor.actions.ActionItemType
import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType
@ -10,6 +11,7 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.mockito.MockitoAnnotations
import kotlin.test.assertContains
import kotlin.test.assertFalse
import kotlin.test.assertTrue
@ -31,35 +33,39 @@ class EditorBlockActionsTest : EditorPresentationTestSetup() {
@Test
fun `preview action should be in actions before style - when link block`() {
if (BuildConfig.ENABLE_LINK_APPERANCE_MENU) {
val link = MockBlockFactory.link()
val link = MockBlockFactory.link()
val smart = Block(
id = root,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(),
children = listOf(header.id, link.id)
)
val document = listOf(smart, header, link)
stubDefaultMethods(document)
val vm = buildViewModel()
vm.onStart(root)
// Simulating long tap on link block, in order to enter multi-select mode.
vm.onClickListener(
ListenerType.LongClick(
target = link.id,
dimensions = BlockDimensions()
val smart = Block(
id = root,
fields = Block.Fields(emptyMap()),
content = Block.Content.Smart(),
children = listOf(header.id, link.id)
)
)
assertTrue {
vm.actions.value.indexOf(ActionItemType.Preview) == vm.actions.value.indexOf(ActionItemType.Style) - 1
val document = listOf(smart, header, link)
stubDefaultMethods(document)
val vm = buildViewModel()
vm.onStart(root)
// Simulating long tap on link block, in order to enter multi-select mode.
vm.onClickListener(
ListenerType.LongClick(
target = link.id,
dimensions = BlockDimensions()
)
)
assertContains(vm.actions.value, ActionItemType.Preview)
assertContains(vm.actions.value, ActionItemType.Style)
assertTrue {
vm.actions.value.indexOf(ActionItemType.Preview) == vm.actions.value.indexOf(
ActionItemType.Style
) - 1
}
}
}