diff --git a/presentation/build.gradle b/presentation/build.gradle index f93f151eed..ed5d830792 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -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 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 04f57bfaad..e52efbded6 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 @@ -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 } diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/splash/SplashViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/splash/SplashViewModel.kt index 710464f3b9..b6b32b1058 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/splash/SplashViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/splash/SplashViewModel.kt @@ -124,7 +124,6 @@ class SplashViewModel( } private fun retryLaunchingWallet() { - val startTime = System.currentTimeMillis() viewModelScope.launch { launchWallet(BaseUseCase.None).process( failure = { e -> diff --git a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBlockActionsTest.kt b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBlockActionsTest.kt index 8b3016d9e5..d5cc139f41 100644 --- a/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBlockActionsTest.kt +++ b/presentation/src/test/java/com/anytypeio/anytype/presentation/editor/editor/EditorBlockActionsTest.kt @@ -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 + } } }