diff --git a/app/build.gradle b/app/build.gradle index d098dbdb33..c8ffe2474c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -203,6 +203,7 @@ dependencies { implementation libs.zxing implementation libs.androidxSecurityCrypto + implementation libs.middleware //Unit/Integration tests dependencies testImplementation libs.androidXTestCore diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/base/EditorTestSetup.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/base/EditorTestSetup.kt index cb1813ba25..1473177fe1 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/base/EditorTestSetup.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/base/EditorTestSetup.kt @@ -61,6 +61,7 @@ import com.anytypeio.anytype.domain.launch.GetDefaultPageType import com.anytypeio.anytype.domain.misc.UrlBuilder import com.anytypeio.anytype.domain.`object`.ConvertObjectToSet import com.anytypeio.anytype.domain.`object`.UpdateDetail +import com.anytypeio.anytype.domain.`object`.ConvertObjectToCollection import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes @@ -261,6 +262,9 @@ open class EditorTestSetup { @Mock lateinit var tableDelegate: EditorTableDelegate + @Mock + lateinit var objectToCollection: ConvertObjectToCollection + val root: String = "rootId123" val workspaceId = MockDataFactory.randomString() @@ -450,7 +454,8 @@ open class EditorTestSetup { featureToggles = featureToggles, tableDelegate = tableDelegate, workspaceManager = workspaceManager, - getObjectTypes = getObjectTypes + getObjectTypes = getObjectTypes, + objectToCollection = objectToCollection ) } diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationStatusValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationStatusValueTest.kt index ee2dc4f625..fb593d6be5 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationStatusValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationStatusValueTest.kt @@ -32,8 +32,8 @@ import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvid import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.test_utils.utils.checkHasText @@ -93,7 +93,7 @@ class AddRelationStatusValueTest { val coroutineTestRule = CoroutinesTestRule() private val ctx = MockDataFactory.randomUuid() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val store : ObjectStore = DefaultObjectStore() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() private val db = ObjectSetDatabase(store = store) @@ -107,7 +107,7 @@ class AddRelationStatusValueTest { urlBuilder = UrlBuilder(gateway) TestRelationOptionValueDVAddFragment.testVmFactory = AddOptionsRelationDVViewModel.Factory( relations = DataViewObjectRelationProvider( - objectSetState = state, + objectState = state, storeOfRelations = storeOfRelations ), values = DataViewObjectValueProvider( @@ -161,12 +161,11 @@ class AddRelationStatusValueTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - state.value = ObjectSet(blocks = listOf(dv)) + state.value = ObjectState.DataView.Set(blocks = listOf(dv)) stubCreateRelationOption() @@ -239,20 +238,11 @@ class AddRelationStatusValueTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) - ) + state.value = ObjectState.DataView.Set(blocks = listOf(dv)) stubCreateRelationOption() @@ -331,20 +321,11 @@ class AddRelationStatusValueTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) - ) + state.value = ObjectState.DataView.Set(blocks = listOf(dv)) // TESTING @@ -422,20 +403,11 @@ class AddRelationStatusValueTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) - ) + state.value = ObjectState.DataView.Set(blocks = listOf(dv)) // TESTING @@ -522,20 +494,11 @@ class AddRelationStatusValueTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) - ) + state.value = ObjectState.DataView.Set(blocks = listOf(dv)) // TESTING diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationTagValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationTagValueTest.kt index 2e0fca7d8d..96b210a3ef 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationTagValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationTagValueTest.kt @@ -31,8 +31,8 @@ import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvid import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.test_utils.utils.checkHasText @@ -91,7 +91,7 @@ class AddRelationTagValueTest { val coroutineTestRule = CoroutinesTestRule() private val ctx = MockDataFactory.randomUuid() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val store : ObjectStore = DefaultObjectStore() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() private val db = ObjectSetDatabase(store = store) @@ -105,7 +105,7 @@ class AddRelationTagValueTest { urlBuilder = UrlBuilder(gateway) TestRelationOptionValueDVAddFragment.testVmFactory = AddOptionsRelationDVViewModel.Factory( relations = DataViewObjectRelationProvider( - objectSetState = state, + objectState = state, storeOfRelations = storeOfRelations ), values = DataViewObjectValueProvider(db = db), @@ -157,20 +157,11 @@ class AddRelationTagValueTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) - ) + state.value = ObjectState.DataView.Set(blocks = listOf(dv)) stubCreateRelationOption() @@ -267,20 +258,11 @@ class AddRelationTagValueTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) - ) + state.value = ObjectState.DataView.Set(blocks = listOf(dv)) // TESTING @@ -358,20 +340,11 @@ class AddRelationTagValueTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) - ) + state.value = ObjectState.DataView.Set(blocks = listOf(dv)) // TESTING @@ -458,20 +431,11 @@ class AddRelationTagValueTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) - ) + state.value = ObjectState.DataView.Set(blocks = listOf(dv)) // TESTING diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayObjectRelationTextValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayObjectRelationTextValueTest.kt index 3e4a201c83..fb31eb57c3 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayObjectRelationTextValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayObjectRelationTextValueTest.kt @@ -22,12 +22,11 @@ import com.anytypeio.anytype.domain.objects.DefaultObjectStore import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations import com.anytypeio.anytype.domain.objects.ObjectStore import com.anytypeio.anytype.domain.objects.StoreOfRelations -import com.anytypeio.anytype.presentation.relations.ObjectSetConfig import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.RelationTextValueViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.test_utils.utils.espresso.TextLineCountMatcher import com.anytypeio.anytype.ui.relations.RelationTextValueFragment @@ -60,7 +59,7 @@ class DisplayObjectRelationTextValueTest { val root = MockDataFactory.randomUuid() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val store: ObjectStore = DefaultObjectStore() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() private val db = ObjectSetDatabase(store = store) @@ -70,7 +69,7 @@ class DisplayObjectRelationTextValueTest { MockitoAnnotations.openMocks(this) TestRelationTextValueFragment.testVmFactory = RelationTextValueViewModel.Factory( relations = DataViewObjectRelationProvider( - objectSetState = state, + objectState = state, storeOfRelations = storeOfRelations ), values = DataViewObjectValueProvider(db = db), @@ -105,29 +104,17 @@ class DisplayObjectRelationTextValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueText - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) launchFragment( @@ -180,29 +167,17 @@ class DisplayObjectRelationTextValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueText - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -257,29 +232,17 @@ class DisplayObjectRelationTextValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueText - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -334,29 +297,17 @@ class DisplayObjectRelationTextValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueText - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) launchFragment( @@ -409,29 +360,17 @@ class DisplayObjectRelationTextValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueText - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) launchFragment( @@ -485,30 +424,18 @@ class DisplayObjectRelationTextValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueText - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) launchFragment( diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationNumberValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationNumberValueTest.kt index 654099a53e..890c7a9888 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationNumberValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationNumberValueTest.kt @@ -13,7 +13,6 @@ import com.anytypeio.anytype.R import com.anytypeio.anytype.analytics.base.Analytics import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.Payload -import com.anytypeio.anytype.core_models.Relation import com.anytypeio.anytype.domain.`object`.ReloadObject import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.config.Gateway @@ -21,12 +20,11 @@ import com.anytypeio.anytype.domain.objects.DefaultObjectStore import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations import com.anytypeio.anytype.domain.objects.ObjectStore import com.anytypeio.anytype.domain.objects.StoreOfRelations -import com.anytypeio.anytype.presentation.relations.ObjectSetConfig import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.RelationTextValueViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.test_utils.utils.TestUtils @@ -68,7 +66,7 @@ class DisplayRelationNumberValueTest { val coroutineTestRule = CoroutinesTestRule() private val root = MockDataFactory.randomUuid() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val store: ObjectStore = DefaultObjectStore() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() private val db = ObjectSetDatabase(store = store) @@ -78,7 +76,7 @@ class DisplayRelationNumberValueTest { MockitoAnnotations.openMocks(this) TestRelationTextValueFragment.testVmFactory = RelationTextValueViewModel.Factory( relations = DataViewObjectRelationProvider( - objectSetState = state, + objectState = state, storeOfRelations = storeOfRelations ), values = DataViewObjectValueProvider(db = db), @@ -94,13 +92,6 @@ class DisplayRelationNumberValueTest { val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val relationText = "Number" - val valueText = 345.09 - - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to valueText - ) val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), @@ -111,32 +102,18 @@ class DisplayRelationNumberValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - val relation = Relation( - key = relationKey, - name = relationText, - source = Relation.Source.values().random(), - format = Relation.Format.NUMBER - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -165,13 +142,6 @@ class DisplayRelationNumberValueTest { val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val relationText = "Number" - val valueText = 345.0 - - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to valueText - ) val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), @@ -182,32 +152,18 @@ class DisplayRelationNumberValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - val relation = Relation( - key = relationKey, - name = relationText, - source = Relation.Source.values().random(), - format = Relation.Format.NUMBER - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -236,13 +192,6 @@ class DisplayRelationNumberValueTest { val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val relationText = "Number" - val valueText = null - - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to valueText - ) val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), @@ -253,32 +202,18 @@ class DisplayRelationNumberValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - val relation = Relation( - key = relationKey, - name = relationText, - source = Relation.Source.values().random(), - format = Relation.Format.NUMBER - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationObjectValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationObjectValueTest.kt index 277306a454..f34412aeab 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationObjectValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationObjectValueTest.kt @@ -17,9 +17,6 @@ import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.Id import com.anytypeio.anytype.core_models.ObjectType import com.anytypeio.anytype.core_models.Payload -import com.anytypeio.anytype.core_models.Relation -import com.anytypeio.anytype.core_models.StubRelationOptionObject -import com.anytypeio.anytype.core_models.ThemeColor import com.anytypeio.anytype.domain.`object`.UpdateDetail import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.config.Gateway @@ -35,9 +32,10 @@ import com.anytypeio.anytype.presentation.relations.ObjectSetConfig import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel +import com.anytypeio.anytype.presentation.sets.dataViewState +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory @@ -56,11 +54,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.MockitoAnnotations -import org.mockito.kotlin.any -import org.mockito.kotlin.doReturn -import org.mockito.kotlin.stub -import org.mockito.kotlin.times -import org.mockito.kotlin.verifyBlocking @RunWith(AndroidJUnit4::class) @LargeTest @@ -92,7 +85,7 @@ class DisplayRelationObjectValueTest { val coroutineTestRule = CoroutinesTestRule() private val root = MockDataFactory.randomUuid() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val store: ObjectStore = DefaultObjectStore() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes() @@ -106,12 +99,13 @@ class DisplayRelationObjectValueTest { urlBuilder = UrlBuilder(gateway) TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory( relations = DataViewObjectRelationProvider( - objectSetState = state, + objectState = state, storeOfRelations = storeOfRelations ), values = DataViewObjectValueProvider(db = db), - details = object: ObjectDetailProvider { - override fun provide(): Map = state.value.details + details = object : ObjectDetailProvider { + override fun provide(): Map = + state.value.dataViewState()?.details.orEmpty() }, urlBuilder = urlBuilder, copyFileToCache = copyFileToCacheDirectory, @@ -144,33 +138,18 @@ class DisplayRelationObjectValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relation, - isMulti = true, - name = MockDataFactory.randomString(), - format = Relation.Format.OBJECT, - source = Relation.Source.values().random() - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -219,33 +198,18 @@ class DisplayRelationObjectValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relation, - isMulti = true, - name = name, - format = Relation.Format.OBJECT, - source = Relation.Source.values().random() - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -271,16 +235,9 @@ class DisplayRelationObjectValueTest { // SETUP - val name = "Object" - val relationId = MockDataFactory.randomUuid() val targetId = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to targetId, - relationId to emptyList() - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -290,32 +247,18 @@ class DisplayRelationObjectValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationId, - name = name, - format = Relation.Format.OBJECT, - source = Relation.Source.values().random() - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -376,11 +319,6 @@ class DisplayRelationObjectValueTest { val relationId = MockDataFactory.randomUuid() val recordId = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to recordId, - relationId to listOf(object1Id, object2Id) - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -390,32 +328,18 @@ class DisplayRelationObjectValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationId, - name = relationName, - format = Relation.Format.OBJECT, - source = Relation.Source.values().random() - ) - ), viewers = listOf(viewer), - ) + ) ) ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ), details = mapOf( object1Id to Block.Fields( mapOf( @@ -495,7 +419,6 @@ class DisplayRelationObjectValueTest { isReadOnly = false ) - val relationName = "Cast" val object1Name = "Charlie Chaplin" val object1Id = MockDataFactory.randomUuid() val object2Name = "Jean-Pierre Léaud" @@ -504,11 +427,6 @@ class DisplayRelationObjectValueTest { val relationId = MockDataFactory.randomUuid() val recordId = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to recordId, - relationId to listOf(object1Id, object2Id) - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -518,32 +436,18 @@ class DisplayRelationObjectValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationId, - name = relationName, - format = Relation.Format.OBJECT, - source = Relation.Source.values().random() - ) - ), viewers = listOf(viewer), - ) + ) ) ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ), details = mapOf( object1Id to Block.Fields( mapOf( @@ -587,7 +491,6 @@ class DisplayRelationObjectValueTest { // SETUP - val relationName = "Writers" val object1Name = "Virginia Woolf" val object1Id = MockDataFactory.randomUuid() val object2Name = "Réné-Auguste Chateaubriand" @@ -622,11 +525,6 @@ class DisplayRelationObjectValueTest { val relationId = MockDataFactory.randomUuid() val recordId = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to recordId, - relationId to listOf(object1Id, object2Id) - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -636,32 +534,18 @@ class DisplayRelationObjectValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationId, - name = relationName, - format = Relation.Format.OBJECT, - source = Relation.Source.values().random() - ) - ), viewers = listOf(viewer), - ) + ) ) ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ), details = mapOf( object1Id to Block.Fields( mapOf( @@ -701,39 +585,9 @@ class DisplayRelationObjectValueTest { } private fun launchFragment(args: Bundle): FragmentScenario { - return launchFragmentInContainer( + return launchFragmentInContainer( fragmentArgs = args, themeResId = R.style.AppTheme ) } - - private fun verifyCreateRelationOptionCalled() { - verifyBlocking(repo, times(1)) { - createRelationOption( - relation = any(), - color = any(), - name = any() - ) - } - } - - private fun stubCreateRelationOption( - name: String = MockDataFactory.randomString(), - id: Id = MockDataFactory.randomUuid(), - color: String = ThemeColor.values().random().code - ) { - repo.stub { - onBlocking { - createRelationOption( - relation = any(), - color = any(), - name = any() - ) - } doReturn StubRelationOptionObject( - id = id, - color = color, - text = name - ) - } - } } \ No newline at end of file diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationStatusValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationStatusValueTest.kt index 7501473e9a..1fb262b24e 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationStatusValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationStatusValueTest.kt @@ -30,13 +30,13 @@ import com.anytypeio.anytype.domain.objects.ObjectStore import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.relations.AddFileToObject -import com.anytypeio.anytype.presentation.relations.ObjectSetConfig import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel +import com.anytypeio.anytype.presentation.sets.dataViewState +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory @@ -86,7 +86,7 @@ class DisplayRelationStatusValueTest { val coroutineTestRule = CoroutinesTestRule() private val root = MockDataFactory.randomUuid() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val store: ObjectStore = DefaultObjectStore() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes() @@ -100,14 +100,15 @@ class DisplayRelationStatusValueTest { urlBuilder = UrlBuilder(gateway) TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory( relations = DataViewObjectRelationProvider( - objectSetState = state, + objectState = state, storeOfRelations = storeOfRelations ), values = DataViewObjectValueProvider( db = db ), details = object : ObjectDetailProvider { - override fun provide(): Map = state.value.details + override fun provide(): Map = + state.value.dataViewState()?.details.orEmpty() }, urlBuilder = urlBuilder, copyFileToCache = copyFileToCacheDirectory, @@ -126,10 +127,6 @@ class DisplayRelationStatusValueTest { val relation = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -139,33 +136,18 @@ class DisplayRelationStatusValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relation, - isMulti = true, - name = MockDataFactory.randomString(), - format = Relation.Format.STATUS, - source = Relation.Source.values().random() - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -199,10 +181,6 @@ class DisplayRelationStatusValueTest { val relation = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -212,33 +190,18 @@ class DisplayRelationStatusValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relation, - isMulti = true, - name = name, - format = Relation.Format.STATUS, - source = Relation.Source.values().random() - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -263,35 +226,17 @@ class DisplayRelationStatusValueTest { // SETUP - val option1Color = ThemeColor.values().random() val option2Color = ThemeColor.values().random() - val option1 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "In progress", - color = option1Color.code - ) - val option2 = Relation.Option( id = MockDataFactory.randomUuid(), text = "Done", color = option2Color.code ) - val option3 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "Todo", - color = "" - ) - val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to listOf(option2.id) - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -301,37 +246,18 @@ class DisplayRelationStatusValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = MockDataFactory.randomString(), - source = Relation.Source.values().random(), - format = Relation.Format.STATUS, - selections = listOf(option1, option2, option3) - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -357,20 +283,9 @@ class DisplayRelationStatusValueTest { // SETUP - val option1 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "In progress", - color = "" - ) - val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to listOf(option1.id) - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -380,37 +295,18 @@ class DisplayRelationStatusValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = MockDataFactory.randomString(), - source = Relation.Source.values().random(), - format = Relation.Format.STATUS, - selections = listOf(option1) - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -435,31 +331,9 @@ class DisplayRelationStatusValueTest { // SETUP - val option1 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "In progress", - color = MockDataFactory.randomString() - ) - - val option2 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "Done", - color = MockDataFactory.randomString() - ) - - val option3 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "Todo", - color = MockDataFactory.randomString() - ) - val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -469,37 +343,18 @@ class DisplayRelationStatusValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = MockDataFactory.randomString(), - source = Relation.Source.values().random(), - format = Relation.Format.STATUS, - selections = listOf(option1, option2, option3) - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationTagValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationTagValueTest.kt index 7cf307569d..c9edc58a4f 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationTagValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/DisplayRelationTagValueTest.kt @@ -30,13 +30,13 @@ import com.anytypeio.anytype.domain.objects.ObjectStore import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.relations.AddFileToObject -import com.anytypeio.anytype.presentation.relations.ObjectSetConfig import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel +import com.anytypeio.anytype.presentation.sets.dataViewState +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory @@ -86,7 +86,7 @@ class DisplayRelationTagValueTest { val coroutineTestRule = CoroutinesTestRule() private val root = MockDataFactory.randomUuid() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val store: ObjectStore = DefaultObjectStore() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() private val db = ObjectSetDatabase(store) @@ -100,12 +100,13 @@ class DisplayRelationTagValueTest { urlBuilder = UrlBuilder(gateway) TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory( relations = DataViewObjectRelationProvider( - objectSetState = state, + objectState = state, storeOfRelations = storeOfRelations ), values = DataViewObjectValueProvider(db = db), - details = object: ObjectDetailProvider { - override fun provide(): Map = state.value.details + details = object : ObjectDetailProvider { + override fun provide(): Map = + state.value.dataViewState()?.details.orEmpty() }, urlBuilder = urlBuilder, copyFileToCache = copyFileToCacheDirectory, @@ -124,10 +125,6 @@ class DisplayRelationTagValueTest { val relation = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -137,33 +134,18 @@ class DisplayRelationTagValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relation, - isMulti = true, - name = MockDataFactory.randomString(), - format = Relation.Format.TAG, - source = Relation.Source.values().random() - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -197,10 +179,6 @@ class DisplayRelationTagValueTest { val relation = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -210,33 +188,18 @@ class DisplayRelationTagValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relation, - isMulti = true, - name = name, - format = Relation.Format.TAG, - source = Relation.Source.values().random() - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -261,15 +224,8 @@ class DisplayRelationTagValueTest { // SETUP - val option1Color = ThemeColor.values().random() val option2Color = ThemeColor.values().random() - val option1 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "Architect", - color = option1Color.code - ) - val option2 = Relation.Option( id = MockDataFactory.randomUuid(), text = "Manager", @@ -285,11 +241,6 @@ class DisplayRelationTagValueTest { val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to listOf(option2.id, option3.id) - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -299,37 +250,18 @@ class DisplayRelationTagValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = MockDataFactory.randomString(), - source = Relation.Source.values().random(), - format = Relation.Format.TAG, - selections = listOf(option1, option2, option3) - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -364,20 +296,9 @@ class DisplayRelationTagValueTest { // SETUP - val option1 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "Architect", - color = "" - ) - val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to listOf(option1.id) - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -387,37 +308,18 @@ class DisplayRelationTagValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = MockDataFactory.randomString(), - source = Relation.Source.values().random(), - format = Relation.Format.TAG, - selections = listOf(option1) - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -442,31 +344,9 @@ class DisplayRelationTagValueTest { // SETUP - val option1 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "TAG1", - color = MockDataFactory.randomString() - ) - - val option2 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "TAG 2", - color = MockDataFactory.randomString() - ) - - val option3 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "TAG 3", - color = MockDataFactory.randomString() - ) - val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -476,37 +356,18 @@ class DisplayRelationTagValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = MockDataFactory.randomString(), - source = Relation.Source.values().random(), - format = Relation.Format.TAG, - selections = listOf(option1, option2, option3) - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/EditRelationTagValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/EditRelationTagValueTest.kt index 4bd0326025..5989cf7142 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/EditRelationTagValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/EditRelationTagValueTest.kt @@ -25,13 +25,13 @@ import com.anytypeio.anytype.domain.objects.ObjectStore import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.relations.AddFileToObject -import com.anytypeio.anytype.presentation.relations.ObjectSetConfig import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel +import com.anytypeio.anytype.presentation.sets.dataViewState +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory @@ -88,7 +88,7 @@ class EditRelationTagValueTest { val coroutineTestRule = CoroutinesTestRule() private val ctx = MockDataFactory.randomUuid() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val store: ObjectStore = DefaultObjectStore() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() private val db = ObjectSetDatabase(store = store) @@ -102,12 +102,13 @@ class EditRelationTagValueTest { addFileToObject = AddFileToObject(repo) TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory( relations = DataViewObjectRelationProvider( - objectSetState = state, + objectState = state, storeOfRelations = storeOfRelations ), values = DataViewObjectValueProvider(db = db), details = object : ObjectDetailProvider { - override fun provide(): Map = state.value.details + override fun provide(): Map = + state.value.dataViewState()?.details.orEmpty() }, urlBuilder = urlBuilder, copyFileToCache = copyFileToCacheDirectory, @@ -127,12 +128,6 @@ class EditRelationTagValueTest { val option1Color = ThemeColor.values().random() val option2Color = ThemeColor.values().random() - val option1 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "Architect", - color = option1Color.code - ) - val option2 = Relation.Option( id = MockDataFactory.randomUuid(), text = "Manager", @@ -148,11 +143,6 @@ class EditRelationTagValueTest { val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to listOf(option2.id, option3.id) - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -162,37 +152,18 @@ class EditRelationTagValueTest { type = Block.Content.DataView.Viewer.Type.GRID ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = "Roles", - source = Relation.Source.values().random(), - format = Relation.Format.TAG, - selections = listOf(option1, option2, option3) - ) - ), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // TESTING @@ -245,32 +216,15 @@ class EditRelationTagValueTest { val option1Color = ThemeColor.values().random() val option2Color = ThemeColor.values().random() - val option1 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "Architect", - color = option1Color.code - ) - val option2 = Relation.Option( id = MockDataFactory.randomUuid(), text = "Manager", color = option2Color.code ) - val option3 = Relation.Option( - id = MockDataFactory.randomUuid(), - text = "Developer", - color = "" - ) - val relationKey = MockDataFactory.randomUuid() val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to listOf(option2.id, option3.id) - ) - val viewer = Block.Content.DataView.Viewer( id = MockDataFactory.randomUuid(), name = MockDataFactory.randomString(), @@ -285,32 +239,13 @@ class EditRelationTagValueTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf( - Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = "Roles", - source = Relation.Source.values().random(), - format = Relation.Format.TAG, - selections = listOf(option1, option2, option3) - ) - ), viewers = listOf(viewer), - - ) + + ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + state.value = ObjectState.DataView.Set( + blocks = listOf(dv) ) // TESTING @@ -334,7 +269,7 @@ class EditRelationTagValueTest { verifyBlocking(repo, times(1)) { setObjectDetail( - ctx= target, + ctx = target, key = relationKey, value = listOf(option2.id) ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/ObjectRelationDateValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/ObjectRelationDateValueTest.kt index fd6c021067..385f3c0627 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/ObjectRelationDateValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/ObjectRelationDateValueTest.kt @@ -23,9 +23,9 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.presentation.relations.ObjectSetConfig import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.RelationDateValueViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.ui.relations.RelationDateValueFragment import com.anytypeio.anytype.utils.CoroutinesTestRule @@ -51,7 +51,7 @@ class ObjectRelationDateValueTest { val root = MockDataFactory.randomUuid() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val store: ObjectStore = DefaultObjectStore() private val db = ObjectSetDatabase(store) private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() @@ -61,7 +61,7 @@ class ObjectRelationDateValueTest { MockitoAnnotations.openMocks(this) TestRelationDateValueFragment.testVmFactory = RelationDateValueViewModel.Factory( relations = DataViewObjectRelationProvider( - objectSetState = state, + objectState = state, storeOfRelations = storeOfRelations ), values = DataViewObjectValueProvider(db = db) @@ -94,30 +94,18 @@ class ObjectRelationDateValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueDate - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) launchFragment( @@ -168,25 +156,18 @@ class ObjectRelationDateValueTest { relation.key to valueDate ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) launchFragment( @@ -233,30 +214,18 @@ class ObjectRelationDateValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueDate - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) launchFragment( @@ -308,25 +277,18 @@ class ObjectRelationDateValueTest { relation.key to valueDate ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) launchFragment( @@ -373,30 +335,18 @@ class ObjectRelationDateValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueDate - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) launchFragment( @@ -444,30 +394,18 @@ class ObjectRelationDateValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueDate - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) val fragment = launchFragment( @@ -528,30 +466,18 @@ class ObjectRelationDateValueTest { source = Relation.Source.values().random() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relation.key to valueDate - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) val fragment = launchFragment( diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridColumnRenderingTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridColumnRenderingTest.kt index 8c5794f309..f4d615f9ab 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridColumnRenderingTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridColumnRenderingTest.kt @@ -131,7 +131,6 @@ class ObjectSetGridColumnRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation1, relation2, relation3, relation4, relation5), viewers = listOf(viewer), ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridFileCellRenderingTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridFileCellRenderingTest.kt index 3c849e5e10..c94a61eee3 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridFileCellRenderingTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridFileCellRenderingTest.kt @@ -121,7 +121,6 @@ class ObjectSetGridFileCellRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridNumberCellRenderingTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridNumberCellRenderingTest.kt index 8056e354f2..9bd8ef0879 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridNumberCellRenderingTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridNumberCellRenderingTest.kt @@ -106,7 +106,6 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) @@ -203,7 +202,6 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) @@ -300,7 +298,6 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) @@ -397,7 +394,6 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) @@ -494,7 +490,6 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) @@ -591,7 +586,6 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridObjectCellRenderingTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridObjectCellRenderingTest.kt index cdb1e09f3b..9fb0c639b9 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridObjectCellRenderingTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridObjectCellRenderingTest.kt @@ -120,7 +120,6 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) @@ -237,7 +236,6 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridPrimitiveRelationTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridPrimitiveRelationTest.kt index eb4fef0265..6579c40a49 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridPrimitiveRelationTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridPrimitiveRelationTest.kt @@ -171,7 +171,6 @@ class ObjectSetGridPrimitiveRelationTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation1, relation2, relation3, relation4, relation5), viewers = listOf(viewer), ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridTagCellRenderingTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridTagCellRenderingTest.kt index a1aedf8681..a86703fff0 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridTagCellRenderingTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetGridTagCellRenderingTest.kt @@ -132,7 +132,6 @@ class ObjectSetGridTagCellRenderingTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetHeaderTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetHeaderTest.kt index c6bcf57413..e7b4a3150a 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetHeaderTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/ObjectSetHeaderTest.kt @@ -61,7 +61,6 @@ class ObjectSetHeaderTest : TestObjectSetSetup() { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = emptyList(), viewers = listOf(viewer), ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/TestObjectSetSetup.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/TestObjectSetSetup.kt index 2504e79a69..f0d501be36 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/TestObjectSetSetup.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/TestObjectSetSetup.kt @@ -19,6 +19,7 @@ import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.base.Result import com.anytypeio.anytype.domain.block.interactor.UpdateText import com.anytypeio.anytype.domain.block.repo.BlockRepository +import com.anytypeio.anytype.domain.collections.AddObjectToCollection import com.anytypeio.anytype.domain.config.Gateway import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.cover.SetDocCoverImage @@ -28,6 +29,7 @@ import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer import com.anytypeio.anytype.domain.event.interactor.InterceptEvents import com.anytypeio.anytype.domain.launch.GetDefaultPageType import com.anytypeio.anytype.domain.misc.UrlBuilder +import com.anytypeio.anytype.domain.`object`.ConvertObjectToCollection import com.anytypeio.anytype.domain.objects.DefaultObjectStore import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations import com.anytypeio.anytype.domain.objects.ObjectStore @@ -38,6 +40,7 @@ import com.anytypeio.anytype.domain.search.CancelSearchSubscription import com.anytypeio.anytype.domain.search.DataViewSubscriptionContainer import com.anytypeio.anytype.domain.search.SubscriptionEventChannel import com.anytypeio.anytype.domain.sets.OpenObjectSet +import com.anytypeio.anytype.domain.sets.SetQueryToObjectSet import com.anytypeio.anytype.domain.status.InterceptThreadStatus import com.anytypeio.anytype.domain.status.ThreadStatusChannel import com.anytypeio.anytype.domain.templates.GetTemplates @@ -50,9 +53,10 @@ import com.anytypeio.anytype.presentation.common.Delegator import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.ObjectSetPaginator -import com.anytypeio.anytype.presentation.sets.ObjectSetReducer import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory +import com.anytypeio.anytype.presentation.sets.state.DefaultObjectStateReducer +import com.anytypeio.anytype.presentation.sets.subscription.DefaultDataViewSubscription import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory import kotlinx.coroutines.flow.Flow @@ -109,6 +113,13 @@ abstract class TestObjectSetSetup { lateinit var analytics: Analytics @Mock lateinit var cancelSearchSubscription: CancelSearchSubscription + @Mock + lateinit var convertObjectToCollection: ConvertObjectToCollection + @Mock + lateinit var setQueryToObjectSet: SetQueryToObjectSet + + @Mock + lateinit var addObjectToCollection: AddObjectToCollection @Mock lateinit var createObject: CreateObject @@ -117,7 +128,6 @@ abstract class TestObjectSetSetup { private lateinit var getDefaultPageType: GetDefaultPageType private val session = ObjectSetSession() - private val reducer = ObjectSetReducer() private val dispatcher: Dispatcher = Dispatcher.Default() private val paginator = ObjectSetPaginator() private val store: ObjectStore = DefaultObjectStore() @@ -150,6 +160,8 @@ abstract class TestObjectSetSetup { ) ) + private val objectStore: ObjectStore = DefaultObjectStore() + private val delegator = Delegator.Default() open fun setup() { @@ -209,18 +221,23 @@ abstract class TestObjectSetSetup { coverImageHashProvider = coverImageHashProvider, session = session, dispatcher = dispatcher, - reducer = reducer, analytics = analytics, downloadUnsplashImage = downloadUnsplashImage, setDocCoverImage = setDocCoverImage, delegator = delegator, createObject = createObject, - setDataViewQuery = setDataViewQuery, cancelSearchSubscription = cancelSearchSubscription, paginator = paginator, database = database, dataViewSubscriptionContainer = dataViewSubscriptionContainer, - storeOfRelations = storeOfRelations + storeOfRelations = storeOfRelations, + objectStateReducer = DefaultObjectStateReducer(), + dataViewSubscription = DefaultDataViewSubscription(dataViewSubscriptionContainer), + workspaceManager = workspaceManager, + objectToCollection = convertObjectToCollection, + setQueryToObjectSet = setQueryToObjectSet, + objectStore = objectStore, + addObjectToCollection = addObjectToCollection ) } @@ -298,7 +315,8 @@ abstract class TestObjectSetSetup { limit = any(), offset = any(), ignoreWorkspace = any(), - noDepSubscription = any() + noDepSubscription = any(), + collection = any() ) } doReturn SearchResult( results = emptyList(), diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/CreateSelectedFilterTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/CreateSelectedFilterTest.kt index a7a7a497be..b8697e5b20 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/CreateSelectedFilterTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/CreateSelectedFilterTest.kt @@ -13,7 +13,6 @@ import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.DVFilter import com.anytypeio.anytype.core_models.DVFilterCondition import com.anytypeio.anytype.core_models.Payload -import com.anytypeio.anytype.core_models.Relation import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.config.Gateway import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer @@ -27,11 +26,10 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.domain.workspace.WorkspaceManager -import com.anytypeio.anytype.presentation.relations.ObjectSetConfig -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.test_utils.utils.TestUtils @@ -77,7 +75,7 @@ class CreateSelectedFilterTest { private val root = MockDataFactory.randomUuid() private val session = ObjectSetSession() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val dispatcher = Dispatcher.Default() private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() @@ -104,7 +102,7 @@ class CreateSelectedFilterTest { dispatcher = dispatcher, urlBuilder = urlBuilder, searchObjects = searchObjects, - objectSetState = state, + objectState = state, analytics = analytics, storeOfObjectTypes = storeOfObjectTypes, storeOfRelations = storeOfRelations, @@ -118,13 +116,6 @@ class CreateSelectedFilterTest { fun shouldShowNonSelectedCheckedAndSelectedNotChecked() { val relationKey = MockDataFactory.randomUuid() - val target = MockDataFactory.randomUuid() - - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to emptyList() - ) - // Defining viewer containing one filter val filter = DVFilter( @@ -148,37 +139,18 @@ class CreateSelectedFilterTest { type = Block.Content.DataView.Viewer.Type.values().random() ) - val relation = Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = "Is read", - source = Relation.Source.values().random(), - format = Relation.Format.CHECKBOX, - selections = emptyList() - ) - val dv = Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), - - ) + + ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + state.value = ObjectState.DataView.Set( + blocks = listOf(dv) ) // Launching fragment @@ -213,11 +185,6 @@ class CreateSelectedFilterTest { val target = MockDataFactory.randomUuid() - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to emptyList() - ) - // Defining viewer containing one filter val filter = DVFilter( @@ -241,37 +208,18 @@ class CreateSelectedFilterTest { type = Block.Content.DataView.Viewer.Type.values().random() ) - val relation = Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = "Is read", - source = Relation.Source.values().random(), - format = Relation.Format.CHECKBOX, - selections = emptyList() - ) - val dv = Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), - - ) + + ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + state.value = ObjectState.DataView.Set( + blocks = listOf(dv) ) // Launching fragment diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/FilterListTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/FilterListTest.kt index c5a1e603a9..847fead262 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/FilterListTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/FilterListTest.kt @@ -22,11 +22,11 @@ import com.anytypeio.anytype.domain.objects.DefaultObjectStore import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.presentation.relations.ObjectSetConfig -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.filter.ViewerFilterViewModel import com.anytypeio.anytype.presentation.sets.model.Viewer +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.test_utils.utils.TestUtils @@ -67,7 +67,7 @@ class FilterListTest { private val root = MockDataFactory.randomUuid() private val session = ObjectSetSession() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val dispatcher = Dispatcher.Default() private val storeOfObjects = DefaultObjectStore() private val db = ObjectSetDatabase(storeOfObjects) @@ -142,20 +142,13 @@ class FilterListTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + state.value = ObjectState.DataView.Set( + blocks = listOf(dv) ) // Launching fragment @@ -233,20 +226,13 @@ class FilterListTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + state.value = ObjectState.DataView.Set( + blocks = listOf(dv) ) // Launching fragment @@ -324,20 +310,13 @@ class FilterListTest { children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + state.value = ObjectState.DataView.Set( + blocks = listOf(dv) ) // Launching fragment diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyInputValueFilterTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyInputValueFilterTest.kt index 05d1ce3153..0077df4c33 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyInputValueFilterTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyInputValueFilterTest.kt @@ -21,7 +21,6 @@ import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_models.DVFilter import com.anytypeio.anytype.core_models.DVFilterCondition import com.anytypeio.anytype.core_models.Payload -import com.anytypeio.anytype.core_models.Relation import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.config.Gateway import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer @@ -35,11 +34,10 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.domain.workspace.WorkspaceManager -import com.anytypeio.anytype.presentation.relations.ObjectSetConfig -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.ui.sets.modals.filter.ModifyFilterFromInputFieldValueFragment @@ -82,7 +80,7 @@ class ModifyInputValueFilterTest { private val root = MockDataFactory.randomUuid() private val session = ObjectSetSession() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val dispatcher = Dispatcher.Default() private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() @@ -103,7 +101,7 @@ class ModifyInputValueFilterTest { workspaceManager.setCurrentWorkspace(workspaceId) } TestModifyFilterFromInputFieldValueFragment.testVmFactory = FilterViewModel.Factory( - objectSetState = state, + objectState = state, session = session, updateDataViewViewer = updateDataViewViewer, dispatcher = dispatcher, @@ -123,13 +121,6 @@ class ModifyInputValueFilterTest { val relationKey = MockDataFactory.randomUuid() - val target = MockDataFactory.randomUuid() - - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to emptyList() - ) - // Defining viewer containing one filter val initialFilterText = "Foo" @@ -155,36 +146,17 @@ class ModifyInputValueFilterTest { type = Block.Content.DataView.Viewer.Type.values().random() ) - val relation = Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = MockDataFactory.randomString(), - source = Relation.Source.values().random(), - format = Relation.Format.LONG_TEXT, - selections = emptyList() - ) - val dv = Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + state.value = ObjectState.DataView.Set( + blocks = listOf(dv) ) // Launching fragment @@ -244,13 +216,6 @@ class ModifyInputValueFilterTest { val relationKey = MockDataFactory.randomUuid() - val target = MockDataFactory.randomUuid() - - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to emptyList() - ) - // Defining viewer containing one filter val initialFilterText = "1" @@ -276,36 +241,17 @@ class ModifyInputValueFilterTest { type = Block.Content.DataView.Viewer.Type.values().random() ) - val relation = Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = MockDataFactory.randomString(), - source = Relation.Source.values().random(), - format = Relation.Format.NUMBER, - selections = emptyList() - ) - val dv = Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + state.value = ObjectState.DataView.Set( + blocks = listOf(dv) ) // Launching fragment @@ -326,8 +272,14 @@ class ModifyInputValueFilterTest { // Checking input type - inputFieldInteraction.check(matches(withInputType(InputType.TYPE_CLASS_NUMBER - or InputType.TYPE_NUMBER_FLAG_DECIMAL or InputType.TYPE_NUMBER_FLAG_SIGNED))) + inputFieldInteraction.check( + matches( + withInputType( + InputType.TYPE_CLASS_NUMBER + or InputType.TYPE_NUMBER_FLAG_DECIMAL or InputType.TYPE_NUMBER_FLAG_SIGNED + ) + ) + ) // Typing additional text before pressing action button @@ -362,7 +314,7 @@ class ModifyInputValueFilterTest { } private fun launchFragment(args: Bundle): FragmentScenario { - return launchFragmentInContainer( + return launchFragmentInContainer( fragmentArgs = args, themeResId = R.style.AppTheme ) diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyStatusFilterTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyStatusFilterTest.kt index 168a5e833e..e593c2e113 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyStatusFilterTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyStatusFilterTest.kt @@ -32,11 +32,10 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.domain.workspace.WorkspaceManager -import com.anytypeio.anytype.presentation.relations.ObjectSetConfig -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.test_utils.utils.TestUtils @@ -80,7 +79,7 @@ class ModifyStatusFilterTest { private val root = MockDataFactory.randomUuid() private val session = ObjectSetSession() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val dispatcher = Dispatcher.Default() private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() @@ -102,7 +101,7 @@ class ModifyStatusFilterTest { workspaceManager.setCurrentWorkspace(workspaceId) } TestModifyFilterFromSelectedValueFragment.testVmFactory = FilterViewModel.Factory( - objectSetState = state, + objectState = state, session = session, updateDataViewViewer = updateDataViewViewer, dispatcher = dispatcher, @@ -121,7 +120,6 @@ class ModifyStatusFilterTest { fun shouldSelectSecondStatusAndApplyChangesOnClick() { val relationKey = MockDataFactory.randomUuid() - val target = MockDataFactory.randomUuid() // Defining three different statuses: @@ -143,11 +141,6 @@ class ModifyStatusFilterTest { color = MockDataFactory.randomString() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to emptyList() - ) - // Defining viewer containing one filter val filter = DVFilter( @@ -170,36 +163,17 @@ class ModifyStatusFilterTest { type = Block.Content.DataView.Viewer.Type.values().random() ) - val relation = Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = MockDataFactory.randomString(), - source = Relation.Source.values().random(), - format = Relation.Format.STATUS, - selections = listOf(option1, option2, option3) - ) - val dv = Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer) ) ) - state.value = ObjectSet( - blocks = listOf(dv), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + state.value = ObjectState.DataView.Set( + blocks = listOf(dv) ) // Launching fragment diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyTagFilterTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyTagFilterTest.kt index 49cbc1f7ed..77f0b0a5f8 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyTagFilterTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyTagFilterTest.kt @@ -19,7 +19,6 @@ import com.anytypeio.anytype.core_models.DVFilter import com.anytypeio.anytype.core_models.DVFilterCondition import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.core_models.Relation -import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.config.Gateway import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer @@ -33,11 +32,10 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.domain.workspace.WorkspaceManager -import com.anytypeio.anytype.presentation.relations.ObjectSetConfig -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.test_utils.utils.TestUtils @@ -66,10 +64,9 @@ class ModifyTagFilterTest { @Mock lateinit var repo: BlockRepository + @Mock lateinit var gateway: Gateway - @Mock - lateinit var objectTypesProvider: ObjectTypesProvider @Mock lateinit var analytics: Analytics @@ -81,7 +78,7 @@ class ModifyTagFilterTest { private val root = MockDataFactory.randomUuid() private val session = ObjectSetSession() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val dispatcher = Dispatcher.Default() private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() @@ -103,7 +100,7 @@ class ModifyTagFilterTest { workspaceManager.setCurrentWorkspace(workspaceId) } TestModifyFilterFromSelectedValueFragment.testVmFactory = FilterViewModel.Factory( - objectSetState = state, + objectState = state, session = session, updateDataViewViewer = updateDataViewViewer, dispatcher = dispatcher, @@ -144,11 +141,6 @@ class ModifyTagFilterTest { color = MockDataFactory.randomString() ) - val record: Map = mapOf( - ObjectSetConfig.ID_KEY to target, - relationKey to emptyList() - ) - // Defining viewer containing one filter val viewer = Block.Content.DataView.Viewer( @@ -171,37 +163,18 @@ class ModifyTagFilterTest { type = Block.Content.DataView.Viewer.Type.values().random() ) - val relation = Relation( - key = relationKey, - defaultValue = null, - isHidden = false, - isReadOnly = false, - isMulti = true, - name = MockDataFactory.randomString(), - source = Relation.Source.values().random(), - format = Relation.Format.TAG, - selections = listOf(option1, option2, option3) - ) - - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), - ) + ) ) - ), -// viewerDb = mapOf( -// viewer.id to ObjectSet.ViewerData( -// records = listOf(record), -// total = 1 -// ) -// ) + ) ) // Launching fragment diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/sort/ViewerObjectSortTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/sort/ViewerObjectSortTest.kt index f3182118e6..786204cfca 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/sort/ViewerObjectSortTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/sort/ViewerObjectSortTest.kt @@ -18,9 +18,9 @@ import com.anytypeio.anytype.core_models.Relation import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer import com.anytypeio.anytype.domain.objects.StoreOfRelations -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.sort.ViewerSortViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.test_utils.MockDataFactory import com.anytypeio.anytype.test_utils.utils.TestUtils.withRecyclerView @@ -58,7 +58,7 @@ class ViewerObjectSortTest { private val root = MockDataFactory.randomUuid() private val session = ObjectSetSession() - private val state = MutableStateFlow(ObjectSet.init()) + private val state: MutableStateFlow = MutableStateFlow(ObjectState.Init) private val dispatcher = Dispatcher.Default() @Before @@ -117,17 +117,16 @@ class ViewerObjectSortTest { selections = emptyList() ) - state.value = ObjectSet( + state.value = ObjectState.DataView.Set( blocks = listOf( Block( id = MockDataFactory.randomUuid(), children = emptyList(), fields = Block.Fields.empty(), content = Block.Content.DataView( - relations = listOf(relation), viewers = listOf(viewer), - ) + ) ) ) ) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 88c5610e5b..c42e93db24 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -5,6 +5,11 @@ + + + + , - objectSetState: StateFlow, + state: MutableStateFlow, objectSetSession: ObjectSetSession, paginator: ObjectSetPaginator, analytics: Analytics @@ -50,7 +51,7 @@ object EditDataViewViewerModule { duplicateDataViewViewer = duplicateDataViewViewer, updateDataViewViewer = updateDataViewViewer, dispatcher = dispatcher, - objectSetState = objectSetState, + objectState = state, objectSetSession = objectSetSession, paginator = paginator, analytics = analytics diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/EditorDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/EditorDI.kt index b9af8e372c..6f310c9564 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/EditorDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/EditorDI.kt @@ -54,6 +54,7 @@ import com.anytypeio.anytype.domain.icon.SetDocumentImageIcon import com.anytypeio.anytype.domain.launch.GetDefaultPageType import com.anytypeio.anytype.domain.misc.UrlBuilder import com.anytypeio.anytype.domain.`object`.ConvertObjectToSet +import com.anytypeio.anytype.domain.`object`.ConvertObjectToCollection import com.anytypeio.anytype.domain.`object`.DuplicateObject import com.anytypeio.anytype.domain.`object`.UpdateDetail import com.anytypeio.anytype.domain.objects.SetObjectIsArchived @@ -259,7 +260,8 @@ object EditorSessionModule { featureToggles: FeatureToggles, tableDelegate: EditorTableDelegate, workspaceManager: WorkspaceManager, - getObjectTypes: GetObjectTypes + getObjectTypes: GetObjectTypes, + objectToCollection: ConvertObjectToCollection ): EditorViewModelFactory = EditorViewModelFactory( openPage = openPage, closeObject = closePage, @@ -294,9 +296,12 @@ object EditorSessionModule { featureToggles = featureToggles, tableDelegate = tableDelegate, workspaceManager = workspaceManager, - getObjectTypes = getObjectTypes + getObjectTypes = getObjectTypes, + objectToCollection = objectToCollection ) + + @JvmStatic @Provides @PerScreen @@ -857,6 +862,17 @@ object EditorUseCaseModule { repo = repo ) + @JvmStatic + @Provides + @PerScreen + fun provideConvertObjectToCollection( + repo: BlockRepository, + dispatchers: AppCoroutineDispatchers + ): ConvertObjectToCollection = ConvertObjectToCollection( + repo = repo, + dispatchers = dispatchers + ) + @JvmStatic @Provides @PerScreen diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ManageViewerDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ManageViewerDI.kt index 5fa576b18f..e34f6516a0 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ManageViewerDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/ManageViewerDI.kt @@ -4,14 +4,14 @@ import com.anytypeio.anytype.analytics.base.Analytics import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.core_utils.di.scope.PerModal import com.anytypeio.anytype.presentation.sets.ManageViewerViewModel -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetSession +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.sets.modals.ManageViewerFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [ManageViewerModule::class]) @PerModal @@ -31,12 +31,12 @@ object ManageViewerModule { @Provides @PerModal fun provideManageViewerViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, dispatcher: Dispatcher, analytics: Analytics ): ManageViewerViewModel.Factory = ManageViewerViewModel.Factory( - state = state, + objectState = state, session = session, dispatcher = dispatcher, analytics = analytics diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ModifyViewerSort.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ModifyViewerSort.kt index 55ada255c6..b8c4f92163 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ModifyViewerSort.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/ModifyViewerSort.kt @@ -5,15 +5,15 @@ import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.core_utils.di.scope.PerModal import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer import com.anytypeio.anytype.domain.objects.StoreOfRelations -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.sort.ModifyViewerSortViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.sets.modals.sort.ModifyViewerSortFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [ModifyViewerSortModule::class]) @PerModal @@ -33,7 +33,7 @@ object ModifyViewerSortModule { @Provides @PerModal fun provideViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, dispatcher: Dispatcher, updateDataViewViewer: UpdateDataViewViewer, diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectMenuDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectMenuDI.kt index b6a126ed46..00aad399fb 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectMenuDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectMenuDI.kt @@ -20,10 +20,11 @@ import com.anytypeio.anytype.domain.page.OpenPage import com.anytypeio.anytype.presentation.common.Action import com.anytypeio.anytype.presentation.common.Delegator import com.anytypeio.anytype.presentation.editor.Editor +import com.anytypeio.anytype.presentation.objects.menu.ObjectMenuOptionsProvider import com.anytypeio.anytype.presentation.objects.menu.ObjectMenuOptionsProviderImpl import com.anytypeio.anytype.presentation.objects.menu.ObjectMenuViewModel import com.anytypeio.anytype.presentation.objects.menu.ObjectSetMenuViewModel -import com.anytypeio.anytype.presentation.sets.ObjectSet +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.presentation.util.downloader.DebugTreeShareDownloader import com.anytypeio.anytype.ui.editor.sheets.ObjectMenuFragment @@ -31,7 +32,10 @@ import com.anytypeio.anytype.ui.sets.ObjectSetMenuFragment import dagger.Module import dagger.Provides import dagger.Subcomponent +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.map @@ -147,7 +151,7 @@ object ObjectSetMenuModule { delegator: Delegator, urlBuilder: UrlBuilder, analytics: Analytics, - state: StateFlow, + state: MutableStateFlow, featureToggles: FeatureToggles, dispatcher: Dispatcher ): ObjectSetMenuViewModel.Factory = ObjectSetMenuViewModel.Factory( @@ -159,7 +163,7 @@ object ObjectSetMenuModule { urlBuilder = urlBuilder, delegator = delegator, analytics = analytics, - state = state, + objectState = state, dispatcher = dispatcher, menuOptionsProvider = createMenuOptionsProvider(state, featureToggles) ) @@ -186,12 +190,20 @@ object ObjectSetMenuModule { @JvmStatic private fun createMenuOptionsProvider( - state: StateFlow, + state: StateFlow, featureToggles: FeatureToggles - ) = - ObjectMenuOptionsProviderImpl( - details = state.map { it.details }, - restrictions = state.map { it.objectRestrictions }, - featureToggles = featureToggles - ) + ): ObjectMenuOptionsProvider { + return when (val currentState = state.value) { + is ObjectState.DataView -> ObjectMenuOptionsProviderImpl( + details = state.map { currentState.details }.distinctUntilChanged(), + restrictions = state.map { currentState.objectRestrictions }.distinctUntilChanged(), + featureToggles = featureToggles + ) + else -> ObjectMenuOptionsProviderImpl( + details = emptyFlow(), + restrictions = emptyFlow(), + featureToggles = featureToggles + ) + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetDI.kt index 3a4c94cf74..d39816487a 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetDI.kt @@ -19,9 +19,9 @@ import com.anytypeio.anytype.domain.auth.repo.AuthRepository import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.interactor.UpdateText import com.anytypeio.anytype.domain.block.repo.BlockRepository +import com.anytypeio.anytype.domain.collections.AddObjectToCollection import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.cover.SetDocCoverImage -import com.anytypeio.anytype.domain.dataview.SetDataViewQuery import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewObject import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer import com.anytypeio.anytype.domain.event.interactor.EventChannel @@ -29,6 +29,7 @@ import com.anytypeio.anytype.domain.event.interactor.InterceptEvents import com.anytypeio.anytype.domain.icon.SetDocumentImageIcon import com.anytypeio.anytype.domain.launch.GetDefaultPageType import com.anytypeio.anytype.domain.misc.UrlBuilder +import com.anytypeio.anytype.domain.`object`.ConvertObjectToCollection import com.anytypeio.anytype.domain.objects.DefaultObjectStore import com.anytypeio.anytype.domain.objects.ObjectStore import com.anytypeio.anytype.domain.objects.SetObjectIsArchived @@ -43,6 +44,7 @@ import com.anytypeio.anytype.domain.search.DataViewSubscriptionContainer import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.domain.search.SubscriptionEventChannel import com.anytypeio.anytype.domain.sets.OpenObjectSet +import com.anytypeio.anytype.domain.sets.SetQueryToObjectSet import com.anytypeio.anytype.domain.status.InterceptThreadStatus import com.anytypeio.anytype.domain.status.ThreadStatusChannel import com.anytypeio.anytype.domain.templates.GetTemplates @@ -57,12 +59,15 @@ import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValu import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.ObjectValueProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.ObjectSetPaginator -import com.anytypeio.anytype.presentation.sets.ObjectSetReducer import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory +import com.anytypeio.anytype.presentation.sets.state.DefaultObjectStateReducer +import com.anytypeio.anytype.presentation.sets.state.ObjectState +import com.anytypeio.anytype.presentation.sets.state.ObjectStateReducer +import com.anytypeio.anytype.presentation.sets.subscription.DataViewSubscription +import com.anytypeio.anytype.presentation.sets.subscription.DefaultDataViewSubscription import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.providers.DefaultCoverImageHashProvider import com.anytypeio.anytype.ui.sets.ObjectSetFragment @@ -71,8 +76,8 @@ import dagger.Module import dagger.Provides import dagger.Subcomponent import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.flow.StateFlow import javax.inject.Named +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [ObjectSetModule::class]) @PerScreen @@ -125,6 +130,15 @@ object ObjectSetModule { repo: BlockRepository ): SetDocumentImageIcon = SetDocumentImageIcon(repo) + @JvmStatic + @Provides + @PerScreen + fun provideDataViewSubscription( + dataViewSubscriptionContainer: DataViewSubscriptionContainer + ): DataViewSubscription = DefaultDataViewSubscription( + dataViewSubscriptionContainer + ) + @JvmStatic @Provides @PerScreen @@ -137,7 +151,6 @@ object ObjectSetModule { interceptThreadStatus: InterceptThreadStatus, createDataViewObject: CreateDataViewObject, createObject: CreateObject, - reducer: ObjectSetReducer, dispatcher: Dispatcher, delegator: Delegator, urlBuilder: UrlBuilder, @@ -148,10 +161,16 @@ object ObjectSetModule { setDocCoverImage: SetDocCoverImage, dataViewSubscriptionContainer: DataViewSubscriptionContainer, cancelSearchSubscription: CancelSearchSubscription, - setDataViewQuery: SetDataViewQuery, + setQueryToObjectSet: SetQueryToObjectSet, database: ObjectSetDatabase, paginator: ObjectSetPaginator, - storeOfRelations: StoreOfRelations + storeOfRelations: StoreOfRelations, + objectStateReducer: ObjectStateReducer, + dataViewSubscription: DataViewSubscription, + workspaceManager: WorkspaceManager, + @Named("object-set-store") objectStore: ObjectStore, + addObjectToCollection: AddObjectToCollection, + convertObjectToCollection: ConvertObjectToCollection ): ObjectSetViewModelFactory = ObjectSetViewModelFactory( openObjectSet = openObjectSet, closeBlock = closeBlock, @@ -160,7 +179,6 @@ object ObjectSetModule { updateText = updateText, interceptEvents = interceptEvents, interceptThreadStatus = interceptThreadStatus, - reducer = reducer, dispatcher = dispatcher, delegator = delegator, coverImageHashProvider = coverImageHashProvider, @@ -172,10 +190,27 @@ object ObjectSetModule { createObject = createObject, dataViewSubscriptionContainer = dataViewSubscriptionContainer, cancelSearchSubscription = cancelSearchSubscription, - setDataViewQuery = setDataViewQuery, + setQueryToObjectSet = setQueryToObjectSet, database = database, paginator = paginator, - storeOfRelations = storeOfRelations + storeOfRelations = storeOfRelations, + objectStateReducer = objectStateReducer, + dataViewSubscription = dataViewSubscription, + workspaceManager = workspaceManager, + objectStore = objectStore, + addObjectToCollection = addObjectToCollection, + objectToCollection = convertObjectToCollection + ) + + @JvmStatic + @Provides + @PerScreen + fun provideConvertObjectToCollection( + repo: BlockRepository, + dispatchers: AppCoroutineDispatchers + ): ConvertObjectToCollection = ConvertObjectToCollection( + repo = repo, + dispatchers = dispatchers ) @JvmStatic @@ -196,9 +231,10 @@ object ObjectSetModule { @JvmStatic @Provides @PerScreen - fun provideSetDataViewSource( - repo: BlockRepository - ): SetDataViewQuery = SetDataViewQuery(repo) + fun provideSetQueryToSet( + repo: BlockRepository, + dispatchers: AppCoroutineDispatchers + ): SetQueryToObjectSet = SetQueryToObjectSet(repo, dispatchers) @JvmStatic @PerScreen @@ -282,14 +318,12 @@ object ObjectSetModule { @JvmStatic @Provides @PerScreen - fun provideObjectSetReducer(): ObjectSetReducer = ObjectSetReducer() + fun provideState(reducer: ObjectStateReducer): MutableStateFlow = reducer.state @JvmStatic @Provides @PerScreen - fun provideState( - reducer: ObjectSetReducer - ): StateFlow = reducer.state + fun provideObjectStateReducer(): ObjectStateReducer = DefaultObjectStateReducer() @JvmStatic @Provides @@ -310,10 +344,10 @@ object ObjectSetModule { @Provides @PerScreen fun provideDataViewObjectRelationProvider( - state: StateFlow, + state: MutableStateFlow, storeOfRelations: StoreOfRelations ): ObjectRelationProvider = DataViewObjectRelationProvider( - objectSetState = state, + objectState = state, storeOfRelations = storeOfRelations ) @@ -330,9 +364,14 @@ object ObjectSetModule { @Provides @PerScreen fun provideObjectDetailProvider( - state: StateFlow, + objectState: MutableStateFlow, ): ObjectDetailProvider = object : ObjectDetailProvider { - override fun provide(): Map = state.value.details + override fun provide(): Map { + return when (val state = objectState.value) { + is ObjectState.DataView -> state.details + else -> emptyMap() + } + } } @JvmStatic @@ -457,6 +496,17 @@ object ObjectSetModule { repo = repo ) + @JvmStatic + @Provides + @PerScreen + fun provideAddObjectToCollection( + repo: BlockRepository, + dispatchers: AppCoroutineDispatchers + ): AddObjectToCollection = AddObjectToCollection( + repo = repo, + dispatchers = dispatchers + ) + @Module interface Bindings { diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetSettingsDi.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetSettingsDi.kt index 41d9ea45ce..8bb5fec0c7 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetSettingsDi.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetSettingsDi.kt @@ -7,14 +7,14 @@ import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.relations.DeleteRelationFromDataView import com.anytypeio.anytype.presentation.relations.ObjectSetSettingsViewModel -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetSession +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.sets.modals.ObjectSetSettingsFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [ObjectSetSettingsModule::class]) @PerModal @@ -35,7 +35,7 @@ object ObjectSetSettingsModule { @Provides @PerModal fun provideViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, dispatcher: Dispatcher, updateDataViewViewer: UpdateDataViewViewer, @@ -43,7 +43,7 @@ object ObjectSetSettingsModule { analytics: Analytics, deleteRelationFromDataView: DeleteRelationFromDataView, ): ObjectSetSettingsViewModel.Factory = ObjectSetSettingsViewModel.Factory( - state = state, + objectState = state, session = session, dispatcher = dispatcher, updateDataViewViewer = updateDataViewViewer, diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/SelectSortRelationDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/SelectSortRelationDI.kt index 85895a1af4..394b86110e 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/SelectSortRelationDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/SelectSortRelationDI.kt @@ -5,15 +5,15 @@ import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.core_utils.di.scope.PerModal import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer import com.anytypeio.anytype.domain.objects.StoreOfRelations -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.SelectSortRelationViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.sets.modals.sort.SelectSortRelationFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [SelectSortRelationModule::class]) @PerModal @@ -33,14 +33,14 @@ object SelectSortRelationModule { @Provides @PerModal fun provideSelectSortRelationViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, dispatcher: Dispatcher, updateDataViewViewer: UpdateDataViewViewer, storeOfRelations: StoreOfRelations, analytics: Analytics ): SelectSortRelationViewModel.Factory = SelectSortRelationViewModel.Factory( - state = state, + objectState = state, session = session, dispatcher = dispatcher, updateDataViewViewer = updateDataViewViewer, diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ViewerFilter.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ViewerFilter.kt index 1facef1d81..5ffc78d2f2 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ViewerFilter.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/ViewerFilter.kt @@ -5,17 +5,17 @@ import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer import com.anytypeio.anytype.domain.misc.UrlBuilder import com.anytypeio.anytype.domain.objects.StoreOfRelations -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.filter.ViewerFilterViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.sets.ViewerFilterFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow import javax.inject.Scope +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [ViewerFilterModule::class]) @ViewerFilterByScope @@ -36,7 +36,7 @@ object ViewerFilterModule { @Provides @ViewerFilterByScope fun provideViewerFilterViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, dispatcher: Dispatcher, updateDataViewViewer: UpdateDataViewViewer, diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ViewerSort.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ViewerSort.kt index e721e304e6..b634e77257 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ViewerSort.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/ViewerSort.kt @@ -5,15 +5,15 @@ import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.core_utils.di.scope.PerModal import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer import com.anytypeio.anytype.domain.objects.StoreOfRelations -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.sort.ViewerSortViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.sets.modals.sort.ViewerSortFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [ViewerSortModule::class]) @PerModal @@ -33,7 +33,7 @@ object ViewerSortModule { @Provides @PerModal fun provideViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, updateDataViewViewer: UpdateDataViewViewer, dispatcher: Dispatcher, diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationAddDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationAddDI.kt index 98543e97ce..c3a34c49b3 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationAddDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationAddDI.kt @@ -15,8 +15,8 @@ import com.anytypeio.anytype.domain.workspace.WorkspaceManager import com.anytypeio.anytype.presentation.relations.RelationAddToDataViewViewModel import com.anytypeio.anytype.presentation.relations.RelationAddToObjectViewModel import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetSession +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.relations.RelationAddToDataViewFragment import com.anytypeio.anytype.ui.relations.RelationAddToObjectBlockFragment @@ -24,8 +24,7 @@ import com.anytypeio.anytype.ui.relations.RelationAddToObjectFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [RelationAddToObjectModule::class]) @PerDialog @@ -107,7 +106,7 @@ object RelationAddToDataViewModule { fun provideViewModelFactory( addRelationToDataView: AddRelationToDataView, dispatcher: Dispatcher, - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, updateDataViewViewer: UpdateDataViewViewer, analytics: Analytics, diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromScratchDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromScratchDI.kt index 1ccc55ed2a..2a9399e93e 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromScratchDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromScratchDI.kt @@ -16,8 +16,8 @@ import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchFor import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForObjectViewModel import com.anytypeio.anytype.presentation.relations.model.CreateFromScratchState import com.anytypeio.anytype.presentation.relations.model.StateHolder -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetSession +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.relations.RelationCreateFromScratchForDataViewFragment import com.anytypeio.anytype.ui.relations.RelationCreateFromScratchForObjectBlockFragment @@ -26,7 +26,7 @@ import com.anytypeio.anytype.ui.relations.RelationCreateFromScratchFormatPickerF import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [RelationCreateFromScratchForObjectModule::class]) @CreateFromScratch @@ -107,7 +107,7 @@ object RelationCreateFromScratchForDataViewModule { @Provides @CreateFromScratch fun provideViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, updateDataViewViewer: UpdateDataViewViewer, dispatcher: Dispatcher, @@ -118,7 +118,7 @@ object RelationCreateFromScratchForDataViewModule { ) = RelationCreateFromScratchForDataViewViewModel.Factory( addRelationToDataView = addRelationToDataView, dispatcher = dispatcher, - state = state, + objectState = state, session = session, updateDataViewViewer = updateDataViewViewer, analytics = analytics, diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/CreateFilter.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/CreateFilter.kt index 7201e296c5..39c98d5055 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/CreateFilter.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/CreateFilter.kt @@ -10,17 +10,17 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.domain.workspace.WorkspaceManager -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.sets.modals.filter.CreateFilterFromInputFieldValueFragment import com.anytypeio.anytype.ui.sets.modals.filter.CreateFilterFromSelectedValueFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [CreateFilterModule::class]) @PerModal @@ -43,7 +43,7 @@ object CreateFilterModule { @Provides @PerModal fun provideViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, dispatcher: Dispatcher, updateDataViewViewer: UpdateDataViewViewer, @@ -56,7 +56,7 @@ object CreateFilterModule { getOptions: GetOptions, workspaceManager: WorkspaceManager ): FilterViewModel.Factory = FilterViewModel.Factory( - objectSetState = state, + objectState = state, session = session, dispatcher = dispatcher, updateDataViewViewer = updateDataViewViewer, diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/ModifyFilter.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/ModifyFilter.kt index d58ea927da..5bfc3c82a7 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/ModifyFilter.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/ModifyFilter.kt @@ -10,17 +10,17 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.domain.workspace.WorkspaceManager -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.sets.modals.filter.ModifyFilterFromInputFieldValueFragment import com.anytypeio.anytype.ui.sets.modals.filter.ModifyFilterFromSelectedValueFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [ModifyFilterModule::class]) @PerModal @@ -43,7 +43,7 @@ object ModifyFilterModule { @Provides @PerModal fun provideViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, dispatcher: Dispatcher, updateDataViewViewer: UpdateDataViewViewer, @@ -56,7 +56,7 @@ object ModifyFilterModule { storeOfRelations: StoreOfRelations, workspaceManager: WorkspaceManager ): FilterViewModel.Factory = FilterViewModel.Factory( - objectSetState = state, + objectState = state, session = session, dispatcher = dispatcher, updateDataViewViewer = updateDataViewViewer, diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/SelectFilterRelationDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/SelectFilterRelationDI.kt index 8c5bc161d1..940e544e46 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/SelectFilterRelationDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/SelectFilterRelationDI.kt @@ -2,14 +2,14 @@ package com.anytypeio.anytype.di.feature.sets import com.anytypeio.anytype.core_utils.di.scope.PerModal import com.anytypeio.anytype.domain.objects.StoreOfRelations -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetSession import com.anytypeio.anytype.presentation.sets.SelectFilterRelationViewModel +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.ui.sets.modals.filter.SelectFilterRelationFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [SelectFilterRelationModule::class]) @PerModal @@ -29,11 +29,11 @@ object SelectFilterRelationModule { @Provides @PerModal fun provideSelectSortRelationViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, storeOfRelations: StoreOfRelations ): SelectFilterRelationViewModel.Factory = SelectFilterRelationViewModel.Factory( - state = state, + objectState = state, session = session, storeOfRelations = storeOfRelations ) diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/viewer/ViewerCardSizeSelectDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/viewer/ViewerCardSizeSelectDI.kt index 49541d29dd..95ae5e99ba 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/viewer/ViewerCardSizeSelectDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/viewer/ViewerCardSizeSelectDI.kt @@ -3,15 +3,15 @@ package com.anytypeio.anytype.di.feature.sets.viewer import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.core_utils.di.scope.PerModal import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer -import com.anytypeio.anytype.presentation.sets.ObjectSet import com.anytypeio.anytype.presentation.sets.ObjectSetSession +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.sets.viewer.ViewerCardSizeSelectViewModel import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.sets.modals.viewer.ViewerCardSizeSelectFragment import dagger.Module import dagger.Provides import dagger.Subcomponent -import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.MutableStateFlow @Subcomponent(modules = [ViewerCardSizeSelectModule::class]) @PerModal @@ -32,12 +32,12 @@ object ViewerCardSizeSelectModule { @Provides @PerModal fun provideViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, dispatcher: Dispatcher, updateDataViewViewer: UpdateDataViewViewer ): ViewerCardSizeSelectViewModel.Factory = ViewerCardSizeSelectViewModel.Factory( - objectSetState = state, + objectState = state, session = session, dispatcher = dispatcher, updateDataViewViewer = updateDataViewViewer diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/viewer/ViewerImagePreviewSelectDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/viewer/ViewerImagePreviewSelectDI.kt index 9e06958265..7e305bbf8c 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/viewer/ViewerImagePreviewSelectDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/viewer/ViewerImagePreviewSelectDI.kt @@ -3,14 +3,16 @@ package com.anytypeio.anytype.di.feature.sets.viewer import com.anytypeio.anytype.core_models.Payload import com.anytypeio.anytype.core_utils.di.scope.PerModal import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer -import com.anytypeio.anytype.presentation.sets.ObjectSet +import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.presentation.sets.ObjectSetSession +import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.sets.viewer.ViewerImagePreviewSelectViewModel import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.ui.sets.modals.viewer.ViewerImagePreviewSelectFragment import dagger.Module import dagger.Provides import dagger.Subcomponent +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow @Subcomponent(modules = [ViewerImagePreviewSelectModule::class]) @@ -32,14 +34,16 @@ object ViewerImagePreviewSelectModule { @Provides @PerModal fun provideViewModelFactory( - state: StateFlow, + state: MutableStateFlow, session: ObjectSetSession, dispatcher: Dispatcher, - updateDataViewViewer: UpdateDataViewViewer + updateDataViewViewer: UpdateDataViewViewer, + storeOfRelations: StoreOfRelations ): ViewerImagePreviewSelectViewModel.Factory = ViewerImagePreviewSelectViewModel.Factory( - objectSetState = state, + objectState = state, session = session, dispatcher = dispatcher, - updateDataViewViewer = updateDataViewViewer + updateDataViewViewer = updateDataViewViewer, + storeOfRelations = storeOfRelations ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/main/LocalNetworkAddressModule.kt b/app/src/main/java/com/anytypeio/anytype/di/main/LocalNetworkAddressModule.kt deleted file mode 100644 index fa4f6d6ebc..0000000000 --- a/app/src/main/java/com/anytypeio/anytype/di/main/LocalNetworkAddressModule.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.anytypeio.anytype.di.main - -import com.anytypeio.anytype.middleware.interactor.LocalNetworkAddressHandler -import dagger.Module -import dagger.Provides -import javax.inject.Singleton - -@Module -class LocalNetworkAddressModule { - - @Singleton - @Provides - fun provideHandler(): LocalNetworkAddressHandler = LocalNetworkAddressHandler() -} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/main/LocalNetworkProviderModule.kt b/app/src/main/java/com/anytypeio/anytype/di/main/LocalNetworkProviderModule.kt new file mode 100644 index 0000000000..55b41f8fac --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/di/main/LocalNetworkProviderModule.kt @@ -0,0 +1,80 @@ +package com.anytypeio.anytype.di.main + +import android.content.Context +import android.net.nsd.NsdManager +import android.net.wifi.WifiManager +import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers +import com.anytypeio.anytype.middleware.discovery.MDNSDelegate +import com.anytypeio.anytype.middleware.discovery.MDNSResolver +import com.anytypeio.anytype.middleware.discovery.NsdDiscoveryListener +import com.anytypeio.anytype.middleware.discovery.NsdRegistrationListener +import com.anytypeio.anytype.middleware.discovery.adresshandler.DefaultInterfaceProvider +import com.anytypeio.anytype.middleware.discovery.adresshandler.LocalNetworkAddressProvider +import dagger.Binds +import dagger.Module +import dagger.Provides +import javax.inject.Singleton +import kotlinx.coroutines.GlobalScope +import service.InterfaceGetter + +@Module(includes = [LocalNetworkProviderModule.Bindings::class]) +class LocalNetworkProviderModule { + + @Singleton + @Provides + fun provideHandler( + dispatchers: AppCoroutineDispatchers, + interfaceGetter: InterfaceGetter, + ): LocalNetworkAddressProvider = + LocalNetworkAddressProvider(GlobalScope, dispatchers.io, interfaceGetter) + + @Singleton + @Provides + fun provideMDNSDelegate( + dispatchers: AppCoroutineDispatchers, + resolver: MDNSResolver + ): MDNSDelegate = MDNSDelegate(GlobalScope, dispatchers.io, resolver) + + @Singleton + @Provides + fun provideNsdDiscoveryListener( + nsdManager: NsdManager, + dispatchers: AppCoroutineDispatchers, + ): NsdDiscoveryListener = NsdDiscoveryListener(GlobalScope, dispatchers.io, nsdManager) + + @Singleton + @Provides + fun provideNsdManager( + context: Context + ): NsdManager = (context.getSystemService(Context.NSD_SERVICE) as NsdManager) + + @Singleton + @Provides + fun provideWifiManager( + context: Context + ): WifiManager = (context.getSystemService(Context.WIFI_SERVICE) as WifiManager) + + @Singleton + @Provides + fun provideMDNSResolver( + nsdManager: NsdManager, + wifiManager: WifiManager, + discoveryListener: NsdDiscoveryListener, + registrationListener: NsdRegistrationListener + ): MDNSResolver = MDNSResolver( + nsdManager, + wifiManager, + discoveryListener, + registrationListener + ) + + @Module + interface Bindings { + + @Singleton + @Binds + fun bindInterfaceGetter( + provider: DefaultInterfaceProvider + ): InterfaceGetter + } +} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt b/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt index 2e265ccabd..9678fbc8c1 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt @@ -57,7 +57,7 @@ import javax.inject.Singleton EmojiModule::class, ClipboardModule::class, AnalyticsModule::class, - LocalNetworkAddressModule::class, + LocalNetworkProviderModule::class, SubscriptionsModule::class ] ) diff --git a/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt b/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt index dcc24dc81c..4602f4715b 100644 --- a/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt +++ b/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt @@ -225,7 +225,7 @@ class Navigator : AppNavigation { R.id.dataViewNavigation, bundleOf(ObjectSetFragment.CONTEXT_ID_KEY to target), navOptions { - popUpTo(R.id.objectNavigation) { inclusive = true } + popUpTo(R.id.main_navigation) { inclusive = true } } ) } else { diff --git a/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt index 59e357da5b..87f41a804d 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt @@ -2086,11 +2086,11 @@ open class EditorFragment : NavigationFragment(R.layout.f } override fun onProceedWithUpdateType(id: Id) { - vm.onObjectTypeChanged(type = id, isObjectDraft = false) + vm.onObjectTypeChanged(type = id, applyTemplate = false) } override fun onProceedWithDraftUpdateType(id: Id) { - vm.onObjectTypeChanged(type = id, isObjectDraft = true) + vm.onObjectTypeChanged(type = id, applyTemplate = true) } private fun observeNavBackStack() { diff --git a/app/src/main/java/com/anytypeio/anytype/ui/main/MainActivity.kt b/app/src/main/java/com/anytypeio/anytype/ui/main/MainActivity.kt index 5e99f03cac..ff1d72722f 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/main/MainActivity.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/main/MainActivity.kt @@ -22,6 +22,7 @@ import com.anytypeio.anytype.core_utils.ext.toast import com.anytypeio.anytype.di.common.componentManager import com.anytypeio.anytype.domain.base.BaseUseCase import com.anytypeio.anytype.domain.theme.GetTheme +import com.anytypeio.anytype.middleware.discovery.MDNSProvider import com.anytypeio.anytype.navigation.Navigator import com.anytypeio.anytype.presentation.editor.cover.CoverGradient import com.anytypeio.anytype.presentation.main.MainViewModel @@ -31,10 +32,10 @@ import com.anytypeio.anytype.presentation.navigation.AppNavigation import com.anytypeio.anytype.presentation.wallpaper.WallpaperColor import com.anytypeio.anytype.ui.editor.CreateObjectFragment import com.anytypeio.anytype.ui_settings.appearance.ThemeApplicator +import javax.inject.Inject import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import timber.log.Timber -import javax.inject.Inject class MainActivity : AppCompatActivity(R.layout.activity_main), AppNavigation.Provider { @@ -54,6 +55,9 @@ class MainActivity : AppCompatActivity(R.layout.activity_main), AppNavigation.Pr @Inject lateinit var themeApplicator: ThemeApplicator + @Inject + lateinit var mdnsProvider: MDNSProvider + val container: FragmentContainerView get() = findViewById(R.id.fragment) override fun onCreate(savedInstanceState: Bundle?) { @@ -159,16 +163,19 @@ class MainActivity : AppCompatActivity(R.layout.activity_main), AppNavigation.Pr override fun onResume() { super.onResume() + mdnsProvider.start() navigator.bind(findNavController(R.id.fragment)) } override fun onPause() { super.onPause() + mdnsProvider.stop() navigator.unbind() } override fun onDestroy() { super.onDestroy() + mdnsProvider.stop() release() } diff --git a/app/src/main/java/com/anytypeio/anytype/ui/navigation/PageNavigationFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/navigation/PageNavigationFragment.kt index 2328eefa3d..03071a713d 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/navigation/PageNavigationFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/navigation/PageNavigationFragment.kt @@ -28,6 +28,7 @@ import com.google.android.material.tabs.TabLayoutMediator import timber.log.Timber import javax.inject.Inject +@Deprecated("Legacy screen, is not used") class PageNavigationFragment : ViewStateFragment, FragmentPageNavigationBinding>(R.layout.fragment_page_navigation) { diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/AppDefaultObjectTypeFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/AppDefaultObjectTypeFragment.kt index 8b08fbc996..6298c37d86 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/AppDefaultObjectTypeFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/AppDefaultObjectTypeFragment.kt @@ -15,7 +15,7 @@ class AppDefaultObjectTypeFragment : BaseObjectTypeChangeFragment() { override fun startWithParams() { vm.onStart( - isWithSet = false, + isWithCollection = false, isWithBookmark = false, isSetSource = false ) diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DataViewSelectSourceFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DataViewSelectSourceFragment.kt index 095c254bf4..9d753342df 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DataViewSelectSourceFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DataViewSelectSourceFragment.kt @@ -15,7 +15,7 @@ class DataViewSelectSourceFragment : BaseObjectTypeChangeFragment() { override fun startWithParams() { vm.onStart( - isWithSet = true, + isWithCollection = true, isWithBookmark = true, excludeTypes = emptyList(), selectedTypes = selectedTypes, diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DraftObjectSelectTypeFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DraftObjectSelectTypeFragment.kt index 2a4fa3069e..16ad05d720 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DraftObjectSelectTypeFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DraftObjectSelectTypeFragment.kt @@ -15,7 +15,7 @@ class DraftObjectSelectTypeFragment : BaseObjectTypeChangeFragment() { override fun startWithParams() { vm.onStart( - isWithSet = true, + isWithCollection = true, isWithBookmark = false, excludeTypes = excludeTypes, selectedTypes = emptyList(), diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/EmptyDataViewSelectSourceFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/EmptyDataViewSelectSourceFragment.kt index aca2c7c909..51a0282783 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/EmptyDataViewSelectSourceFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/EmptyDataViewSelectSourceFragment.kt @@ -14,7 +14,7 @@ class EmptyDataViewSelectSourceFragment : BaseObjectTypeChangeFragment() { override fun startWithParams() { vm.onStart( - isWithSet = false, + isWithCollection = false, isWithBookmark = true, excludeTypes = emptyList(), selectedTypes = emptyList(), diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/ObjectSelectTypeFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/ObjectSelectTypeFragment.kt index 00caab64bf..c601720a24 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/ObjectSelectTypeFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/ObjectSelectTypeFragment.kt @@ -15,7 +15,7 @@ class ObjectSelectTypeFragment : BaseObjectTypeChangeFragment() { override fun startWithParams() { vm.onStart( - isWithSet = false, + isWithCollection = false, isWithBookmark = false, excludeTypes = excludeTypes, selectedTypes = emptyList(), diff --git a/app/src/main/java/com/anytypeio/anytype/ui/sets/ObjectSetFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/sets/ObjectSetFragment.kt index cda0df5457..f5433cc396 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/sets/ObjectSetFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/sets/ObjectSetFragment.kt @@ -13,11 +13,14 @@ import android.view.ViewGroup import android.view.animation.AccelerateDecelerateInterpolator import android.view.inputmethod.EditorInfo.IME_ACTION_DONE import android.view.inputmethod.EditorInfo.IME_ACTION_GO +import android.widget.Button import android.widget.FrameLayout import android.widget.ImageView +import android.widget.LinearLayout import android.widget.TextView import androidx.activity.addCallback import androidx.constraintlayout.motion.widget.MotionLayout +import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.os.bundleOf import androidx.core.view.WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_STOP import androidx.core.view.children @@ -44,6 +47,7 @@ import com.anytypeio.anytype.core_ui.tools.DefaultTextWatcher import com.anytypeio.anytype.core_ui.widgets.FeaturedRelationGroupWidget import com.anytypeio.anytype.core_ui.widgets.StatusBadgeWidget import com.anytypeio.anytype.core_ui.widgets.text.TextInputWidget +import com.anytypeio.anytype.core_ui.widgets.toolbar.DataViewInfo import com.anytypeio.anytype.core_utils.OnSwipeListener import com.anytypeio.anytype.core_utils.ext.argString import com.anytypeio.anytype.core_utils.ext.dimen @@ -64,6 +68,7 @@ import com.anytypeio.anytype.di.common.componentManager import com.anytypeio.anytype.presentation.editor.cover.CoverColor import com.anytypeio.anytype.presentation.editor.cover.CoverGradient import com.anytypeio.anytype.presentation.editor.editor.model.BlockView +import com.anytypeio.anytype.presentation.sets.DataViewViewState import com.anytypeio.anytype.presentation.sets.ObjectSetCommand import com.anytypeio.anytype.presentation.sets.ObjectSetViewModel import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory @@ -104,6 +109,9 @@ open class ObjectSetFragment : private val title: TextInputWidget get() = binding.objectHeader.root.findViewById(R.id.tvSetTitle) + private val header: LinearLayout + get() = binding.objectHeader.root + private val topToolbarTitle: TextView get() = binding.topToolbar.root.findViewById(R.id.tvTopToolbarTitle) @@ -120,13 +128,13 @@ open class ObjectSetFragment : get() = binding.topToolbar.root.findViewById(R.id.tvStatus) private val addNewButton: TextView - get() = binding.dataViewHeader.root.findViewById(R.id.addNewButton) + get() = binding.dataViewHeader.addNewButton private val customizeViewButton: ImageView - get() = binding.dataViewHeader.root.findViewById(R.id.customizeViewButton) + get() = binding.dataViewHeader.customizeViewButton private val tvCurrentViewerName: TextView - get() = binding.dataViewHeader.root.findViewById(R.id.tvCurrentViewerName) + get() = binding.dataViewHeader.tvCurrentViewerName private val menuButton: FrameLayout get() = binding.topToolbar.root.findViewById(R.id.threeDotsButton) @@ -134,6 +142,14 @@ open class ObjectSetFragment : private val featuredRelations: FeaturedRelationGroupWidget get() = binding.objectHeader.root.findViewById(R.id.featuredRelationsWidget) + private val dataViewHeader: ConstraintLayout + get() = binding.dataViewHeader.root + + private val viewerTitle: TextView + get() = binding.dataViewHeader.root.findViewById(R.id.tvCurrentViewerName) + + private val initView: View get() = binding.initState.root + private val dataViewInfo: DataViewInfo get() = binding.dataViewInfo private val rvHeaders: RecyclerView get() = binding.root.findViewById(R.id.rvHeader) private val rvRows: RecyclerView get() = binding.root.findViewById(R.id.rvRows) @@ -189,6 +205,14 @@ open class ObjectSetFragment : with(lifecycleScope) { subscribe(addNewButton.clicks().throttleFirst()) { vm.onCreateNewDataViewObject() } + subscribe(dataViewInfo.clicks().throttleFirst()) { type -> + when (type) { + DataViewInfo.TYPE.COLLECTION_NO_ITEMS -> vm.onCreateObjectInCollectionClicked() + DataViewInfo.TYPE.SET_NO_QUERY -> vm.onSelectQueryButtonClicked() + DataViewInfo.TYPE.SET_NO_ITEMS -> vm.onCreateNewDataViewObject() + DataViewInfo.TYPE.INIT -> {} + } + } subscribe(title.editorActionEvents(actionHandler)) { title.apply { hideKeyboard() @@ -264,11 +288,11 @@ open class ObjectSetFragment : ) setFragmentResultListener(BaseObjectTypeChangeFragment.OBJECT_TYPE_REQUEST_KEY) { _, bundle -> - val source = bundle.getString(BaseObjectTypeChangeFragment.OBJECT_TYPE_URL_KEY) - if (source != null) { - vm.onDataViewQueryPicked(source = source) + val query = bundle.getString(BaseObjectTypeChangeFragment.OBJECT_TYPE_URL_KEY) + if (query != null) { + vm.onObjectSetQueryPicked(query = query) } else { - toast("Error while setting Set source. Source is empty") + toast("Error while setting the Set query. The query is empty") } } } @@ -340,7 +364,7 @@ open class ObjectSetFragment : override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) vm.navigation.observe(viewLifecycleOwner, navObserver) - lifecycleScope.subscribe(vm.toasts.stream()) { toast(it) } + lifecycleScope.subscribe(vm.toasts) { toast(it) } lifecycleScope.subscribe(vm.status) { setStatus(it) } lifecycleScope.subscribe(vm.isCustomizeViewPanelVisible) { isCustomizeViewPanelVisible -> if (isCustomizeViewPanelVisible) showBottomPanel() else hideBottomPanel() @@ -359,13 +383,106 @@ open class ObjectSetFragment : } } - private fun setupViewer(viewer: Viewer?) { - binding.dataViewHeader.root.findViewById(R.id.tvCurrentViewerName).text = - viewer?.title + private fun setupDataViewViewState(state: DataViewViewState) { + when (state) { + DataViewViewState.Collection.NoView, DataViewViewState.Set.NoView -> { + topToolbarThreeDotsButton.visible() + topToolbarStatusContainer.visible() + initView.gone() + dataViewHeader.gone() + dataViewInfo.hide() + toast(getString(R.string.set_collection_view_not_present)) + setViewer(viewer = null) + } + is DataViewViewState.Collection.NoItems -> { + topToolbarThreeDotsButton.visible() + topToolbarStatusContainer.visible() + initView.gone() + header.visible() + dataViewHeader.visible() + viewerTitle.isEnabled = true + addNewButton.isEnabled = true + customizeViewButton.isEnabled = true + viewerTitle.text = state.title + dataViewInfo.show(DataViewInfo.TYPE.COLLECTION_NO_ITEMS) + setViewer(viewer = null) + } + is DataViewViewState.Collection.Default -> { + topToolbarThreeDotsButton.visible() + topToolbarStatusContainer.visible() + initView.gone() + dataViewHeader.visible() + viewerTitle.isEnabled = true + addNewButton.isEnabled = true + customizeViewButton.isEnabled = true + viewerTitle.text = state.viewer?.title ?: getString(R.string.viewer_default_title) + dataViewInfo.hide() + setViewer(viewer = state.viewer) + } + DataViewViewState.Set.NoQuery -> { + topToolbarThreeDotsButton.visible() + topToolbarStatusContainer.visible() + initView.gone() + header.visible() + dataViewHeader.visible() + viewerTitle.isEnabled = false + addNewButton.isEnabled = false + customizeViewButton.isEnabled = false + viewerTitle.text = getString(R.string.viewer_default_title) + dataViewInfo.show(type = DataViewInfo.TYPE.SET_NO_QUERY) + setViewer(viewer = null) + } + is DataViewViewState.Set.NoItems -> { + topToolbarThreeDotsButton.visible() + topToolbarStatusContainer.visible() + initView.gone() + header.visible() + dataViewHeader.visible() + viewerTitle.isEnabled = true + addNewButton.isEnabled = true + customizeViewButton.isEnabled = true + viewerTitle.text = state.title + dataViewInfo.show(type = DataViewInfo.TYPE.SET_NO_ITEMS, extra = state.type) + setViewer(viewer = null) + + } + is DataViewViewState.Set.Default -> { + topToolbarThreeDotsButton.visible() + topToolbarStatusContainer.visible() + initView.gone() + header.visible() + viewerTitle.isEnabled = true + addNewButton.isEnabled = true + customizeViewButton.isEnabled = true + viewerTitle.text = state.viewer?.title ?: getString(R.string.viewer_default_title) + setViewer(viewer = state.viewer) + dataViewInfo.hide() + } + DataViewViewState.Init -> { + topToolbarThreeDotsButton.invisible() + topToolbarStatusContainer.invisible() + header.gone() + dataViewHeader.invisible() + initView.visible() + dataViewInfo.hide() + setViewer(viewer = null) + } + is DataViewViewState.Error -> { + topToolbarThreeDotsButton.visible() + topToolbarStatusContainer.visible() + initView.gone() + dataViewHeader.gone() + toast(state.msg) + dataViewInfo.hide() + setViewer(viewer = null) + } + } + } + + private fun setViewer(viewer: Viewer?) { when (viewer) { is Viewer.GridView -> { with(binding) { - dataViewHeader.root.visible() unsupportedViewError.gone() unsupportedViewError.text = null galleryView.clear() @@ -380,7 +497,6 @@ open class ObjectSetFragment : viewerGridHeaderAdapter.submitList(emptyList()) viewerGridAdapter.submitList(emptyList()) with(binding) { - dataViewHeader.root.visible() unsupportedViewError.gone() unsupportedViewError.text = null listView.gone() @@ -396,7 +512,6 @@ open class ObjectSetFragment : viewerGridHeaderAdapter.submitList(emptyList()) viewerGridAdapter.submitList(emptyList()) with(binding) { - dataViewHeader.root.visible() unsupportedViewError.gone() unsupportedViewError.text = null galleryView.gone() @@ -409,7 +524,6 @@ open class ObjectSetFragment : viewerGridHeaderAdapter.submitList(emptyList()) viewerGridAdapter.submitList(emptyList()) with(binding) { - dataViewHeader.root.visible() galleryView.gone() galleryView.clear() listView.gone() @@ -422,7 +536,6 @@ open class ObjectSetFragment : viewerGridHeaderAdapter.submitList(emptyList()) viewerGridAdapter.submitList(emptyList()) with(binding) { - dataViewHeader.root.invisible() galleryView.gone() galleryView.clear() listView.gone() @@ -784,7 +897,7 @@ open class ObjectSetFragment : super.onStart() jobs += lifecycleScope.subscribe(vm.commands) { observeCommands(it) } jobs += lifecycleScope.subscribe(vm.header.filterNotNull()) { bindHeader(it) } - jobs += lifecycleScope.subscribe(vm.currentViewer) { setupViewer(it) } + jobs += lifecycleScope.subscribe(vm.currentViewer) { setupDataViewViewState(it) } jobs += lifecycleScope.subscribe(vm.error) { err -> if (err.isNullOrEmpty()) binding.tvError.gone() @@ -801,20 +914,12 @@ open class ObjectSetFragment : binding.paginatorToolbar.gone() } } - jobs += lifecycleScope.subscribe(vm.isLoading) { isLoading -> - if (isLoading) { - binding.dvProgressBar.show() - } else { - binding.dvProgressBar.hide() - } - } jobs += lifecycleScope.subscribe(vm.featured) { featured -> if (featured != null) { featuredRelations.visible() featuredRelations.set( item = featured, - click = vm::onClickListener, - isObjectSet = true + click = vm::onClickListener ) } else { featuredRelations.clear() @@ -880,7 +985,7 @@ open class ObjectSetFragment : } override fun onProceedWithSelectSource(id: Id) { - vm.onDataViewQueryPicked(source = id) + vm.onObjectSetQueryPicked(query = id) } override fun injectDependencies() { diff --git a/app/src/main/java/com/anytypeio/anytype/ui/sets/modals/viewer/ViewerCardSizeSelectFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/sets/modals/viewer/ViewerCardSizeSelectFragment.kt index dd12fb52db..e46d61565d 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/sets/modals/viewer/ViewerCardSizeSelectFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/sets/modals/viewer/ViewerCardSizeSelectFragment.kt @@ -30,7 +30,7 @@ class ViewerCardSizeSelectFragment : BaseBottomSheetFragment + subscribe(vm.viewState) { state -> when (state) { ViewerCardSizeSelectViewModel.STATE_DISMISSED -> dismiss() ViewerCardSizeSelectViewModel.STATE_LARGE_CARD_SELECTED -> { diff --git a/app/src/main/res/drawable/ic_arrow_expand_dv_viewer.xml b/app/src/main/res/drawable/ic_arrow_expand_dv_viewer.xml deleted file mode 100644 index a167f52af2..0000000000 --- a/app/src/main/res/drawable/ic_arrow_expand_dv_viewer.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/layout/fragment_object_set.xml b/app/src/main/res/layout/fragment_object_set.xml index b52668fb4f..26f59cf2cf 100644 --- a/app/src/main/res/layout/fragment_object_set.xml +++ b/app/src/main/res/layout/fragment_object_set.xml @@ -8,17 +8,8 @@ android:background="@color/background_primary" android:focusable="true" android:focusableInTouchMode="true" - app:layoutDescription="@xml/fragment_object_set_scene"> - - + app:layoutDescription="@xml/fragment_object_set_scene" + tools:context="com.anytypeio.anytype.ui.sets.ObjectSetFragment"> @@ -138,4 +129,22 @@ app:layout_constraintStart_toStartOf="parent" tools:visibility="visible" /> + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_object_set_dv_header.xml b/app/src/main/res/layout/layout_object_set_dv_header.xml deleted file mode 100644 index 04cd3faab5..0000000000 --- a/app/src/main/res/layout/layout_object_set_dv_header.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/layout_object_set_header.xml b/app/src/main/res/layout/layout_object_set_header.xml index 6414d376ec..88c52f2c06 100644 --- a/app/src/main/res/layout/layout_object_set_header.xml +++ b/app/src/main/res/layout/layout_object_set_header.xml @@ -86,7 +86,7 @@ Name for new relation New Plus button - Customize-view button Image icon Emoji icon Sort by @@ -219,6 +218,7 @@ Do the computation of an expensive paragraph of text on a background thread: Inbox Unknown type Set + Collection Layout Restore from archive Icon diff --git a/app/src/main/res/xml/fragment_object_set_scene.xml b/app/src/main/res/xml/fragment_object_set_scene.xml index da30b9981a..ffdd8dd019 100644 --- a/app/src/main/res/xml/fragment_object_set_scene.xml +++ b/app/src/main/res/xml/fragment_object_set_scene.xml @@ -14,19 +14,18 @@ + motion:layout_constraintTop_toTopOf="parent" + motion:visibilityMode="ignore"> + + + motion:layout_constraintStart_toStartOf="parent" + motion:visibilityMode="ignore"> + motion:visibilityMode="ignore" /> + motion:visibilityMode="ignore" /> + + \ No newline at end of file diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt index 52bde961d7..2319022209 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt @@ -285,10 +285,8 @@ data class Block( data class DataView( val viewers: List, - @Deprecated("To be deleted") - val relations: List, - val relationsIndex: List = emptyList(), - val targetObjectId: Id = "", + val relationLinks: List = emptyList(), + val targetObjectId: Id = "" ) : Content() { data class Viewer( diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt index 91df089d53..763b97102f 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt @@ -418,4 +418,7 @@ sealed class Command { data class UpdateRelation(val ctx: Id, val dv: Id, val view: Id, val relation: DVViewerRelation) data class DeleteRelation(val ctx: Id, val dv: Id, val view: Id, val keys: List) data class SortRelations(val ctx: Id, val dv: Id, val view: Id, val keys: List) + + data class AddObjectToCollection(val ctx: Id, val afterId: Id, val ids: List) + data class SetQueryToSet(val ctx: Id, val query: String) } \ No newline at end of file diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectType.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectType.kt index 797ff617c9..f790f3c9d9 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectType.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectType.kt @@ -45,6 +45,7 @@ data class ObjectType( SPACE(10), BOOKMARK(11), DATABASE(20), + COLLECTION(14) } /** diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt index 17b1090c8e..fe07633895 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt @@ -13,6 +13,7 @@ object ObjectTypeIds { const val VIDEO = "ot-video" const val AUDIO = "ot-audio" const val SET = "ot-set" + const val COLLECTION = "ot-collection" const val TASK = "ot-task" const val DATE = "ot-date" const val PROFILE = "ot-profile" //contains User Profile page and Anytype Person page diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/SmartBlockType.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/SmartBlockType.kt index 2b8dfb74c1..f349fa7f75 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/SmartBlockType.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/SmartBlockType.kt @@ -9,6 +9,7 @@ enum class SmartBlockType(val code: Int) { ARCHIVE(code = 48), DATABASE(code = 64), SET(code = 65), + COLLECTION(code = 66), CUSTOM_OBJECT_TYPE(code = 96), FILE(code = 256), TEMPLATE(code = 288), diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockViewDiffUtil.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockViewDiffUtil.kt index 331de6c27a..8b99247a7c 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockViewDiffUtil.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/BlockViewDiffUtil.kt @@ -5,7 +5,7 @@ import com.anytypeio.anytype.presentation.editor.editor.Markup import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.editor.editor.model.BlockView.Indentable import com.anytypeio.anytype.presentation.editor.editor.model.Focusable -import com.anytypeio.anytype.presentation.relations.DocumentRelationView +import com.anytypeio.anytype.presentation.relations.ObjectRelationView import timber.log.Timber class BlockViewDiffUtil( @@ -198,33 +198,33 @@ class BlockViewDiffUtil( } when { - newRelationView is DocumentRelationView.Default && oldRelationView is DocumentRelationView.Default -> { + newRelationView is ObjectRelationView.Default && oldRelationView is ObjectRelationView.Default -> { if (newBlock.view.value != oldBlock.view.value) { changes.add(RELATION_VALUE_CHANGED) } } - newRelationView is DocumentRelationView.Checkbox && oldRelationView is DocumentRelationView.Checkbox -> { + newRelationView is ObjectRelationView.Checkbox && oldRelationView is ObjectRelationView.Checkbox -> { if (newRelationView.isChecked != oldRelationView.isChecked) { changes.add(RELATION_VALUE_CHANGED) } } - newRelationView is DocumentRelationView.Status && oldRelationView is DocumentRelationView.Status -> { + newRelationView is ObjectRelationView.Status && oldRelationView is ObjectRelationView.Status -> { if (newRelationView.status != oldRelationView.status) { changes.add(RELATION_VALUE_CHANGED) } } - newRelationView is DocumentRelationView.Tags && oldRelationView is DocumentRelationView.Tags -> { + newRelationView is ObjectRelationView.Tags && oldRelationView is ObjectRelationView.Tags -> { if (newRelationView.tags != oldRelationView.tags) { changes.add(RELATION_VALUE_CHANGED) } } - newRelationView is DocumentRelationView.Object && oldRelationView is DocumentRelationView.Object -> { + newRelationView is ObjectRelationView.Object && oldRelationView is ObjectRelationView.Object -> { if (newRelationView.objects != oldRelationView.objects) { changes.add(RELATION_VALUE_CHANGED) } } - newRelationView is DocumentRelationView.File && oldRelationView is DocumentRelationView.File -> { + newRelationView is ObjectRelationView.File && oldRelationView is ObjectRelationView.File -> { if (newRelationView.files != oldRelationView.files) { changes.add(RELATION_VALUE_CHANGED) } diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/relations/ListRelationViewHolder.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/relations/ListRelationViewHolder.kt index 5940ecf62f..85258e0e7d 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/relations/ListRelationViewHolder.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/relations/ListRelationViewHolder.kt @@ -18,7 +18,7 @@ import com.anytypeio.anytype.core_ui.widgets.text.TagWidget import com.anytypeio.anytype.core_utils.ext.gone import com.anytypeio.anytype.core_utils.ext.visible import com.anytypeio.anytype.core_models.ThemeColor -import com.anytypeio.anytype.presentation.relations.DocumentRelationView +import com.anytypeio.anytype.presentation.relations.ObjectRelationView import com.anytypeio.anytype.presentation.sets.model.ObjectView sealed class ListRelationViewHolder( @@ -32,11 +32,11 @@ sealed class ListRelationViewHolder( private val tvValue = binding.content.tvRelationValue private val systemIcon = binding.icSystem - fun bind(item: DocumentRelationView) { + fun bind(item: ObjectRelationView) { tvTitle.text = item.name tvValue.apply { text = item.value - if (item is DocumentRelationView.Default) { + if (item is ObjectRelationView.Default) { when (item.format) { Relation.Format.SHORT_TEXT -> setHint(R.string.enter_text) Relation.Format.LONG_TEXT -> setHint(R.string.enter_text) @@ -49,7 +49,7 @@ sealed class ListRelationViewHolder( } } } - setSystemIcon(systemIcon, item.isSystem) + setSystemIcon(systemIcon, item.system) } } @@ -60,10 +60,10 @@ sealed class ListRelationViewHolder( private val ivCheckbox = binding.content.ivRelationCheckbox private val systemIcon = binding.icSystem - fun bind(item: DocumentRelationView.Checkbox) = with(itemView) { + fun bind(item: ObjectRelationView.Checkbox) = with(itemView) { tvTitle.text = item.name ivCheckbox.isSelected = item.isChecked - setSystemIcon(systemIcon, item.isSystem) + setSystemIcon(systemIcon, item.system) } } @@ -74,7 +74,7 @@ sealed class ListRelationViewHolder( private val tvValue = binding.content.tvRelationValue private val systemIcon = binding.icSystem - fun bind(item: DocumentRelationView.Status) { + fun bind(item: ObjectRelationView.Status) { tvTitle.text = item.name tvValue.apply { if (item.status.isNotEmpty()) { @@ -91,7 +91,7 @@ sealed class ListRelationViewHolder( text = null } } - setSystemIcon(systemIcon, item.isSystem) + setSystemIcon(systemIcon, item.system) } } @@ -102,14 +102,14 @@ sealed class ListRelationViewHolder( private val tvTitle = binding.content.tvRelationTitle private val systemIcon = binding.icSystem - fun bind(item: DocumentRelationView.Tags) = with(itemView) { + fun bind(item: ObjectRelationView.Tags) = with(itemView) { tvTitle.text = item.name if (item.tags.isEmpty()) { placeholder.visible() } else { placeholder.gone() } - setSystemIcon(systemIcon, item.isSystem) + setSystemIcon(systemIcon, item.system) for (i in 0..MAX_VISIBLE_TAGS_INDEX) getViewByIndex(i)?.gone() item.tags.forEachIndexed { index, tagView -> when (index) { @@ -144,14 +144,14 @@ sealed class ListRelationViewHolder( private val content = binding.content private val systemIcon = binding.icSystem - fun bind(item: DocumentRelationView.Object) { + fun bind(item: ObjectRelationView.Object) { content.tvRelationTitle.text = item.name if (item.objects.isEmpty()) { placeholder.visible() } else { placeholder.gone() } - setSystemIcon(systemIcon, item.isSystem) + setSystemIcon(systemIcon, item.system) for (i in 0..MAX_VISIBLE_OBJECTS_INDEX) getViewByIndex(i)?.gone() item.objects.forEachIndexed { index, objectView -> when (index) { @@ -191,14 +191,14 @@ sealed class ListRelationViewHolder( private val tvTitle = binding.content.tvRelationTitle private val systemIcon = binding.icSystem - fun bind(item: DocumentRelationView.File) = with(itemView) { + fun bind(item: ObjectRelationView.File) = with(itemView) { tvTitle.text = item.name if (item.files.isEmpty()) { placeholder.visible() } else { placeholder.gone() } - setSystemIcon(systemIcon, item.isSystem) + setSystemIcon(systemIcon, item.system) item.files.forEachIndexed { index, fileView -> when (index) { in 0..MAX_VISIBLE_FILES_INDEX -> { diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/relations/RelationBlockViewHolder.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/relations/RelationBlockViewHolder.kt index 8ff4390793..722ce32a54 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/relations/RelationBlockViewHolder.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/holders/relations/RelationBlockViewHolder.kt @@ -34,7 +34,7 @@ import com.anytypeio.anytype.core_ui.extensions.clearDrawable import com.anytypeio.anytype.core_ui.extensions.setDrawable import com.anytypeio.anytype.core_ui.features.editor.BlockViewDiffUtil import com.anytypeio.anytype.presentation.editor.editor.model.BlockView -import com.anytypeio.anytype.presentation.relations.DocumentRelationView +import com.anytypeio.anytype.presentation.relations.ObjectRelationView import com.anytypeio.anytype.presentation.sets.model.ObjectView sealed class RelationBlockViewHolder( @@ -121,7 +121,7 @@ sealed class RelationBlockViewHolder( applyRelationValue(block.view) } if (payload.relationNameChanged()) { - applyRelationName(block.view.name, block.view.isReadOnly) + applyRelationName(block.view.name, block.view.readOnly) } } } @@ -131,7 +131,7 @@ sealed class RelationBlockViewHolder( relationName.setReadOnly(isReadOnly) } - abstract fun applyRelationValue(item: DocumentRelationView) + abstract fun applyRelationValue(item: ObjectRelationView) init { applyDefaultOffsets(itemView) @@ -161,7 +161,7 @@ sealed class RelationBlockViewHolder( super.applyContentDecorations(itemView, decorations) } - override fun applyRelationValue(item: DocumentRelationView) {} + override fun applyRelationValue(item: ObjectRelationView) {} } class Default(binding: ItemBlockRelationDefaultBinding) : @@ -174,8 +174,8 @@ sealed class RelationBlockViewHolder( override val relationName: TextView = tvTitle override val decoratableContainer: EditorDecorationContainer = binding.decorationContainer - fun bind(item: DocumentRelationView) { - applyRelationName(item.name, item.isReadOnly) + fun bind(item: ObjectRelationView) { + applyRelationName(item.name, item.readOnly) applyRelationValue(item) } @@ -187,10 +187,10 @@ sealed class RelationBlockViewHolder( super.applyContentDecorations(itemView, decorations) } - override fun applyRelationValue(item: DocumentRelationView) { + override fun applyRelationValue(item: ObjectRelationView) { tvValue.apply { text = item.value - if (item is DocumentRelationView.Default) { + if (item is ObjectRelationView.Default) { when (item.format) { Relation.Format.SHORT_TEXT -> setHint(R.string.enter_text) Relation.Format.LONG_TEXT -> setHint(R.string.enter_text) @@ -215,8 +215,8 @@ sealed class RelationBlockViewHolder( override val selected = binding.selected override val relationName: TextView = tvTitle - fun bind(item: DocumentRelationView) { - applyRelationName(item.name, item.isReadOnly) + fun bind(item: ObjectRelationView) { + applyRelationName(item.name, item.readOnly) applyRelationValue(item) } @@ -230,8 +230,8 @@ sealed class RelationBlockViewHolder( super.applyContentDecorations(itemView, decorations) } - override fun applyRelationValue(item: DocumentRelationView) { - if (item is DocumentRelationView.Checkbox) { + override fun applyRelationValue(item: ObjectRelationView) { + if (item is ObjectRelationView.Checkbox) { tvCheckbox.isSelected = item.isChecked } } @@ -247,8 +247,8 @@ sealed class RelationBlockViewHolder( val c = binding.content - fun bind(item: DocumentRelationView) { - applyRelationName(item.name, item.isReadOnly) + fun bind(item: ObjectRelationView) { + applyRelationName(item.name, item.readOnly) applyRelationValue(item) } @@ -262,8 +262,8 @@ sealed class RelationBlockViewHolder( super.applyContentDecorations(itemView, decorations) } - override fun applyRelationValue(item: DocumentRelationView) { - if (item is DocumentRelationView.Status) { + override fun applyRelationValue(item: ObjectRelationView) { + if (item is ObjectRelationView.Status) { tvValue.apply { if (item.status.isNotEmpty()) { val status = item.status.first() @@ -292,13 +292,13 @@ sealed class RelationBlockViewHolder( override val selected = binding.selected override val relationName: TextView = tvTitle - fun bind(item: DocumentRelationView) { - applyRelationName(item.name, item.isReadOnly) + fun bind(item: ObjectRelationView) { + applyRelationName(item.name, item.readOnly) applyRelationValue(item) } - override fun applyRelationValue(item: DocumentRelationView) { - if (item is DocumentRelationView.Tags) { + override fun applyRelationValue(item: ObjectRelationView) { + if (item is ObjectRelationView.Tags) { if (item.tags.isEmpty()) { placeholder.visible() } else { @@ -349,13 +349,13 @@ sealed class RelationBlockViewHolder( override val selected = binding.selected override val relationName: TextView = tvTitle - fun bind(item: DocumentRelationView) { - applyRelationName(item.name, item.isReadOnly) + fun bind(item: ObjectRelationView) { + applyRelationName(item.name, item.readOnly) applyRelationValue(item) } - override fun applyRelationValue(item: DocumentRelationView) { - if (item is DocumentRelationView.Object) { + override fun applyRelationValue(item: ObjectRelationView) { + if (item is ObjectRelationView.Object) { if (item.objects.isEmpty()) { placeholder.visible() } else { @@ -412,13 +412,13 @@ sealed class RelationBlockViewHolder( override val selected = binding.selected override val relationName: TextView = tvTitle - fun bind(item: DocumentRelationView) { - applyRelationName(item.name, item.isReadOnly) + fun bind(item: ObjectRelationView) { + applyRelationName(item.name, item.readOnly) applyRelationValue(item) } - override fun applyRelationValue(item: DocumentRelationView) { - if (item is DocumentRelationView.File) { + override fun applyRelationValue(item: ObjectRelationView) { + if (item is ObjectRelationView.File) { if (item.files.isEmpty()) { placeholder.visible() } else { @@ -467,7 +467,7 @@ sealed class RelationBlockViewHolder( override val relationName: TextView = binding.tvTitle - override fun applyRelationValue(item: DocumentRelationView) {} + override fun applyRelationValue(item: ObjectRelationView) {} fun bind(item: BlockView.Relation.Deleted) { indentize(item) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/slash/SlashRelationsAdapter.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/slash/SlashRelationsAdapter.kt index f85e002d8e..796868f726 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/slash/SlashRelationsAdapter.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/editor/slash/SlashRelationsAdapter.kt @@ -22,7 +22,7 @@ import com.anytypeio.anytype.core_utils.diff.DefaultDiffUtil import com.anytypeio.anytype.core_utils.ext.visible import com.anytypeio.anytype.presentation.editor.editor.slash.SlashItem import com.anytypeio.anytype.presentation.editor.editor.slash.SlashRelationView -import com.anytypeio.anytype.presentation.relations.DocumentRelationView +import com.anytypeio.anytype.presentation.relations.ObjectRelationView import timber.log.Timber class SlashRelationsAdapter( @@ -147,37 +147,37 @@ class SlashRelationsAdapter( is ListRelationViewHolder.Status -> { check(item is SlashRelationView.Item) val view = item.view - check(view is DocumentRelationView.Status) + check(view is ObjectRelationView.Status) holder.bind(view) } is ListRelationViewHolder.Checkbox -> { check(item is SlashRelationView.Item) val view = item.view - check(view is DocumentRelationView.Checkbox) + check(view is ObjectRelationView.Checkbox) holder.bind(view) } is ListRelationViewHolder.Tags -> { check(item is SlashRelationView.Item) val view = item.view - check(view is DocumentRelationView.Tags) + check(view is ObjectRelationView.Tags) holder.bind(view) } is ListRelationViewHolder.Object -> { check(item is SlashRelationView.Item) val view = item.view - check(view is DocumentRelationView.Object) + check(view is ObjectRelationView.Object) holder.bind(view) } is ListRelationViewHolder.File -> { check(item is SlashRelationView.Item) val view = item.view - check(view is DocumentRelationView.File) + check(view is ObjectRelationView.File) holder.bind(view) } is ListRelationViewHolder.Default -> { check(item is SlashRelationView.Item) val view = item.view - check(view is DocumentRelationView.Default) + check(view is ObjectRelationView.Default) holder.bind(view) } is RelationsSubheaderMenuHolder -> { @@ -195,11 +195,11 @@ class SlashRelationsAdapter( override fun getItemViewType(position: Int): Int = when (val item = items[position]) { is SlashRelationView.Item -> { when (item.view) { - is DocumentRelationView.Checkbox -> R.layout.item_relation_list_relation_checkbox - is DocumentRelationView.Object -> R.layout.item_relation_list_relation_object - is DocumentRelationView.Status -> R.layout.item_relation_list_relation_status - is DocumentRelationView.Tags -> R.layout.item_relation_list_relation_tag - is DocumentRelationView.File -> R.layout.item_relation_list_relation_file + is ObjectRelationView.Checkbox -> R.layout.item_relation_list_relation_checkbox + is ObjectRelationView.Object -> R.layout.item_relation_list_relation_object + is ObjectRelationView.Status -> R.layout.item_relation_list_relation_status + is ObjectRelationView.Tags -> R.layout.item_relation_list_relation_tag + is ObjectRelationView.File -> R.layout.item_relation_list_relation_file else -> R.layout.item_relation_list_relation_default } } diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/relations/DocumentRelationAdapter.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/relations/DocumentRelationAdapter.kt index 3b2d915bef..882aa812f7 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/relations/DocumentRelationAdapter.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/relations/DocumentRelationAdapter.kt @@ -16,7 +16,7 @@ import com.anytypeio.anytype.core_ui.databinding.ItemRelationListRelationTagBind import com.anytypeio.anytype.core_ui.features.editor.holders.relations.ListRelationViewHolder import com.anytypeio.anytype.core_utils.diff.DefaultDiffUtil import com.anytypeio.anytype.core_utils.ext.visible -import com.anytypeio.anytype.presentation.relations.DocumentRelationView +import com.anytypeio.anytype.presentation.relations.ObjectRelationView import com.anytypeio.anytype.presentation.relations.RelationListViewModel import timber.log.Timber @@ -191,37 +191,37 @@ class DocumentRelationAdapter( is ListRelationViewHolder.Status -> { check(item is RelationListViewModel.Model.Item) val view = item.view - check(view is DocumentRelationView.Status) + check(view is ObjectRelationView.Status) holder.bind(view) } is ListRelationViewHolder.Checkbox -> { check(item is RelationListViewModel.Model.Item) val view = item.view - check(view is DocumentRelationView.Checkbox) + check(view is ObjectRelationView.Checkbox) holder.bind(view) } is ListRelationViewHolder.Tags -> { check(item is RelationListViewModel.Model.Item) val view = item.view - check(view is DocumentRelationView.Tags) + check(view is ObjectRelationView.Tags) holder.bind(view) } is ListRelationViewHolder.Object -> { check(item is RelationListViewModel.Model.Item) val view = item.view - check(view is DocumentRelationView.Object) + check(view is ObjectRelationView.Object) holder.bind(view) } is ListRelationViewHolder.File -> { check(item is RelationListViewModel.Model.Item) val view = item.view - check(view is DocumentRelationView.File) + check(view is ObjectRelationView.File) holder.bind(view) } is ListRelationViewHolder.Default -> { check(item is RelationListViewModel.Model.Item) val view = item.view - check(view is DocumentRelationView.Default) + check(view is ObjectRelationView.Default) holder.bind(view) } is SectionViewHolder -> { @@ -234,7 +234,7 @@ class DocumentRelationAdapter( } if (holder is ListRelationViewHolder) { check(item is RelationListViewModel.Model.Item) - holder.setIsFeatured(item.view.isFeatured) + holder.setIsFeatured(item.view.featured) holder.setIsRemovable(item.isRemoveable) } } @@ -244,11 +244,11 @@ class DocumentRelationAdapter( override fun getItemViewType(position: Int): Int = when (val item = items[position]) { is RelationListViewModel.Model.Item -> { when (item.view) { - is DocumentRelationView.Checkbox -> R.layout.item_relation_list_relation_checkbox - is DocumentRelationView.Object -> R.layout.item_relation_list_relation_object - is DocumentRelationView.Status -> R.layout.item_relation_list_relation_status - is DocumentRelationView.Tags -> R.layout.item_relation_list_relation_tag - is DocumentRelationView.File -> R.layout.item_relation_list_relation_file + is ObjectRelationView.Checkbox -> R.layout.item_relation_list_relation_checkbox + is ObjectRelationView.Object -> R.layout.item_relation_list_relation_object + is ObjectRelationView.Status -> R.layout.item_relation_list_relation_status + is ObjectRelationView.Tags -> R.layout.item_relation_list_relation_tag + is ObjectRelationView.File -> R.layout.item_relation_list_relation_file else -> R.layout.item_relation_list_relation_default } } diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/menu/ObjectSetTypePopupMenu.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/menu/ObjectSetTypePopupMenu.kt new file mode 100644 index 0000000000..2c707737ba --- /dev/null +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/menu/ObjectSetTypePopupMenu.kt @@ -0,0 +1,26 @@ +package com.anytypeio.anytype.core_ui.menu + +import android.content.Context +import android.view.Gravity +import android.view.View +import android.widget.PopupMenu +import com.anytypeio.anytype.core_ui.R + +class ObjectSetTypePopupMenu( + context: Context, + view: View, + onChangeTypeClicked: () -> Unit, + onConvertToCollection: () -> Unit +) : PopupMenu(context, view, Gravity.BOTTOM, 0, R.style.DefaultPopupMenuStyle) { + init { + menuInflater.inflate(R.menu.menu_set_type, menu) + setOnMenuItemClickListener { item -> + when (item.itemId) { + R.id.turn_into -> onConvertToCollection() + R.id.change_query -> onChangeTypeClicked() + else -> throw IllegalStateException("Unexpected menu item: $item") + } + true + } + } +} \ No newline at end of file diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/menu/ObjectTypePopupMenu.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/menu/ObjectTypePopupMenu.kt index 6b2184541a..b3c8b3c658 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/menu/ObjectTypePopupMenu.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/menu/ObjectTypePopupMenu.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.core_ui.menu import android.content.Context +import android.view.Gravity import android.view.View import android.widget.PopupMenu import com.anytypeio.anytype.core_ui.R @@ -12,7 +13,7 @@ class ObjectTypePopupMenu( onOpenSetClicked: () -> Unit, allowChangingObjectType: Boolean = false, allowOnlyChangingType: Boolean = false -) : PopupMenu(context, view) { +) : PopupMenu(context, view, Gravity.BOTTOM, 0, R.style.DefaultPopupMenuStyle) { init { if (allowOnlyChangingType) { menuInflater.inflate(R.menu.menu_object_type_only, menu) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/DoсIconWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/DoсIconWidget.kt deleted file mode 100644 index f6d55fde6f..0000000000 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/DoсIconWidget.kt +++ /dev/null @@ -1,52 +0,0 @@ -package com.anytypeio.anytype.core_ui.widgets - -import android.content.Context -import android.util.AttributeSet -import android.view.ViewOutlineProvider -import androidx.appcompat.widget.AppCompatImageView -import com.anytypeio.anytype.core_ui.R -import com.anytypeio.anytype.emojifier.Emojifier -import com.bumptech.glide.Glide -import com.bumptech.glide.load.engine.DiskCacheStrategy -import timber.log.Timber -import kotlin.math.min - -class DocIconWidget @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : AppCompatImageView(context, attrs, defStyleAttr) { - - init { - outlineProvider = ViewOutlineProvider.BACKGROUND - clipToOutline = true - setBackgroundResource(R.drawable.rectangle_default_page_logo_background) - } - - /** - * Make sure width and height of image are same - */ - override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { - val width = MeasureSpec.getSize(widthMeasureSpec) - val height = MeasureSpec.getSize(heightMeasureSpec) - val minDimension = min(width, height) - setMeasuredDimension(minDimension, minDimension) - } - - fun setEmoji(unicode: String?) { - try { - if (unicode != null) { - Glide - .with(this) - .load(Emojifier.uri(unicode)) - .diskCacheStrategy(DiskCacheStrategy.ALL) - .centerInside() - .into(this) - } else { - setImageDrawable(null) - } - } catch (e: Exception) { - Timber.e(e, "Error while setting emoji with unicode: $unicode") - } - } -} \ No newline at end of file diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/FeaturedRelationGroupWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/FeaturedRelationGroupWidget.kt index cec4253f1d..2b07144e2e 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/FeaturedRelationGroupWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/FeaturedRelationGroupWidget.kt @@ -13,14 +13,17 @@ import com.anytypeio.anytype.core_models.ThemeColor import com.anytypeio.anytype.core_ui.R import com.anytypeio.anytype.core_ui.extensions.color import com.anytypeio.anytype.core_ui.extensions.dark +import com.anytypeio.anytype.core_ui.extensions.drawable import com.anytypeio.anytype.core_ui.extensions.light +import com.anytypeio.anytype.core_ui.menu.ObjectSetTypePopupMenu import com.anytypeio.anytype.core_ui.menu.ObjectTypePopupMenu import com.anytypeio.anytype.core_utils.ext.dimen +import com.anytypeio.anytype.core_utils.ext.px import com.anytypeio.anytype.core_utils.ext.setDrawableColor import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.objects.ObjectIcon -import com.anytypeio.anytype.presentation.relations.DocumentRelationView +import com.anytypeio.anytype.presentation.relations.ObjectRelationView import com.anytypeio.anytype.presentation.sets.model.ObjectView class FeaturedRelationGroupWidget : ConstraintLayout { @@ -33,14 +36,13 @@ class FeaturedRelationGroupWidget : ConstraintLayout { defStyleAttr: Int ) : super(context, attrs, defStyleAttr) - private val defaultTextSize: Float = context.dimen(R.dimen.sp_13) + private val defaultTextSize: Float = context.dimen(R.dimen.sp_15) private val dividerSize: Int = context.dimen(R.dimen.dp_4).toInt() private val defaultTextColor = resources.getColor(R.color.text_secondary, null) fun set( item: BlockView.FeaturedRelation, - click: (ListenerType.Relation) -> Unit, - isObjectSet: Boolean = false + click: (ListenerType.Relation) -> Unit ) { clear() @@ -60,7 +62,7 @@ class FeaturedRelationGroupWidget : ConstraintLayout { item.relations.forEachIndexed { index, relation -> when (relation) { - is DocumentRelationView.Default -> { + is ObjectRelationView.Default -> { val view = TextView(context).apply { id = generateViewId() text = relation.value ?: getPlaceholderHint(relation) @@ -77,7 +79,7 @@ class FeaturedRelationGroupWidget : ConstraintLayout { addView(view) ids.add(view.id) } - is DocumentRelationView.Checkbox -> { + is ObjectRelationView.Checkbox -> { val view = View(context).apply { id = generateViewId() val size = context.dimen(R.dimen.dp_16).toInt() @@ -89,7 +91,7 @@ class FeaturedRelationGroupWidget : ConstraintLayout { addView(view) ids.add(view.id) } - is DocumentRelationView.File -> { + is ObjectRelationView.File -> { relation.files.forEach { file -> val view = TextView(context).apply { id = generateViewId() @@ -113,7 +115,7 @@ class FeaturedRelationGroupWidget : ConstraintLayout { ids.add(placeholder.id) } } - is DocumentRelationView.Object -> { + is ObjectRelationView.Object -> { relation.objects.forEach { obj -> if (obj is ObjectView.Default) { val view = TextView(context).apply { @@ -152,7 +154,7 @@ class FeaturedRelationGroupWidget : ConstraintLayout { ids.add(placeholder.id) } } - is DocumentRelationView.Status -> { + is ObjectRelationView.Status -> { relation.status.forEach { status -> val color = ThemeColor.values().find { v -> v.code == status.color } val view = TextView(context).apply { @@ -181,7 +183,7 @@ class FeaturedRelationGroupWidget : ConstraintLayout { ids.add(placeholder.id) } } - is DocumentRelationView.Tags -> { + is ObjectRelationView.Tags -> { relation.tags.forEach { tag -> val color = ThemeColor.values().find { v -> v.code == tag.color } val defaultBackground = resources.getColor(R.color.shape_primary, null) @@ -219,39 +221,26 @@ class FeaturedRelationGroupWidget : ConstraintLayout { ids.add(placeholder.id) } } - is DocumentRelationView.ObjectType.Base -> { - val view = TextView(context).apply { - id = generateViewId() - if (relation.name.isEmpty()) { - hint = context.resources.getString(R.string.untitled) - } - text = relation.name - isSingleLine = true - maxLines = 1 - ellipsize = TextUtils.TruncateAt.END - setTextColor(defaultTextColor) - setTextSize(TypedValue.COMPLEX_UNIT_PX, defaultTextSize) - } + is ObjectRelationView.ObjectType.Base -> { + val view = inflateObjectTypeTextView(name = relation.name) view.setOnClickListener { - if (!isObjectSet) { - val popup = ObjectTypePopupMenu( - context = context, - view = it, - onChangeTypeClicked = { - click(ListenerType.Relation.ChangeObjectType(type = relation.relationId)) - }, - onOpenSetClicked = { - click(ListenerType.Relation.ObjectTypeOpenSet(type = relation.type)) - }, - allowChangingObjectType = item.allowChangingObjectType - ) - popup.show() - } + val popup = ObjectTypePopupMenu( + context = context, + view = it, + onChangeTypeClicked = { + click(ListenerType.Relation.ChangeObjectType(type = relation.id)) + }, + onOpenSetClicked = { + click(ListenerType.Relation.ObjectTypeOpenSet(type = relation.type)) + }, + allowChangingObjectType = item.allowChangingObjectType + ) + popup.show() } addView(view) ids.add(view.id) } - is DocumentRelationView.Source.Base -> { + is ObjectRelationView.Source.Base -> { if (relation.sources.isEmpty()) { inflateEmptySourcePlaceholderTextView( click = click, @@ -273,13 +262,13 @@ class FeaturedRelationGroupWidget : ConstraintLayout { } } } - is DocumentRelationView.Source.Deleted -> { + is ObjectRelationView.Source.Deleted -> { inflateDeletedSourceTextView( click = click, ids = ids ) } - is DocumentRelationView.ObjectType.Deleted -> { + is ObjectRelationView.ObjectType.Deleted -> { val view = TextView(context).apply { id = generateViewId() text = context.resources.getString(R.string.deleted_type) @@ -294,7 +283,7 @@ class FeaturedRelationGroupWidget : ConstraintLayout { context = context, view = it, onChangeTypeClicked = { - click(ListenerType.Relation.ChangeObjectType(type = relation.relationId)) + click(ListenerType.Relation.ChangeObjectType(type = relation.id)) }, onOpenSetClicked = {}, allowOnlyChangingType = true @@ -304,6 +293,31 @@ class FeaturedRelationGroupWidget : ConstraintLayout { addView(view) ids.add(view.id) } + is ObjectRelationView.ObjectType.Collection -> { + val view = inflateObjectTypeTextView(name = relation.name) + addView(view) + ids.add(view.id) + } + is ObjectRelationView.ObjectType.Set -> { + val view = inflateObjectTypeTextView(name = relation.name) + view.setOnClickListener { + val popup = ObjectSetTypePopupMenu( + context = context, + view = it, + onChangeTypeClicked = { + click(ListenerType.Relation.SetQuery(queries = emptyList())) + }, + onConvertToCollection = { + click(ListenerType.Relation.TurnIntoCollection) + } + ) + popup.setOnDismissListener { view.background = null } + view.background = context.drawable(R.drawable.bg_featured_relation) + popup.show() + } + addView(view) + ids.add(view.id) + } } if (index != item.relations.lastIndex) { @@ -320,6 +334,24 @@ class FeaturedRelationGroupWidget : ConstraintLayout { flow.referencedIds = ids.toIntArray() } + private fun inflateObjectTypeTextView(name: String): TextView { + val textView = TextView(context).apply { + id = View.generateViewId() + isSingleLine = true + maxLines = 1 + ellipsize = TextUtils.TruncateAt.END + setPadding(4.px, 2.px, 4.px, 2.px) + setTextColor(defaultTextColor) + setTextSize(TypedValue.COMPLEX_UNIT_PX, defaultTextSize) + } + if (name.isEmpty()) { + textView.hint = context.resources.getString(R.string.untitled) + } else { + textView.text = name + } + return textView + } + private fun inflateEmptySourcePlaceholderTextView( click: (ListenerType.Relation) -> Unit, ids: MutableList @@ -337,7 +369,7 @@ class FeaturedRelationGroupWidget : ConstraintLayout { } private fun inflateDefaultSourceTextView( - relation: DocumentRelationView.Source.Base, + relation: ObjectRelationView.Source.Base, click: (ListenerType.Relation) -> Unit, ids: MutableList ) { @@ -376,7 +408,7 @@ class FeaturedRelationGroupWidget : ConstraintLayout { } private fun inflateSourceByRelationTextView( - relation: DocumentRelationView.Source.Base, + relation: ObjectRelationView.Source.Base, click: (ListenerType.Relation) -> Unit, ids: MutableList ) { @@ -431,7 +463,7 @@ class FeaturedRelationGroupWidget : ConstraintLayout { ids.add(view.id) } - private fun getPlaceholderHint(relation: DocumentRelationView.Default): String { + private fun getPlaceholderHint(relation: ObjectRelationView.Default): String { return when (relation.format) { Relation.Format.SHORT_TEXT -> resources.getString(R.string.enter_text) Relation.Format.LONG_TEXT -> resources.getString(R.string.enter_text) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/toolbar/DataViewInfo.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/toolbar/DataViewInfo.kt new file mode 100644 index 0000000000..f9248e775d --- /dev/null +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/toolbar/DataViewInfo.kt @@ -0,0 +1,74 @@ +package com.anytypeio.anytype.core_ui.widgets.toolbar + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import com.anytypeio.anytype.core_ui.R +import com.anytypeio.anytype.core_ui.databinding.ViewDataviewInfoBinding +import com.anytypeio.anytype.core_ui.reactive.checkMainThread +import com.anytypeio.anytype.core_utils.ext.invisible +import com.anytypeio.anytype.core_utils.ext.visible +import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.callbackFlow +import kotlinx.coroutines.flow.conflate + +class DataViewInfo @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + + val binding = ViewDataviewInfoBinding.inflate(LayoutInflater.from(context), this, true) + private var type: TYPE = TYPE.INIT + + fun show(type: TYPE, extra: String = "") { + this.type = type + visible() + when (type) { + TYPE.INIT -> { + binding.title.text = null + binding.description.text = null + binding.button.text = "" + } + TYPE.COLLECTION_NO_ITEMS -> { + binding.title.text = resources.getString(R.string.collection_no_items_title) + binding.description.text = + resources.getString(R.string.collection_no_items_description) + binding.button.text = resources.getString(R.string.collection_no_items_button) + } + TYPE.SET_NO_QUERY -> { + binding.title.text = resources.getString(R.string.set_no_query_title) + binding.description.text = resources.getString(R.string.set_no_query_description) + binding.button.text = resources.getString(R.string.set_no_query_button) + } + TYPE.SET_NO_ITEMS -> { + binding.title.text = resources.getString(R.string.set_no_items_title) + binding.description.text = + resources.getString(R.string.set_no_items_description, extra) + binding.button.text = resources.getString(R.string.set_no_items_button) + } + } + } + + fun hide() { + invisible() + } + + fun clicks(): Flow = callbackFlow { + checkMainThread() + val listener = OnClickListener { + trySend(this@DataViewInfo.type) + } + binding.button.setOnClickListener(listener) + awaitClose { binding.button.setOnClickListener(null) } + }.conflate() + + enum class TYPE { + INIT, + COLLECTION_NO_ITEMS, + SET_NO_QUERY, + SET_NO_ITEMS + } +} \ No newline at end of file diff --git a/core-ui/src/main/res/color/ds_button_primary_text.xml b/core-ui/src/main/res/color/ds_button_primary_text.xml new file mode 100644 index 0000000000..7756f260cd --- /dev/null +++ b/core-ui/src/main/res/color/ds_button_primary_text.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/core-ui/src/main/res/color/selector_viewer_header.xml b/core-ui/src/main/res/color/selector_viewer_header.xml new file mode 100644 index 0000000000..cc4294d87e --- /dev/null +++ b/core-ui/src/main/res/color/selector_viewer_header.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core-ui/src/main/res/drawable/bg_featured_relation.xml b/core-ui/src/main/res/drawable/bg_featured_relation.xml new file mode 100644 index 0000000000..a864e103e9 --- /dev/null +++ b/core-ui/src/main/res/drawable/bg_featured_relation.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/core-ui/src/main/res/drawable/bg_menu_default.xml b/core-ui/src/main/res/drawable/bg_menu_default.xml new file mode 100644 index 0000000000..6e36a3bb32 --- /dev/null +++ b/core-ui/src/main/res/drawable/bg_menu_default.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/core-ui/src/main/res/drawable/bg_set_new_button.xml b/core-ui/src/main/res/drawable/bg_set_new_button.xml deleted file mode 100644 index 8a8c238dfd..0000000000 --- a/core-ui/src/main/res/drawable/bg_set_new_button.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/core-ui/src/main/res/drawable/bg_viewer_settings_icon_bg.xml b/core-ui/src/main/res/drawable/bg_viewer_settings_icon_bg.xml new file mode 100644 index 0000000000..8df86fafdc --- /dev/null +++ b/core-ui/src/main/res/drawable/bg_viewer_settings_icon_bg.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-ui/src/main/res/drawable/ds_button_primary_background_selector.xml b/core-ui/src/main/res/drawable/ds_button_primary_background_selector.xml new file mode 100644 index 0000000000..8d6394afb5 --- /dev/null +++ b/core-ui/src/main/res/drawable/ds_button_primary_background_selector.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-ui/src/main/res/drawable/ic_arrow_expand_dv_viewer.xml b/core-ui/src/main/res/drawable/ic_arrow_expand_dv_viewer.xml new file mode 100644 index 0000000000..9d51c79b23 --- /dev/null +++ b/core-ui/src/main/res/drawable/ic_arrow_expand_dv_viewer.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/core-ui/src/main/res/layout/collection_loading_state.xml b/core-ui/src/main/res/layout/collection_loading_state.xml new file mode 100644 index 0000000000..b03f75d561 --- /dev/null +++ b/core-ui/src/main/res/layout/collection_loading_state.xml @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-ui/src/main/res/layout/layout_object_set_dv_header.xml b/core-ui/src/main/res/layout/layout_object_set_dv_header.xml new file mode 100644 index 0000000000..241a2e11cf --- /dev/null +++ b/core-ui/src/main/res/layout/layout_object_set_dv_header.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/core-ui/src/main/res/layout/view_dataview_info.xml b/core-ui/src/main/res/layout/view_dataview_info.xml new file mode 100644 index 0000000000..6207e8531a --- /dev/null +++ b/core-ui/src/main/res/layout/view_dataview_info.xml @@ -0,0 +1,60 @@ + + + + + + + +