DROID-607 Relations & types and options | Refactoring | Everything-is-an-object refactoring (#2720)
* DROID-439 App | Relations refactoring, use SearchObjects for object types (#2592) * DROID-446 Objects | Enhancement | Store relation links and process its updates (#2597) * DROID-456 Tech | Remove deprecated API for creating object types (#2601) * DROID-455 Object types | Enhancement Get object type list from ObjectSearch on Global search screen (#2602) * DROID-459 Sets | Refactoring | Use relations links instead of relations for building search params to get data view data (#2603) * DROID-458 Objects | Refactoring | Integrate new api for creating objets (#2604) * DROID-464 Relations | Refactoring | New API for creating a relation from scratch - for data view or for an object (#2605) * DROID-467 Relations | Refactoring | New API for creating options - for tags and statuses (#2607) * DROID-470 Relations | Refactoring | New API for removing any relation from an object or from a data view (#2608) * DROID-460 Tech | Object relations list (#2610) * DROID-486 Sets | Refactoring | Displaying and controlling visibility of data view relations (#2611) * DROID-500 Relations | Refactoring | Extend API of ObjectStore to be able to get a relation by its id (#2619) * DROID-459 Sets | Fix | Get relations from store by id and not by key (#2618) * DROID-489 Tech | Relations as object, add relationKey to relation connected screens (#2622) * DROID-490 Sets | Refactoring | Displaying relation values for current object in bottom sheet cells (#2629) * DROID-505 Relations | Refactoring | New interface for relations store (#2633) * DROID-509 Relations | Refactoring | Bind new relations store with subscription container (#2635) * DROID-507 Tech | MW , migration + relation links (#2636) * DROID-507 Tech | MW , migration + relation links, fixes (#2637) * DROID-517 Sets | Fix | Provide correct keys for data view search-and-subscribe query (#2641) * DROID-409 Relations | Refactoring | Use relation key instead of id when creating new relation (#2642) * DROID-521 Sets & Objects | Refactoring | Add relation to a data view or to an object from existing relations (#2644) * DROID-522 Relations | Refactoring | Add objects to relations with object format (#2645) * DROID-523 Object types | Refactoring | Implement global store for object types (#2646) * DROID-527 Object types | Refactoring | Integrate global store for object types (#2647) * DROID-531 Relations | Refactoring | Parse tag and status relations values (#2649) * DROID-535 Tech | Integrate new MW lib with migration fixes (#2653) * DROID-535 Tech | MW integration fixes (#2660) * DROID-559 Relations | Refactoring | Parse tag and status values in editor (#2662) * DROID-560 Relations | Refactoring | Integrate new lib with fixes (#2663) * DROID-561 Relations | Refactoring | Parsing tag and status values in dv (#2665) * DROID-562 Dashboard | Refactoring | Use store of object types as object type provider for favorites tab on dashboard (#2667) * DROID-567 Relations | Refactoring | Suggest available options to populate a relation (#2671) * DROID-604 Relations | Refactoring | Use details from Object.CreateRelation.Response to populate relation store (#2705) * DROID-603 Relations | Refactoring | Creating relation options + Deleting relation from object (#2706) * DROID-619 Relations | Refactoring | Migrate data view sorts and filters to the new relation-as-object paradigm (#2711) * DROID-622 Relations | Tech | Update MW to 0.24.0-rc1 (#2714) * DROID-598 Sets | Refactoring | Provide relation format for date filters (#2715) * DROID-625 Protocol | Enhancement | Integrate v0.24.0-rc2 (#2718)
This commit is contained in:
parent
11fdf626c1
commit
36fe52e5ad
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -13,7 +13,8 @@
|
||||||
/analytics/gradle.properties
|
/analytics/gradle.properties
|
||||||
.DS_Store
|
.DS_Store
|
||||||
**/build
|
**/build
|
||||||
/libs
|
/libs/build
|
||||||
|
/libs/lib.aar
|
||||||
/captures
|
/captures
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
ktlint
|
ktlint
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -15,3 +15,5 @@ enable_analytics_for_debug:
|
||||||
|
|
||||||
pr_check: compile_android_test_sources test_debug_all
|
pr_check: compile_android_test_sources test_debug_all
|
||||||
|
|
||||||
|
setup_local_mw:
|
||||||
|
./gradlew libs:publishToMavenLocal
|
||||||
|
|
37
RELATIONS_REFACTORING.md
Normal file
37
RELATIONS_REFACTORING.md
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
|
||||||
|
# Relations as object
|
||||||
|
New API docs [here](https://linear.app/anytype/document/new-api-59b2f463bb78)
|
||||||
|
|
||||||
|
### New Api
|
||||||
|
- [ ] ObjectCreateRelation
|
||||||
|
- [ ] ObjectCreateRelationOption
|
||||||
|
- [ ] RelationListRemoveOption
|
||||||
|
- [ ] RelationOptions
|
||||||
|
|
||||||
|
### Removed or deprecated API:
|
||||||
|
#### DataView
|
||||||
|
- [ ] BlockDataviewRecordCreate
|
||||||
|
- [ ] BlockDataviewRecordUpdate
|
||||||
|
- [ ] BlockDataviewRecordDelete
|
||||||
|
- [ ] BlockDataviewRecordRelationOptionAdd
|
||||||
|
- [ ] BlockDataviewRecordRelationOptionUpdate
|
||||||
|
- [ ] BlockDataviewRecordRelationOptionDelete
|
||||||
|
- [ ] BlockDataviewRelationUpdate
|
||||||
|
|
||||||
|
#### Relations
|
||||||
|
- [ ] ObjectRelationOptionAdd
|
||||||
|
- [ ] ObjectRelationOptionUpdate
|
||||||
|
- [ ] ObjectRelationOptionDelete
|
||||||
|
- [ ] ObjectRelationUpdate
|
||||||
|
|
||||||
|
#### Types
|
||||||
|
- [ ] ObjectTypeList
|
||||||
|
|
||||||
|
##### Classes to update
|
||||||
|
- [ ] android-anytype/middleware/***/Middleware.kt
|
||||||
|
- [ ] android-anytype/middleware/***/MiddlewareService.kt
|
||||||
|
- [ ] android-anytype/middleware/***/MiddlewareServiceImplementation.kt
|
||||||
|
- [ ] android-anytype/middleware/***/MiddlewareEventChannel.kt
|
||||||
|
- [ ] android-anytype/middleware/***/MiddlewareEventMapper.kt
|
||||||
|
- [ ] android-anytype/middleware/***/ToCoreModelMappers.kt
|
|
@ -14,9 +14,10 @@ import androidx.test.filters.LargeTest
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.core_models.Block
|
import com.anytypeio.anytype.core_models.Block
|
||||||
import com.anytypeio.anytype.core_models.Event
|
import com.anytypeio.anytype.core_models.Event
|
||||||
import com.anytypeio.anytype.core_models.ObjectType
|
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||||
import com.anytypeio.anytype.core_models.Position
|
import com.anytypeio.anytype.core_models.Position
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.Relation
|
||||||
|
import com.anytypeio.anytype.core_models.Relations
|
||||||
import com.anytypeio.anytype.core_models.StubBookmark
|
import com.anytypeio.anytype.core_models.StubBookmark
|
||||||
import com.anytypeio.anytype.core_ui.features.editor.slash.holders.MainMenuHolder
|
import com.anytypeio.anytype.core_ui.features.editor.slash.holders.MainMenuHolder
|
||||||
import com.anytypeio.anytype.core_ui.features.editor.slash.holders.MediaMenuHolder
|
import com.anytypeio.anytype.core_ui.features.editor.slash.holders.MediaMenuHolder
|
||||||
|
@ -478,29 +479,15 @@ class SlashWidgetTesting : EditorTestSetup() {
|
||||||
val document = listOf(page, header, title, paragraph)
|
val document = listOf(page, header, title, paragraph)
|
||||||
|
|
||||||
val objectTypes = listOf(
|
val objectTypes = listOf(
|
||||||
ObjectType(
|
ObjectWrapper.Type(
|
||||||
url = MockDataFactory.randomUuid(),
|
mapOf(
|
||||||
name = MockDataFactory.randomString(),
|
Relations.ID to MockDataFactory.randomUuid()
|
||||||
emoji = MockDataFactory.randomString(),
|
)
|
||||||
layout = ObjectType.Layout.BASIC,
|
|
||||||
relations = emptyList(),
|
|
||||||
description = MockDataFactory.randomString(),
|
|
||||||
isHidden = false,
|
|
||||||
smartBlockTypes = listOf(),
|
|
||||||
isArchived = false,
|
|
||||||
isReadOnly = false
|
|
||||||
),
|
),
|
||||||
ObjectType(
|
ObjectWrapper.Type(
|
||||||
url = MockDataFactory.randomUuid(),
|
mapOf(
|
||||||
name = MockDataFactory.randomString(),
|
Relations.ID to MockDataFactory.randomUuid()
|
||||||
emoji = MockDataFactory.randomString(),
|
)
|
||||||
layout = ObjectType.Layout.BASIC,
|
|
||||||
relations = emptyList(),
|
|
||||||
description = MockDataFactory.randomString(),
|
|
||||||
isHidden = false,
|
|
||||||
smartBlockTypes = listOf(),
|
|
||||||
isArchived = false,
|
|
||||||
isReadOnly = false
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,11 @@ import com.anytypeio.anytype.core_models.Command
|
||||||
import com.anytypeio.anytype.core_models.DocumentInfo
|
import com.anytypeio.anytype.core_models.DocumentInfo
|
||||||
import com.anytypeio.anytype.core_models.Event
|
import com.anytypeio.anytype.core_models.Event
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
import com.anytypeio.anytype.core_models.ObjectType
|
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.Relation
|
||||||
import com.anytypeio.anytype.core_utils.tools.FeatureToggles
|
import com.anytypeio.anytype.core_utils.tools.FeatureToggles
|
||||||
import com.anytypeio.anytype.domain.`object`.ConvertObjectToSet
|
import com.anytypeio.anytype.domain.`object`.ConvertObjectToSet
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||||
import com.anytypeio.anytype.domain.base.Either
|
import com.anytypeio.anytype.domain.base.Either
|
||||||
|
@ -54,15 +53,16 @@ import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
||||||
import com.anytypeio.anytype.domain.cover.RemoveDocCover
|
import com.anytypeio.anytype.domain.cover.RemoveDocCover
|
||||||
import com.anytypeio.anytype.domain.cover.SetDocCoverImage
|
import com.anytypeio.anytype.domain.cover.SetDocCoverImage
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.GetCompatibleObjectTypes
|
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
|
||||||
import com.anytypeio.anytype.domain.relations.SetRelationKey
|
|
||||||
import com.anytypeio.anytype.domain.download.DownloadFile
|
import com.anytypeio.anytype.domain.download.DownloadFile
|
||||||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||||
import com.anytypeio.anytype.domain.icon.DocumentEmojiIconProvider
|
import com.anytypeio.anytype.domain.icon.DocumentEmojiIconProvider
|
||||||
import com.anytypeio.anytype.domain.icon.SetDocumentImageIcon
|
import com.anytypeio.anytype.domain.icon.SetDocumentImageIcon
|
||||||
import com.anytypeio.anytype.domain.launch.GetDefaultEditorType
|
import com.anytypeio.anytype.domain.launch.GetDefaultEditorType
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.page.CloseBlock
|
import com.anytypeio.anytype.domain.page.CloseBlock
|
||||||
import com.anytypeio.anytype.domain.page.CreateDocument
|
import com.anytypeio.anytype.domain.page.CreateDocument
|
||||||
import com.anytypeio.anytype.domain.page.CreateNewDocument
|
import com.anytypeio.anytype.domain.page.CreateNewDocument
|
||||||
|
@ -73,6 +73,8 @@ import com.anytypeio.anytype.domain.page.Redo
|
||||||
import com.anytypeio.anytype.domain.page.Undo
|
import com.anytypeio.anytype.domain.page.Undo
|
||||||
import com.anytypeio.anytype.domain.page.bookmark.CreateBookmarkBlock
|
import com.anytypeio.anytype.domain.page.bookmark.CreateBookmarkBlock
|
||||||
import com.anytypeio.anytype.domain.page.bookmark.SetupBookmark
|
import com.anytypeio.anytype.domain.page.bookmark.SetupBookmark
|
||||||
|
import com.anytypeio.anytype.domain.relations.SetRelationKey
|
||||||
|
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||||
import com.anytypeio.anytype.domain.sets.FindObjectSetForType
|
import com.anytypeio.anytype.domain.sets.FindObjectSetForType
|
||||||
import com.anytypeio.anytype.domain.status.InterceptThreadStatus
|
import com.anytypeio.anytype.domain.status.InterceptThreadStatus
|
||||||
import com.anytypeio.anytype.domain.status.ThreadStatusChannel
|
import com.anytypeio.anytype.domain.status.ThreadStatusChannel
|
||||||
|
@ -98,6 +100,7 @@ import com.anytypeio.anytype.presentation.editor.selection.SelectionStateHolder
|
||||||
import com.anytypeio.anytype.presentation.editor.template.DefaultEditorTemplateDelegate
|
import com.anytypeio.anytype.presentation.editor.template.DefaultEditorTemplateDelegate
|
||||||
import com.anytypeio.anytype.presentation.editor.template.EditorTemplateDelegate
|
import com.anytypeio.anytype.presentation.editor.template.EditorTemplateDelegate
|
||||||
import com.anytypeio.anytype.presentation.editor.toggle.ToggleStateHolder
|
import com.anytypeio.anytype.presentation.editor.toggle.ToggleStateHolder
|
||||||
|
import com.anytypeio.anytype.presentation.search.ObjectSearchConstants
|
||||||
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
import com.anytypeio.anytype.presentation.util.downloader.MiddlewareShareDownloader
|
import com.anytypeio.anytype.presentation.util.downloader.MiddlewareShareDownloader
|
||||||
|
@ -133,8 +136,6 @@ open class EditorTestSetup {
|
||||||
lateinit var move: Move
|
lateinit var move: Move
|
||||||
lateinit var setRelationKey: SetRelationKey
|
lateinit var setRelationKey: SetRelationKey
|
||||||
lateinit var updateDetail: UpdateDetail
|
lateinit var updateDetail: UpdateDetail
|
||||||
lateinit var getCompatibleObjectTypes: GetCompatibleObjectTypes
|
|
||||||
|
|
||||||
|
|
||||||
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
||||||
|
|
||||||
|
@ -242,9 +243,6 @@ open class EditorTestSetup {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var documentEmojiIconProvider: DocumentEmojiIconProvider
|
lateinit var documentEmojiIconProvider: DocumentEmojiIconProvider
|
||||||
|
|
||||||
@Mock
|
|
||||||
lateinit var objectTypesProvider: ObjectTypesProvider
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var createTable: CreateTable
|
lateinit var createTable: CreateTable
|
||||||
|
|
||||||
|
@ -270,6 +268,9 @@ open class EditorTestSetup {
|
||||||
intents = intents
|
intents = intents
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
|
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||||
|
|
||||||
open fun setup() {
|
open fun setup() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
|
|
||||||
|
@ -322,7 +323,6 @@ open class EditorTestSetup {
|
||||||
removeDocCover = RemoveDocCover(repo)
|
removeDocCover = RemoveDocCover(repo)
|
||||||
turnIntoStyle = TurnIntoStyle(repo)
|
turnIntoStyle = TurnIntoStyle(repo)
|
||||||
updateDetail = UpdateDetail(repo)
|
updateDetail = UpdateDetail(repo)
|
||||||
getCompatibleObjectTypes = GetCompatibleObjectTypes(repo)
|
|
||||||
getDefaultEditorType = GetDefaultEditorType(userSettingsRepository)
|
getDefaultEditorType = GetDefaultEditorType(userSettingsRepository)
|
||||||
createObjectSet = CreateObjectSet(repo)
|
createObjectSet = CreateObjectSet(repo)
|
||||||
findObjectSetForType = FindObjectSetForType(repo)
|
findObjectSetForType = FindObjectSetForType(repo)
|
||||||
|
@ -357,7 +357,8 @@ open class EditorTestSetup {
|
||||||
renderer = DefaultBlockViewRenderer(
|
renderer = DefaultBlockViewRenderer(
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
toggleStateHolder = ToggleStateHolder.Default(),
|
toggleStateHolder = ToggleStateHolder.Default(),
|
||||||
coverImageHashProvider = coverImageHashProvider
|
coverImageHashProvider = coverImageHashProvider,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
),
|
),
|
||||||
orchestrator = Orchestrator(
|
orchestrator = Orchestrator(
|
||||||
createBlock = createBlock,
|
createBlock = createBlock,
|
||||||
|
@ -411,8 +412,6 @@ open class EditorTestSetup {
|
||||||
dispatcher = Dispatcher.Default(),
|
dispatcher = Dispatcher.Default(),
|
||||||
detailModificationManager = InternalDetailModificationManager(stores.details),
|
detailModificationManager = InternalDetailModificationManager(stores.details),
|
||||||
updateDetail = updateDetail,
|
updateDetail = updateDetail,
|
||||||
getCompatibleObjectTypes = getCompatibleObjectTypes,
|
|
||||||
objectTypesProvider = objectTypesProvider,
|
|
||||||
searchObjects = getSearchObjects,
|
searchObjects = getSearchObjects,
|
||||||
getDefaultEditorType = getDefaultEditorType,
|
getDefaultEditorType = getDefaultEditorType,
|
||||||
createObjectSet = createObjectSet,
|
createObjectSet = createObjectSet,
|
||||||
|
@ -425,6 +424,8 @@ open class EditorTestSetup {
|
||||||
editorTemplateDelegate = editorTemplateDelegate,
|
editorTemplateDelegate = editorTemplateDelegate,
|
||||||
createNewObject = createNewObject,
|
createNewObject = createNewObject,
|
||||||
objectToSet = objectToSet,
|
objectToSet = objectToSet,
|
||||||
|
storeOfRelations = storeOfRelations,
|
||||||
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
featureToggles = featureToggles,
|
featureToggles = featureToggles,
|
||||||
tableDelegate = tableDelegate
|
tableDelegate = tableDelegate
|
||||||
)
|
)
|
||||||
|
@ -505,9 +506,18 @@ open class EditorTestSetup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stubGetObjectTypes(objectTypes: List<ObjectType>) {
|
fun stubGetObjectTypes(objectTypes: List<ObjectWrapper.Type>) {
|
||||||
repo.stub {
|
repo.stub {
|
||||||
onBlocking { getObjectTypes() } doReturn objectTypes
|
onBlocking {
|
||||||
|
searchObjects(
|
||||||
|
filters = ObjectSearchConstants.filterObjectType,
|
||||||
|
keys = ObjectSearchConstants.defaultKeysObjectType,
|
||||||
|
sorts = emptyList(),
|
||||||
|
limit = 0,
|
||||||
|
offset = 0,
|
||||||
|
fulltext = ""
|
||||||
|
)
|
||||||
|
} doReturn objectTypes.map { it.map }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,26 +10,30 @@ import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.analytics.base.Analytics
|
import com.anytypeio.anytype.analytics.base.Analytics
|
||||||
import com.anytypeio.anytype.core_models.Block
|
import com.anytypeio.anytype.core_models.Block
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
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.core_models.ThemeColor
|
||||||
import com.anytypeio.anytype.core_ui.extensions.dark
|
import com.anytypeio.anytype.core_ui.extensions.dark
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewRelationOption
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
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.ObjectStore
|
||||||
import com.anytypeio.anytype.domain.relations.AddObjectRelationOption
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
|
import com.anytypeio.anytype.domain.objects.options.GetOptions
|
||||||
|
import com.anytypeio.anytype.domain.relations.CreateRelationOption
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel
|
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel
|
||||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider
|
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
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.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||||
|
@ -74,9 +78,12 @@ class AddRelationStatusValueTest {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var analytics: Analytics
|
lateinit var analytics: Analytics
|
||||||
|
|
||||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
@Mock
|
||||||
private lateinit var addObjectRelationOption: AddObjectRelationOption
|
lateinit var objectDetailProvider: ObjectDetailProvider
|
||||||
|
|
||||||
|
private lateinit var createRelationOption: CreateRelationOption
|
||||||
private lateinit var updateDetail: UpdateDetail
|
private lateinit var updateDetail: UpdateDetail
|
||||||
|
private lateinit var getOptions: GetOptions
|
||||||
private lateinit var urlBuilder: UrlBuilder
|
private lateinit var urlBuilder: UrlBuilder
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
|
@ -88,25 +95,31 @@ class AddRelationStatusValueTest {
|
||||||
private val ctx = MockDataFactory.randomUuid()
|
private val ctx = MockDataFactory.randomUuid()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val store : ObjectStore = DefaultObjectStore()
|
private val store : ObjectStore = DefaultObjectStore()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
private val db = ObjectSetDatabase(store = store)
|
private val db = ObjectSetDatabase(store = store)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
addRelationOption = AddDataViewRelationOption(repo)
|
createRelationOption = CreateRelationOption(repo)
|
||||||
addObjectRelationOption = AddObjectRelationOption(repo)
|
getOptions = GetOptions(repo)
|
||||||
updateDetail = UpdateDetail(repo)
|
updateDetail = UpdateDetail(repo)
|
||||||
urlBuilder = UrlBuilder(gateway)
|
urlBuilder = UrlBuilder(gateway)
|
||||||
TestRelationOptionValueDVAddFragment.testVmFactory = AddOptionsRelationDVViewModel.Factory(
|
TestRelationOptionValueDVAddFragment.testVmFactory = AddOptionsRelationDVViewModel.Factory(
|
||||||
relations = DataViewObjectRelationProvider(state),
|
relations = DataViewObjectRelationProvider(
|
||||||
|
objectSetState = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
),
|
||||||
values = DataViewObjectValueProvider(
|
values = DataViewObjectValueProvider(
|
||||||
db = db
|
db = db
|
||||||
),
|
),
|
||||||
addDataViewRelationOption = addRelationOption,
|
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
optionsProvider = AddOptionsRelationProvider(),
|
optionsProvider = AddOptionsRelationProvider(),
|
||||||
setObjectDetail = updateDetail,
|
setObjectDetail = updateDetail,
|
||||||
analytics = analytics
|
analytics = analytics,
|
||||||
|
createRelationOption = createRelationOption,
|
||||||
|
detailsProvider = objectDetailProvider,
|
||||||
|
getOptions = getOptions
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,34 +169,9 @@ class AddRelationStatusValueTest {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
state.value = ObjectSet(
|
state.value = ObjectSet(blocks = listOf(dv))
|
||||||
blocks = listOf(dv),
|
|
||||||
// viewerDb = mapOf(
|
|
||||||
// viewer.id to ObjectSet.ViewerData(
|
|
||||||
// records = listOf(record),
|
|
||||||
// total = 1
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
)
|
|
||||||
|
|
||||||
repo.stub {
|
stubCreateRelationOption()
|
||||||
onBlocking {
|
|
||||||
addDataViewRelationOption(
|
|
||||||
ctx = any(),
|
|
||||||
dataview = any(),
|
|
||||||
relation = any(),
|
|
||||||
color = any(),
|
|
||||||
name = any(),
|
|
||||||
record = any()
|
|
||||||
)
|
|
||||||
} doReturn Pair(
|
|
||||||
Payload(
|
|
||||||
context = ctx,
|
|
||||||
events = emptyList()
|
|
||||||
),
|
|
||||||
MockDataFactory.randomUuid()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TESTING
|
// TESTING
|
||||||
|
|
||||||
|
@ -213,16 +201,7 @@ class AddRelationStatusValueTest {
|
||||||
|
|
||||||
// Verifying that the request is made.
|
// Verifying that the request is made.
|
||||||
|
|
||||||
verifyBlocking(repo, times(1)) {
|
verifyCreateRelationOptionCalled()
|
||||||
addDataViewRelationOption(
|
|
||||||
ctx = any(),
|
|
||||||
dataview = any(),
|
|
||||||
relation = any(),
|
|
||||||
color = any(),
|
|
||||||
name = any(),
|
|
||||||
record = any()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -281,24 +260,7 @@ class AddRelationStatusValueTest {
|
||||||
// )
|
// )
|
||||||
)
|
)
|
||||||
|
|
||||||
repo.stub {
|
stubCreateRelationOption()
|
||||||
onBlocking {
|
|
||||||
addDataViewRelationOption(
|
|
||||||
ctx = any(),
|
|
||||||
dataview = any(),
|
|
||||||
relation = any(),
|
|
||||||
color = any(),
|
|
||||||
name = any(),
|
|
||||||
record = any()
|
|
||||||
)
|
|
||||||
} doReturn Pair(
|
|
||||||
Payload(
|
|
||||||
context = ctx,
|
|
||||||
events = emptyList()
|
|
||||||
),
|
|
||||||
MockDataFactory.randomUuid()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TESTING
|
// TESTING
|
||||||
|
|
||||||
|
@ -610,14 +572,10 @@ class AddRelationStatusValueTest {
|
||||||
// Veryfying UI
|
// Veryfying UI
|
||||||
|
|
||||||
verifyBlocking(repo, times(1)) {
|
verifyBlocking(repo, times(1)) {
|
||||||
updateDataViewRecord(
|
updateDetail(
|
||||||
context = ctx,
|
ctx = target,
|
||||||
target = dv.id,
|
key = relationKey,
|
||||||
record = target,
|
value = listOf(option2.id)
|
||||||
values = mapOf(
|
|
||||||
ObjectSetConfig.ID_KEY to target,
|
|
||||||
relationKey to listOf(option2.id)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,4 +586,35 @@ class AddRelationStatusValueTest {
|
||||||
themeResId = R.style.AppTheme
|
themeResId = R.style.AppTheme
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun verifyCreateRelationOptionCalled() {
|
||||||
|
verifyBlocking(repo, times(1)) {
|
||||||
|
createRelationOption(
|
||||||
|
relation = any(),
|
||||||
|
color = any(),
|
||||||
|
name = any()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun stubCreateRelationOption(
|
||||||
|
relation: Key = MockDataFactory.randomUuid(),
|
||||||
|
name: String = MockDataFactory.randomString(),
|
||||||
|
id: Id = MockDataFactory.randomUuid(),
|
||||||
|
color: String = ThemeColor.values().random().code
|
||||||
|
) {
|
||||||
|
repo.stub {
|
||||||
|
onBlocking {
|
||||||
|
createRelationOption(
|
||||||
|
relation = relation,
|
||||||
|
color = color,
|
||||||
|
name = name
|
||||||
|
)
|
||||||
|
} doReturn StubRelationOptionObject(
|
||||||
|
id = id,
|
||||||
|
text = name,
|
||||||
|
color = color
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -12,24 +12,27 @@ import com.anytypeio.anytype.core_models.Block
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
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.core_models.ThemeColor
|
||||||
import com.anytypeio.anytype.core_ui.extensions.dark
|
import com.anytypeio.anytype.core_ui.extensions.dark
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewRelationOption
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
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.ObjectStore
|
||||||
import com.anytypeio.anytype.domain.relations.AddObjectRelationOption
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
|
import com.anytypeio.anytype.domain.objects.options.GetOptions
|
||||||
|
import com.anytypeio.anytype.domain.relations.CreateRelationOption
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel
|
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel
|
||||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider
|
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
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.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||||
|
@ -73,9 +76,12 @@ class AddRelationTagValueTest {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var analytics: Analytics
|
lateinit var analytics: Analytics
|
||||||
|
|
||||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
@Mock
|
||||||
private lateinit var addObjectRelationOption: AddObjectRelationOption
|
lateinit var objectDetailProvider: ObjectDetailProvider
|
||||||
|
|
||||||
|
private lateinit var createRelationOption: CreateRelationOption
|
||||||
private lateinit var updateDetail: UpdateDetail
|
private lateinit var updateDetail: UpdateDetail
|
||||||
|
private lateinit var getOptions: GetOptions
|
||||||
private lateinit var urlBuilder: UrlBuilder
|
private lateinit var urlBuilder: UrlBuilder
|
||||||
|
|
||||||
@get:Rule
|
@get:Rule
|
||||||
|
@ -87,23 +93,29 @@ class AddRelationTagValueTest {
|
||||||
private val ctx = MockDataFactory.randomUuid()
|
private val ctx = MockDataFactory.randomUuid()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val store : ObjectStore = DefaultObjectStore()
|
private val store : ObjectStore = DefaultObjectStore()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
private val db = ObjectSetDatabase(store = store)
|
private val db = ObjectSetDatabase(store = store)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
addRelationOption = AddDataViewRelationOption(repo)
|
createRelationOption = CreateRelationOption(repo)
|
||||||
addObjectRelationOption = AddObjectRelationOption(repo)
|
getOptions = GetOptions(repo)
|
||||||
updateDetail = UpdateDetail(repo)
|
updateDetail = UpdateDetail(repo)
|
||||||
urlBuilder = UrlBuilder(gateway)
|
urlBuilder = UrlBuilder(gateway)
|
||||||
TestRelationOptionValueDVAddFragment.testVmFactory = AddOptionsRelationDVViewModel.Factory(
|
TestRelationOptionValueDVAddFragment.testVmFactory = AddOptionsRelationDVViewModel.Factory(
|
||||||
relations = DataViewObjectRelationProvider(state),
|
relations = DataViewObjectRelationProvider(
|
||||||
|
objectSetState = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
),
|
||||||
values = DataViewObjectValueProvider(db = db),
|
values = DataViewObjectValueProvider(db = db),
|
||||||
addDataViewRelationOption = addRelationOption,
|
createRelationOption = createRelationOption,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
optionsProvider = AddOptionsRelationProvider(),
|
optionsProvider = AddOptionsRelationProvider(),
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
setObjectDetail = updateDetail
|
setObjectDetail = updateDetail,
|
||||||
|
detailsProvider = objectDetailProvider,
|
||||||
|
getOptions = getOptions
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,24 +175,7 @@ class AddRelationTagValueTest {
|
||||||
// )
|
// )
|
||||||
)
|
)
|
||||||
|
|
||||||
repo.stub {
|
stubCreateRelationOption()
|
||||||
onBlocking {
|
|
||||||
addDataViewRelationOption(
|
|
||||||
ctx = any(),
|
|
||||||
dataview = any(),
|
|
||||||
relation = any(),
|
|
||||||
color = any(),
|
|
||||||
name = any(),
|
|
||||||
record = any()
|
|
||||||
)
|
|
||||||
} doReturn Pair(
|
|
||||||
Payload(
|
|
||||||
context = ctx,
|
|
||||||
events = emptyList()
|
|
||||||
),
|
|
||||||
MockDataFactory.randomUuid()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TESTING
|
// TESTING
|
||||||
|
|
||||||
|
@ -212,16 +207,7 @@ class AddRelationTagValueTest {
|
||||||
|
|
||||||
// Verifying that the request is made.
|
// Verifying that the request is made.
|
||||||
|
|
||||||
verifyBlocking(repo, times(1)) {
|
verifyCreateRelationOptionCalled()
|
||||||
addDataViewRelationOption(
|
|
||||||
ctx = any(),
|
|
||||||
dataview = any(),
|
|
||||||
relation = any(),
|
|
||||||
color = any(),
|
|
||||||
name = any(),
|
|
||||||
record = any()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -533,14 +519,10 @@ class AddRelationTagValueTest {
|
||||||
R.id.btnAdd.performClick()
|
R.id.btnAdd.performClick()
|
||||||
|
|
||||||
verifyBlocking(repo, times(1)) {
|
verifyBlocking(repo, times(1)) {
|
||||||
updateDataViewRecord(
|
updateDetail(
|
||||||
context = ctx,
|
ctx = target,
|
||||||
target = dv.id,
|
key = relationKey,
|
||||||
record = target,
|
value = listOf(option1.id, option2.id)
|
||||||
values = mapOf(
|
|
||||||
ObjectSetConfig.ID_KEY to target,
|
|
||||||
relationKey to listOf(option1.id, option2.id)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,4 +533,34 @@ class AddRelationTagValueTest {
|
||||||
themeResId = R.style.AppTheme
|
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,
|
||||||
|
text = name,
|
||||||
|
color = color
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -19,13 +19,14 @@ import com.anytypeio.anytype.core_models.Block
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.Relation
|
||||||
import com.anytypeio.anytype.domain.`object`.ReloadObject
|
import com.anytypeio.anytype.domain.`object`.ReloadObject
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
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.ObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
|
||||||
import com.anytypeio.anytype.presentation.sets.RelationTextValueViewModel
|
import com.anytypeio.anytype.presentation.sets.RelationTextValueViewModel
|
||||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||||
import com.anytypeio.anytype.test_utils.utils.espresso.TextLineCountMatcher
|
import com.anytypeio.anytype.test_utils.utils.espresso.TextLineCountMatcher
|
||||||
|
@ -61,13 +62,17 @@ class DisplayObjectRelationTextValueTest {
|
||||||
|
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val store: ObjectStore = DefaultObjectStore()
|
private val store: ObjectStore = DefaultObjectStore()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
private val db = ObjectSetDatabase(store = store)
|
private val db = ObjectSetDatabase(store = store)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun before() {
|
fun before() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
TestRelationTextValueFragment.testVmFactory = RelationTextValueViewModel.Factory(
|
TestRelationTextValueFragment.testVmFactory = RelationTextValueViewModel.Factory(
|
||||||
relations = DataViewObjectRelationProvider(state),
|
relations = DataViewObjectRelationProvider(
|
||||||
|
objectSetState = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
),
|
||||||
values = DataViewObjectValueProvider(db = db),
|
values = DataViewObjectValueProvider(db = db),
|
||||||
reloadObject = reloadObject,
|
reloadObject = reloadObject,
|
||||||
analytics = analytics
|
analytics = analytics
|
||||||
|
|
|
@ -18,13 +18,14 @@ import com.anytypeio.anytype.domain.`object`.ReloadObject
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
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.ObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
|
||||||
import com.anytypeio.anytype.presentation.sets.RelationTextValueViewModel
|
import com.anytypeio.anytype.presentation.sets.RelationTextValueViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||||
|
@ -69,13 +70,17 @@ class DisplayRelationNumberValueTest {
|
||||||
private val root = MockDataFactory.randomUuid()
|
private val root = MockDataFactory.randomUuid()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val store: ObjectStore = DefaultObjectStore()
|
private val store: ObjectStore = DefaultObjectStore()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
private val db = ObjectSetDatabase(store = store)
|
private val db = ObjectSetDatabase(store = store)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
TestRelationTextValueFragment.testVmFactory = RelationTextValueViewModel.Factory(
|
TestRelationTextValueFragment.testVmFactory = RelationTextValueViewModel.Factory(
|
||||||
relations = DataViewObjectRelationProvider(state),
|
relations = DataViewObjectRelationProvider(
|
||||||
|
objectSetState = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
),
|
||||||
values = DataViewObjectValueProvider(db = db),
|
values = DataViewObjectValueProvider(db = db),
|
||||||
reloadObject = reloadObject,
|
reloadObject = reloadObject,
|
||||||
analytics = analytics
|
analytics = analytics
|
||||||
|
|
|
@ -18,14 +18,18 @@ import com.anytypeio.anytype.core_models.Id
|
||||||
import com.anytypeio.anytype.core_models.ObjectType
|
import com.anytypeio.anytype.core_models.ObjectType
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.Relation
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
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.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewRelationOption
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
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.domain.relations.AddFileToObject
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||||
|
@ -33,7 +37,6 @@ import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValu
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
|
||||||
import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel
|
import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -53,6 +56,11 @@ import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.MockitoAnnotations
|
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)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
|
@ -73,7 +81,6 @@ class DisplayRelationObjectValueTest {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
||||||
|
|
||||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
|
||||||
private lateinit var updateDetail: UpdateDetail
|
private lateinit var updateDetail: UpdateDetail
|
||||||
private lateinit var urlBuilder: UrlBuilder
|
private lateinit var urlBuilder: UrlBuilder
|
||||||
private lateinit var addFileToObject: AddFileToObject
|
private lateinit var addFileToObject: AddFileToObject
|
||||||
|
@ -87,31 +94,32 @@ class DisplayRelationObjectValueTest {
|
||||||
private val root = MockDataFactory.randomUuid()
|
private val root = MockDataFactory.randomUuid()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val store: ObjectStore = DefaultObjectStore()
|
private val store: ObjectStore = DefaultObjectStore()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
|
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||||
private val db = ObjectSetDatabase(store = store)
|
private val db = ObjectSetDatabase(store = store)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
addRelationOption = AddDataViewRelationOption(repo)
|
|
||||||
updateDetail = UpdateDetail(repo)
|
updateDetail = UpdateDetail(repo)
|
||||||
addFileToObject = AddFileToObject(repo)
|
addFileToObject = AddFileToObject(repo)
|
||||||
urlBuilder = UrlBuilder(gateway)
|
urlBuilder = UrlBuilder(gateway)
|
||||||
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
||||||
relations = DataViewObjectRelationProvider(state),
|
relations = DataViewObjectRelationProvider(
|
||||||
|
objectSetState = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
),
|
||||||
values = DataViewObjectValueProvider(db = db),
|
values = DataViewObjectValueProvider(db = db),
|
||||||
details = object: ObjectDetailProvider {
|
details = object: ObjectDetailProvider {
|
||||||
override fun provide(): Map<Id, Block.Fields> = state.value.details
|
override fun provide(): Map<Id, Block.Fields> = state.value.details
|
||||||
},
|
},
|
||||||
types = object : ObjectTypesProvider {
|
|
||||||
override fun set(objectTypes: List<ObjectType>) {}
|
|
||||||
override fun get(): List<ObjectType> = state.value.objectTypes
|
|
||||||
},
|
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
copyFileToCache = copyFileToCacheDirectory,
|
copyFileToCache = copyFileToCacheDirectory,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
addFileToObject = addFileToObject,
|
addFileToObject = addFileToObject,
|
||||||
setObjectDetails = updateDetail,
|
setObjectDetails = updateDetail,
|
||||||
dispatcher = dispatcher
|
dispatcher = dispatcher,
|
||||||
|
storeOfObjectTypes = storeOfObjectTypes
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +356,7 @@ class DisplayRelationObjectValueTest {
|
||||||
val objectType1 = ObjectType(
|
val objectType1 = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Director",
|
name = "Director",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = "",
|
emoji = "",
|
||||||
layout = ObjectType.Layout.values().random(),
|
layout = ObjectType.Layout.values().random(),
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -361,7 +369,7 @@ class DisplayRelationObjectValueTest {
|
||||||
val objectType2 = ObjectType(
|
val objectType2 = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Actor",
|
name = "Actor",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = "",
|
emoji = "",
|
||||||
layout = ObjectType.Layout.values().random(),
|
layout = ObjectType.Layout.values().random(),
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -473,7 +481,7 @@ class DisplayRelationObjectValueTest {
|
||||||
val objectType1 = ObjectType(
|
val objectType1 = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Writer",
|
name = "Writer",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = "",
|
emoji = "",
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -486,7 +494,7 @@ class DisplayRelationObjectValueTest {
|
||||||
val objectType2 = ObjectType(
|
val objectType2 = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Writer",
|
name = "Writer",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = "",
|
emoji = "",
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -600,7 +608,7 @@ class DisplayRelationObjectValueTest {
|
||||||
val objectType1 = ObjectType(
|
val objectType1 = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Writer",
|
name = "Writer",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = "",
|
emoji = "",
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -613,7 +621,7 @@ class DisplayRelationObjectValueTest {
|
||||||
val objectType2 = ObjectType(
|
val objectType2 = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Writer",
|
name = "Writer",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = "",
|
emoji = "",
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -714,4 +722,33 @@ class DisplayRelationObjectValueTest {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -15,19 +15,20 @@ import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.analytics.base.Analytics
|
import com.anytypeio.anytype.analytics.base.Analytics
|
||||||
import com.anytypeio.anytype.core_models.Block
|
import com.anytypeio.anytype.core_models.Block
|
||||||
import com.anytypeio.anytype.core_models.Id
|
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.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.Relation
|
||||||
|
import com.anytypeio.anytype.core_models.ThemeColor
|
||||||
import com.anytypeio.anytype.core_ui.extensions.dark
|
import com.anytypeio.anytype.core_ui.extensions.dark
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewRelationOption
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
import com.anytypeio.anytype.core_models.ThemeColor
|
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
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.domain.relations.AddFileToObject
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||||
|
@ -35,7 +36,6 @@ import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValu
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
|
||||||
import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel
|
import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -75,7 +75,6 @@ class DisplayRelationStatusValueTest {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
||||||
|
|
||||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
|
||||||
private lateinit var updateDetail: UpdateDetail
|
private lateinit var updateDetail: UpdateDetail
|
||||||
private lateinit var addFileToObject: AddFileToObject
|
private lateinit var addFileToObject: AddFileToObject
|
||||||
private lateinit var urlBuilder: UrlBuilder
|
private lateinit var urlBuilder: UrlBuilder
|
||||||
|
@ -89,33 +88,34 @@ class DisplayRelationStatusValueTest {
|
||||||
private val root = MockDataFactory.randomUuid()
|
private val root = MockDataFactory.randomUuid()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val store: ObjectStore = DefaultObjectStore()
|
private val store: ObjectStore = DefaultObjectStore()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
|
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||||
private val db = ObjectSetDatabase(store)
|
private val db = ObjectSetDatabase(store)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
addRelationOption = AddDataViewRelationOption(repo)
|
|
||||||
updateDetail = UpdateDetail(repo)
|
updateDetail = UpdateDetail(repo)
|
||||||
addFileToObject = AddFileToObject(repo)
|
addFileToObject = AddFileToObject(repo)
|
||||||
urlBuilder = UrlBuilder(gateway)
|
urlBuilder = UrlBuilder(gateway)
|
||||||
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
||||||
relations = DataViewObjectRelationProvider(state),
|
relations = DataViewObjectRelationProvider(
|
||||||
|
objectSetState = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
),
|
||||||
values = DataViewObjectValueProvider(
|
values = DataViewObjectValueProvider(
|
||||||
db = db
|
db = db
|
||||||
),
|
),
|
||||||
details = object : ObjectDetailProvider {
|
details = object : ObjectDetailProvider {
|
||||||
override fun provide(): Map<Id, Block.Fields> = state.value.details
|
override fun provide(): Map<Id, Block.Fields> = state.value.details
|
||||||
},
|
},
|
||||||
types = object : ObjectTypesProvider {
|
|
||||||
override fun set(objectTypes: List<ObjectType>) {}
|
|
||||||
override fun get(): List<ObjectType> = state.value.objectTypes
|
|
||||||
},
|
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
copyFileToCache = copyFileToCacheDirectory,
|
copyFileToCache = copyFileToCacheDirectory,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
setObjectDetails = updateDetail,
|
setObjectDetails = updateDetail,
|
||||||
addFileToObject = addFileToObject
|
addFileToObject = addFileToObject,
|
||||||
|
storeOfObjectTypes = storeOfObjectTypes
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,19 +15,20 @@ import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.analytics.base.Analytics
|
import com.anytypeio.anytype.analytics.base.Analytics
|
||||||
import com.anytypeio.anytype.core_models.Block
|
import com.anytypeio.anytype.core_models.Block
|
||||||
import com.anytypeio.anytype.core_models.Id
|
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.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.Relation
|
||||||
|
import com.anytypeio.anytype.core_models.ThemeColor
|
||||||
import com.anytypeio.anytype.core_ui.extensions.dark
|
import com.anytypeio.anytype.core_ui.extensions.dark
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewRelationOption
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
import com.anytypeio.anytype.core_models.ThemeColor
|
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
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.domain.relations.AddFileToObject
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||||
|
@ -35,7 +36,6 @@ import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValu
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
|
||||||
import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel
|
import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -75,7 +75,6 @@ class DisplayRelationTagValueTest {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
||||||
|
|
||||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
|
||||||
private lateinit var updateDetail: UpdateDetail
|
private lateinit var updateDetail: UpdateDetail
|
||||||
private lateinit var addFileToObject: AddFileToObject
|
private lateinit var addFileToObject: AddFileToObject
|
||||||
private lateinit var urlBuilder: UrlBuilder
|
private lateinit var urlBuilder: UrlBuilder
|
||||||
|
@ -89,31 +88,32 @@ class DisplayRelationTagValueTest {
|
||||||
private val root = MockDataFactory.randomUuid()
|
private val root = MockDataFactory.randomUuid()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val store: ObjectStore = DefaultObjectStore()
|
private val store: ObjectStore = DefaultObjectStore()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
private val db = ObjectSetDatabase(store)
|
private val db = ObjectSetDatabase(store)
|
||||||
|
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
addRelationOption = AddDataViewRelationOption(repo)
|
|
||||||
updateDetail = UpdateDetail(repo)
|
updateDetail = UpdateDetail(repo)
|
||||||
addFileToObject = AddFileToObject(repo)
|
addFileToObject = AddFileToObject(repo)
|
||||||
urlBuilder = UrlBuilder(gateway)
|
urlBuilder = UrlBuilder(gateway)
|
||||||
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
||||||
relations = DataViewObjectRelationProvider(state),
|
relations = DataViewObjectRelationProvider(
|
||||||
|
objectSetState = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
),
|
||||||
values = DataViewObjectValueProvider(db = db),
|
values = DataViewObjectValueProvider(db = db),
|
||||||
details = object: ObjectDetailProvider {
|
details = object: ObjectDetailProvider {
|
||||||
override fun provide(): Map<Id, Block.Fields> = state.value.details
|
override fun provide(): Map<Id, Block.Fields> = state.value.details
|
||||||
},
|
},
|
||||||
types = object : ObjectTypesProvider {
|
|
||||||
override fun set(objectTypes: List<ObjectType>) {}
|
|
||||||
override fun get(): List<ObjectType> = state.value.objectTypes
|
|
||||||
},
|
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
copyFileToCache = copyFileToCacheDirectory,
|
copyFileToCache = copyFileToCacheDirectory,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
setObjectDetails = updateDetail,
|
setObjectDetails = updateDetail,
|
||||||
addFileToObject = addFileToObject
|
addFileToObject = addFileToObject,
|
||||||
|
storeOfObjectTypes = storeOfObjectTypes
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ class DisplayRelationTagValueTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchFragment(args: Bundle): FragmentScenario<TestRelationValueDVFragment> {
|
private fun launchFragment(args: Bundle): FragmentScenario<TestRelationValueDVFragment> {
|
||||||
return launchFragmentInContainer<TestRelationValueDVFragment>(
|
return launchFragmentInContainer(
|
||||||
fragmentArgs = args,
|
fragmentArgs = args,
|
||||||
themeResId = R.style.AppTheme
|
themeResId = R.style.AppTheme
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,19 +10,20 @@ import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.analytics.base.Analytics
|
import com.anytypeio.anytype.analytics.base.Analytics
|
||||||
import com.anytypeio.anytype.core_models.Block
|
import com.anytypeio.anytype.core_models.Block
|
||||||
import com.anytypeio.anytype.core_models.Id
|
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.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.Relation
|
||||||
|
import com.anytypeio.anytype.core_models.ThemeColor
|
||||||
import com.anytypeio.anytype.core_ui.extensions.dark
|
import com.anytypeio.anytype.core_ui.extensions.dark
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewRelationOption
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
import com.anytypeio.anytype.core_models.ThemeColor
|
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
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.domain.relations.AddFileToObject
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||||
|
@ -30,7 +31,6 @@ import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValu
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
|
||||||
import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel
|
import com.anytypeio.anytype.presentation.sets.RelationValueDVViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
import com.anytypeio.anytype.presentation.util.CopyFileToCacheDirectory
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -77,7 +77,6 @@ class EditRelationTagValueTest {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
||||||
|
|
||||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
|
||||||
private lateinit var updateDetail: UpdateDetail
|
private lateinit var updateDetail: UpdateDetail
|
||||||
private lateinit var urlBuilder: UrlBuilder
|
private lateinit var urlBuilder: UrlBuilder
|
||||||
private lateinit var addFileToObject: AddFileToObject
|
private lateinit var addFileToObject: AddFileToObject
|
||||||
|
@ -91,31 +90,32 @@ class EditRelationTagValueTest {
|
||||||
private val ctx = MockDataFactory.randomUuid()
|
private val ctx = MockDataFactory.randomUuid()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val store: ObjectStore = DefaultObjectStore()
|
private val store: ObjectStore = DefaultObjectStore()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
private val db = ObjectSetDatabase(store = store)
|
private val db = ObjectSetDatabase(store = store)
|
||||||
|
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
addRelationOption = AddDataViewRelationOption(repo)
|
|
||||||
updateDetail = UpdateDetail(repo)
|
updateDetail = UpdateDetail(repo)
|
||||||
urlBuilder = UrlBuilder(gateway)
|
urlBuilder = UrlBuilder(gateway)
|
||||||
addFileToObject = AddFileToObject(repo)
|
addFileToObject = AddFileToObject(repo)
|
||||||
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
||||||
relations = DataViewObjectRelationProvider(state),
|
relations = DataViewObjectRelationProvider(
|
||||||
|
objectSetState = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
),
|
||||||
values = DataViewObjectValueProvider(db = db),
|
values = DataViewObjectValueProvider(db = db),
|
||||||
details = object : ObjectDetailProvider {
|
details = object : ObjectDetailProvider {
|
||||||
override fun provide(): Map<Id, Block.Fields> = state.value.details
|
override fun provide(): Map<Id, Block.Fields> = state.value.details
|
||||||
},
|
},
|
||||||
types = object : ObjectTypesProvider {
|
|
||||||
override fun set(objectTypes: List<ObjectType>) {}
|
|
||||||
override fun get(): List<ObjectType> = state.value.objectTypes
|
|
||||||
},
|
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
copyFileToCache = copyFileToCacheDirectory,
|
copyFileToCache = copyFileToCacheDirectory,
|
||||||
addFileToObject = addFileToObject,
|
addFileToObject = addFileToObject,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
setObjectDetails = updateDetail
|
setObjectDetails = updateDetail,
|
||||||
|
storeOfObjectTypes = storeOfObjectTypes
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,13 +337,10 @@ class EditRelationTagValueTest {
|
||||||
rvMatcher.onItemView(1, R.id.btnRemoveTag).performClick()
|
rvMatcher.onItemView(1, R.id.btnRemoveTag).performClick()
|
||||||
|
|
||||||
verifyBlocking(repo, times(1)) {
|
verifyBlocking(repo, times(1)) {
|
||||||
updateDataViewRecord(
|
updateDetail(
|
||||||
context = ctx,
|
ctx= target,
|
||||||
target = dv.id,
|
key = relationKey,
|
||||||
record = target,
|
value = listOf(option2.id)
|
||||||
values = mapOf(
|
|
||||||
relationKey to listOf(option2.id)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,9 @@ import com.anytypeio.anytype.core_models.Relation
|
||||||
import com.anytypeio.anytype.core_utils.const.DateConst.DEFAULT_DATE_FORMAT
|
import com.anytypeio.anytype.core_utils.const.DateConst.DEFAULT_DATE_FORMAT
|
||||||
import com.anytypeio.anytype.core_utils.ext.formatTimeInMillis
|
import com.anytypeio.anytype.core_utils.ext.formatTimeInMillis
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
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.ObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
||||||
|
@ -52,12 +54,16 @@ class ObjectRelationDateValueTest {
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val store: ObjectStore = DefaultObjectStore()
|
private val store: ObjectStore = DefaultObjectStore()
|
||||||
private val db = ObjectSetDatabase(store)
|
private val db = ObjectSetDatabase(store)
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
TestRelationDateValueFragment.testVmFactory = RelationDateValueViewModel.Factory(
|
TestRelationDateValueFragment.testVmFactory = RelationDateValueViewModel.Factory(
|
||||||
relations = DataViewObjectRelationProvider(state),
|
relations = DataViewObjectRelationProvider(
|
||||||
|
objectSetState = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
),
|
||||||
values = DataViewObjectValueProvider(db = db)
|
values = DataViewObjectValueProvider(db = db)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,20 +15,21 @@ import com.anytypeio.anytype.core_models.Block
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.Relation
|
||||||
|
import com.anytypeio.anytype.core_models.ThemeColor
|
||||||
import com.anytypeio.anytype.core_ui.extensions.dark
|
import com.anytypeio.anytype.core_ui.extensions.dark
|
||||||
import com.anytypeio.anytype.core_utils.const.DateConst
|
import com.anytypeio.anytype.core_utils.const.DateConst
|
||||||
import com.anytypeio.anytype.core_utils.ext.toTimeSeconds
|
import com.anytypeio.anytype.core_utils.ext.toTimeSeconds
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.relations.ObjectRelationList
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.relations.AddToFeaturedRelations
|
import com.anytypeio.anytype.domain.relations.AddToFeaturedRelations
|
||||||
import com.anytypeio.anytype.domain.relations.DeleteRelationFromObject
|
import com.anytypeio.anytype.domain.relations.DeleteRelationFromObject
|
||||||
|
import com.anytypeio.anytype.domain.relations.ObjectRelationList
|
||||||
import com.anytypeio.anytype.domain.relations.RemoveFromFeaturedRelations
|
import com.anytypeio.anytype.domain.relations.RemoveFromFeaturedRelations
|
||||||
import com.anytypeio.anytype.presentation.editor.Editor
|
import com.anytypeio.anytype.presentation.editor.Editor
|
||||||
import com.anytypeio.anytype.presentation.editor.editor.DetailModificationManager
|
import com.anytypeio.anytype.presentation.editor.editor.DetailModificationManager
|
||||||
import com.anytypeio.anytype.core_models.ThemeColor
|
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectRelationListViewModelFactory
|
import com.anytypeio.anytype.presentation.relations.ObjectRelationListViewModelFactory
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||||
|
@ -76,6 +77,9 @@ class ObjectRelationListTest {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var analytics: Analytics
|
lateinit var analytics: Analytics
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
lateinit var storeOfRelations: StoreOfRelations
|
||||||
|
|
||||||
private lateinit var objectRelationList: ObjectRelationList
|
private lateinit var objectRelationList: ObjectRelationList
|
||||||
private lateinit var updateDetail: UpdateDetail
|
private lateinit var updateDetail: UpdateDetail
|
||||||
private lateinit var addToFeaturedRelations: AddToFeaturedRelations
|
private lateinit var addToFeaturedRelations: AddToFeaturedRelations
|
||||||
|
@ -106,7 +110,8 @@ class ObjectRelationListTest {
|
||||||
addToFeaturedRelations = addToFeaturedRelations,
|
addToFeaturedRelations = addToFeaturedRelations,
|
||||||
removeFromFeaturedRelations = removeFromFeaturedRelations,
|
removeFromFeaturedRelations = removeFromFeaturedRelations,
|
||||||
deleteRelationFromObject = deleteRelationFromObject,
|
deleteRelationFromObject = deleteRelationFromObject,
|
||||||
analytics = analytics
|
analytics = analytics,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class ObjectSetGridColumnRenderingTest : TestObjectSetSetup() {
|
||||||
name = MockDataFactory.randomString(),
|
name = MockDataFactory.randomString(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.BASIC,
|
layout = ObjectType.Layout.BASIC,
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
description = "",
|
description = "",
|
||||||
isHidden = false,
|
isHidden = false,
|
||||||
smartBlockTypes = listOf(),
|
smartBlockTypes = listOf(),
|
||||||
|
@ -150,15 +150,10 @@ class ObjectSetGridColumnRenderingTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation1, relation2, relation3, relation4, relation5),
|
relations = listOf(relation1, relation2, relation3, relation4, relation5),
|
||||||
details = defaultDetails,
|
details = defaultDetails,
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = emptyList(),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(type)
|
objectTypes = listOf(type)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ class ObjectSetGridFileCellRenderingTest : TestObjectSetSetup() {
|
||||||
val objectType = ObjectType(
|
val objectType = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Movie",
|
name = "Movie",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -159,15 +159,10 @@ class ObjectSetGridFileCellRenderingTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation),
|
relations = listOf(relation),
|
||||||
details = details,
|
details = details,
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1, record2),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(objectType)
|
objectTypes = listOf(objectType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
val objectType = ObjectType(
|
val objectType = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Movie",
|
name = "Movie",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -125,14 +125,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation),
|
relations = listOf(relation),
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(objectType)
|
objectTypes = listOf(objectType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -166,7 +161,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
val objectType = ObjectType(
|
val objectType = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Movie",
|
name = "Movie",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -229,14 +224,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation),
|
relations = listOf(relation),
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(objectType)
|
objectTypes = listOf(objectType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -270,7 +260,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
val objectType = ObjectType(
|
val objectType = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Movie",
|
name = "Movie",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -333,14 +323,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation),
|
relations = listOf(relation),
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(objectType)
|
objectTypes = listOf(objectType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -374,7 +359,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
val objectType = ObjectType(
|
val objectType = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Movie",
|
name = "Movie",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -437,14 +422,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation),
|
relations = listOf(relation),
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(objectType)
|
objectTypes = listOf(objectType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -478,7 +458,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
val objectType = ObjectType(
|
val objectType = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Movie",
|
name = "Movie",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -541,14 +521,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation),
|
relations = listOf(relation),
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(objectType)
|
objectTypes = listOf(objectType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -582,7 +557,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
val objectType = ObjectType(
|
val objectType = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Movie",
|
name = "Movie",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -645,14 +620,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation),
|
relations = listOf(relation),
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(objectType)
|
objectTypes = listOf(objectType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
||||||
val objectType = ObjectType(
|
val objectType = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Movie",
|
name = "Movie",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -158,15 +158,10 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation),
|
relations = listOf(relation),
|
||||||
details = details,
|
details = details,
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1, record2),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(objectType)
|
objectTypes = listOf(objectType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -197,7 +192,7 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
||||||
val objectType = ObjectType(
|
val objectType = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Movie",
|
name = "Movie",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.PROFILE,
|
layout = ObjectType.Layout.PROFILE,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -282,15 +277,10 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation),
|
relations = listOf(relation),
|
||||||
details = details,
|
details = details,
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(objectType)
|
objectTypes = listOf(objectType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ObjectSetGridPrimitiveRelationTest : TestObjectSetSetup() {
|
||||||
name = MockDataFactory.randomString(),
|
name = MockDataFactory.randomString(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.BASIC,
|
layout = ObjectType.Layout.BASIC,
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
description = "",
|
description = "",
|
||||||
isHidden = false,
|
isHidden = false,
|
||||||
smartBlockTypes = listOf(),
|
smartBlockTypes = listOf(),
|
||||||
|
@ -190,15 +190,10 @@ class ObjectSetGridPrimitiveRelationTest : TestObjectSetSetup() {
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation1, relation2, relation3, relation4, relation5),
|
relations = listOf(relation1, relation2, relation3, relation4, relation5),
|
||||||
details = defaultDetails,
|
details = defaultDetails,
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1, record2),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(type)
|
objectTypes = listOf(type)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class ObjectSetGridTagCellRenderingTest : TestObjectSetSetup() {
|
||||||
val objectType = ObjectType(
|
val objectType = ObjectType(
|
||||||
url = MockDataFactory.randomUuid(),
|
url = MockDataFactory.randomUuid(),
|
||||||
name = "Film",
|
name = "Film",
|
||||||
relations = emptyList(),
|
relationLinks = emptyList(),
|
||||||
emoji = MockDataFactory.randomString(),
|
emoji = MockDataFactory.randomString(),
|
||||||
layout = ObjectType.Layout.BASIC ,
|
layout = ObjectType.Layout.BASIC ,
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -152,16 +152,11 @@ class ObjectSetGridTagCellRenderingTest : TestObjectSetSetup() {
|
||||||
val set = listOf(root, header, title, dataview)
|
val set = listOf(root, header, title, dataview)
|
||||||
|
|
||||||
stubInterceptEvents()
|
stubInterceptEvents()
|
||||||
stubSetActiveViewer()
|
|
||||||
stubInterceptThreadStatus()
|
stubInterceptThreadStatus()
|
||||||
stubOpenObjectSetWithRecord(
|
stubOpenObjectSetWithRecord(
|
||||||
set = set,
|
set = set,
|
||||||
relations = listOf(relation),
|
relations = listOf(relation),
|
||||||
details = details,
|
details = details,
|
||||||
viewer = viewer.id,
|
|
||||||
dataview = dataview.id,
|
|
||||||
records = listOf(record1, record2),
|
|
||||||
total = 1,
|
|
||||||
objectTypes = listOf(objectType)
|
objectTypes = listOf(objectType)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,8 @@ import androidx.fragment.app.testing.launchFragmentInContainer
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.analytics.base.Analytics
|
import com.anytypeio.anytype.analytics.base.Analytics
|
||||||
import com.anytypeio.anytype.core_models.Block
|
import com.anytypeio.anytype.core_models.Block
|
||||||
import com.anytypeio.anytype.core_models.DVFilter
|
|
||||||
import com.anytypeio.anytype.core_models.DVRecord
|
|
||||||
import com.anytypeio.anytype.core_models.DVSort
|
|
||||||
import com.anytypeio.anytype.core_models.Event
|
import com.anytypeio.anytype.core_models.Event
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
import com.anytypeio.anytype.core_models.Key
|
|
||||||
import com.anytypeio.anytype.core_models.ObjectType
|
import com.anytypeio.anytype.core_models.ObjectType
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.Relation
|
||||||
|
@ -26,14 +22,19 @@ import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.cover.SetDocCoverImage
|
import com.anytypeio.anytype.domain.cover.SetDocCoverImage
|
||||||
import com.anytypeio.anytype.domain.dataview.SetDataViewSource
|
import com.anytypeio.anytype.domain.dataview.SetDataViewSource
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddNewRelationToDataView
|
import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewObject
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewRecord
|
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
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.ObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.page.CloseBlock
|
import com.anytypeio.anytype.domain.page.CloseBlock
|
||||||
|
import com.anytypeio.anytype.domain.page.CreateNewObject
|
||||||
|
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.OpenObjectSet
|
||||||
import com.anytypeio.anytype.domain.status.InterceptThreadStatus
|
import com.anytypeio.anytype.domain.status.InterceptThreadStatus
|
||||||
import com.anytypeio.anytype.domain.status.ThreadStatusChannel
|
import com.anytypeio.anytype.domain.status.ThreadStatusChannel
|
||||||
|
@ -43,14 +44,9 @@ import com.anytypeio.anytype.domain.unsplash.UnsplashRepository
|
||||||
import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider
|
import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider
|
||||||
import com.anytypeio.anytype.presentation.common.Action
|
import com.anytypeio.anytype.presentation.common.Action
|
||||||
import com.anytypeio.anytype.presentation.common.Delegator
|
import com.anytypeio.anytype.presentation.common.Delegator
|
||||||
import com.anytypeio.anytype.domain.page.CreateNewObject
|
|
||||||
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.presentation.editor.cover.CoverImageHashProvider
|
import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetPaginator
|
import com.anytypeio.anytype.presentation.sets.ObjectSetPaginator
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetRecordCache
|
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetReducer
|
import com.anytypeio.anytype.presentation.sets.ObjectSetReducer
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory
|
import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory
|
||||||
|
@ -68,11 +64,10 @@ import org.mockito.kotlin.stub
|
||||||
abstract class TestObjectSetSetup {
|
abstract class TestObjectSetSetup {
|
||||||
|
|
||||||
private lateinit var openObjectSet: OpenObjectSet
|
private lateinit var openObjectSet: OpenObjectSet
|
||||||
private lateinit var addDataViewRelation: AddNewRelationToDataView
|
|
||||||
private lateinit var updateDataViewViewer: UpdateDataViewViewer
|
private lateinit var updateDataViewViewer: UpdateDataViewViewer
|
||||||
private lateinit var setObjectDetails: UpdateDetail
|
private lateinit var setObjectDetails: UpdateDetail
|
||||||
private lateinit var updateText: UpdateText
|
private lateinit var updateText: UpdateText
|
||||||
private lateinit var createDataViewRecord: CreateDataViewRecord
|
private lateinit var createDataViewObject: CreateDataViewObject
|
||||||
private lateinit var closeBlock: CloseBlock
|
private lateinit var closeBlock: CloseBlock
|
||||||
private lateinit var interceptThreadStatus: InterceptThreadStatus
|
private lateinit var interceptThreadStatus: InterceptThreadStatus
|
||||||
private lateinit var setDocCoverImage: SetDocCoverImage
|
private lateinit var setDocCoverImage: SetDocCoverImage
|
||||||
|
@ -109,17 +104,17 @@ abstract class TestObjectSetSetup {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var createNewObject: CreateNewObject
|
lateinit var createNewObject: CreateNewObject
|
||||||
|
|
||||||
lateinit var getTemplates: GetTemplates
|
private lateinit var getTemplates: GetTemplates
|
||||||
|
|
||||||
private val session = ObjectSetSession()
|
private val session = ObjectSetSession()
|
||||||
private val reducer = ObjectSetReducer()
|
private val reducer = ObjectSetReducer()
|
||||||
private val dispatcher: Dispatcher<Payload> = Dispatcher.Default()
|
private val dispatcher: Dispatcher<Payload> = Dispatcher.Default()
|
||||||
private val objectSetRecordCache = ObjectSetRecordCache()
|
|
||||||
private val paginator = ObjectSetPaginator()
|
private val paginator = ObjectSetPaginator()
|
||||||
private val store: ObjectStore = DefaultObjectStore()
|
private val store: ObjectStore = DefaultObjectStore()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
|
|
||||||
lateinit var database: ObjectSetDatabase
|
private lateinit var database: ObjectSetDatabase
|
||||||
lateinit var dataViewSubscriptionContainer: DataViewSubscriptionContainer
|
private lateinit var dataViewSubscriptionContainer: DataViewSubscriptionContainer
|
||||||
|
|
||||||
val ctx : Id = MockDataFactory.randomUuid()
|
val ctx : Id = MockDataFactory.randomUuid()
|
||||||
|
|
||||||
|
@ -144,16 +139,15 @@ abstract class TestObjectSetSetup {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val delegator = Delegator.Default<Action>()
|
private val delegator = Delegator.Default<Action>()
|
||||||
|
|
||||||
open fun setup() {
|
open fun setup() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
|
|
||||||
setDataViewSource = SetDataViewSource(repo)
|
setDataViewSource = SetDataViewSource(repo)
|
||||||
addDataViewRelation = AddNewRelationToDataView(repo)
|
|
||||||
updateText = UpdateText(repo)
|
updateText = UpdateText(repo)
|
||||||
openObjectSet = OpenObjectSet(repo, auth)
|
openObjectSet = OpenObjectSet(repo, auth)
|
||||||
createDataViewRecord = CreateDataViewRecord(repo)
|
createDataViewObject = CreateDataViewObject(repo)
|
||||||
setObjectDetails = UpdateDetail(repo)
|
setObjectDetails = UpdateDetail(repo)
|
||||||
updateDataViewViewer = UpdateDataViewViewer(repo)
|
updateDataViewViewer = UpdateDataViewViewer(repo)
|
||||||
interceptThreadStatus = InterceptThreadStatus(channel = threadStatusChannel)
|
interceptThreadStatus = InterceptThreadStatus(channel = threadStatusChannel)
|
||||||
|
@ -183,11 +177,10 @@ abstract class TestObjectSetSetup {
|
||||||
TestObjectSetFragment.testVmFactory = ObjectSetViewModelFactory(
|
TestObjectSetFragment.testVmFactory = ObjectSetViewModelFactory(
|
||||||
openObjectSet = openObjectSet,
|
openObjectSet = openObjectSet,
|
||||||
closeBlock = closeBlock,
|
closeBlock = closeBlock,
|
||||||
addDataViewRelation = addDataViewRelation,
|
|
||||||
interceptEvents = interceptEvents,
|
interceptEvents = interceptEvents,
|
||||||
interceptThreadStatus = interceptThreadStatus,
|
interceptThreadStatus = interceptThreadStatus,
|
||||||
updateDataViewViewer = updateDataViewViewer,
|
updateDataViewViewer = updateDataViewViewer,
|
||||||
createDataViewRecord = createDataViewRecord,
|
createDataViewObject = createDataViewObject,
|
||||||
setObjectDetails = setObjectDetails,
|
setObjectDetails = setObjectDetails,
|
||||||
updateText = updateText,
|
updateText = updateText,
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
|
@ -195,7 +188,6 @@ abstract class TestObjectSetSetup {
|
||||||
session = session,
|
session = session,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
reducer = reducer,
|
reducer = reducer,
|
||||||
objectSetRecordCache = objectSetRecordCache,
|
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
downloadUnsplashImage = downloadUnsplashImage,
|
downloadUnsplashImage = downloadUnsplashImage,
|
||||||
setDocCoverImage = setDocCoverImage,
|
setDocCoverImage = setDocCoverImage,
|
||||||
|
@ -206,7 +198,8 @@ abstract class TestObjectSetSetup {
|
||||||
cancelSearchSubscription = cancelSearchSubscription,
|
cancelSearchSubscription = cancelSearchSubscription,
|
||||||
paginator = paginator,
|
paginator = paginator,
|
||||||
database = database,
|
database = database,
|
||||||
dataViewSubscriptionContainer = dataViewSubscriptionContainer
|
dataViewSubscriptionContainer = dataViewSubscriptionContainer,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,24 +209,6 @@ abstract class TestObjectSetSetup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("To be deleted")
|
|
||||||
fun stubSetActiveViewer() {
|
|
||||||
repo.stub {
|
|
||||||
onBlocking {
|
|
||||||
setActiveDataViewViewer(
|
|
||||||
context = any(),
|
|
||||||
block = any(),
|
|
||||||
view = any(),
|
|
||||||
offset = any(),
|
|
||||||
limit = any()
|
|
||||||
)
|
|
||||||
} doReturn Payload(
|
|
||||||
context = ctx,
|
|
||||||
events = emptyList()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun stubInterceptThreadStatus() {
|
fun stubInterceptThreadStatus() {
|
||||||
threadStatusChannel.stub {
|
threadStatusChannel.stub {
|
||||||
onBlocking { observe(any()) } doReturn emptyFlow()
|
onBlocking { observe(any()) } doReturn emptyFlow()
|
||||||
|
@ -263,15 +238,10 @@ abstract class TestObjectSetSetup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("To be deleted")
|
|
||||||
fun stubOpenObjectSetWithRecord(
|
fun stubOpenObjectSetWithRecord(
|
||||||
set: List<Block>,
|
set: List<Block>,
|
||||||
details: Block.Details = Block.Details(),
|
details: Block.Details = Block.Details(),
|
||||||
relations: List<Relation> = emptyList(),
|
relations: List<Relation> = emptyList(),
|
||||||
dataview: Id,
|
|
||||||
viewer: Id,
|
|
||||||
total: Int,
|
|
||||||
records: List<DVRecord>,
|
|
||||||
objectTypes: List<ObjectType>
|
objectTypes: List<ObjectType>
|
||||||
) {
|
) {
|
||||||
repo.stub {
|
repo.stub {
|
||||||
|
@ -293,35 +263,6 @@ abstract class TestObjectSetSetup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stubSearchWithSubscription(
|
|
||||||
subscription: Id,
|
|
||||||
filters: List<DVFilter>,
|
|
||||||
sorts: List<DVSort>,
|
|
||||||
afterId: Id? = null,
|
|
||||||
beforeId: Id? = null,
|
|
||||||
sources: List<Id> = emptyList(),
|
|
||||||
keys: List<Key>,
|
|
||||||
offset: Long,
|
|
||||||
limit: Int,
|
|
||||||
result: SearchResult
|
|
||||||
) {
|
|
||||||
repo.stub {
|
|
||||||
onBlocking {
|
|
||||||
searchObjectsWithSubscription(
|
|
||||||
subscription = subscription,
|
|
||||||
filters = filters,
|
|
||||||
sorts = sorts,
|
|
||||||
afterId = afterId,
|
|
||||||
beforeId = beforeId,
|
|
||||||
source = sources,
|
|
||||||
keys = keys,
|
|
||||||
limit = limit,
|
|
||||||
offset = offset
|
|
||||||
)
|
|
||||||
} doReturn result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun stubSearchWithSubscription() {
|
fun stubSearchWithSubscription() {
|
||||||
repo.stub {
|
repo.stub {
|
||||||
onBlocking {
|
onBlocking {
|
||||||
|
@ -334,7 +275,9 @@ abstract class TestObjectSetSetup {
|
||||||
source = any(),
|
source = any(),
|
||||||
keys = any(),
|
keys = any(),
|
||||||
limit = any(),
|
limit = any(),
|
||||||
offset = any()
|
offset = any(),
|
||||||
|
ignoreWorkspace = any(),
|
||||||
|
noDepSubscription = any()
|
||||||
)
|
)
|
||||||
} doReturn SearchResult(
|
} doReturn SearchResult(
|
||||||
results = emptyList(),
|
results = emptyList(),
|
||||||
|
|
|
@ -14,14 +14,20 @@ import com.anytypeio.anytype.core_models.DVFilter
|
||||||
import com.anytypeio.anytype.core_models.DVFilterCondition
|
import com.anytypeio.anytype.core_models.DVFilterCondition
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
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.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||||
|
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.search.SearchObjects
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
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.ObjectSetSession
|
||||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -58,9 +64,6 @@ class CreateSelectedFilterTest {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var gateway: Gateway
|
lateinit var gateway: Gateway
|
||||||
|
|
||||||
@Mock
|
|
||||||
lateinit var objectTypesProvider: ObjectTypesProvider
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var analytics: Analytics
|
lateinit var analytics: Analytics
|
||||||
|
|
||||||
|
@ -72,6 +75,10 @@ class CreateSelectedFilterTest {
|
||||||
private val session = ObjectSetSession()
|
private val session = ObjectSetSession()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val dispatcher = Dispatcher.Default<Payload>()
|
private val dispatcher = Dispatcher.Default<Payload>()
|
||||||
|
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
|
private val objectStore: ObjectStore = DefaultObjectStore()
|
||||||
|
private val db = ObjectSetDatabase(store = objectStore)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
@ -86,8 +93,10 @@ class CreateSelectedFilterTest {
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
searchObjects = searchObjects,
|
searchObjects = searchObjects,
|
||||||
objectSetState = state,
|
objectSetState = state,
|
||||||
objectTypesProvider = objectTypesProvider,
|
analytics = analytics,
|
||||||
analytics = analytics
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
|
storeOfRelations = storeOfRelations,
|
||||||
|
objectSetDatabase = db
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,14 +22,20 @@ import com.anytypeio.anytype.core_models.DVFilter
|
||||||
import com.anytypeio.anytype.core_models.DVFilterCondition
|
import com.anytypeio.anytype.core_models.DVFilterCondition
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
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.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||||
|
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.search.SearchObjects
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
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.ObjectSetSession
|
||||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -60,9 +66,6 @@ class ModifyInputValueFilterTest {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var repo: BlockRepository
|
lateinit var repo: BlockRepository
|
||||||
|
|
||||||
@Mock
|
|
||||||
lateinit var objectTypesProvider: ObjectTypesProvider
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var gateway: Gateway
|
lateinit var gateway: Gateway
|
||||||
|
|
||||||
|
@ -77,6 +80,10 @@ class ModifyInputValueFilterTest {
|
||||||
private val session = ObjectSetSession()
|
private val session = ObjectSetSession()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val dispatcher = Dispatcher.Default<Payload>()
|
private val dispatcher = Dispatcher.Default<Payload>()
|
||||||
|
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
|
private val objectStore: ObjectStore = DefaultObjectStore()
|
||||||
|
private val db = ObjectSetDatabase(store = objectStore)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
@ -91,8 +98,10 @@ class ModifyInputValueFilterTest {
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
searchObjects = searchObjects,
|
searchObjects = searchObjects,
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
objectTypesProvider = objectTypesProvider,
|
analytics = analytics,
|
||||||
analytics = analytics
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
|
storeOfRelations = storeOfRelations,
|
||||||
|
objectSetDatabase = db
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,20 @@ import com.anytypeio.anytype.core_models.DVFilter
|
||||||
import com.anytypeio.anytype.core_models.DVFilterCondition
|
import com.anytypeio.anytype.core_models.DVFilterCondition
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
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.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||||
|
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.search.SearchObjects
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
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.ObjectSetSession
|
||||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -60,8 +66,6 @@ class ModifyStatusFilterTest {
|
||||||
lateinit var repo: BlockRepository
|
lateinit var repo: BlockRepository
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var gateway: Gateway
|
lateinit var gateway: Gateway
|
||||||
@Mock
|
|
||||||
lateinit var objectTypesProvider: ObjectTypesProvider
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var analytics: Analytics
|
lateinit var analytics: Analytics
|
||||||
|
@ -74,6 +78,10 @@ class ModifyStatusFilterTest {
|
||||||
private val session = ObjectSetSession()
|
private val session = ObjectSetSession()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val dispatcher = Dispatcher.Default<Payload>()
|
private val dispatcher = Dispatcher.Default<Payload>()
|
||||||
|
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
|
private val objectStore: ObjectStore = DefaultObjectStore()
|
||||||
|
private val db = ObjectSetDatabase(store = objectStore)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
@ -88,8 +96,10 @@ class ModifyStatusFilterTest {
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
searchObjects = searchObjects,
|
searchObjects = searchObjects,
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
objectTypesProvider = objectTypesProvider,
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
analytics = analytics
|
analytics = analytics,
|
||||||
|
storeOfRelations = storeOfRelations,
|
||||||
|
objectSetDatabase = db
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,18 @@ import com.anytypeio.anytype.core_models.Relation
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.Gateway
|
import com.anytypeio.anytype.domain.config.Gateway
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||||
|
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.search.SearchObjects
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
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.ObjectSetSession
|
||||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -72,6 +79,10 @@ class ModifyTagFilterTest {
|
||||||
private val session = ObjectSetSession()
|
private val session = ObjectSetSession()
|
||||||
private val state = MutableStateFlow(ObjectSet.init())
|
private val state = MutableStateFlow(ObjectSet.init())
|
||||||
private val dispatcher = Dispatcher.Default<Payload>()
|
private val dispatcher = Dispatcher.Default<Payload>()
|
||||||
|
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||||
|
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||||
|
private val objectStore: ObjectStore = DefaultObjectStore()
|
||||||
|
private val db = ObjectSetDatabase(store = objectStore)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
@ -86,8 +97,10 @@ class ModifyTagFilterTest {
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
searchObjects = searchObjects,
|
searchObjects = searchObjects,
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
objectTypesProvider = objectTypesProvider,
|
analytics = analytics,
|
||||||
analytics = analytics
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
|
storeOfRelations = storeOfRelations,
|
||||||
|
objectSetDatabase = db
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,6 @@ import com.anytypeio.anytype.di.feature.CreateAccountModule
|
||||||
import com.anytypeio.anytype.di.feature.CreateBookmarkModule
|
import com.anytypeio.anytype.di.feature.CreateBookmarkModule
|
||||||
import com.anytypeio.anytype.di.feature.CreateDataViewViewerModule
|
import com.anytypeio.anytype.di.feature.CreateDataViewViewerModule
|
||||||
import com.anytypeio.anytype.di.feature.CreateObjectModule
|
import com.anytypeio.anytype.di.feature.CreateObjectModule
|
||||||
import com.anytypeio.anytype.di.feature.CreateObjectTypeModule
|
|
||||||
import com.anytypeio.anytype.di.feature.CreateSetModule
|
|
||||||
import com.anytypeio.anytype.di.feature.DataViewViewerActionModule
|
import com.anytypeio.anytype.di.feature.DataViewViewerActionModule
|
||||||
import com.anytypeio.anytype.di.feature.DebugSettingsModule
|
import com.anytypeio.anytype.di.feature.DebugSettingsModule
|
||||||
import com.anytypeio.anytype.di.feature.DocumentRelationModule
|
import com.anytypeio.anytype.di.feature.DocumentRelationModule
|
||||||
|
@ -36,12 +34,13 @@ import com.anytypeio.anytype.di.feature.ObjectIconPickerModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectLayoutModule
|
import com.anytypeio.anytype.di.feature.ObjectLayoutModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectMenuModule
|
import com.anytypeio.anytype.di.feature.ObjectMenuModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectMenuModuleBase
|
import com.anytypeio.anytype.di.feature.ObjectMenuModuleBase
|
||||||
import com.anytypeio.anytype.di.feature.ObjectRelationValueModule
|
import com.anytypeio.anytype.di.feature.ObjectObjectRelationValueModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectSearchModule
|
import com.anytypeio.anytype.di.feature.ObjectSearchModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectSetCreateBookmarkRecordModule
|
import com.anytypeio.anytype.di.feature.ObjectSetCreateBookmarkRecordModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectSetIconPickerModule
|
import com.anytypeio.anytype.di.feature.ObjectSetIconPickerModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectSetMenuModule
|
import com.anytypeio.anytype.di.feature.ObjectSetMenuModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectSetModule
|
import com.anytypeio.anytype.di.feature.ObjectSetModule
|
||||||
|
import com.anytypeio.anytype.di.feature.ObjectSetObjectRelationValueModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectSetRecordModule
|
import com.anytypeio.anytype.di.feature.ObjectSetRecordModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectSetSettingsModule
|
import com.anytypeio.anytype.di.feature.ObjectSetSettingsModule
|
||||||
import com.anytypeio.anytype.di.feature.ObjectTypeChangeModule
|
import com.anytypeio.anytype.di.feature.ObjectTypeChangeModule
|
||||||
|
@ -338,18 +337,6 @@ class ComponentManager(
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
val createSetComponent = Component {
|
|
||||||
main.createSetComponentBuilder()
|
|
||||||
.module(CreateSetModule)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
val createObjectTypeComponent = Component {
|
|
||||||
main.createObjectTypeComponentBuilder()
|
|
||||||
.module(CreateObjectTypeModule)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
val objectSetComponent = ComponentMap {
|
val objectSetComponent = ComponentMap {
|
||||||
main.objectSetComponentBuilder()
|
main.objectSetComponentBuilder()
|
||||||
.module(ObjectSetModule)
|
.module(ObjectSetModule)
|
||||||
|
@ -456,7 +443,7 @@ class ComponentManager(
|
||||||
objectSetComponent
|
objectSetComponent
|
||||||
.get(ctx)
|
.get(ctx)
|
||||||
.objectRelationValueComponent()
|
.objectRelationValueComponent()
|
||||||
.module(ObjectRelationValueModule)
|
.module(ObjectSetObjectRelationValueModule)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +459,7 @@ class ComponentManager(
|
||||||
editorComponent
|
editorComponent
|
||||||
.get(ctx)
|
.get(ctx)
|
||||||
.editDocRelationComponent()
|
.editDocRelationComponent()
|
||||||
.module(ObjectRelationValueModule)
|
.module(ObjectObjectRelationValueModule)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.anytypeio.anytype.di.feature
|
package com.anytypeio.anytype.di.feature
|
||||||
|
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerDialog
|
import com.anytypeio.anytype.core_utils.di.scope.PerDialog
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||||
import com.anytypeio.anytype.presentation.relations.add.AddObjectRelationViewModel
|
import com.anytypeio.anytype.presentation.relations.add.AddObjectRelationViewModel
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectValueProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectValueProvider
|
||||||
|
@ -34,11 +34,11 @@ object AddObjectRelationModule {
|
||||||
fun provideViewModelFactory(
|
fun provideViewModelFactory(
|
||||||
relations: ObjectRelationProvider,
|
relations: ObjectRelationProvider,
|
||||||
values: ObjectValueProvider,
|
values: ObjectValueProvider,
|
||||||
objectTypesProvider: ObjectTypesProvider,
|
storeOfObjectTypes: StoreOfObjectTypes,
|
||||||
searchObjects: SearchObjects,
|
searchObjects: SearchObjects,
|
||||||
urlBuilder: UrlBuilder
|
urlBuilder: UrlBuilder
|
||||||
): AddObjectRelationViewModel.Factory =
|
): AddObjectRelationViewModel.Factory =
|
||||||
AddObjectRelationViewModel.Factory(
|
AddObjectRelationViewModel.Factory(
|
||||||
relations, values, searchObjects, urlBuilder, objectTypesProvider
|
relations, values, searchObjects, urlBuilder, storeOfObjectTypes
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -5,11 +5,12 @@ import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerDialog
|
import com.anytypeio.anytype.core_utils.di.scope.PerDialog
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewRelationOption
|
import com.anytypeio.anytype.domain.objects.options.GetOptions
|
||||||
import com.anytypeio.anytype.domain.relations.AddObjectRelationOption
|
import com.anytypeio.anytype.domain.relations.CreateRelationOption
|
||||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel
|
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel
|
||||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider
|
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationViewModel
|
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationViewModel
|
||||||
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectValueProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectValueProvider
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -42,17 +43,21 @@ object AddObjectRelationValueModule {
|
||||||
relations: ObjectRelationProvider,
|
relations: ObjectRelationProvider,
|
||||||
values: ObjectValueProvider,
|
values: ObjectValueProvider,
|
||||||
dispatcher: Dispatcher<Payload>,
|
dispatcher: Dispatcher<Payload>,
|
||||||
addDataViewRelationOption: AddDataViewRelationOption,
|
createRelationOption: CreateRelationOption,
|
||||||
analytics: Analytics,
|
analytics: Analytics,
|
||||||
setObjectDetail: UpdateDetail,
|
setObjectDetail: UpdateDetail,
|
||||||
|
detailsProvider: ObjectDetailProvider,
|
||||||
|
getOptions: GetOptions
|
||||||
): AddOptionsRelationDVViewModel.Factory = AddOptionsRelationDVViewModel.Factory(
|
): AddOptionsRelationDVViewModel.Factory = AddOptionsRelationDVViewModel.Factory(
|
||||||
relations = relations,
|
relations = relations,
|
||||||
values = values,
|
values = values,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
addDataViewRelationOption = addDataViewRelationOption,
|
createRelationOption = createRelationOption,
|
||||||
optionsProvider = AddOptionsRelationProvider(),
|
optionsProvider = AddOptionsRelationProvider(),
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
setObjectDetail = setObjectDetail
|
setObjectDetail = setObjectDetail,
|
||||||
|
detailsProvider = detailsProvider,
|
||||||
|
getOptions = getOptions
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -62,23 +67,32 @@ object AddObjectRelationValueModule {
|
||||||
relations: ObjectRelationProvider,
|
relations: ObjectRelationProvider,
|
||||||
values: ObjectValueProvider,
|
values: ObjectValueProvider,
|
||||||
dispatcher: Dispatcher<Payload>,
|
dispatcher: Dispatcher<Payload>,
|
||||||
addObjectRelationOption: AddObjectRelationOption,
|
createRelationOption: CreateRelationOption,
|
||||||
updateDetail: UpdateDetail,
|
updateDetail: UpdateDetail,
|
||||||
analytics: Analytics
|
analytics: Analytics,
|
||||||
|
detailsProvider: ObjectDetailProvider,
|
||||||
|
getOptions: GetOptions
|
||||||
): AddOptionsRelationViewModel.Factory = AddOptionsRelationViewModel.Factory(
|
): AddOptionsRelationViewModel.Factory = AddOptionsRelationViewModel.Factory(
|
||||||
relations = relations,
|
relations = relations,
|
||||||
values = values,
|
values = values,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
addObjectRelationOption = addObjectRelationOption,
|
createRelationOption = createRelationOption,
|
||||||
updateDetail = updateDetail,
|
updateDetail = updateDetail,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
optionsProvider = AddOptionsRelationProvider()
|
optionsProvider = AddOptionsRelationProvider(),
|
||||||
|
detailProvider = detailsProvider,
|
||||||
|
getOptions = getOptions
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@PerDialog
|
@PerDialog
|
||||||
fun provideAddObjectRelationOptionUseCase(
|
fun createRelationOption(
|
||||||
repo: BlockRepository
|
repo: BlockRepository
|
||||||
): AddObjectRelationOption = AddObjectRelationOption(repo = repo)
|
): CreateRelationOption = CreateRelationOption(repo = repo)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@PerDialog
|
||||||
|
fun getOptions(repo: BlockRepository) = GetOptions(repo)
|
||||||
}
|
}
|
|
@ -1,70 +0,0 @@
|
||||||
package com.anytypeio.anytype.di.feature
|
|
||||||
|
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
|
||||||
import com.anytypeio.anytype.domain.block.interactor.sets.CreateObjectSet
|
|
||||||
import com.anytypeio.anytype.domain.block.interactor.sets.CreateObjectType
|
|
||||||
import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes
|
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
|
||||||
import com.anytypeio.anytype.domain.icon.DocumentEmojiIconProvider
|
|
||||||
import com.anytypeio.anytype.presentation.sets.CreateObjectSetViewModel
|
|
||||||
import com.anytypeio.anytype.ui.sets.CreateObjectSetFragment
|
|
||||||
import dagger.Module
|
|
||||||
import dagger.Provides
|
|
||||||
import dagger.Subcomponent
|
|
||||||
|
|
||||||
@Subcomponent(modules = [CreateSetModule::class])
|
|
||||||
@PerScreen
|
|
||||||
interface CreateSetSubComponent {
|
|
||||||
|
|
||||||
@Subcomponent.Builder
|
|
||||||
interface Builder {
|
|
||||||
fun module(module: CreateSetModule): Builder
|
|
||||||
fun build(): CreateSetSubComponent
|
|
||||||
}
|
|
||||||
|
|
||||||
fun inject(fragment: CreateObjectSetFragment)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Module
|
|
||||||
object CreateSetModule {
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@PerScreen
|
|
||||||
fun provideCreateSetViewModelFactory(
|
|
||||||
getObjectTypes: GetObjectTypes,
|
|
||||||
createObjectSet: CreateObjectSet,
|
|
||||||
createObjectType: CreateObjectType
|
|
||||||
): CreateObjectSetViewModel.Factory {
|
|
||||||
return CreateObjectSetViewModel.Factory(
|
|
||||||
getObjectTypes = getObjectTypes,
|
|
||||||
createObjectSet = createObjectSet,
|
|
||||||
createObjectType = createObjectType
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@PerScreen
|
|
||||||
fun provideCreateObjectTypeUseCase(
|
|
||||||
repo: BlockRepository,
|
|
||||||
documentEmojiProvider: DocumentEmojiIconProvider
|
|
||||||
): CreateObjectType = CreateObjectType(
|
|
||||||
repo = repo,
|
|
||||||
documentEmojiProvider = documentEmojiProvider
|
|
||||||
)
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@PerScreen
|
|
||||||
fun provideGetObjectTypesUseCase(
|
|
||||||
repo: BlockRepository
|
|
||||||
): GetObjectTypes = GetObjectTypes(repo = repo)
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@PerScreen
|
|
||||||
fun provideCreateObjectSetUseCase(
|
|
||||||
repo: BlockRepository
|
|
||||||
): CreateObjectSet = CreateObjectSet(repo = repo)
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.anytypeio.anytype.di.feature
|
|
||||||
|
|
||||||
import com.anytypeio.anytype.presentation.sets.CreateObjectTypeViewModel
|
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
|
||||||
import com.anytypeio.anytype.ui.sets.CreateObjectTypeFragment
|
|
||||||
import dagger.Module
|
|
||||||
import dagger.Provides
|
|
||||||
import dagger.Subcomponent
|
|
||||||
|
|
||||||
@Subcomponent(modules = [CreateObjectTypeModule::class])
|
|
||||||
@PerScreen
|
|
||||||
interface CreateObjectTypeSubComponent {
|
|
||||||
|
|
||||||
@Subcomponent.Builder
|
|
||||||
interface Builder {
|
|
||||||
fun module(module: CreateObjectTypeModule): Builder
|
|
||||||
fun build(): CreateObjectTypeSubComponent
|
|
||||||
}
|
|
||||||
|
|
||||||
fun inject(fragment: CreateObjectTypeFragment)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Module
|
|
||||||
object CreateObjectTypeModule {
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@PerScreen
|
|
||||||
fun provideCreateObjectTypeViewModelFactory(
|
|
||||||
): CreateObjectTypeViewModel.Factory {
|
|
||||||
return CreateObjectTypeViewModel.Factory()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,7 +16,6 @@ import com.anytypeio.anytype.domain.config.InfrastructureRepository
|
||||||
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
||||||
import com.anytypeio.anytype.domain.dashboard.interactor.CloseDashboard
|
import com.anytypeio.anytype.domain.dashboard.interactor.CloseDashboard
|
||||||
import com.anytypeio.anytype.domain.dashboard.interactor.OpenDashboard
|
import com.anytypeio.anytype.domain.dashboard.interactor.OpenDashboard
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
|
||||||
import com.anytypeio.anytype.domain.event.interactor.EventChannel
|
import com.anytypeio.anytype.domain.event.interactor.EventChannel
|
||||||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||||
import com.anytypeio.anytype.domain.launch.GetDefaultEditorType
|
import com.anytypeio.anytype.domain.launch.GetDefaultEditorType
|
||||||
|
@ -24,12 +23,14 @@ import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
import com.anytypeio.anytype.domain.objects.DeleteObjects
|
import com.anytypeio.anytype.domain.objects.DeleteObjects
|
||||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||||
import com.anytypeio.anytype.domain.objects.SetObjectListIsArchived
|
import com.anytypeio.anytype.domain.objects.SetObjectListIsArchived
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.page.CreateNewObject
|
||||||
import com.anytypeio.anytype.domain.page.CreatePage
|
import com.anytypeio.anytype.domain.page.CreatePage
|
||||||
import com.anytypeio.anytype.domain.search.CancelSearchSubscription
|
import com.anytypeio.anytype.domain.search.CancelSearchSubscription
|
||||||
import com.anytypeio.anytype.domain.search.ObjectSearchSubscriptionContainer
|
import com.anytypeio.anytype.domain.search.ObjectSearchSubscriptionContainer
|
||||||
|
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||||
import com.anytypeio.anytype.domain.search.SubscriptionEventChannel
|
import com.anytypeio.anytype.domain.search.SubscriptionEventChannel
|
||||||
import com.anytypeio.anytype.domain.templates.GetTemplates
|
import com.anytypeio.anytype.domain.templates.GetTemplates
|
||||||
import com.anytypeio.anytype.domain.page.CreateNewObject
|
|
||||||
import com.anytypeio.anytype.presentation.dashboard.HomeDashboardEventConverter
|
import com.anytypeio.anytype.presentation.dashboard.HomeDashboardEventConverter
|
||||||
import com.anytypeio.anytype.presentation.dashboard.HomeDashboardViewModelFactory
|
import com.anytypeio.anytype.presentation.dashboard.HomeDashboardViewModelFactory
|
||||||
import com.anytypeio.anytype.ui.dashboard.DashboardFragment
|
import com.anytypeio.anytype.ui.dashboard.DashboardFragment
|
||||||
|
@ -77,8 +78,9 @@ object HomeDashboardModule {
|
||||||
objectSearchSubscriptionContainer: ObjectSearchSubscriptionContainer,
|
objectSearchSubscriptionContainer: ObjectSearchSubscriptionContainer,
|
||||||
cancelSearchSubscription: CancelSearchSubscription,
|
cancelSearchSubscription: CancelSearchSubscription,
|
||||||
objectStore: ObjectStore,
|
objectStore: ObjectStore,
|
||||||
|
featureToggles: FeatureToggles,
|
||||||
createNewObject: CreateNewObject,
|
createNewObject: CreateNewObject,
|
||||||
featureToggles: FeatureToggles
|
storeOfObjectTypes: StoreOfObjectTypes
|
||||||
): HomeDashboardViewModelFactory = HomeDashboardViewModelFactory(
|
): HomeDashboardViewModelFactory = HomeDashboardViewModelFactory(
|
||||||
getProfile = getProfile,
|
getProfile = getProfile,
|
||||||
openDashboard = openDashboard,
|
openDashboard = openDashboard,
|
||||||
|
@ -97,7 +99,8 @@ object HomeDashboardModule {
|
||||||
cancelSearchSubscription = cancelSearchSubscription,
|
cancelSearchSubscription = cancelSearchSubscription,
|
||||||
objectStore = objectStore,
|
objectStore = objectStore,
|
||||||
createNewObject = createNewObject,
|
createNewObject = createNewObject,
|
||||||
featureToggles = featureToggles
|
featureToggles = featureToggles,
|
||||||
|
storeOfObjectTypes = storeOfObjectTypes
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|
|
@ -12,9 +12,8 @@ import com.anytypeio.anytype.di.feature.cover.UnsplashSubComponent
|
||||||
import com.anytypeio.anytype.di.feature.relations.RelationAddToObjectSubComponent
|
import com.anytypeio.anytype.di.feature.relations.RelationAddToObjectSubComponent
|
||||||
import com.anytypeio.anytype.di.feature.relations.RelationCreateFromScratchForObjectBlockSubComponent
|
import com.anytypeio.anytype.di.feature.relations.RelationCreateFromScratchForObjectBlockSubComponent
|
||||||
import com.anytypeio.anytype.di.feature.relations.RelationCreateFromScratchForObjectSubComponent
|
import com.anytypeio.anytype.di.feature.relations.RelationCreateFromScratchForObjectSubComponent
|
||||||
import com.anytypeio.anytype.domain.`object`.DuplicateObject
|
|
||||||
import com.anytypeio.anytype.domain.`object`.ConvertObjectToSet
|
import com.anytypeio.anytype.domain.`object`.ConvertObjectToSet
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
import com.anytypeio.anytype.domain.`object`.DuplicateObject
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||||
|
@ -51,7 +50,6 @@ import com.anytypeio.anytype.domain.clipboard.Copy
|
||||||
import com.anytypeio.anytype.domain.clipboard.Paste
|
import com.anytypeio.anytype.domain.clipboard.Paste
|
||||||
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
||||||
import com.anytypeio.anytype.domain.cover.SetDocCoverImage
|
import com.anytypeio.anytype.domain.cover.SetDocCoverImage
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.GetCompatibleObjectTypes
|
|
||||||
import com.anytypeio.anytype.domain.download.DownloadFile
|
import com.anytypeio.anytype.domain.download.DownloadFile
|
||||||
import com.anytypeio.anytype.domain.download.Downloader
|
import com.anytypeio.anytype.domain.download.Downloader
|
||||||
import com.anytypeio.anytype.domain.event.interactor.EventChannel
|
import com.anytypeio.anytype.domain.event.interactor.EventChannel
|
||||||
|
@ -61,6 +59,8 @@ import com.anytypeio.anytype.domain.icon.SetDocumentImageIcon
|
||||||
import com.anytypeio.anytype.domain.launch.GetDefaultEditorType
|
import com.anytypeio.anytype.domain.launch.GetDefaultEditorType
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
import com.anytypeio.anytype.domain.objects.SetObjectIsArchived
|
import com.anytypeio.anytype.domain.objects.SetObjectIsArchived
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.page.CloseBlock
|
import com.anytypeio.anytype.domain.page.CloseBlock
|
||||||
import com.anytypeio.anytype.domain.page.CreateDocument
|
import com.anytypeio.anytype.domain.page.CreateDocument
|
||||||
import com.anytypeio.anytype.domain.page.CreateNewDocument
|
import com.anytypeio.anytype.domain.page.CreateNewDocument
|
||||||
|
@ -74,6 +74,7 @@ import com.anytypeio.anytype.domain.page.UpdateTitle
|
||||||
import com.anytypeio.anytype.domain.page.bookmark.CreateBookmarkBlock
|
import com.anytypeio.anytype.domain.page.bookmark.CreateBookmarkBlock
|
||||||
import com.anytypeio.anytype.domain.page.bookmark.SetupBookmark
|
import com.anytypeio.anytype.domain.page.bookmark.SetupBookmark
|
||||||
import com.anytypeio.anytype.domain.relations.AddFileToObject
|
import com.anytypeio.anytype.domain.relations.AddFileToObject
|
||||||
|
import com.anytypeio.anytype.domain.relations.AddRelationToObject
|
||||||
import com.anytypeio.anytype.domain.relations.SetRelationKey
|
import com.anytypeio.anytype.domain.relations.SetRelationKey
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||||
import com.anytypeio.anytype.domain.sets.FindObjectSetForType
|
import com.anytypeio.anytype.domain.sets.FindObjectSetForType
|
||||||
|
@ -217,8 +218,6 @@ object EditorSessionModule {
|
||||||
delegator: Delegator<Action>,
|
delegator: Delegator<Action>,
|
||||||
detailModificationManager: DetailModificationManager,
|
detailModificationManager: DetailModificationManager,
|
||||||
updateDetail: UpdateDetail,
|
updateDetail: UpdateDetail,
|
||||||
getCompatibleObjectTypes: GetCompatibleObjectTypes,
|
|
||||||
objectTypesProvider: ObjectTypesProvider,
|
|
||||||
searchObjects: SearchObjects,
|
searchObjects: SearchObjects,
|
||||||
getDefaultEditorType: GetDefaultEditorType,
|
getDefaultEditorType: GetDefaultEditorType,
|
||||||
findObjectSetForType: FindObjectSetForType,
|
findObjectSetForType: FindObjectSetForType,
|
||||||
|
@ -228,6 +227,8 @@ object EditorSessionModule {
|
||||||
setDocImageIcon: SetDocumentImageIcon,
|
setDocImageIcon: SetDocumentImageIcon,
|
||||||
editorTemplateDelegate: EditorTemplateDelegate,
|
editorTemplateDelegate: EditorTemplateDelegate,
|
||||||
createNewObject: CreateNewObject,
|
createNewObject: CreateNewObject,
|
||||||
|
storeOfRelations: StoreOfRelations,
|
||||||
|
storeOfObjectTypes: StoreOfObjectTypes,
|
||||||
objectToSet: ConvertObjectToSet,
|
objectToSet: ConvertObjectToSet,
|
||||||
featureToggles: FeatureToggles,
|
featureToggles: FeatureToggles,
|
||||||
tableDelegate: EditorTableDelegate
|
tableDelegate: EditorTableDelegate
|
||||||
|
@ -250,8 +251,6 @@ object EditorSessionModule {
|
||||||
delegator = delegator,
|
delegator = delegator,
|
||||||
detailModificationManager = detailModificationManager,
|
detailModificationManager = detailModificationManager,
|
||||||
updateDetail = updateDetail,
|
updateDetail = updateDetail,
|
||||||
getCompatibleObjectTypes = getCompatibleObjectTypes,
|
|
||||||
objectTypesProvider = objectTypesProvider,
|
|
||||||
searchObjects = searchObjects,
|
searchObjects = searchObjects,
|
||||||
getDefaultEditorType = getDefaultEditorType,
|
getDefaultEditorType = getDefaultEditorType,
|
||||||
findObjectSetForType = findObjectSetForType,
|
findObjectSetForType = findObjectSetForType,
|
||||||
|
@ -262,6 +261,8 @@ object EditorSessionModule {
|
||||||
setDocImageIcon = setDocImageIcon,
|
setDocImageIcon = setDocImageIcon,
|
||||||
editorTemplateDelegate = editorTemplateDelegate,
|
editorTemplateDelegate = editorTemplateDelegate,
|
||||||
createNewObject = createNewObject,
|
createNewObject = createNewObject,
|
||||||
|
storeOfRelations = storeOfRelations,
|
||||||
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
objectToSet = objectToSet,
|
objectToSet = objectToSet,
|
||||||
featureToggles = featureToggles,
|
featureToggles = featureToggles,
|
||||||
tableDelegate = tableDelegate
|
tableDelegate = tableDelegate
|
||||||
|
@ -307,11 +308,13 @@ object EditorSessionModule {
|
||||||
fun provideDefaultBlockViewRenderer(
|
fun provideDefaultBlockViewRenderer(
|
||||||
urlBuilder: UrlBuilder,
|
urlBuilder: UrlBuilder,
|
||||||
toggleStateHolder: ToggleStateHolder,
|
toggleStateHolder: ToggleStateHolder,
|
||||||
coverImageHashProvider: CoverImageHashProvider
|
coverImageHashProvider: CoverImageHashProvider,
|
||||||
|
storeOfRelations: StoreOfRelations
|
||||||
): DefaultBlockViewRenderer = DefaultBlockViewRenderer(
|
): DefaultBlockViewRenderer = DefaultBlockViewRenderer(
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
toggleStateHolder = toggleStateHolder,
|
toggleStateHolder = toggleStateHolder,
|
||||||
coverImageHashProvider = coverImageHashProvider
|
coverImageHashProvider = coverImageHashProvider,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -831,8 +834,12 @@ object EditorUseCaseModule {
|
||||||
@Provides
|
@Provides
|
||||||
@PerScreen
|
@PerScreen
|
||||||
fun provideDefaultObjectRelationProvider(
|
fun provideDefaultObjectRelationProvider(
|
||||||
storage: Editor.Storage
|
storage: Editor.Storage,
|
||||||
): ObjectRelationProvider = DefaultObjectRelationProvider(storage.relations)
|
storeOfRelations: StoreOfRelations
|
||||||
|
): ObjectRelationProvider = DefaultObjectRelationProvider(
|
||||||
|
storage = storage,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -924,13 +931,6 @@ object EditorUseCaseModule {
|
||||||
fun provideGetDefaultPageType(repo: UserSettingsRepository): GetDefaultEditorType =
|
fun provideGetDefaultPageType(repo: UserSettingsRepository): GetDefaultEditorType =
|
||||||
GetDefaultEditorType(repo)
|
GetDefaultEditorType(repo)
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@PerScreen
|
|
||||||
fun provideGetCompatibleObjectTypesUseCase(
|
|
||||||
repository: BlockRepository
|
|
||||||
): GetCompatibleObjectTypes = GetCompatibleObjectTypes(repository)
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@PerScreen
|
@PerScreen
|
||||||
|
@ -997,6 +997,11 @@ object EditorUseCaseModule {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@PerScreen
|
||||||
|
fun provideAddRelationToObject(repo: BlockRepository) = AddRelationToObject(repo)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@PerScreen
|
@PerScreen
|
||||||
|
|
|
@ -3,9 +3,9 @@ package com.anytypeio.anytype.di.feature
|
||||||
import com.anytypeio.anytype.analytics.base.Analytics
|
import com.anytypeio.anytype.analytics.base.Analytics
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||||
import com.anytypeio.anytype.core_utils.tools.UrlValidator
|
import com.anytypeio.anytype.core_utils.tools.UrlValidator
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||||
import com.anytypeio.anytype.presentation.editor.Editor
|
import com.anytypeio.anytype.presentation.editor.Editor
|
||||||
import com.anytypeio.anytype.presentation.linking.LinkToObjectOrWebViewModelFactory
|
import com.anytypeio.anytype.presentation.linking.LinkToObjectOrWebViewModelFactory
|
||||||
import com.anytypeio.anytype.ui.linking.LinkToObjectOrWebPagesFragment
|
import com.anytypeio.anytype.ui.linking.LinkToObjectOrWebPagesFragment
|
||||||
|
@ -36,14 +36,14 @@ object LinkToObjectOrWebModule {
|
||||||
@Provides
|
@Provides
|
||||||
fun provideLinkToObjectViewModelFactory(
|
fun provideLinkToObjectViewModelFactory(
|
||||||
urlBuilder: UrlBuilder,
|
urlBuilder: UrlBuilder,
|
||||||
objectTypesProvider: ObjectTypesProvider,
|
storeOfObjectTypes: StoreOfObjectTypes,
|
||||||
searchObjects: SearchObjects,
|
searchObjects: SearchObjects,
|
||||||
analytics: Analytics,
|
analytics: Analytics,
|
||||||
stores: Editor.Storage,
|
stores: Editor.Storage,
|
||||||
urlValidator: UrlValidator
|
urlValidator: UrlValidator
|
||||||
): LinkToObjectOrWebViewModelFactory = LinkToObjectOrWebViewModelFactory(
|
): LinkToObjectOrWebViewModelFactory = LinkToObjectOrWebViewModelFactory(
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
objectTypesProvider = objectTypesProvider,
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
searchObjects = searchObjects,
|
searchObjects = searchObjects,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
stores = stores,
|
stores = stores,
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||||
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
import com.anytypeio.anytype.domain.config.FeaturesConfigProvider
|
||||||
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
||||||
import com.anytypeio.anytype.domain.device.PathProvider
|
import com.anytypeio.anytype.domain.device.PathProvider
|
||||||
|
import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager
|
||||||
import com.anytypeio.anytype.domain.theme.GetTheme
|
import com.anytypeio.anytype.domain.theme.GetTheme
|
||||||
import com.anytypeio.anytype.domain.wallpaper.ObserveWallpaper
|
import com.anytypeio.anytype.domain.wallpaper.ObserveWallpaper
|
||||||
import com.anytypeio.anytype.domain.wallpaper.RestoreWallpaper
|
import com.anytypeio.anytype.domain.wallpaper.RestoreWallpaper
|
||||||
|
@ -49,14 +50,16 @@ object MainEntryModule {
|
||||||
observeWallpaper: ObserveWallpaper,
|
observeWallpaper: ObserveWallpaper,
|
||||||
restoreWallpaper: RestoreWallpaper,
|
restoreWallpaper: RestoreWallpaper,
|
||||||
interceptAccountStatus: InterceptAccountStatus,
|
interceptAccountStatus: InterceptAccountStatus,
|
||||||
logout: Logout
|
logout: Logout,
|
||||||
|
relationsSubscriptionManager: RelationsSubscriptionManager
|
||||||
): MainViewModelFactory = MainViewModelFactory(
|
): MainViewModelFactory = MainViewModelFactory(
|
||||||
resumeAccount = resumeAccount,
|
resumeAccount = resumeAccount,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
observeWallpaper = observeWallpaper,
|
observeWallpaper = observeWallpaper,
|
||||||
restoreWallpaper = restoreWallpaper,
|
restoreWallpaper = restoreWallpaper,
|
||||||
interceptAccountStatus = interceptAccountStatus,
|
interceptAccountStatus = interceptAccountStatus,
|
||||||
logout = logout
|
logout = logout,
|
||||||
|
relationsSubscriptionManager = relationsSubscriptionManager
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|
|
@ -5,10 +5,11 @@ import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.relations.ObjectRelationList
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.relations.AddToFeaturedRelations
|
import com.anytypeio.anytype.domain.relations.AddToFeaturedRelations
|
||||||
import com.anytypeio.anytype.domain.relations.DeleteRelationFromObject
|
import com.anytypeio.anytype.domain.relations.DeleteRelationFromObject
|
||||||
|
import com.anytypeio.anytype.domain.relations.ObjectRelationList
|
||||||
import com.anytypeio.anytype.domain.relations.RemoveFromFeaturedRelations
|
import com.anytypeio.anytype.domain.relations.RemoveFromFeaturedRelations
|
||||||
import com.anytypeio.anytype.presentation.editor.Editor
|
import com.anytypeio.anytype.presentation.editor.Editor
|
||||||
import com.anytypeio.anytype.presentation.editor.editor.DetailModificationManager
|
import com.anytypeio.anytype.presentation.editor.editor.DetailModificationManager
|
||||||
|
@ -47,7 +48,8 @@ object DocumentRelationModule {
|
||||||
addToFeaturedRelations: AddToFeaturedRelations,
|
addToFeaturedRelations: AddToFeaturedRelations,
|
||||||
removeFromFeaturedRelations: RemoveFromFeaturedRelations,
|
removeFromFeaturedRelations: RemoveFromFeaturedRelations,
|
||||||
deleteRelationFromObject: DeleteRelationFromObject,
|
deleteRelationFromObject: DeleteRelationFromObject,
|
||||||
analytics: Analytics
|
analytics: Analytics,
|
||||||
|
storeOfRelations: StoreOfRelations
|
||||||
): ObjectRelationListViewModelFactory {
|
): ObjectRelationListViewModelFactory {
|
||||||
return ObjectRelationListViewModelFactory(
|
return ObjectRelationListViewModelFactory(
|
||||||
stores = stores,
|
stores = stores,
|
||||||
|
@ -59,7 +61,8 @@ object DocumentRelationModule {
|
||||||
addToFeaturedRelations = addToFeaturedRelations,
|
addToFeaturedRelations = addToFeaturedRelations,
|
||||||
removeFromFeaturedRelations = removeFromFeaturedRelations,
|
removeFromFeaturedRelations = removeFromFeaturedRelations,
|
||||||
deleteRelationFromObject = deleteRelationFromObject,
|
deleteRelationFromObject = deleteRelationFromObject,
|
||||||
analytics = analytics
|
analytics = analytics,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,9 @@ import android.content.Context
|
||||||
import com.anytypeio.anytype.analytics.base.Analytics
|
import com.anytypeio.anytype.analytics.base.Analytics
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewRelationOption
|
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||||
import com.anytypeio.anytype.domain.relations.AddFileToObject
|
import com.anytypeio.anytype.domain.relations.AddFileToObject
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
||||||
|
@ -24,12 +22,12 @@ import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.Subcomponent
|
import dagger.Subcomponent
|
||||||
|
|
||||||
@Subcomponent(modules = [ObjectRelationValueModule::class, ObjectSetObjectRelationValueModule::class])
|
@Subcomponent(modules = [ObjectSetObjectRelationValueModule::class])
|
||||||
@PerModal
|
@PerModal
|
||||||
interface ObjectSetObjectRelationValueSubComponent {
|
interface ObjectSetObjectRelationValueSubComponent {
|
||||||
@Subcomponent.Builder
|
@Subcomponent.Builder
|
||||||
interface Builder {
|
interface Builder {
|
||||||
fun module(module: ObjectRelationValueModule): Builder
|
fun module(module: ObjectSetObjectRelationValueModule): Builder
|
||||||
fun build(): ObjectSetObjectRelationValueSubComponent
|
fun build(): ObjectSetObjectRelationValueSubComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,12 +38,12 @@ interface ObjectSetObjectRelationValueSubComponent {
|
||||||
fun addRelationFileValueAddComponent() : AddFileRelationSubComponent.Builder
|
fun addRelationFileValueAddComponent() : AddFileRelationSubComponent.Builder
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcomponent(modules = [ObjectRelationValueModule::class, ObjectObjectRelationValueModule::class])
|
@Subcomponent(modules = [ObjectObjectRelationValueModule::class])
|
||||||
@PerModal
|
@PerModal
|
||||||
interface ObjectObjectRelationValueSubComponent {
|
interface ObjectObjectRelationValueSubComponent {
|
||||||
@Subcomponent.Builder
|
@Subcomponent.Builder
|
||||||
interface Builder {
|
interface Builder {
|
||||||
fun module(module: ObjectRelationValueModule): Builder
|
fun module(module: ObjectObjectRelationValueModule): Builder
|
||||||
fun build(): ObjectObjectRelationValueSubComponent
|
fun build(): ObjectObjectRelationValueSubComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,17 +54,6 @@ interface ObjectObjectRelationValueSubComponent {
|
||||||
fun addRelationFileValueAddComponent() : AddFileRelationSubComponent.Builder
|
fun addRelationFileValueAddComponent() : AddFileRelationSubComponent.Builder
|
||||||
}
|
}
|
||||||
|
|
||||||
@Module
|
|
||||||
object ObjectRelationValueModule {
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@PerModal
|
|
||||||
fun provideAddRelationOptionUseCase(
|
|
||||||
repo: BlockRepository
|
|
||||||
): AddDataViewRelationOption = AddDataViewRelationOption(repo = repo)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
object ObjectSetObjectRelationValueModule {
|
object ObjectSetObjectRelationValueModule {
|
||||||
|
|
||||||
|
@ -84,7 +71,7 @@ object ObjectSetObjectRelationValueModule {
|
||||||
relations: ObjectRelationProvider,
|
relations: ObjectRelationProvider,
|
||||||
values: ObjectValueProvider,
|
values: ObjectValueProvider,
|
||||||
details: ObjectDetailProvider,
|
details: ObjectDetailProvider,
|
||||||
types: ObjectTypesProvider,
|
storeOfObjectTypes: StoreOfObjectTypes,
|
||||||
urlBuilder: UrlBuilder,
|
urlBuilder: UrlBuilder,
|
||||||
setObjectDetails: UpdateDetail,
|
setObjectDetails: UpdateDetail,
|
||||||
addFileToObject: AddFileToObject,
|
addFileToObject: AddFileToObject,
|
||||||
|
@ -95,7 +82,7 @@ object ObjectSetObjectRelationValueModule {
|
||||||
relations = relations,
|
relations = relations,
|
||||||
values = values,
|
values = values,
|
||||||
details = details,
|
details = details,
|
||||||
types = types,
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
addFileToObject = addFileToObject,
|
addFileToObject = addFileToObject,
|
||||||
copyFileToCache = copyFileToCacheDirectory,
|
copyFileToCache = copyFileToCacheDirectory,
|
||||||
|
@ -115,7 +102,7 @@ object ObjectObjectRelationValueModule {
|
||||||
relations: ObjectRelationProvider,
|
relations: ObjectRelationProvider,
|
||||||
values: ObjectValueProvider,
|
values: ObjectValueProvider,
|
||||||
details: ObjectDetailProvider,
|
details: ObjectDetailProvider,
|
||||||
types: ObjectTypesProvider,
|
storeOfObjectTypes: StoreOfObjectTypes,
|
||||||
urlBuilder: UrlBuilder,
|
urlBuilder: UrlBuilder,
|
||||||
dispatcher: Dispatcher<Payload>,
|
dispatcher: Dispatcher<Payload>,
|
||||||
updateDetail: UpdateDetail,
|
updateDetail: UpdateDetail,
|
||||||
|
@ -126,7 +113,7 @@ object ObjectObjectRelationValueModule {
|
||||||
relations = relations,
|
relations = relations,
|
||||||
values = values,
|
values = values,
|
||||||
details = details,
|
details = details,
|
||||||
types = types,
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
updateDetail = updateDetail,
|
updateDetail = updateDetail,
|
||||||
|
|
|
@ -23,8 +23,7 @@ import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
import com.anytypeio.anytype.domain.config.UserSettingsRepository
|
||||||
import com.anytypeio.anytype.domain.cover.SetDocCoverImage
|
import com.anytypeio.anytype.domain.cover.SetDocCoverImage
|
||||||
import com.anytypeio.anytype.domain.dataview.SetDataViewSource
|
import com.anytypeio.anytype.domain.dataview.SetDataViewSource
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddNewRelationToDataView
|
import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewObject
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewRecord
|
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||||
import com.anytypeio.anytype.domain.event.interactor.EventChannel
|
import com.anytypeio.anytype.domain.event.interactor.EventChannel
|
||||||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||||
|
@ -34,6 +33,7 @@ import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||||
import com.anytypeio.anytype.domain.objects.SetObjectIsArchived
|
import com.anytypeio.anytype.domain.objects.SetObjectIsArchived
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.page.CloseBlock
|
import com.anytypeio.anytype.domain.page.CloseBlock
|
||||||
import com.anytypeio.anytype.domain.page.CreateNewObject
|
import com.anytypeio.anytype.domain.page.CreateNewObject
|
||||||
import com.anytypeio.anytype.domain.page.CreatePage
|
import com.anytypeio.anytype.domain.page.CreatePage
|
||||||
|
@ -61,14 +61,11 @@ import com.anytypeio.anytype.presentation.relations.providers.ObjectValueProvide
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetPaginator
|
import com.anytypeio.anytype.presentation.sets.ObjectSetPaginator
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetRecordCache
|
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetReducer
|
import com.anytypeio.anytype.presentation.sets.ObjectSetReducer
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory
|
import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
import com.anytypeio.anytype.presentation.util.downloader.UriFileProvider
|
|
||||||
import com.anytypeio.anytype.providers.DefaultCoverImageHashProvider
|
import com.anytypeio.anytype.providers.DefaultCoverImageHashProvider
|
||||||
import com.anytypeio.anytype.providers.DefaultUriFileProvider
|
|
||||||
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
|
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
|
||||||
import dagger.Binds
|
import dagger.Binds
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
|
@ -138,17 +135,16 @@ object ObjectSetModule {
|
||||||
fun provideObjectSetViewModelFactory(
|
fun provideObjectSetViewModelFactory(
|
||||||
openObjectSet: OpenObjectSet,
|
openObjectSet: OpenObjectSet,
|
||||||
closeBlock: CloseBlock,
|
closeBlock: CloseBlock,
|
||||||
addDataViewRelation: AddNewRelationToDataView,
|
|
||||||
updateDataViewViewer: UpdateDataViewViewer,
|
updateDataViewViewer: UpdateDataViewViewer,
|
||||||
setObjectDetails: UpdateDetail,
|
setObjectDetails: UpdateDetail,
|
||||||
updateText: UpdateText,
|
updateText: UpdateText,
|
||||||
interceptEvents: InterceptEvents,
|
interceptEvents: InterceptEvents,
|
||||||
interceptThreadStatus: InterceptThreadStatus,
|
interceptThreadStatus: InterceptThreadStatus,
|
||||||
createDataViewRecord: CreateDataViewRecord,
|
createDataViewObject: CreateDataViewObject,
|
||||||
|
createNewObject: CreateNewObject,
|
||||||
reducer: ObjectSetReducer,
|
reducer: ObjectSetReducer,
|
||||||
dispatcher: Dispatcher<Payload>,
|
dispatcher: Dispatcher<Payload>,
|
||||||
delegator: Delegator<Action>,
|
delegator: Delegator<Action>,
|
||||||
objectSetRecordCache: ObjectSetRecordCache,
|
|
||||||
urlBuilder: UrlBuilder,
|
urlBuilder: UrlBuilder,
|
||||||
coverImageHashProvider: CoverImageHashProvider,
|
coverImageHashProvider: CoverImageHashProvider,
|
||||||
session: ObjectSetSession,
|
session: ObjectSetSession,
|
||||||
|
@ -158,24 +154,22 @@ object ObjectSetModule {
|
||||||
getTemplates: GetTemplates,
|
getTemplates: GetTemplates,
|
||||||
dataViewSubscriptionContainer: DataViewSubscriptionContainer,
|
dataViewSubscriptionContainer: DataViewSubscriptionContainer,
|
||||||
cancelSearchSubscription: CancelSearchSubscription,
|
cancelSearchSubscription: CancelSearchSubscription,
|
||||||
createNewObject: CreateNewObject,
|
|
||||||
setDataViewSource: SetDataViewSource,
|
setDataViewSource: SetDataViewSource,
|
||||||
database: ObjectSetDatabase,
|
database: ObjectSetDatabase,
|
||||||
paginator: ObjectSetPaginator
|
paginator: ObjectSetPaginator,
|
||||||
|
storeOfRelations: StoreOfRelations
|
||||||
): ObjectSetViewModelFactory = ObjectSetViewModelFactory(
|
): ObjectSetViewModelFactory = ObjectSetViewModelFactory(
|
||||||
openObjectSet = openObjectSet,
|
openObjectSet = openObjectSet,
|
||||||
closeBlock = closeBlock,
|
closeBlock = closeBlock,
|
||||||
addDataViewRelation = addDataViewRelation,
|
|
||||||
updateDataViewViewer = updateDataViewViewer,
|
updateDataViewViewer = updateDataViewViewer,
|
||||||
setObjectDetails = setObjectDetails,
|
setObjectDetails = setObjectDetails,
|
||||||
createDataViewRecord = createDataViewRecord,
|
createDataViewObject = createDataViewObject,
|
||||||
updateText = updateText,
|
updateText = updateText,
|
||||||
interceptEvents = interceptEvents,
|
interceptEvents = interceptEvents,
|
||||||
interceptThreadStatus = interceptThreadStatus,
|
interceptThreadStatus = interceptThreadStatus,
|
||||||
reducer = reducer,
|
reducer = reducer,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
delegator = delegator,
|
delegator = delegator,
|
||||||
objectSetRecordCache = objectSetRecordCache,
|
|
||||||
coverImageHashProvider = coverImageHashProvider,
|
coverImageHashProvider = coverImageHashProvider,
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
session = session,
|
session = session,
|
||||||
|
@ -188,7 +182,8 @@ object ObjectSetModule {
|
||||||
cancelSearchSubscription = cancelSearchSubscription,
|
cancelSearchSubscription = cancelSearchSubscription,
|
||||||
setDataViewSource = setDataViewSource,
|
setDataViewSource = setDataViewSource,
|
||||||
database = database,
|
database = database,
|
||||||
paginator = paginator
|
paginator = paginator,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -234,13 +229,6 @@ object ObjectSetModule {
|
||||||
auth: AuthRepository
|
auth: AuthRepository
|
||||||
): OpenObjectSet = OpenObjectSet(repo = repo, auth = auth)
|
): OpenObjectSet = OpenObjectSet(repo = repo, auth = auth)
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@PerScreen
|
|
||||||
fun provideAddDataViewRelationUseCase(
|
|
||||||
repo: BlockRepository
|
|
||||||
): AddNewRelationToDataView = AddNewRelationToDataView(repo = repo)
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@PerScreen
|
@PerScreen
|
||||||
|
@ -253,7 +241,7 @@ object ObjectSetModule {
|
||||||
@PerScreen
|
@PerScreen
|
||||||
fun provideCreateDataViewRecordUseCase(
|
fun provideCreateDataViewRecordUseCase(
|
||||||
repo: BlockRepository
|
repo: BlockRepository
|
||||||
): CreateDataViewRecord = CreateDataViewRecord(repo = repo)
|
): CreateDataViewObject = CreateDataViewObject(repo = repo)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -315,17 +303,16 @@ object ObjectSetModule {
|
||||||
@PerScreen
|
@PerScreen
|
||||||
fun provideDelegator(): Delegator<Action> = Delegator.Default()
|
fun provideDelegator(): Delegator<Action> = Delegator.Default()
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@PerScreen
|
|
||||||
fun provideObjectSetRecordCache(): ObjectSetRecordCache = ObjectSetRecordCache()
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@PerScreen
|
@PerScreen
|
||||||
fun provideDataViewObjectRelationProvider(
|
fun provideDataViewObjectRelationProvider(
|
||||||
state: StateFlow<ObjectSet>
|
state: StateFlow<ObjectSet>,
|
||||||
): ObjectRelationProvider = DataViewObjectRelationProvider(state)
|
storeOfRelations: StoreOfRelations
|
||||||
|
): ObjectRelationProvider = DataViewObjectRelationProvider(
|
||||||
|
objectSetState = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package com.anytypeio.anytype.di.feature;
|
package com.anytypeio.anytype.di.feature;
|
||||||
|
|
||||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetRecordCache
|
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetRecordViewModel
|
import com.anytypeio.anytype.presentation.sets.ObjectSetRecordViewModel
|
||||||
import com.anytypeio.anytype.ui.sets.modals.SetObjectSetRecordNameFragment
|
import com.anytypeio.anytype.ui.sets.modals.SetObjectSetRecordNameFragment
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.Subcomponent
|
import dagger.Subcomponent
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import javax.inject.Named
|
||||||
import javax.inject.Scope
|
import javax.inject.Scope
|
||||||
|
|
||||||
@Subcomponent(modules = [ObjectSetRecordModule::class])
|
@Subcomponent(modules = [ObjectSetRecordModule::class])
|
||||||
|
@ -25,20 +24,18 @@ interface ObjectSetRecordSubComponent {
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
object ObjectSetRecordModule {
|
object ObjectSetRecordModule {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@ObjectSetRecordScope
|
@ObjectSetRecordScope
|
||||||
fun provideObjectSetRecordViewModelFactory(
|
fun provideObjectSetRecordViewModelFactory(
|
||||||
setObjectDetails: UpdateDetail,
|
setObjectDetails: UpdateDetail,
|
||||||
objectSetState: StateFlow<ObjectSet>,
|
@Named("object-set-store") objectStore: ObjectStore
|
||||||
objectSetRecordCache: ObjectSetRecordCache
|
|
||||||
): ObjectSetRecordViewModel.Factory = ObjectSetRecordViewModel.Factory(
|
): ObjectSetRecordViewModel.Factory = ObjectSetRecordViewModel.Factory(
|
||||||
setObjectDetails = setObjectDetails,
|
setObjectDetails = setObjectDetails,
|
||||||
objectSetRecordCache = objectSetRecordCache
|
objectStore = objectStore
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scope
|
@Scope
|
||||||
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
annotation class ObjectSetRecordScope
|
annotation class ObjectSetRecordScope
|
|
@ -6,6 +6,7 @@ import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.ModifyDataViewViewerRelationOrder
|
import com.anytypeio.anytype.domain.dataview.interactor.ModifyDataViewViewerRelationOrder
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
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.domain.relations.DeleteRelationFromDataView
|
||||||
import com.anytypeio.anytype.presentation.relations.ObjectSetSettingsViewModel
|
import com.anytypeio.anytype.presentation.relations.ObjectSetSettingsViewModel
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||||
|
@ -42,6 +43,7 @@ object ObjectSetSettingsModule {
|
||||||
modifyViewerRelationOrder: ModifyDataViewViewerRelationOrder,
|
modifyViewerRelationOrder: ModifyDataViewViewerRelationOrder,
|
||||||
updateDataViewViewer: UpdateDataViewViewer,
|
updateDataViewViewer: UpdateDataViewViewer,
|
||||||
deleteRelationFromDataView: DeleteRelationFromDataView,
|
deleteRelationFromDataView: DeleteRelationFromDataView,
|
||||||
|
store: StoreOfRelations,
|
||||||
analytics: Analytics
|
analytics: Analytics
|
||||||
): ObjectSetSettingsViewModel.Factory = ObjectSetSettingsViewModel.Factory(
|
): ObjectSetSettingsViewModel.Factory = ObjectSetSettingsViewModel.Factory(
|
||||||
state = state,
|
state = state,
|
||||||
|
@ -50,7 +52,8 @@ object ObjectSetSettingsModule {
|
||||||
modifyViewerRelationOrder = modifyViewerRelationOrder,
|
modifyViewerRelationOrder = modifyViewerRelationOrder,
|
||||||
updateDataViewViewer = updateDataViewViewer,
|
updateDataViewViewer = updateDataViewViewer,
|
||||||
deleteRelationFromDataView = deleteRelationFromDataView,
|
deleteRelationFromDataView = deleteRelationFromDataView,
|
||||||
analytics = analytics
|
analytics = analytics,
|
||||||
|
store = store,
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|
|
@ -2,9 +2,14 @@ package com.anytypeio.anytype.di.feature
|
||||||
|
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.GetCompatibleObjectTypes
|
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||||
import com.anytypeio.anytype.presentation.objects.ObjectTypeChangeViewModelFactory
|
import com.anytypeio.anytype.presentation.objects.ObjectTypeChangeViewModelFactory
|
||||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment
|
import com.anytypeio.anytype.ui.objects.types.pickers.AppDefaultObjectTypeFragment
|
||||||
|
import com.anytypeio.anytype.ui.objects.types.pickers.DataViewSelectSourceFragment
|
||||||
|
import com.anytypeio.anytype.ui.objects.types.pickers.DraftObjectSelectTypeFragment
|
||||||
|
import com.anytypeio.anytype.ui.objects.types.pickers.EmptyDataViewSelectSourceFragment
|
||||||
|
import com.anytypeio.anytype.ui.objects.types.pickers.ObjectSelectTypeFragment
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.Subcomponent
|
import dagger.Subcomponent
|
||||||
|
@ -19,7 +24,11 @@ interface ObjectTypeChangeSubComponent {
|
||||||
fun build(): ObjectTypeChangeSubComponent
|
fun build(): ObjectTypeChangeSubComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
fun inject(fragment: ObjectTypeChangeFragment)
|
fun inject(fragment: DraftObjectSelectTypeFragment)
|
||||||
|
fun inject(fragment: ObjectSelectTypeFragment)
|
||||||
|
fun inject(fragment: DataViewSelectSourceFragment)
|
||||||
|
fun inject(fragment: EmptyDataViewSelectSourceFragment)
|
||||||
|
fun inject(fragment: AppDefaultObjectTypeFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
|
@ -29,17 +38,17 @@ object ObjectTypeChangeModule {
|
||||||
@Provides
|
@Provides
|
||||||
@PerScreen
|
@PerScreen
|
||||||
fun provideObjectTypeViewModelFactory(
|
fun provideObjectTypeViewModelFactory(
|
||||||
getCompatibleObjectTypes: GetCompatibleObjectTypes
|
storeOfObjectTypes: StoreOfObjectTypes
|
||||||
): ObjectTypeChangeViewModelFactory {
|
): ObjectTypeChangeViewModelFactory {
|
||||||
return ObjectTypeChangeViewModelFactory(
|
return ObjectTypeChangeViewModelFactory(
|
||||||
getCompatibleObjectTypes = getCompatibleObjectTypes
|
storeOfObjectTypes = storeOfObjectTypes
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@PerScreen
|
@PerScreen
|
||||||
fun provideGetCompatibleObjectTypesUseCase(
|
fun provideSearchObjectsUseCase(
|
||||||
repository: BlockRepository
|
repository: BlockRepository
|
||||||
): GetCompatibleObjectTypes = GetCompatibleObjectTypes(repository)
|
): SearchObjects = SearchObjects(repository)
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewViewerSort
|
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewViewerSort
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||||
import com.anytypeio.anytype.presentation.sets.SelectSortRelationViewModel
|
import com.anytypeio.anytype.presentation.sets.SelectSortRelationViewModel
|
||||||
|
@ -37,12 +38,14 @@ object SelectSortRelationModule {
|
||||||
session: ObjectSetSession,
|
session: ObjectSetSession,
|
||||||
dispatcher: Dispatcher<Payload>,
|
dispatcher: Dispatcher<Payload>,
|
||||||
addDataViewViewerSort: AddDataViewViewerSort,
|
addDataViewViewerSort: AddDataViewViewerSort,
|
||||||
|
storeOfRelations: StoreOfRelations,
|
||||||
analytics: Analytics
|
analytics: Analytics
|
||||||
): SelectSortRelationViewModel.Factory = SelectSortRelationViewModel.Factory(
|
): SelectSortRelationViewModel.Factory = SelectSortRelationViewModel.Factory(
|
||||||
state = state,
|
state = state,
|
||||||
session = session,
|
session = session,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
addDataViewViewerSort = addDataViewViewerSort,
|
addDataViewViewerSort = addDataViewViewerSort,
|
||||||
|
storeOfRelations = storeOfRelations,
|
||||||
analytics = analytics
|
analytics = analytics
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ import com.anytypeio.anytype.domain.launch.GetDefaultEditorType
|
||||||
import com.anytypeio.anytype.domain.launch.SetDefaultEditorType
|
import com.anytypeio.anytype.domain.launch.SetDefaultEditorType
|
||||||
import com.anytypeio.anytype.domain.misc.AppActionManager
|
import com.anytypeio.anytype.domain.misc.AppActionManager
|
||||||
import com.anytypeio.anytype.domain.page.CreatePage
|
import com.anytypeio.anytype.domain.page.CreatePage
|
||||||
|
import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager
|
||||||
|
import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager
|
||||||
import com.anytypeio.anytype.presentation.splash.SplashViewModelFactory
|
import com.anytypeio.anytype.presentation.splash.SplashViewModelFactory
|
||||||
import com.anytypeio.anytype.ui.splash.SplashFragment
|
import com.anytypeio.anytype.ui.splash.SplashFragment
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
|
@ -48,23 +50,25 @@ object SplashModule {
|
||||||
launchAccount: LaunchAccount,
|
launchAccount: LaunchAccount,
|
||||||
launchWallet: LaunchWallet,
|
launchWallet: LaunchWallet,
|
||||||
analytics: Analytics,
|
analytics: Analytics,
|
||||||
storeObjectTypes: StoreObjectTypes,
|
|
||||||
getLastOpenedObject: GetLastOpenedObject,
|
getLastOpenedObject: GetLastOpenedObject,
|
||||||
getDefaultEditorType: GetDefaultEditorType,
|
getDefaultEditorType: GetDefaultEditorType,
|
||||||
setDefaultEditorType: SetDefaultEditorType,
|
setDefaultEditorType: SetDefaultEditorType,
|
||||||
createPage: CreatePage,
|
createPage: CreatePage,
|
||||||
appActionManager: AppActionManager
|
appActionManager: AppActionManager,
|
||||||
|
relationsSubscriptionManager: RelationsSubscriptionManager,
|
||||||
|
objectTypesSubscriptionManager: ObjectTypesSubscriptionManager
|
||||||
): SplashViewModelFactory = SplashViewModelFactory(
|
): SplashViewModelFactory = SplashViewModelFactory(
|
||||||
checkAuthorizationStatus = checkAuthorizationStatus,
|
checkAuthorizationStatus = checkAuthorizationStatus,
|
||||||
launchAccount = launchAccount,
|
launchAccount = launchAccount,
|
||||||
launchWallet = launchWallet,
|
launchWallet = launchWallet,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
storeObjectTypes = storeObjectTypes,
|
|
||||||
getLastOpenedObject = getLastOpenedObject,
|
getLastOpenedObject = getLastOpenedObject,
|
||||||
setDefaultEditorType = setDefaultEditorType,
|
setDefaultEditorType = setDefaultEditorType,
|
||||||
getDefaultEditorType = getDefaultEditorType,
|
getDefaultEditorType = getDefaultEditorType,
|
||||||
createPage = createPage,
|
createPage = createPage,
|
||||||
appActionManager = appActionManager
|
appActionManager = appActionManager,
|
||||||
|
relationsSubscriptionManager = relationsSubscriptionManager,
|
||||||
|
objectTypesSubscriptionManager = objectTypesSubscriptionManager
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.anytypeio.anytype.di.feature
|
package com.anytypeio.anytype.di.feature
|
||||||
|
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ViewerSortByViewModel
|
import com.anytypeio.anytype.presentation.sets.ViewerSortByViewModel
|
||||||
import com.anytypeio.anytype.ui.sets.ViewerSortByFragment
|
import com.anytypeio.anytype.ui.sets.ViewerSortByFragment
|
||||||
|
@ -29,8 +30,12 @@ object ViewerSortByModule {
|
||||||
@Provides
|
@Provides
|
||||||
@ViewerSortByScope
|
@ViewerSortByScope
|
||||||
fun provideViewerSortByViewModelFactory(
|
fun provideViewerSortByViewModelFactory(
|
||||||
state: StateFlow<ObjectSet>
|
state: StateFlow<ObjectSet>,
|
||||||
): ViewerSortByViewModel.Factory = ViewerSortByViewModel.Factory(state)
|
storeOfRelations: StoreOfRelations
|
||||||
|
): ViewerSortByViewModel.Factory = ViewerSortByViewModel.Factory(
|
||||||
|
state = state,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scope
|
@Scope
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.anytypeio.anytype.domain.account.RestoreAccount
|
||||||
import com.anytypeio.anytype.domain.auth.interactor.Logout
|
import com.anytypeio.anytype.domain.auth.interactor.Logout
|
||||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||||
|
import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager
|
||||||
import com.anytypeio.anytype.ext.DefaultDateHelper
|
import com.anytypeio.anytype.ext.DefaultDateHelper
|
||||||
import com.anytypeio.anytype.presentation.auth.account.DeletedAccountViewModel
|
import com.anytypeio.anytype.presentation.auth.account.DeletedAccountViewModel
|
||||||
import com.anytypeio.anytype.ui.auth.account.DeletedAccountFragment
|
import com.anytypeio.anytype.ui.auth.account.DeletedAccountFragment
|
||||||
|
@ -35,12 +36,14 @@ object DeletedAccountModule {
|
||||||
restoreAccount: RestoreAccount,
|
restoreAccount: RestoreAccount,
|
||||||
logout: Logout,
|
logout: Logout,
|
||||||
helper: DateHelper,
|
helper: DateHelper,
|
||||||
analytics: Analytics
|
analytics: Analytics,
|
||||||
|
relationsSubscriptionManager: RelationsSubscriptionManager
|
||||||
): DeletedAccountViewModel.Factory = DeletedAccountViewModel.Factory(
|
): DeletedAccountViewModel.Factory = DeletedAccountViewModel.Factory(
|
||||||
restoreAccount = restoreAccount,
|
restoreAccount = restoreAccount,
|
||||||
logout = logout,
|
logout = logout,
|
||||||
helper = helper,
|
helper = helper,
|
||||||
analytics = analytics
|
analytics = analytics,
|
||||||
|
relationsSubscriptionManager = relationsSubscriptionManager
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|
|
@ -5,9 +5,10 @@ import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerDialog
|
import com.anytypeio.anytype.core_utils.di.scope.PerDialog
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddRelationToDataView
|
import com.anytypeio.anytype.domain.dataview.interactor.AddRelationToDataView
|
||||||
import com.anytypeio.anytype.domain.relations.ObjectRelationList
|
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
import com.anytypeio.anytype.domain.relations.AddRelationToObject
|
import com.anytypeio.anytype.domain.relations.AddRelationToObject
|
||||||
|
import com.anytypeio.anytype.domain.relations.ObjectRelationList
|
||||||
import com.anytypeio.anytype.presentation.relations.RelationAddToDataViewViewModel
|
import com.anytypeio.anytype.presentation.relations.RelationAddToDataViewViewModel
|
||||||
import com.anytypeio.anytype.presentation.relations.RelationAddToObjectViewModel
|
import com.anytypeio.anytype.presentation.relations.RelationAddToObjectViewModel
|
||||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
||||||
|
@ -43,12 +44,12 @@ object RelationAddToObjectModule {
|
||||||
@PerDialog
|
@PerDialog
|
||||||
fun provideViewModelFactory(
|
fun provideViewModelFactory(
|
||||||
addRelationToObject: AddRelationToObject,
|
addRelationToObject: AddRelationToObject,
|
||||||
objectRelationList: ObjectRelationList,
|
storeOfRelations: StoreOfRelations,
|
||||||
dispatcher: Dispatcher<Payload>,
|
dispatcher: Dispatcher<Payload>,
|
||||||
analytics: Analytics,
|
analytics: Analytics,
|
||||||
relationsProvider: ObjectRelationProvider,
|
relationsProvider: ObjectRelationProvider,
|
||||||
): RelationAddToObjectViewModel.Factory = RelationAddToObjectViewModel.Factory(
|
): RelationAddToObjectViewModel.Factory = RelationAddToObjectViewModel.Factory(
|
||||||
objectRelationList = objectRelationList,
|
storeOfRelations = storeOfRelations,
|
||||||
addRelationToObject = addRelationToObject,
|
addRelationToObject = addRelationToObject,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
|
@ -61,13 +62,6 @@ object RelationAddToObjectModule {
|
||||||
fun provideObjectRelationListUseCase(
|
fun provideObjectRelationListUseCase(
|
||||||
repo: BlockRepository
|
repo: BlockRepository
|
||||||
): ObjectRelationList = ObjectRelationList(repo)
|
): ObjectRelationList = ObjectRelationList(repo)
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@PerDialog
|
|
||||||
fun provideAddRelationToObjectUseCase(
|
|
||||||
repo: BlockRepository
|
|
||||||
): AddRelationToObject = AddRelationToObject(repo)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcomponent(modules = [RelationAddToDataViewModule::class])
|
@Subcomponent(modules = [RelationAddToDataViewModule::class])
|
||||||
|
@ -90,7 +84,7 @@ object RelationAddToDataViewModule {
|
||||||
@PerDialog
|
@PerDialog
|
||||||
fun provideViewModelFactory(
|
fun provideViewModelFactory(
|
||||||
addRelationToDataView: AddRelationToDataView,
|
addRelationToDataView: AddRelationToDataView,
|
||||||
objectRelationList: ObjectRelationList,
|
storeOfRelations: StoreOfRelations,
|
||||||
dispatcher: Dispatcher<Payload>,
|
dispatcher: Dispatcher<Payload>,
|
||||||
state: StateFlow<ObjectSet>,
|
state: StateFlow<ObjectSet>,
|
||||||
session: ObjectSetSession,
|
session: ObjectSetSession,
|
||||||
|
@ -98,7 +92,7 @@ object RelationAddToDataViewModule {
|
||||||
analytics: Analytics,
|
analytics: Analytics,
|
||||||
relationsProvider: ObjectRelationProvider,
|
relationsProvider: ObjectRelationProvider,
|
||||||
): RelationAddToDataViewViewModel.Factory = RelationAddToDataViewViewModel.Factory(
|
): RelationAddToDataViewViewModel.Factory = RelationAddToDataViewViewModel.Factory(
|
||||||
objectRelationList = objectRelationList,
|
storeOfRelations = storeOfRelations,
|
||||||
addRelationToDataView = addRelationToDataView,
|
addRelationToDataView = addRelationToDataView,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
state = state,
|
state = state,
|
||||||
|
|
|
@ -6,9 +6,11 @@ import com.anytypeio.anytype.core_models.RelationFormat
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.CreateFromScratch
|
import com.anytypeio.anytype.core_utils.di.scope.CreateFromScratch
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerDialog
|
import com.anytypeio.anytype.core_utils.di.scope.PerDialog
|
||||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.AddNewRelationToDataView
|
import com.anytypeio.anytype.domain.dataview.interactor.AddRelationToDataView
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||||
import com.anytypeio.anytype.domain.relations.AddNewRelationToObject
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
|
import com.anytypeio.anytype.domain.relations.AddRelationToObject
|
||||||
|
import com.anytypeio.anytype.domain.relations.CreateRelation
|
||||||
import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForDataViewViewModel
|
import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForDataViewViewModel
|
||||||
import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForObjectBlockViewModel
|
import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForObjectBlockViewModel
|
||||||
import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForObjectViewModel
|
import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForObjectViewModel
|
||||||
|
@ -48,24 +50,29 @@ object RelationCreateFromScratchForObjectModule {
|
||||||
@Provides
|
@Provides
|
||||||
@CreateFromScratch
|
@CreateFromScratch
|
||||||
fun provideViewModelFactory(
|
fun provideViewModelFactory(
|
||||||
addNewRelationToObject: AddNewRelationToObject,
|
addRelationToObject: AddRelationToObject,
|
||||||
dispatcher: Dispatcher<Payload>,
|
dispatcher: Dispatcher<Payload>,
|
||||||
analytics: Analytics,
|
analytics: Analytics,
|
||||||
createFromScratchState: StateHolder<CreateFromScratchState>
|
createFromScratchState: StateHolder<CreateFromScratchState>,
|
||||||
): RelationCreateFromScratchForObjectViewModel.Factory =
|
createRelation: CreateRelation
|
||||||
RelationCreateFromScratchForObjectViewModel.Factory(
|
) = RelationCreateFromScratchForObjectViewModel.Factory(
|
||||||
addNewRelationToObject = addNewRelationToObject,
|
addRelationToObject = addRelationToObject,
|
||||||
|
createRelation = createRelation,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
createFromScratchState = createFromScratchState
|
createFromScratchState = createFromScratchState
|
||||||
)
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@CreateFromScratch
|
@CreateFromScratch
|
||||||
fun provideAddNewRelationToObjectUseCase(
|
fun createRelation(
|
||||||
repo: BlockRepository
|
repo: BlockRepository,
|
||||||
): AddNewRelationToObject = AddNewRelationToObject(repo)
|
storeOfRelations: StoreOfRelations
|
||||||
|
) = CreateRelation(
|
||||||
|
repo = repo,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -95,6 +102,7 @@ interface RelationCreateFromScratchForDataViewSubComponent {
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
object RelationCreateFromScratchForDataViewModule {
|
object RelationCreateFromScratchForDataViewModule {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@CreateFromScratch
|
@CreateFromScratch
|
||||||
|
@ -102,20 +110,21 @@ object RelationCreateFromScratchForDataViewModule {
|
||||||
state: StateFlow<ObjectSet>,
|
state: StateFlow<ObjectSet>,
|
||||||
session: ObjectSetSession,
|
session: ObjectSetSession,
|
||||||
updateDataViewViewer: UpdateDataViewViewer,
|
updateDataViewViewer: UpdateDataViewViewer,
|
||||||
addNewRelationToDataView: AddNewRelationToDataView,
|
|
||||||
dispatcher: Dispatcher<Payload>,
|
dispatcher: Dispatcher<Payload>,
|
||||||
analytics: Analytics,
|
analytics: Analytics,
|
||||||
createFromScratchState: StateHolder<CreateFromScratchState>
|
createFromScratchState: StateHolder<CreateFromScratchState>,
|
||||||
): RelationCreateFromScratchForDataViewViewModel.Factory =
|
createRelation: CreateRelation,
|
||||||
RelationCreateFromScratchForDataViewViewModel.Factory(
|
addRelationToDataView: AddRelationToDataView
|
||||||
addNewRelationToDataView = addNewRelationToDataView,
|
) = RelationCreateFromScratchForDataViewViewModel.Factory(
|
||||||
|
addRelationToDataView = addRelationToDataView,
|
||||||
dispatcher = dispatcher,
|
dispatcher = dispatcher,
|
||||||
state = state,
|
state = state,
|
||||||
session = session,
|
session = session,
|
||||||
updateDataViewViewer = updateDataViewViewer,
|
updateDataViewViewer = updateDataViewViewer,
|
||||||
analytics = analytics,
|
analytics = analytics,
|
||||||
createFromScratchState = createFromScratchState
|
createFromScratchState = createFromScratchState,
|
||||||
)
|
createRelation = createRelation
|
||||||
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -126,6 +135,22 @@ object RelationCreateFromScratchForDataViewModule {
|
||||||
limitObjectTypes = emptyList()
|
limitObjectTypes = emptyList()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@CreateFromScratch
|
||||||
|
fun createRelation(
|
||||||
|
repo: BlockRepository,
|
||||||
|
storeOfRelations: StoreOfRelations
|
||||||
|
) = CreateRelation(
|
||||||
|
repo = repo,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@CreateFromScratch
|
||||||
|
fun addRelationToDataView(repo: BlockRepository) = AddRelationToDataView(repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcomponent(modules = [RelationCreateFromScratchForObjectBlockModule::class])
|
@Subcomponent(modules = [RelationCreateFromScratchForObjectBlockModule::class])
|
||||||
|
@ -145,28 +170,23 @@ interface RelationCreateFromScratchForObjectBlockSubComponent {
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
object RelationCreateFromScratchForObjectBlockModule {
|
object RelationCreateFromScratchForObjectBlockModule {
|
||||||
@JvmStatic
|
|
||||||
@Provides
|
|
||||||
@CreateFromScratch
|
|
||||||
fun provideViewModelFactory(
|
|
||||||
addNewRelationToObject: AddNewRelationToObject,
|
|
||||||
dispatcher: Dispatcher<Payload>,
|
|
||||||
analytics: Analytics,
|
|
||||||
createFromScratchState: StateHolder<CreateFromScratchState>
|
|
||||||
): RelationCreateFromScratchForObjectBlockViewModel.Factory =
|
|
||||||
RelationCreateFromScratchForObjectBlockViewModel.Factory(
|
|
||||||
addNewRelationToObject = addNewRelationToObject,
|
|
||||||
dispatcher = dispatcher,
|
|
||||||
analytics = analytics,
|
|
||||||
createFromScratchState = createFromScratchState
|
|
||||||
)
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
@CreateFromScratch
|
@CreateFromScratch
|
||||||
fun provideAddNewRelationToObjectUseCase(
|
fun provideViewModelFactory(
|
||||||
repo: BlockRepository
|
addRelationToObject: AddRelationToObject,
|
||||||
): AddNewRelationToObject = AddNewRelationToObject(repo)
|
createRelation: CreateRelation,
|
||||||
|
dispatcher: Dispatcher<Payload>,
|
||||||
|
analytics: Analytics,
|
||||||
|
createFromScratchState: StateHolder<CreateFromScratchState>
|
||||||
|
) = RelationCreateFromScratchForObjectBlockViewModel.Factory(
|
||||||
|
addRelationToObject = addRelationToObject,
|
||||||
|
createRelation = createRelation,
|
||||||
|
dispatcher = dispatcher,
|
||||||
|
analytics = analytics,
|
||||||
|
createFromScratchState = createFromScratchState
|
||||||
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -177,6 +197,17 @@ object RelationCreateFromScratchForObjectBlockModule {
|
||||||
limitObjectTypes = emptyList()
|
limitObjectTypes = emptyList()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@CreateFromScratch
|
||||||
|
fun createRelation(
|
||||||
|
repo: BlockRepository,
|
||||||
|
storeOfRelations: StoreOfRelations
|
||||||
|
) = CreateRelation(
|
||||||
|
repo = repo,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcomponent
|
@Subcomponent
|
||||||
|
|
|
@ -3,11 +3,13 @@ package com.anytypeio.anytype.di.feature.sets;
|
||||||
import com.anytypeio.anytype.analytics.base.Analytics
|
import com.anytypeio.anytype.analytics.base.Analytics
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
|
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
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.ObjectSetSession
|
||||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -45,7 +47,9 @@ object CreateFilterModule {
|
||||||
updateDataViewViewer: UpdateDataViewViewer,
|
updateDataViewViewer: UpdateDataViewViewer,
|
||||||
searchObjects: SearchObjects,
|
searchObjects: SearchObjects,
|
||||||
urlBuilder: UrlBuilder,
|
urlBuilder: UrlBuilder,
|
||||||
objectTypesProvider: ObjectTypesProvider,
|
storeOfObjectTypes: StoreOfObjectTypes,
|
||||||
|
storeOfRelations: StoreOfRelations,
|
||||||
|
objectSetDatabase: ObjectSetDatabase,
|
||||||
analytics: Analytics
|
analytics: Analytics
|
||||||
): FilterViewModel.Factory = FilterViewModel.Factory(
|
): FilterViewModel.Factory = FilterViewModel.Factory(
|
||||||
objectSetState = state,
|
objectSetState = state,
|
||||||
|
@ -54,7 +58,9 @@ object CreateFilterModule {
|
||||||
updateDataViewViewer = updateDataViewViewer,
|
updateDataViewViewer = updateDataViewViewer,
|
||||||
searchObjects = searchObjects,
|
searchObjects = searchObjects,
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
objectTypesProvider = objectTypesProvider,
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
|
storeOfRelations = storeOfRelations,
|
||||||
|
objectSetDatabase = objectSetDatabase,
|
||||||
analytics = analytics
|
analytics = analytics
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,13 @@ package com.anytypeio.anytype.di.feature.sets;
|
||||||
import com.anytypeio.anytype.analytics.base.Analytics
|
import com.anytypeio.anytype.analytics.base.Analytics
|
||||||
import com.anytypeio.anytype.core_models.Payload
|
import com.anytypeio.anytype.core_models.Payload
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
|
||||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
|
||||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
|
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
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.ObjectSetSession
|
||||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||||
|
@ -45,8 +47,10 @@ object ModifyFilterModule {
|
||||||
updateDataViewViewer: UpdateDataViewViewer,
|
updateDataViewViewer: UpdateDataViewViewer,
|
||||||
searchObjects: SearchObjects,
|
searchObjects: SearchObjects,
|
||||||
urlBuilder: UrlBuilder,
|
urlBuilder: UrlBuilder,
|
||||||
objectTypesProvider: ObjectTypesProvider,
|
storeOfObjectTypes: StoreOfObjectTypes,
|
||||||
analytics: Analytics
|
analytics: Analytics,
|
||||||
|
objectSetDatabase: ObjectSetDatabase,
|
||||||
|
storeOfRelations: StoreOfRelations
|
||||||
): FilterViewModel.Factory = FilterViewModel.Factory(
|
): FilterViewModel.Factory = FilterViewModel.Factory(
|
||||||
objectSetState = state,
|
objectSetState = state,
|
||||||
session = session,
|
session = session,
|
||||||
|
@ -54,7 +58,9 @@ object ModifyFilterModule {
|
||||||
updateDataViewViewer = updateDataViewViewer,
|
updateDataViewViewer = updateDataViewViewer,
|
||||||
searchObjects = searchObjects,
|
searchObjects = searchObjects,
|
||||||
urlBuilder = urlBuilder,
|
urlBuilder = urlBuilder,
|
||||||
objectTypesProvider = objectTypesProvider,
|
storeOfObjectTypes = storeOfObjectTypes,
|
||||||
|
objectSetDatabase = objectSetDatabase,
|
||||||
|
storeOfRelations = storeOfRelations,
|
||||||
analytics = analytics
|
analytics = analytics
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.anytypeio.anytype.di.feature.sets
|
package com.anytypeio.anytype.di.feature.sets
|
||||||
|
|
||||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
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.ObjectSet
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||||
import com.anytypeio.anytype.presentation.sets.SelectFilterRelationViewModel
|
import com.anytypeio.anytype.presentation.sets.SelectFilterRelationViewModel
|
||||||
|
@ -29,9 +30,11 @@ object SelectFilterRelationModule {
|
||||||
@PerModal
|
@PerModal
|
||||||
fun provideSelectSortRelationViewModelFactory(
|
fun provideSelectSortRelationViewModelFactory(
|
||||||
state: StateFlow<ObjectSet>,
|
state: StateFlow<ObjectSet>,
|
||||||
session: ObjectSetSession
|
session: ObjectSetSession,
|
||||||
|
storeOfRelations: StoreOfRelations
|
||||||
): SelectFilterRelationViewModel.Factory = SelectFilterRelationViewModel.Factory(
|
): SelectFilterRelationViewModel.Factory = SelectFilterRelationViewModel.Factory(
|
||||||
state = state,
|
state = state,
|
||||||
session = session
|
session = session,
|
||||||
|
storeOfRelations = storeOfRelations
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||||
import com.anytypeio.anytype.domain.auth.interactor.Logout
|
import com.anytypeio.anytype.domain.auth.interactor.Logout
|
||||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||||
|
import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager
|
||||||
import com.anytypeio.anytype.ui.settings.LogoutWarningFragment
|
import com.anytypeio.anytype.ui.settings.LogoutWarningFragment
|
||||||
import com.anytypeio.anytype.ui_settings.account.LogoutWarningViewModel
|
import com.anytypeio.anytype.ui_settings.account.LogoutWarningViewModel
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
|
@ -32,8 +33,13 @@ object LogoutWarningModule {
|
||||||
@PerScreen
|
@PerScreen
|
||||||
fun provideViewModelFactory(
|
fun provideViewModelFactory(
|
||||||
logout: Logout,
|
logout: Logout,
|
||||||
analytics: Analytics
|
analytics: Analytics,
|
||||||
): LogoutWarningViewModel.Factory = LogoutWarningViewModel.Factory(logout, analytics)
|
relationsSubscriptionManager: RelationsSubscriptionManager
|
||||||
|
): LogoutWarningViewModel.Factory = LogoutWarningViewModel.Factory(
|
||||||
|
logout = logout,
|
||||||
|
analytics = analytics,
|
||||||
|
relationsSubscriptionManager = relationsSubscriptionManager
|
||||||
|
)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@PerScreen
|
@PerScreen
|
||||||
|
|
|
@ -3,7 +3,23 @@ package com.anytypeio.anytype.di.main
|
||||||
import com.anytypeio.anytype.app.AndroidApplication
|
import com.anytypeio.anytype.app.AndroidApplication
|
||||||
import com.anytypeio.anytype.di.common.ComponentDependencies
|
import com.anytypeio.anytype.di.common.ComponentDependencies
|
||||||
import com.anytypeio.anytype.di.common.ComponentDependenciesKey
|
import com.anytypeio.anytype.di.common.ComponentDependenciesKey
|
||||||
import com.anytypeio.anytype.di.feature.*
|
import com.anytypeio.anytype.di.feature.ArchiveSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.AuthSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.CreateBookmarkSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.CreateObjectSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.DebugSettingsSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.EditorSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.HomeDashboardSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.KeychainPhraseSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.LinkToObjectSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.MainEntrySubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.MoveToSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.ObjectSearchSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.ObjectSetSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.ObjectTypeChangeSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.OtherSettingsSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.PageNavigationSubComponent
|
||||||
|
import com.anytypeio.anytype.di.feature.SplashSubComponent
|
||||||
import com.anytypeio.anytype.di.feature.auth.DeletedAccountSubcomponent
|
import com.anytypeio.anytype.di.feature.auth.DeletedAccountSubcomponent
|
||||||
import com.anytypeio.anytype.di.feature.settings.AboutAppSubComponent
|
import com.anytypeio.anytype.di.feature.settings.AboutAppSubComponent
|
||||||
import com.anytypeio.anytype.di.feature.settings.AccountAndDataSubComponent
|
import com.anytypeio.anytype.di.feature.settings.AccountAndDataSubComponent
|
||||||
|
@ -32,7 +48,8 @@ import javax.inject.Singleton
|
||||||
EmojiModule::class,
|
EmojiModule::class,
|
||||||
ClipboardModule::class,
|
ClipboardModule::class,
|
||||||
AnalyticsModule::class,
|
AnalyticsModule::class,
|
||||||
LocalNetworkAddressModule::class
|
LocalNetworkAddressModule::class,
|
||||||
|
SubscriptionsModule::class
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
interface MainComponent : AppearanceDependencies {
|
interface MainComponent : AppearanceDependencies {
|
||||||
|
@ -48,8 +65,6 @@ interface MainComponent : AppearanceDependencies {
|
||||||
fun moveToBuilder(): MoveToSubComponent.Builder
|
fun moveToBuilder(): MoveToSubComponent.Builder
|
||||||
fun objectSearchComponentBuilder(): ObjectSearchSubComponent.Builder
|
fun objectSearchComponentBuilder(): ObjectSearchSubComponent.Builder
|
||||||
fun mainEntryComponentBuilder(): MainEntrySubComponent.Builder
|
fun mainEntryComponentBuilder(): MainEntrySubComponent.Builder
|
||||||
fun createSetComponentBuilder(): CreateSetSubComponent.Builder
|
|
||||||
fun createObjectTypeComponentBuilder(): CreateObjectTypeSubComponent.Builder
|
|
||||||
fun objectSetComponentBuilder(): ObjectSetSubComponent.Builder
|
fun objectSetComponentBuilder(): ObjectSetSubComponent.Builder
|
||||||
fun objectTypeChangeComponent(): ObjectTypeChangeSubComponent.Builder
|
fun objectTypeChangeComponent(): ObjectTypeChangeSubComponent.Builder
|
||||||
fun wallpaperSelectComponent(): WallpaperSelectSubComponent.Builder
|
fun wallpaperSelectComponent(): WallpaperSelectSubComponent.Builder
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package com.anytypeio.anytype.di.main
|
||||||
|
|
||||||
|
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||||
|
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes
|
||||||
|
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||||
|
import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionContainer
|
||||||
|
import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager
|
||||||
|
import com.anytypeio.anytype.domain.search.RelationsSubscriptionContainer
|
||||||
|
import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager
|
||||||
|
import com.anytypeio.anytype.domain.search.SubscriptionEventChannel
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.Provides
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Module
|
||||||
|
object SubscriptionsModule {
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun relationsSubscriptionContainer(
|
||||||
|
repo: BlockRepository,
|
||||||
|
channel: SubscriptionEventChannel,
|
||||||
|
store: StoreOfRelations
|
||||||
|
): RelationsSubscriptionContainer = RelationsSubscriptionContainer(
|
||||||
|
repo = repo,
|
||||||
|
channel = channel,
|
||||||
|
store = store,
|
||||||
|
dispatchers = AppCoroutineDispatchers(
|
||||||
|
io = Dispatchers.IO,
|
||||||
|
computation = Dispatchers.Default,
|
||||||
|
main = Dispatchers.Main
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun objectTypesSubscriptionContainer(
|
||||||
|
repo: BlockRepository,
|
||||||
|
channel: SubscriptionEventChannel,
|
||||||
|
store: StoreOfObjectTypes
|
||||||
|
): ObjectTypesSubscriptionContainer = ObjectTypesSubscriptionContainer(
|
||||||
|
repo = repo,
|
||||||
|
channel = channel,
|
||||||
|
store = store,
|
||||||
|
dispatchers = AppCoroutineDispatchers(
|
||||||
|
io = Dispatchers.IO,
|
||||||
|
computation = Dispatchers.Default,
|
||||||
|
main = Dispatchers.Main
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun relationsStore(): StoreOfRelations = DefaultStoreOfRelations()
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun objectTypesStore(): StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun relationsSubscriptionManager(
|
||||||
|
subscription: RelationsSubscriptionContainer
|
||||||
|
): RelationsSubscriptionManager = RelationsSubscriptionManager(
|
||||||
|
subscription = subscription
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun objectTypesSubscriptionManager(
|
||||||
|
subscription: ObjectTypesSubscriptionContainer
|
||||||
|
): ObjectTypesSubscriptionManager = ObjectTypesSubscriptionManager(
|
||||||
|
subscription = subscription
|
||||||
|
)
|
||||||
|
}
|
|
@ -15,7 +15,6 @@ import com.anytypeio.anytype.ui.auth.account.DeletedAccountFragment
|
||||||
import com.anytypeio.anytype.ui.dashboard.DashboardFragment
|
import com.anytypeio.anytype.ui.dashboard.DashboardFragment
|
||||||
import com.anytypeio.anytype.ui.editor.EditorFragment
|
import com.anytypeio.anytype.ui.editor.EditorFragment
|
||||||
import com.anytypeio.anytype.ui.navigation.PageNavigationFragment
|
import com.anytypeio.anytype.ui.navigation.PageNavigationFragment
|
||||||
import com.anytypeio.anytype.ui.sets.CreateObjectSetFragment
|
|
||||||
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
|
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
|
||||||
import com.anytypeio.anytype.ui.templates.TemplateSelectFragment
|
import com.anytypeio.anytype.ui.templates.TemplateSelectFragment
|
||||||
|
|
||||||
|
@ -228,13 +227,6 @@ class Navigator : AppNavigation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openCreateSetScreen(ctx: Id) {
|
|
||||||
navController?.navigate(
|
|
||||||
R.id.from_desktop_to_create_sets,
|
|
||||||
bundleOf(CreateObjectSetFragment.CONTEXT_ID_KEY to ctx)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun openUserSettingsScreen() {
|
override fun openUserSettingsScreen() {
|
||||||
navController?.navigate(R.id.action_profileScreen_to_userSettingsFragment)
|
navController?.navigate(R.id.action_profileScreen_to_userSettingsFragment)
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,6 @@ abstract class NavigationFragment<BINDING : ViewBinding>(
|
||||||
is Command.OpenPageNavigationScreen -> navigation.openPageNavigation(command.target)
|
is Command.OpenPageNavigationScreen -> navigation.openPageNavigation(command.target)
|
||||||
is Command.ExitToDesktopAndOpenPage -> navigation.exitToDesktopAndOpenPage(command.pageId)
|
is Command.ExitToDesktopAndOpenPage -> navigation.exitToDesktopAndOpenPage(command.pageId)
|
||||||
is Command.OpenPageSearch -> navigation.openPageSearch()
|
is Command.OpenPageSearch -> navigation.openPageSearch()
|
||||||
is Command.OpenCreateSetScreen -> navigation.openCreateSetScreen(command.ctx)
|
|
||||||
is Command.OpenUpdateAppScreen -> navigation.openUpdateAppScreen()
|
is Command.OpenUpdateAppScreen -> navigation.openUpdateAppScreen()
|
||||||
is Command.DeletedAccountScreen -> navigation.deletedAccountScreen(command.deadline)
|
is Command.DeletedAccountScreen -> navigation.deletedAccountScreen(command.deadline)
|
||||||
is Command.OpenTemplates -> navigation.openTemplates(
|
is Command.OpenTemplates -> navigation.openTemplates(
|
||||||
|
|
|
@ -29,7 +29,6 @@ import androidx.core.view.WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_STO
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.fragment.app.setFragmentResultListener
|
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.LifecycleEventObserver
|
import androidx.lifecycle.LifecycleEventObserver
|
||||||
|
@ -48,6 +47,7 @@ import androidx.viewbinding.ViewBinding
|
||||||
import com.anytypeio.anytype.BuildConfig
|
import com.anytypeio.anytype.BuildConfig
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_models.SyncStatus
|
import com.anytypeio.anytype.core_models.SyncStatus
|
||||||
import com.anytypeio.anytype.core_models.ThemeColor
|
import com.anytypeio.anytype.core_models.ThemeColor
|
||||||
import com.anytypeio.anytype.core_models.Url
|
import com.anytypeio.anytype.core_models.Url
|
||||||
|
@ -132,10 +132,9 @@ import com.anytypeio.anytype.ui.linking.LinkToObjectOrWebPagesFragment
|
||||||
import com.anytypeio.anytype.ui.linking.OnLinkToAction
|
import com.anytypeio.anytype.ui.linking.OnLinkToAction
|
||||||
import com.anytypeio.anytype.ui.moving.MoveToFragment
|
import com.anytypeio.anytype.ui.moving.MoveToFragment
|
||||||
import com.anytypeio.anytype.ui.moving.OnMoveToAction
|
import com.anytypeio.anytype.ui.moving.OnMoveToAction
|
||||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment
|
import com.anytypeio.anytype.ui.objects.types.pickers.DraftObjectSelectTypeFragment
|
||||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment.Companion.OBJECT_IS_DRAFT_KEY
|
import com.anytypeio.anytype.ui.objects.types.pickers.ObjectSelectTypeFragment
|
||||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment.Companion.OBJECT_TYPE_REQUEST_KEY
|
import com.anytypeio.anytype.ui.objects.types.pickers.OnObjectSelectTypeAction
|
||||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment.Companion.OBJECT_TYPE_URL_KEY
|
|
||||||
import com.anytypeio.anytype.ui.objects.appearance.ObjectAppearanceSettingFragment
|
import com.anytypeio.anytype.ui.objects.appearance.ObjectAppearanceSettingFragment
|
||||||
import com.anytypeio.anytype.ui.relations.RelationAddBaseFragment.Companion.CTX_KEY
|
import com.anytypeio.anytype.ui.relations.RelationAddBaseFragment.Companion.CTX_KEY
|
||||||
import com.anytypeio.anytype.ui.relations.RelationAddResult
|
import com.anytypeio.anytype.ui.relations.RelationAddResult
|
||||||
|
@ -172,7 +171,8 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
DocumentMenuActionReceiver,
|
DocumentMenuActionReceiver,
|
||||||
ClipboardInterceptor,
|
ClipboardInterceptor,
|
||||||
OnMoveToAction,
|
OnMoveToAction,
|
||||||
OnLinkToAction {
|
OnLinkToAction,
|
||||||
|
OnObjectSelectTypeAction {
|
||||||
|
|
||||||
private val keyboardDelayJobs = mutableListOf<Job>()
|
private val keyboardDelayJobs = mutableListOf<Job>()
|
||||||
|
|
||||||
|
@ -413,15 +413,6 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
pickerDelegate.initPicker(vm, ctx)
|
pickerDelegate.initPicker(vm, ctx)
|
||||||
setFragmentResultListener(OBJECT_TYPE_REQUEST_KEY) { _, bundle ->
|
|
||||||
val type = bundle.getString(OBJECT_TYPE_URL_KEY)
|
|
||||||
val isObjectDraft = bundle.getBoolean(OBJECT_IS_DRAFT_KEY, false)
|
|
||||||
if (type != null) {
|
|
||||||
onObjectTypePicked(type = type, isObjectDraft = isObjectDraft)
|
|
||||||
} else {
|
|
||||||
toast("Cannot change object type, when new one is unknown")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setupOnBackPressedDispatcher()
|
setupOnBackPressedDispatcher()
|
||||||
getEditorSettings()
|
getEditorSettings()
|
||||||
}
|
}
|
||||||
|
@ -886,10 +877,6 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
vm.onSetRelationKeyClicked(blockId = blockId, key = key)
|
vm.onSetRelationKeyClicked(blockId = blockId, key = key)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onObjectTypePicked(type: Id, isObjectDraft: Boolean) {
|
|
||||||
vm.onObjectTypeChanged(type = type, isObjectDraft = isObjectDraft)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun execute(event: EventWrapper<Command>) {
|
private fun execute(event: EventWrapper<Command>) {
|
||||||
event.getContentIfNotHandled()?.let { command ->
|
event.getContentIfNotHandled()?.let { command ->
|
||||||
when (command) {
|
when (command) {
|
||||||
|
@ -1031,7 +1018,8 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
val fr = RelationValueFragment.new(
|
val fr = RelationValueFragment.new(
|
||||||
ctx = command.ctx,
|
ctx = command.ctx,
|
||||||
target = command.target,
|
target = command.target,
|
||||||
relation = command.relation,
|
relationId = command.relationId,
|
||||||
|
relationKey = command.relationKey,
|
||||||
targetObjectTypes = command.targetObjectTypes,
|
targetObjectTypes = command.targetObjectTypes,
|
||||||
isLocked = command.isLocked
|
isLocked = command.isLocked
|
||||||
)
|
)
|
||||||
|
@ -1041,8 +1029,9 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
val fr = RelationTextValueFragment.new(
|
val fr = RelationTextValueFragment.new(
|
||||||
ctx = command.ctx,
|
ctx = command.ctx,
|
||||||
|
relationId = command.relationId,
|
||||||
|
relationKey = command.relationKey,
|
||||||
objectId = command.target,
|
objectId = command.target,
|
||||||
relationId = command.relation,
|
|
||||||
isLocked = command.isLocked
|
isLocked = command.isLocked
|
||||||
)
|
)
|
||||||
fr.show(childFragmentManager, null)
|
fr.show(childFragmentManager, null)
|
||||||
|
@ -1052,25 +1041,27 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
val fr = RelationDateValueFragment.new(
|
val fr = RelationDateValueFragment.new(
|
||||||
ctx = command.ctx,
|
ctx = command.ctx,
|
||||||
objectId = command.target,
|
objectId = command.target,
|
||||||
relationId = command.relation
|
relationId = command.relationId,
|
||||||
|
relationKey = command.relationKey
|
||||||
)
|
)
|
||||||
fr.show(childFragmentManager, null)
|
fr.show(childFragmentManager, null)
|
||||||
}
|
}
|
||||||
Command.AddSlashWidgetTriggerToFocusedBlock -> {
|
Command.AddSlashWidgetTriggerToFocusedBlock -> {
|
||||||
binding.recycler.addTextFromSelectedStart(text = "/")
|
binding.recycler.addTextFromSelectedStart(text = "/")
|
||||||
}
|
}
|
||||||
is Command.OpenChangeObjectTypeScreen -> {
|
is Command.OpenDraftObjectSelectTypeScreen -> {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
findNavController()
|
val fr = DraftObjectSelectTypeFragment.newInstance(
|
||||||
.safeNavigate(
|
excludeTypes = command.excludedTypes
|
||||||
R.id.pageScreen,
|
)
|
||||||
R.id.objectTypeChangeScreen,
|
fr.show(childFragmentManager, null)
|
||||||
bundleOf(
|
}
|
||||||
ObjectTypeChangeFragment.ARG_SMART_BLOCK_TYPE to command.smartBlockType,
|
is Command.OpenObjectSelectTypeScreen -> {
|
||||||
ObjectTypeChangeFragment.ARG_EXCLUDED_TYPES to command.excludedTypes,
|
hideKeyboard()
|
||||||
ObjectTypeChangeFragment.OBJECT_IS_DRAFT_KEY to command.isDraft
|
val fr = ObjectSelectTypeFragment.newInstance(
|
||||||
)
|
excludeTypes = command.excludedTypes
|
||||||
)
|
)
|
||||||
|
fr.show(childFragmentManager, null)
|
||||||
}
|
}
|
||||||
is Command.OpenMoveToScreen -> {
|
is Command.OpenMoveToScreen -> {
|
||||||
jobs += lifecycleScope.launch {
|
jobs += lifecycleScope.launch {
|
||||||
|
@ -1999,19 +1990,19 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
vm.onLayoutClicked()
|
vm.onLayoutClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextValueChanged(ctx: Id, text: String, objectId: Id, relationId: Id) {
|
override fun onTextValueChanged(ctx: Id, text: String, objectId: Id, relationKey: Key) {
|
||||||
vm.onRelationTextValueChanged(
|
vm.onRelationTextValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
value = text,
|
value = text,
|
||||||
relationId = relationId
|
relationKey = relationKey
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNumberValueChanged(ctx: Id, number: Double?, objectId: Id, relationId: Id) {
|
override fun onNumberValueChanged(ctx: Id, number: Double?, objectId: Id, relationKey: Key) {
|
||||||
vm.onRelationTextValueChanged(
|
vm.onRelationTextValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
value = number,
|
value = number,
|
||||||
relationId = relationId
|
relationKey = relationKey
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2019,11 +2010,11 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
timeInSeconds: Number?,
|
timeInSeconds: Number?,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id
|
relationKey: Key
|
||||||
) {
|
) {
|
||||||
vm.onRelationTextValueChanged(
|
vm.onRelationTextValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = relationId,
|
relationKey = relationKey,
|
||||||
value = timeInSeconds
|
value = timeInSeconds
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2090,6 +2081,14 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
vm.proceedToCreateObjectAndAddToTextAsLink(name)
|
vm.proceedToCreateObjectAndAddToTextAsLink(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onProceedWithUpdateType(id: Id) {
|
||||||
|
vm.onObjectTypeChanged(type = id, isObjectDraft = false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onProceedWithDraftUpdateType(id: Id) {
|
||||||
|
vm.onObjectTypeChanged(type = id, isObjectDraft = true)
|
||||||
|
}
|
||||||
|
|
||||||
private fun observeNavBackStack() {
|
private fun observeNavBackStack() {
|
||||||
findNavController().run {
|
findNavController().run {
|
||||||
val navBackStackEntry = getBackStackEntry(R.id.pageScreen)
|
val navBackStackEntry = getBackStackEntry(R.id.pageScreen)
|
||||||
|
@ -2115,7 +2114,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
if (resultRelationAdd != null) {
|
if (resultRelationAdd != null) {
|
||||||
vm.proceedWithAddingRelationToTarget(
|
vm.proceedWithAddingRelationToTarget(
|
||||||
target = resultRelationAdd.target,
|
target = resultRelationAdd.target,
|
||||||
relation = resultRelationAdd.relation
|
relationKey = resultRelationAdd.relation
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2125,7 +2124,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
||||||
if (resultRelationNew != null) {
|
if (resultRelationNew != null) {
|
||||||
vm.proceedWithAddingRelationToTarget(
|
vm.proceedWithAddingRelationToTarget(
|
||||||
target = resultRelationNew.target,
|
target = resultRelationNew.target,
|
||||||
relation = resultRelationNew.relation
|
relationKey = resultRelationNew.relation
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,46 +5,36 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import androidx.core.os.bundleOf
|
|
||||||
import androidx.fragment.app.setFragmentResult
|
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.anytypeio.anytype.R
|
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
import com.anytypeio.anytype.core_models.SmartBlockType
|
|
||||||
import com.anytypeio.anytype.core_ui.features.objects.ObjectTypeVerticalAdapter
|
import com.anytypeio.anytype.core_ui.features.objects.ObjectTypeVerticalAdapter
|
||||||
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
||||||
import com.anytypeio.anytype.core_utils.ext.arg
|
|
||||||
import com.anytypeio.anytype.core_utils.ext.argOrNull
|
import com.anytypeio.anytype.core_utils.ext.argOrNull
|
||||||
import com.anytypeio.anytype.core_utils.ext.hideKeyboard
|
|
||||||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetTextInputFragment
|
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetTextInputFragment
|
||||||
import com.anytypeio.anytype.databinding.FragmentObjectTypeChangeBinding
|
import com.anytypeio.anytype.databinding.FragmentObjectTypeChangeBinding
|
||||||
import com.anytypeio.anytype.di.common.componentManager
|
|
||||||
import com.anytypeio.anytype.presentation.objects.ObjectTypeChangeViewModel
|
import com.anytypeio.anytype.presentation.objects.ObjectTypeChangeViewModel
|
||||||
import com.anytypeio.anytype.presentation.objects.ObjectTypeChangeViewModelFactory
|
import com.anytypeio.anytype.presentation.objects.ObjectTypeChangeViewModelFactory
|
||||||
import com.anytypeio.anytype.presentation.objects.ObjectTypeView
|
import com.anytypeio.anytype.presentation.objects.ObjectTypeView
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ObjectTypeChangeFragment :
|
abstract class BaseObjectTypeChangeFragment :
|
||||||
BaseBottomSheetTextInputFragment<FragmentObjectTypeChangeBinding>() {
|
BaseBottomSheetTextInputFragment<FragmentObjectTypeChangeBinding>() {
|
||||||
|
|
||||||
private val smartBlockType: SmartBlockType get() = arg(ARG_SMART_BLOCK_TYPE)
|
abstract fun setTitle()
|
||||||
private val excludedTypes: List<Id>
|
abstract fun startWithParams()
|
||||||
get() = argOrNull<List<Id>>(ARG_EXCLUDED_TYPES) ?: emptyList()
|
abstract fun onItemClicked(id: Id, name: String)
|
||||||
|
|
||||||
private val vm by viewModels<ObjectTypeChangeViewModel> { factory }
|
|
||||||
|
|
||||||
private val isDraft: Boolean get() = argOrNull<Boolean>(OBJECT_IS_DRAFT_KEY) ?: false
|
|
||||||
|
|
||||||
private val isSetSource: Boolean get() = argOrNull<Boolean>(ARG_IS_SET_SOURCE) ?: false
|
|
||||||
|
|
||||||
private val selectedSources : List<Id>
|
|
||||||
get() = argOrNull<List<Id>>(ARG_SOURCES) ?: emptyList()
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var factory: ObjectTypeChangeViewModelFactory
|
lateinit var factory: ObjectTypeChangeViewModelFactory
|
||||||
|
protected val vm by viewModels<ObjectTypeChangeViewModel> { factory }
|
||||||
|
|
||||||
|
protected val excludeTypes: List<Id>
|
||||||
|
get() = argOrNull<List<Id>>(ARG_EXCLUDE_TYPES) ?: emptyList()
|
||||||
|
protected val selectedTypes: List<Id>
|
||||||
|
get() = argOrNull<List<Id>>(ARG_SELECTED_TYPES) ?: emptyList()
|
||||||
|
|
||||||
private val objectTypeAdapter by lazy {
|
private val objectTypeAdapter by lazy {
|
||||||
ObjectTypeVerticalAdapter(
|
ObjectTypeVerticalAdapter(
|
||||||
|
@ -57,31 +47,19 @@ class ObjectTypeChangeFragment :
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
if (isSetSource) {
|
setTitle()
|
||||||
binding.tvTitle.text = getString(R.string.select_source)
|
|
||||||
}
|
|
||||||
binding.recycler.apply {
|
binding.recycler.apply {
|
||||||
adapter = objectTypeAdapter
|
adapter = objectTypeAdapter
|
||||||
layoutManager = LinearLayoutManager(context)
|
layoutManager = LinearLayoutManager(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeViews(views: List<ObjectTypeView.Item>) {
|
private fun observeViews(views: List<ObjectTypeView>) {
|
||||||
objectTypeAdapter.update(views)
|
objectTypeAdapter.update(views)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onItemClicked(id: String, name: String) {
|
|
||||||
val bundle = bundleOf(
|
|
||||||
OBJECT_TYPE_URL_KEY to id,
|
|
||||||
OBJECT_TYPE_NAME_KEY to name,
|
|
||||||
OBJECT_IS_DRAFT_KEY to isDraft
|
|
||||||
)
|
|
||||||
setFragmentResult(OBJECT_TYPE_REQUEST_KEY, bundle)
|
|
||||||
view?.rootView?.hideKeyboard()
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
expand()
|
expand()
|
||||||
with(lifecycleScope) {
|
with(lifecycleScope) {
|
||||||
jobs += subscribe(vm.results) { observeViews(it) }
|
jobs += subscribe(vm.results) { observeViews(it) }
|
||||||
|
@ -89,22 +67,7 @@ class ObjectTypeChangeFragment :
|
||||||
vm.onQueryChanged(it.toString())
|
vm.onQueryChanged(it.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onStart()
|
startWithParams()
|
||||||
vm.onStart(
|
|
||||||
smartBlockType = smartBlockType,
|
|
||||||
excludedTypes = excludedTypes,
|
|
||||||
isDraft = isDraft,
|
|
||||||
selectedSources = selectedSources,
|
|
||||||
isSetSource = isSetSource
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun injectDependencies() {
|
|
||||||
componentManager().objectTypeChangeComponent.get().inject(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun releaseDependencies() {
|
|
||||||
componentManager().objectTypeChangeComponent.release()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun inflateBinding(
|
override fun inflateBinding(
|
||||||
|
@ -115,13 +78,9 @@ class ObjectTypeChangeFragment :
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val ARG_SMART_BLOCK_TYPE = "arg.object-type.smart-block-type"
|
const val ARG_EXCLUDE_TYPES = "arg.object-type-change.exclude-types"
|
||||||
const val ARG_EXCLUDED_TYPES = "arg.object-type.excluded-types"
|
const val ARG_SELECTED_TYPES = "arg.object-type-change.selected-types"
|
||||||
const val ARG_IS_SET_SOURCE = "arg.object-type.is-set-source"
|
|
||||||
const val ARG_SOURCES = "arg.object-type.sources"
|
|
||||||
const val OBJECT_TYPE_URL_KEY = "object-type-url.key"
|
const val OBJECT_TYPE_URL_KEY = "object-type-url.key"
|
||||||
const val OBJECT_TYPE_NAME_KEY = "object-type-name.key"
|
|
||||||
const val OBJECT_TYPE_REQUEST_KEY = "object-type.request"
|
const val OBJECT_TYPE_REQUEST_KEY = "object-type.request"
|
||||||
const val OBJECT_IS_DRAFT_KEY = "arg.object-type-change.isDraft"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.anytypeio.anytype.ui.objects.types.pickers
|
||||||
|
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
|
import com.anytypeio.anytype.R
|
||||||
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.hideSoftInput
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.withParent
|
||||||
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
|
import com.anytypeio.anytype.ui.objects.BaseObjectTypeChangeFragment
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selecting a default object type for application
|
||||||
|
*/
|
||||||
|
class AppDefaultObjectTypeFragment : BaseObjectTypeChangeFragment() {
|
||||||
|
|
||||||
|
override fun startWithParams() {
|
||||||
|
vm.onStart(
|
||||||
|
isWithSet = false,
|
||||||
|
isWithBookmark = false,
|
||||||
|
excludeTypes = excludeTypes,
|
||||||
|
selectedTypes = emptyList(),
|
||||||
|
isSetSource = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemClicked(id: Id, name: String) {
|
||||||
|
withParent<OnObjectTypeAction> {
|
||||||
|
onProceedWithUpdateType(
|
||||||
|
id = id,
|
||||||
|
name = name
|
||||||
|
)
|
||||||
|
}
|
||||||
|
hideSoftInput()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTitle() {
|
||||||
|
binding.tvTitle.text = getString(R.string.change_type)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun injectDependencies() {
|
||||||
|
componentManager().objectTypeChangeComponent.get().inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun releaseDependencies() {
|
||||||
|
componentManager().objectTypeChangeComponent.release()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(excludeTypes: List<Id>) = AppDefaultObjectTypeFragment().apply {
|
||||||
|
arguments = bundleOf(ARG_EXCLUDE_TYPES to excludeTypes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OnObjectTypeAction {
|
||||||
|
fun onProceedWithUpdateType(id: Id, name: String)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.anytypeio.anytype.ui.objects.types.pickers
|
||||||
|
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
|
import com.anytypeio.anytype.R
|
||||||
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.hideSoftInput
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.withParent
|
||||||
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
|
import com.anytypeio.anytype.ui.objects.BaseObjectTypeChangeFragment
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selecting a source by SmartBlockType.Page for the non-empty data view
|
||||||
|
*/
|
||||||
|
class DataViewSelectSourceFragment : BaseObjectTypeChangeFragment() {
|
||||||
|
|
||||||
|
override fun startWithParams() {
|
||||||
|
vm.onStart(
|
||||||
|
isWithSet = false,
|
||||||
|
isWithBookmark = true,
|
||||||
|
excludeTypes = emptyList(),
|
||||||
|
selectedTypes = selectedTypes,
|
||||||
|
isSetSource = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemClicked(id: Id, name: String) {
|
||||||
|
withParent<OnDataViewSelectSourceAction> {
|
||||||
|
onProceedWithSelectSource(id = id)
|
||||||
|
}
|
||||||
|
hideSoftInput()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTitle() {
|
||||||
|
binding.tvTitle.text = getString(R.string.select_source)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun injectDependencies() {
|
||||||
|
componentManager().objectTypeChangeComponent.get().inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun releaseDependencies() {
|
||||||
|
componentManager().objectTypeChangeComponent.release()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(selectedTypes: List<Id>) = DataViewSelectSourceFragment().apply {
|
||||||
|
arguments = bundleOf(ARG_SELECTED_TYPES to selectedTypes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.anytypeio.anytype.ui.objects.types.pickers
|
||||||
|
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
|
import com.anytypeio.anytype.R
|
||||||
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.hideSoftInput
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.withParent
|
||||||
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
|
import com.anytypeio.anytype.ui.objects.BaseObjectTypeChangeFragment
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selecting an object type by SmartBlockType.Page for the object in draft state
|
||||||
|
*/
|
||||||
|
class DraftObjectSelectTypeFragment : BaseObjectTypeChangeFragment() {
|
||||||
|
|
||||||
|
override fun startWithParams() {
|
||||||
|
vm.onStart(
|
||||||
|
isWithSet = true,
|
||||||
|
isWithBookmark = false,
|
||||||
|
excludeTypes = excludeTypes,
|
||||||
|
selectedTypes = emptyList(),
|
||||||
|
isSetSource = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemClicked(id: Id, name: String) {
|
||||||
|
withParent<OnObjectSelectTypeAction> {
|
||||||
|
onProceedWithDraftUpdateType(id = id)
|
||||||
|
}
|
||||||
|
hideSoftInput()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTitle() {
|
||||||
|
binding.tvTitle.text = getString(R.string.change_type)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun injectDependencies() {
|
||||||
|
componentManager().objectTypeChangeComponent.get().inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun releaseDependencies() {
|
||||||
|
componentManager().objectTypeChangeComponent.release()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(excludeTypes: List<Id>) = DraftObjectSelectTypeFragment().apply {
|
||||||
|
arguments = bundleOf(ARG_EXCLUDE_TYPES to excludeTypes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.anytypeio.anytype.ui.objects.types.pickers
|
||||||
|
|
||||||
|
import com.anytypeio.anytype.R
|
||||||
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.hideSoftInput
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.withParent
|
||||||
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
|
import com.anytypeio.anytype.ui.objects.BaseObjectTypeChangeFragment
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selecting a source by SmartBlockType.Page for the empty data view
|
||||||
|
*/
|
||||||
|
class EmptyDataViewSelectSourceFragment : BaseObjectTypeChangeFragment() {
|
||||||
|
|
||||||
|
override fun startWithParams() {
|
||||||
|
vm.onStart(
|
||||||
|
isWithSet = false,
|
||||||
|
isWithBookmark = true,
|
||||||
|
excludeTypes = emptyList(),
|
||||||
|
selectedTypes = emptyList(),
|
||||||
|
isSetSource = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemClicked(id: Id, name: String) {
|
||||||
|
withParent<OnDataViewSelectSourceAction> {
|
||||||
|
onProceedWithSelectSource(id = id)
|
||||||
|
}
|
||||||
|
hideSoftInput()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTitle() {
|
||||||
|
binding.tvTitle.text = getString(R.string.select_source)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun injectDependencies() {
|
||||||
|
componentManager().objectTypeChangeComponent.get().inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun releaseDependencies() {
|
||||||
|
componentManager().objectTypeChangeComponent.release()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance() = EmptyDataViewSelectSourceFragment()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.anytypeio.anytype.ui.objects.types.pickers
|
||||||
|
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
|
import com.anytypeio.anytype.R
|
||||||
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.hideSoftInput
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.withParent
|
||||||
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
|
import com.anytypeio.anytype.ui.objects.BaseObjectTypeChangeFragment
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selecting an object type by SmartBlockType.Page for the object
|
||||||
|
*/
|
||||||
|
class ObjectSelectTypeFragment : BaseObjectTypeChangeFragment() {
|
||||||
|
|
||||||
|
override fun startWithParams() {
|
||||||
|
vm.onStart(
|
||||||
|
isWithSet = false,
|
||||||
|
isWithBookmark = false,
|
||||||
|
excludeTypes = excludeTypes,
|
||||||
|
selectedTypes = emptyList(),
|
||||||
|
isSetSource = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemClicked(id: Id, name: String) {
|
||||||
|
withParent<OnObjectSelectTypeAction> {
|
||||||
|
onProceedWithUpdateType(id = id)
|
||||||
|
}
|
||||||
|
hideSoftInput()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setTitle() {
|
||||||
|
binding.tvTitle.text = getString(R.string.change_type)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun injectDependencies() {
|
||||||
|
componentManager().objectTypeChangeComponent.get().inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun releaseDependencies() {
|
||||||
|
componentManager().objectTypeChangeComponent.release()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newInstance(excludeTypes: List<Id>) = ObjectSelectTypeFragment().apply {
|
||||||
|
arguments = bundleOf(ARG_EXCLUDE_TYPES to excludeTypes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.anytypeio.anytype.ui.objects.types.pickers
|
||||||
|
|
||||||
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
|
||||||
|
interface OnDataViewSelectSourceAction {
|
||||||
|
fun onProceedWithSelectSource(id: Id)
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.anytypeio.anytype.ui.objects.types.pickers
|
||||||
|
|
||||||
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
|
||||||
|
interface OnObjectSelectTypeAction {
|
||||||
|
fun onProceedWithUpdateType(id: Id)
|
||||||
|
fun onProceedWithDraftUpdateType(id: Id)
|
||||||
|
}
|
|
@ -21,7 +21,13 @@ import com.anytypeio.anytype.core_ui.features.relations.RelationAddAdapter
|
||||||
import com.anytypeio.anytype.core_ui.features.relations.RelationAddHeaderAdapter
|
import com.anytypeio.anytype.core_ui.features.relations.RelationAddHeaderAdapter
|
||||||
import com.anytypeio.anytype.core_ui.reactive.focusChanges
|
import com.anytypeio.anytype.core_ui.reactive.focusChanges
|
||||||
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
||||||
import com.anytypeio.anytype.core_utils.ext.*
|
import com.anytypeio.anytype.core_utils.ext.arg
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.drawable
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.invisible
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.statusBarHeight
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.toast
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.visible
|
||||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetTextInputFragment
|
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetTextInputFragment
|
||||||
import com.anytypeio.anytype.databinding.FragmentRelationAddBinding
|
import com.anytypeio.anytype.databinding.FragmentRelationAddBinding
|
||||||
import com.anytypeio.anytype.di.common.componentManager
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
|
@ -104,7 +110,7 @@ abstract class RelationAddBaseFragment : BaseBottomSheetTextInputFragment<Fragme
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
vm.onStart(ctx)
|
vm.onStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun onRelationSelected(ctx: Id, relation: RelationView.Existing)
|
abstract fun onRelationSelected(ctx: Id, relation: RelationView.Existing)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_utils.ext.*
|
import com.anytypeio.anytype.core_utils.ext.*
|
||||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment
|
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment
|
||||||
import com.anytypeio.anytype.databinding.FragmentRelationDateValueBinding
|
import com.anytypeio.anytype.databinding.FragmentRelationDateValueBinding
|
||||||
|
@ -28,6 +29,7 @@ open class RelationDateValueFragment : BaseBottomSheetFragment<FragmentRelationD
|
||||||
private val ctx get() = argString(CONTEXT_ID)
|
private val ctx get() = argString(CONTEXT_ID)
|
||||||
private val objectId get() = argString(OBJECT_ID)
|
private val objectId get() = argString(OBJECT_ID)
|
||||||
private val relationId get() = argString(RELATION_ID)
|
private val relationId get() = argString(RELATION_ID)
|
||||||
|
private val relationKey get() = argString(RELATION_KEY)
|
||||||
private val flow get() = arg<Int>(FLOW_KEY)
|
private val flow get() = arg<Int>(FLOW_KEY)
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
@ -105,7 +107,7 @@ open class RelationDateValueFragment : BaseBottomSheetFragment<FragmentRelationD
|
||||||
onDateValueChanged(
|
onDateValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
objectId = objectId,
|
objectId = objectId,
|
||||||
relationId = relationId,
|
relationKey = relationKey,
|
||||||
timeInSeconds = timeInSeconds
|
timeInSeconds = timeInSeconds
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -148,12 +150,14 @@ open class RelationDateValueFragment : BaseBottomSheetFragment<FragmentRelationD
|
||||||
fun new(
|
fun new(
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
relationId: Id,
|
relationId: Id,
|
||||||
|
relationKey: Key,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
flow: Int = FLOW_DEFAULT
|
flow: Int = FLOW_DEFAULT
|
||||||
) = RelationDateValueFragment().apply {
|
) = RelationDateValueFragment().apply {
|
||||||
arguments = bundleOf(
|
arguments = bundleOf(
|
||||||
CONTEXT_ID to ctx,
|
CONTEXT_ID to ctx,
|
||||||
RELATION_ID to relationId,
|
RELATION_ID to relationId,
|
||||||
|
RELATION_KEY to relationKey,
|
||||||
OBJECT_ID to objectId,
|
OBJECT_ID to objectId,
|
||||||
FLOW_KEY to flow
|
FLOW_KEY to flow
|
||||||
)
|
)
|
||||||
|
@ -161,6 +165,7 @@ open class RelationDateValueFragment : BaseBottomSheetFragment<FragmentRelationD
|
||||||
|
|
||||||
const val CONTEXT_ID = "arg.relation.date.context"
|
const val CONTEXT_ID = "arg.relation.date.context"
|
||||||
const val RELATION_ID = "arg.relation.date.relation.id"
|
const val RELATION_ID = "arg.relation.date.relation.id"
|
||||||
|
const val RELATION_KEY = "arg.relation.date.relation.key"
|
||||||
const val OBJECT_ID = "arg.relation.date.object.id"
|
const val OBJECT_ID = "arg.relation.date.object.id"
|
||||||
|
|
||||||
const val FLOW_KEY = "arg.relation.date.flow"
|
const val FLOW_KEY = "arg.relation.date.flow"
|
||||||
|
@ -173,7 +178,7 @@ open class RelationDateValueFragment : BaseBottomSheetFragment<FragmentRelationD
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
timeInSeconds: Number?,
|
timeInSeconds: Number?,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id
|
relationKey: Key
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,11 +8,11 @@ import android.widget.EditText
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.fragment.findNavController
|
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration
|
import androidx.recyclerview.widget.DividerItemDecoration
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_ui.features.relations.DocumentRelationAdapter
|
import com.anytypeio.anytype.core_ui.features.relations.DocumentRelationAdapter
|
||||||
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
||||||
import com.anytypeio.anytype.core_utils.ext.*
|
import com.anytypeio.anytype.core_utils.ext.*
|
||||||
|
@ -98,55 +98,14 @@ open class RelationListFragment : BaseBottomSheetFragment<FragmentRelationListBi
|
||||||
}
|
}
|
||||||
binding.btnEditOrDone.setOnClickListener { vm.onEditOrDoneClicked(isLocked) }
|
binding.btnEditOrDone.setOnClickListener { vm.onEditOrDoneClicked(isLocked) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
with(lifecycleScope) {
|
|
||||||
if (mode == MODE_ADD) {
|
|
||||||
binding.searchBar.root.visible()
|
|
||||||
val queries = searchRelationInput.textChanges()
|
|
||||||
.onStart { emit(searchRelationInput.text.toString()) }
|
|
||||||
val views = vm.views.combine(queries) { views, query ->
|
|
||||||
if (views.isEmpty()) {
|
|
||||||
views
|
|
||||||
} else {
|
|
||||||
views.filter { model ->
|
|
||||||
if (model is RelationListViewModel.Model.Item) {
|
|
||||||
model.view.name.contains(query, true)
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
subscribe(searchRelationInput.textChanges()) {
|
|
||||||
if (it.isEmpty()) clearSearchText.invisible() else clearSearchText.visible()
|
|
||||||
}
|
|
||||||
subscribe(views) { docRelationAdapter.update(it) }
|
|
||||||
} else {
|
|
||||||
binding.searchBar.root.gone()
|
|
||||||
subscribe(vm.views) { docRelationAdapter.update(it) }
|
|
||||||
}
|
|
||||||
subscribe(vm.commands) { command -> execute(command) }
|
|
||||||
subscribe(vm.toasts) { toast(it) }
|
|
||||||
subscribe(vm.isEditMode) { isEditMode ->
|
|
||||||
if (isEditMode) {
|
|
||||||
binding.btnEditOrDone.setText(R.string.done)
|
|
||||||
binding.btnPlus.invisible()
|
|
||||||
} else {
|
|
||||||
binding.btnPlus.visible()
|
|
||||||
binding.btnEditOrDone.setText(R.string.edit)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun execute(command: Command) {
|
private fun execute(command: Command) {
|
||||||
when (command) {
|
when (command) {
|
||||||
is Command.EditTextRelationValue -> {
|
is Command.EditTextRelationValue -> {
|
||||||
val fr = RelationTextValueFragment.new(
|
val fr = RelationTextValueFragment.new(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = command.relation,
|
relationId = command.relationId,
|
||||||
|
relationKey = command.relationKey,
|
||||||
objectId = command.target,
|
objectId = command.target,
|
||||||
isLocked = command.isLocked
|
isLocked = command.isLocked
|
||||||
)
|
)
|
||||||
|
@ -155,22 +114,22 @@ open class RelationListFragment : BaseBottomSheetFragment<FragmentRelationListBi
|
||||||
is Command.EditDateRelationValue -> {
|
is Command.EditDateRelationValue -> {
|
||||||
val fr = RelationDateValueFragment.new(
|
val fr = RelationDateValueFragment.new(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = command.relation,
|
relationId = command.relationId,
|
||||||
|
relationKey = command.relationKey,
|
||||||
objectId = command.target
|
objectId = command.target
|
||||||
)
|
)
|
||||||
fr.show(childFragmentManager, null)
|
fr.show(childFragmentManager, null)
|
||||||
}
|
}
|
||||||
is Command.EditRelationValue -> {
|
is Command.EditRelationValue -> {
|
||||||
findNavController().navigate(
|
val fr = RelationValueFragment.new(
|
||||||
R.id.objectRelationValueScreen,
|
ctx = ctx,
|
||||||
bundleOf(
|
target = command.target,
|
||||||
RelationValueBaseFragment.CTX_KEY to command.ctx,
|
relationId = command.relationId,
|
||||||
RelationValueBaseFragment.TARGET_KEY to command.target,
|
relationKey = command.relationKey,
|
||||||
RelationValueBaseFragment.RELATION_KEY to command.relation,
|
targetObjectTypes = command.targetObjectTypes,
|
||||||
RelationValueBaseFragment.TARGET_TYPES_KEY to command.targetObjectTypes,
|
isLocked = command.isLocked
|
||||||
RelationValueBaseFragment.IS_LOCKED_KEY to command.isLocked
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
fr.show(childFragmentManager, null)
|
||||||
}
|
}
|
||||||
is Command.SetRelationKey -> {
|
is Command.SetRelationKey -> {
|
||||||
withParent<OnFragmentInteractionListener> {
|
withParent<OnFragmentInteractionListener> {
|
||||||
|
@ -185,6 +144,42 @@ open class RelationListFragment : BaseBottomSheetFragment<FragmentRelationListBi
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
jobs += lifecycleScope.subscribe(vm.commands) { command -> execute(command) }
|
||||||
|
jobs += lifecycleScope.subscribe(vm.toasts) { toast(it) }
|
||||||
|
jobs += lifecycleScope.subscribe(vm.isEditMode) { isEditMode ->
|
||||||
|
if (isEditMode) {
|
||||||
|
binding.btnEditOrDone.setText(R.string.done)
|
||||||
|
binding.btnPlus.invisible()
|
||||||
|
} else {
|
||||||
|
binding.btnPlus.visible()
|
||||||
|
binding.btnEditOrDone.setText(R.string.edit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mode == MODE_ADD) {
|
||||||
|
binding.searchBar.root.visible()
|
||||||
|
val queries = searchRelationInput.textChanges()
|
||||||
|
.onStart { emit(searchRelationInput.text.toString()) }
|
||||||
|
val views = vm.views.combine(queries) { views, query ->
|
||||||
|
if (views.isEmpty()) {
|
||||||
|
views
|
||||||
|
} else {
|
||||||
|
views.filter { model ->
|
||||||
|
if (model is RelationListViewModel.Model.Item) {
|
||||||
|
model.view.name.contains(query, true)
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jobs += lifecycleScope.subscribe(searchRelationInput.textChanges()) {
|
||||||
|
if (it.isEmpty()) clearSearchText.invisible() else clearSearchText.visible()
|
||||||
|
}
|
||||||
|
jobs += lifecycleScope.subscribe(views) { docRelationAdapter.update(it) }
|
||||||
|
} else {
|
||||||
|
binding.searchBar.root.gone()
|
||||||
|
jobs += lifecycleScope.subscribe(vm.views) { docRelationAdapter.update(it) }
|
||||||
|
}
|
||||||
super.onStart()
|
super.onStart()
|
||||||
if (mode == MODE_LIST) {
|
if (mode == MODE_LIST) {
|
||||||
vm.onStartListMode(ctx)
|
vm.onStartListMode(ctx)
|
||||||
|
@ -198,19 +193,19 @@ open class RelationListFragment : BaseBottomSheetFragment<FragmentRelationListBi
|
||||||
vm.onStop()
|
vm.onStop()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextValueChanged(ctx: Id, text: String, objectId: Id, relationId: Id) {
|
override fun onTextValueChanged(ctx: Id, text: String, objectId: Id, relationKey: Key) {
|
||||||
vm.onRelationTextValueChanged(
|
vm.onRelationTextValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
value = text,
|
relationKey = relationKey,
|
||||||
relationId = relationId
|
value = text
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNumberValueChanged(ctx: Id, number: Double?, objectId: Id, relationId: Id) {
|
override fun onNumberValueChanged(ctx: Id, number: Double?, objectId: Id, relationKey: Key) {
|
||||||
vm.onRelationTextValueChanged(
|
vm.onRelationTextValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
value = number,
|
relationKey = relationKey,
|
||||||
relationId = relationId
|
value = number
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,11 +213,11 @@ open class RelationListFragment : BaseBottomSheetFragment<FragmentRelationListBi
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
timeInSeconds: Number?,
|
timeInSeconds: Number?,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id
|
relationKey: Key
|
||||||
) {
|
) {
|
||||||
vm.onRelationTextValueChanged(
|
vm.onRelationTextValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = relationId,
|
relationKey = relationKey,
|
||||||
value = timeInSeconds
|
value = timeInSeconds
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.EditText
|
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
|
@ -15,6 +14,7 @@ import androidx.recyclerview.widget.DividerItemDecoration
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_ui.features.relations.RelationActionAdapter
|
import com.anytypeio.anytype.core_ui.features.relations.RelationActionAdapter
|
||||||
import com.anytypeio.anytype.core_ui.features.relations.RelationTextValueAdapter
|
import com.anytypeio.anytype.core_ui.features.relations.RelationTextValueAdapter
|
||||||
import com.anytypeio.anytype.core_utils.ext.arg
|
import com.anytypeio.anytype.core_utils.ext.arg
|
||||||
|
@ -45,6 +45,7 @@ open class RelationTextValueFragment :
|
||||||
|
|
||||||
private val ctx get() = arg<String>(CONTEXT_ID)
|
private val ctx get() = arg<String>(CONTEXT_ID)
|
||||||
private val relationId get() = arg<String>(RELATION_ID)
|
private val relationId get() = arg<String>(RELATION_ID)
|
||||||
|
private val relationKey get() = arg<Key>(RELATION_KEY)
|
||||||
private val objectId get() = arg<String>(OBJECT_ID)
|
private val objectId get() = arg<String>(OBJECT_ID)
|
||||||
private val flow get() = arg<Int>(FLOW_KEY)
|
private val flow get() = arg<Int>(FLOW_KEY)
|
||||||
private val isLocked get() = arg<Boolean>(LOCKED_KEY)
|
private val isLocked get() = arg<Boolean>(LOCKED_KEY)
|
||||||
|
@ -82,7 +83,7 @@ open class RelationTextValueFragment :
|
||||||
withParent<TextValueEditReceiver> {
|
withParent<TextValueEditReceiver> {
|
||||||
onTextValueChanged(
|
onTextValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = relationId,
|
relationKey = relationKey,
|
||||||
objectId = objectId,
|
objectId = objectId,
|
||||||
text = parsed
|
text = parsed
|
||||||
)
|
)
|
||||||
|
@ -122,7 +123,7 @@ open class RelationTextValueFragment :
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
jobs += lifecycleScope.subscribe(vm.views) { relationValueAdapter.update(it) }
|
jobs += lifecycleScope.subscribe(vm.views) { relationValueAdapter.update(it) }
|
||||||
jobs += lifecycleScope.subscribe(vm.actions) { relationValueActionAdapter.submitList(it) }
|
jobs += lifecycleScope.subscribe(vm.actions) { relationValueActionAdapter.submitList(it) }
|
||||||
jobs += lifecycleScope.subscribe(vm.intents) { proceedWithAction(it) }
|
jobs += lifecycleScope.subscribe(vm.intents) { proceedWithAction(it) }
|
||||||
jobs += lifecycleScope.subscribe(vm.title) { binding.tvRelationHeader.text = it }
|
jobs += lifecycleScope.subscribe(vm.title) { binding.tvRelationHeader.text = it }
|
||||||
jobs += lifecycleScope.subscribe(vm.isDismissed) { isDismissed ->
|
jobs += lifecycleScope.subscribe(vm.isDismissed) { isDismissed ->
|
||||||
|
@ -138,6 +139,7 @@ open class RelationTextValueFragment :
|
||||||
} else {
|
} else {
|
||||||
vm.onStart(
|
vm.onStart(
|
||||||
relationId = relationId,
|
relationId = relationId,
|
||||||
|
relationKey = relationKey,
|
||||||
recordId = objectId,
|
recordId = objectId,
|
||||||
isLocked = isLocked,
|
isLocked = isLocked,
|
||||||
)
|
)
|
||||||
|
@ -154,7 +156,7 @@ open class RelationTextValueFragment :
|
||||||
withParent<TextValueEditReceiver> {
|
withParent<TextValueEditReceiver> {
|
||||||
onTextValueChanged(
|
onTextValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = relationId,
|
relationKey = relationKey,
|
||||||
objectId = objectId,
|
objectId = objectId,
|
||||||
text = txt
|
text = txt
|
||||||
)
|
)
|
||||||
|
@ -167,7 +169,7 @@ open class RelationTextValueFragment :
|
||||||
withParent<TextValueEditReceiver> {
|
withParent<TextValueEditReceiver> {
|
||||||
onNumberValueChanged(
|
onNumberValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = relationId,
|
relationKey = relationKey,
|
||||||
objectId = objectId,
|
objectId = objectId,
|
||||||
number = number
|
number = number
|
||||||
)
|
)
|
||||||
|
@ -221,6 +223,7 @@ open class RelationTextValueFragment :
|
||||||
fun new(
|
fun new(
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
relationId: Id,
|
relationId: Id,
|
||||||
|
relationKey: Key,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
flow: Int = FLOW_DEFAULT,
|
flow: Int = FLOW_DEFAULT,
|
||||||
isLocked: Boolean = false,
|
isLocked: Boolean = false,
|
||||||
|
@ -228,6 +231,7 @@ open class RelationTextValueFragment :
|
||||||
arguments = bundleOf(
|
arguments = bundleOf(
|
||||||
CONTEXT_ID to ctx,
|
CONTEXT_ID to ctx,
|
||||||
RELATION_ID to relationId,
|
RELATION_ID to relationId,
|
||||||
|
RELATION_KEY to relationKey,
|
||||||
OBJECT_ID to objectId,
|
OBJECT_ID to objectId,
|
||||||
FLOW_KEY to flow,
|
FLOW_KEY to flow,
|
||||||
LOCKED_KEY to isLocked
|
LOCKED_KEY to isLocked
|
||||||
|
@ -238,7 +242,7 @@ open class RelationTextValueFragment :
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
name: String = "",
|
name: String = "",
|
||||||
value: Long? = null
|
value: Long? = null
|
||||||
) = new(ctx, "", "", FLOW_CHANGE_DATE)
|
) = new(ctx, "", "", "", FLOW_CHANGE_DATE)
|
||||||
.apply {
|
.apply {
|
||||||
arguments?.apply {
|
arguments?.apply {
|
||||||
putString(KEY_NAME, name)
|
putString(KEY_NAME, name)
|
||||||
|
@ -248,6 +252,7 @@ open class RelationTextValueFragment :
|
||||||
|
|
||||||
const val CONTEXT_ID = "arg.edit-relation-value.context"
|
const val CONTEXT_ID = "arg.edit-relation-value.context"
|
||||||
const val RELATION_ID = "arg.edit-relation-value.relation.id"
|
const val RELATION_ID = "arg.edit-relation-value.relation.id"
|
||||||
|
const val RELATION_KEY = "arg.edit-relation-value.relation.key"
|
||||||
const val OBJECT_ID = "arg.edit-relation-value.object.id"
|
const val OBJECT_ID = "arg.edit-relation-value.object.id"
|
||||||
const val FLOW_KEY = "arg.edit-relation-value.flow"
|
const val FLOW_KEY = "arg.edit-relation-value.flow"
|
||||||
const val LOCKED_KEY = "arg.edit-relation-value.locked"
|
const val LOCKED_KEY = "arg.edit-relation-value.locked"
|
||||||
|
@ -264,14 +269,14 @@ open class RelationTextValueFragment :
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
text: String,
|
text: String,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id
|
relationKey: Key
|
||||||
)
|
)
|
||||||
|
|
||||||
fun onNumberValueChanged(
|
fun onNumberValueChanged(
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
number: Double?,
|
number: Double?,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id
|
relationKey: Key
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.anytypeio.anytype.BuildConfig
|
import com.anytypeio.anytype.BuildConfig
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_ui.features.sets.RelationValueAdapter
|
import com.anytypeio.anytype.core_ui.features.sets.RelationValueAdapter
|
||||||
import com.anytypeio.anytype.core_ui.reactive.clicks
|
import com.anytypeio.anytype.core_ui.reactive.clicks
|
||||||
import com.anytypeio.anytype.core_ui.tools.DefaultDragAndDropBehavior
|
import com.anytypeio.anytype.core_ui.tools.DefaultDragAndDropBehavior
|
||||||
|
@ -73,12 +74,13 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
||||||
PickiTCallbacks {
|
PickiTCallbacks {
|
||||||
|
|
||||||
protected val ctx get() = argString(CTX_KEY)
|
protected val ctx get() = argString(CTX_KEY)
|
||||||
protected val relation get() = argString(RELATION_KEY)
|
protected val relationId get() = argString(RELATION_ID)
|
||||||
|
protected val relationKey get() = argString(RELATION_KEY)
|
||||||
protected val target get() = argString(TARGET_KEY)
|
protected val target get() = argString(TARGET_KEY)
|
||||||
protected val dataview get() = argString(DATAVIEW_KEY)
|
protected val dataview get() = argString(DATAVIEW_KEY)
|
||||||
protected val viewer get() = argString(VIEWER_KEY)
|
protected val viewer get() = argString(VIEWER_KEY)
|
||||||
protected val types get() = arg<List<String>>(TARGET_TYPES_KEY)
|
protected val types get() = arg<List<String>>(TARGET_TYPES_KEY)
|
||||||
protected val isLocked get() = arg<Boolean>(IS_LOCKED_KEY)
|
private val isLocked get() = arg<Boolean>(IS_LOCKED_KEY)
|
||||||
|
|
||||||
abstract val vm: RelationValueBaseViewModel
|
abstract val vm: RelationValueBaseViewModel
|
||||||
|
|
||||||
|
@ -92,7 +94,7 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
||||||
onItemDropped = {
|
onItemDropped = {
|
||||||
vm.onObjectValueOrderChanged(
|
vm.onObjectValueOrderChanged(
|
||||||
target = target,
|
target = target,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
order = relationValueAdapter.order()
|
order = relationValueAdapter.order()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -118,14 +120,14 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
||||||
onRemoveStatusClicked = { status ->
|
onRemoveStatusClicked = { status ->
|
||||||
vm.onRemoveStatusFromObjectClicked(
|
vm.onRemoveStatusFromObjectClicked(
|
||||||
target = target,
|
target = target,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
status = status.id
|
status = status.id
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onRemoveTagClicked = { tag ->
|
onRemoveTagClicked = { tag ->
|
||||||
vm.onRemoveTagFromObjectClicked(
|
vm.onRemoveTagFromObjectClicked(
|
||||||
target = target,
|
target = target,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
tag = tag.id
|
tag = tag.id
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -146,7 +148,7 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
||||||
onRemoveObjectClicked = { obj ->
|
onRemoveObjectClicked = { obj ->
|
||||||
vm.onRemoveObjectFromObjectClicked(
|
vm.onRemoveObjectFromObjectClicked(
|
||||||
target = target,
|
target = target,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
objectId = obj
|
objectId = obj
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -154,7 +156,7 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
||||||
onRemoveFileClicked = { file ->
|
onRemoveFileClicked = { file ->
|
||||||
vm.onRemoveFileFromObjectClicked(
|
vm.onRemoveFileFromObjectClicked(
|
||||||
target = target,
|
target = target,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
fileId = file
|
fileId = file
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -190,7 +192,10 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
||||||
jobs += lifecycleScope.subscribe(vm.isLoading) { isLoading -> observeLoading(isLoading) }
|
jobs += lifecycleScope.subscribe(vm.isLoading) { isLoading -> observeLoading(isLoading) }
|
||||||
jobs += lifecycleScope.subscribe(vm.copyFileStatus) { command -> onCopyFileCommand(command) }
|
jobs += lifecycleScope.subscribe(vm.copyFileStatus) { command -> onCopyFileCommand(command) }
|
||||||
super.onStart()
|
super.onStart()
|
||||||
vm.onStart(relationId = relation, objectId = target)
|
vm.onStart(
|
||||||
|
relationKey = relationKey,
|
||||||
|
objectId = target
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeLoading(isLoading: Boolean) {
|
private fun observeLoading(isLoading: Boolean) {
|
||||||
|
@ -451,7 +456,8 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
||||||
companion object {
|
companion object {
|
||||||
const val CTX_KEY = "arg.edit-cell-tag.ctx"
|
const val CTX_KEY = "arg.edit-cell-tag.ctx"
|
||||||
const val IS_LOCKED_KEY = "arg.edit-cell-tag.locked"
|
const val IS_LOCKED_KEY = "arg.edit-cell-tag.locked"
|
||||||
const val RELATION_KEY = "arg.edit-cell-tag.relation"
|
const val RELATION_ID = "arg.edit-cell-tag.relation.id"
|
||||||
|
const val RELATION_KEY = "arg.edit-cell-tag.relation.key"
|
||||||
const val TARGET_KEY = "arg.edit-cell-tag.target"
|
const val TARGET_KEY = "arg.edit-cell-tag.target"
|
||||||
const val DATAVIEW_KEY = "arg.edit-cell-tag.dataview"
|
const val DATAVIEW_KEY = "arg.edit-cell-tag.dataview"
|
||||||
const val VIEWER_KEY = "arg.edit-cell-tag.viewer"
|
const val VIEWER_KEY = "arg.edit-cell-tag.viewer"
|
||||||
|
@ -468,20 +474,20 @@ open class RelationValueDVFragment : RelationValueBaseFragment() {
|
||||||
override fun onObjectValueChanged(
|
override fun onObjectValueChanged(
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id,
|
relationKey: Key,
|
||||||
ids: List<Id>
|
ids: List<Id>
|
||||||
) {
|
) {
|
||||||
vm.onAddObjectsOrFilesValueToRecord(
|
vm.onAddObjectsOrFilesValueToRecord(
|
||||||
record = target,
|
record = objectId,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
ids = ids
|
ids = ids
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFileValueChanged(ctx: Id, objectId: Id, relationId: Id, ids: List<Id>) {
|
override fun onFileValueChanged(ctx: Id, objectId: Id, relationKey: Key, ids: List<Id>) {
|
||||||
vm.onAddObjectsOrFilesValueToRecord(
|
vm.onAddObjectsOrFilesValueToRecord(
|
||||||
record = target,
|
record = objectId,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
ids = ids
|
ids = ids
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -492,7 +498,8 @@ open class RelationValueDVFragment : RelationValueBaseFragment() {
|
||||||
val fragmentFlow = AddObjectRelationFragment.FLOW_DATAVIEW
|
val fragmentFlow = AddObjectRelationFragment.FLOW_DATAVIEW
|
||||||
val fr = AddObjectRelationFragment.new(
|
val fr = AddObjectRelationFragment.new(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = relation,
|
relationId = relationId,
|
||||||
|
relationKey = relationKey,
|
||||||
objectId = target,
|
objectId = target,
|
||||||
types = types,
|
types = types,
|
||||||
flow = fragmentFlow
|
flow = fragmentFlow
|
||||||
|
@ -503,7 +510,8 @@ open class RelationValueDVFragment : RelationValueBaseFragment() {
|
||||||
val fr = AddOptionsRelationDVFragment.new(
|
val fr = AddOptionsRelationDVFragment.new(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
target = target,
|
target = target,
|
||||||
relation = relation,
|
relationId = relationId,
|
||||||
|
relationKey = relationKey,
|
||||||
dataview = dataview,
|
dataview = dataview,
|
||||||
viewer = viewer
|
viewer = viewer
|
||||||
)
|
)
|
||||||
|
@ -512,9 +520,10 @@ open class RelationValueDVFragment : RelationValueBaseFragment() {
|
||||||
RelationValueBaseViewModel.ObjectRelationValueCommand.ShowAddFileScreen -> {
|
RelationValueBaseViewModel.ObjectRelationValueCommand.ShowAddFileScreen -> {
|
||||||
val fr = AddFileRelationFragment.new(
|
val fr = AddFileRelationFragment.new(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = relation,
|
relationId = relationId,
|
||||||
objectId = target,
|
objectId = target,
|
||||||
flow = AddFileRelationFragment.FLOW_DATAVIEW
|
flow = AddFileRelationFragment.FLOW_DATAVIEW,
|
||||||
|
relationKey = relationKey
|
||||||
)
|
)
|
||||||
fr.show(childFragmentManager, null)
|
fr.show(childFragmentManager, null)
|
||||||
}
|
}
|
||||||
|
@ -543,7 +552,7 @@ open class RelationValueDVFragment : RelationValueBaseFragment() {
|
||||||
vm.onAddFileToObject(
|
vm.onAddFileToObject(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
target = target,
|
target = target,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
filePath = filePath
|
filePath = filePath
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -582,22 +591,22 @@ class RelationValueFragment : RelationValueBaseFragment() {
|
||||||
override fun onObjectValueChanged(
|
override fun onObjectValueChanged(
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id,
|
relationKey: Key,
|
||||||
ids: List<Id>
|
ids: List<Id>
|
||||||
) {
|
) {
|
||||||
vm.onAddObjectsOrFilesValueToObject(
|
vm.onAddObjectsOrFilesValueToObject(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
target = target,
|
target = objectId,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
ids = ids
|
ids = ids
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFileValueChanged(ctx: Id, objectId: Id, relationId: Id, ids: List<Id>) {
|
override fun onFileValueChanged(ctx: Id, objectId: Id, relationKey: Key, ids: List<Id>) {
|
||||||
vm.onAddObjectsOrFilesValueToObject(
|
vm.onAddObjectsOrFilesValueToObject(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
target = target,
|
target = objectId,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
ids = ids
|
ids = ids
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -615,7 +624,8 @@ class RelationValueFragment : RelationValueBaseFragment() {
|
||||||
RelationValueBaseViewModel.ObjectRelationValueCommand.ShowAddObjectScreen -> {
|
RelationValueBaseViewModel.ObjectRelationValueCommand.ShowAddObjectScreen -> {
|
||||||
val fr = AddObjectRelationFragment.new(
|
val fr = AddObjectRelationFragment.new(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = relation,
|
relationId = relationId,
|
||||||
|
relationKey = relationKey,
|
||||||
objectId = target,
|
objectId = target,
|
||||||
types = types
|
types = types
|
||||||
)
|
)
|
||||||
|
@ -625,14 +635,16 @@ class RelationValueFragment : RelationValueBaseFragment() {
|
||||||
val fr = AddOptionsRelationFragment.new(
|
val fr = AddOptionsRelationFragment.new(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
objectId = target,
|
objectId = target,
|
||||||
relationId = relation
|
relationId = relationId,
|
||||||
|
relationKey = relationKey
|
||||||
)
|
)
|
||||||
fr.show(childFragmentManager, null)
|
fr.show(childFragmentManager, null)
|
||||||
}
|
}
|
||||||
RelationValueBaseViewModel.ObjectRelationValueCommand.ShowAddFileScreen -> {
|
RelationValueBaseViewModel.ObjectRelationValueCommand.ShowAddFileScreen -> {
|
||||||
val fr = AddFileRelationFragment.new(
|
val fr = AddFileRelationFragment.new(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = relation,
|
relationId = relationId,
|
||||||
|
relationKey = relationKey,
|
||||||
objectId = target,
|
objectId = target,
|
||||||
flow = AddFileRelationFragment.FLOW_DEFAULT
|
flow = AddFileRelationFragment.FLOW_DEFAULT
|
||||||
)
|
)
|
||||||
|
@ -668,7 +680,7 @@ class RelationValueFragment : RelationValueBaseFragment() {
|
||||||
vm.onAddFileToObject(
|
vm.onAddFileToObject(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
target = target,
|
target = target,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
filePath = filePath
|
filePath = filePath
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -688,14 +700,16 @@ class RelationValueFragment : RelationValueBaseFragment() {
|
||||||
fun new(
|
fun new(
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
target: Id,
|
target: Id,
|
||||||
relation: Id,
|
relationId: Id,
|
||||||
|
relationKey: Key,
|
||||||
targetObjectTypes: List<Id>,
|
targetObjectTypes: List<Id>,
|
||||||
isLocked: Boolean = false
|
isLocked: Boolean = false
|
||||||
) = RelationValueFragment().apply {
|
) = RelationValueFragment().apply {
|
||||||
arguments = bundleOf(
|
arguments = bundleOf(
|
||||||
CTX_KEY to ctx,
|
CTX_KEY to ctx,
|
||||||
TARGET_KEY to target,
|
TARGET_KEY to target,
|
||||||
RELATION_KEY to relation,
|
RELATION_ID to relationId,
|
||||||
|
RELATION_KEY to relationKey,
|
||||||
TARGET_TYPES_KEY to targetObjectTypes,
|
TARGET_TYPES_KEY to targetObjectTypes,
|
||||||
IS_LOCKED_KEY to isLocked
|
IS_LOCKED_KEY to isLocked
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,6 +11,7 @@ import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_ui.features.relations.RelationFileValueAdapter
|
import com.anytypeio.anytype.core_ui.features.relations.RelationFileValueAdapter
|
||||||
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
||||||
import com.anytypeio.anytype.core_utils.ext.arg
|
import com.anytypeio.anytype.core_utils.ext.arg
|
||||||
|
@ -37,6 +38,7 @@ class AddFileRelationFragment :
|
||||||
private val ctx get() = argString(CONTEXT_ID)
|
private val ctx get() = argString(CONTEXT_ID)
|
||||||
private val objectId get() = argString(OBJECT_ID)
|
private val objectId get() = argString(OBJECT_ID)
|
||||||
private val relationId get() = argString(RELATION_ID)
|
private val relationId get() = argString(RELATION_ID)
|
||||||
|
private val relationKey get() = argString(RELATION_KEY)
|
||||||
private val flow get() = arg<Int>(FLOW_KEY)
|
private val flow get() = arg<Int>(FLOW_KEY)
|
||||||
|
|
||||||
private lateinit var searchRelationInput: EditText
|
private lateinit var searchRelationInput: EditText
|
||||||
|
@ -104,7 +106,7 @@ class AddFileRelationFragment :
|
||||||
onFileValueChanged(
|
onFileValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
objectId = objectId,
|
objectId = objectId,
|
||||||
relationId = relationId,
|
relationKey = relationKey,
|
||||||
ids = ids
|
ids = ids
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -144,18 +146,21 @@ class AddFileRelationFragment :
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id,
|
relationId: Id,
|
||||||
|
relationKey: Key,
|
||||||
flow: Int = FLOW_DEFAULT
|
flow: Int = FLOW_DEFAULT
|
||||||
) = AddFileRelationFragment().apply {
|
) = AddFileRelationFragment().apply {
|
||||||
arguments = bundleOf(
|
arguments = bundleOf(
|
||||||
CONTEXT_ID to ctx,
|
CONTEXT_ID to ctx,
|
||||||
OBJECT_ID to objectId,
|
OBJECT_ID to objectId,
|
||||||
RELATION_ID to relationId,
|
RELATION_ID to relationId,
|
||||||
|
RELATION_KEY to relationKey,
|
||||||
FLOW_KEY to flow
|
FLOW_KEY to flow
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const val CONTEXT_ID = "arg.relation.add.file.context"
|
const val CONTEXT_ID = "arg.relation.add.file.context"
|
||||||
const val RELATION_ID = "arg.relation.add.file.relation.id"
|
const val RELATION_ID = "arg.relation.add.file.relation.id"
|
||||||
|
const val RELATION_KEY = "arg.relation.add.file.relation.key"
|
||||||
const val OBJECT_ID = "arg.relation.add.file.object.id"
|
const val OBJECT_ID = "arg.relation.add.file.object.id"
|
||||||
const val FLOW_KEY = "arg.relation.add.file.flow"
|
const val FLOW_KEY = "arg.relation.add.file.flow"
|
||||||
const val FLOW_DEFAULT = 0
|
const val FLOW_DEFAULT = 0
|
||||||
|
@ -166,7 +171,7 @@ class AddFileRelationFragment :
|
||||||
fun onFileValueChanged(
|
fun onFileValueChanged(
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id,
|
relationKey: Key,
|
||||||
ids: List<Id>
|
ids: List<Id>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_ui.features.relations.RelationObjectValueAdapter
|
import com.anytypeio.anytype.core_ui.features.relations.RelationObjectValueAdapter
|
||||||
import com.anytypeio.anytype.core_ui.reactive.clicks
|
import com.anytypeio.anytype.core_ui.reactive.clicks
|
||||||
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
||||||
|
@ -43,6 +44,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
||||||
private val ctx get() = argString(CONTEXT_ID)
|
private val ctx get() = argString(CONTEXT_ID)
|
||||||
private val objectId get() = argString(OBJECT_ID)
|
private val objectId get() = argString(OBJECT_ID)
|
||||||
private val relationId get() = argString(RELATION_ID)
|
private val relationId get() = argString(RELATION_ID)
|
||||||
|
private val relationKey get() = argString(RELATION_KEY)
|
||||||
private val types get() = arg<List<String>>(TARGET_TYPES)
|
private val types get() = arg<List<String>>(TARGET_TYPES)
|
||||||
private val flow get() = arg<Int>(FLOW_KEY)
|
private val flow get() = arg<Int>(FLOW_KEY)
|
||||||
|
|
||||||
|
@ -116,7 +118,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
||||||
}
|
}
|
||||||
super.onStart()
|
super.onStart()
|
||||||
setupAppearance()
|
setupAppearance()
|
||||||
vm.onStart(objectId = objectId, relationId = relationId, targetTypes = types)
|
vm.onStart(objectId = objectId, relationKey = relationKey, targetTypes = types)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
@ -142,7 +144,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
||||||
onObjectValueChanged(
|
onObjectValueChanged(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
objectId = objectId,
|
objectId = objectId,
|
||||||
relationId = relationId,
|
relationKey = relationKey,
|
||||||
ids = ids
|
ids = ids
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -187,6 +189,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id,
|
relationId: Id,
|
||||||
|
relationKey: Key,
|
||||||
types: List<Id>,
|
types: List<Id>,
|
||||||
flow: Int = FLOW_DEFAULT
|
flow: Int = FLOW_DEFAULT
|
||||||
) = AddObjectRelationFragment().apply {
|
) = AddObjectRelationFragment().apply {
|
||||||
|
@ -194,6 +197,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
||||||
CONTEXT_ID to ctx,
|
CONTEXT_ID to ctx,
|
||||||
OBJECT_ID to objectId,
|
OBJECT_ID to objectId,
|
||||||
RELATION_ID to relationId,
|
RELATION_ID to relationId,
|
||||||
|
RELATION_KEY to relationKey,
|
||||||
TARGET_TYPES to types,
|
TARGET_TYPES to types,
|
||||||
FLOW_KEY to flow
|
FLOW_KEY to flow
|
||||||
)
|
)
|
||||||
|
@ -201,6 +205,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
||||||
|
|
||||||
const val CONTEXT_ID = "arg.relation.add.object.context"
|
const val CONTEXT_ID = "arg.relation.add.object.context"
|
||||||
const val RELATION_ID = "arg.relation.add.object.relation.id"
|
const val RELATION_ID = "arg.relation.add.object.relation.id"
|
||||||
|
const val RELATION_KEY = "arg.relation.add.object.relation.key"
|
||||||
const val OBJECT_ID = "arg.relation.add.object.object.id"
|
const val OBJECT_ID = "arg.relation.add.object.object.id"
|
||||||
const val TARGET_TYPES = "arg.relation.add.object.target_types"
|
const val TARGET_TYPES = "arg.relation.add.object.target_types"
|
||||||
const val FLOW_KEY = "arg.relation.add.object.flow"
|
const val FLOW_KEY = "arg.relation.add.object.flow"
|
||||||
|
@ -212,7 +217,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
||||||
fun onObjectValueChanged(
|
fun onObjectValueChanged(
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id,
|
relationKey: Key,
|
||||||
ids: List<Id>
|
ids: List<Id>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.anytypeio.anytype.ui.relations.add
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.di.common.componentManager
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
import com.anytypeio.anytype.presentation.relations.RelationValueView
|
import com.anytypeio.anytype.presentation.relations.RelationValueView
|
||||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel
|
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel
|
||||||
|
@ -16,31 +17,24 @@ open class AddOptionsRelationDVFragment : BaseAddOptionsRelationFragment() {
|
||||||
|
|
||||||
override fun onStatusClicked(status: RelationValueView.Option.Status) {
|
override fun onStatusClicked(status: RelationValueView.Option.Status) {
|
||||||
vm.onAddObjectSetStatusClicked(
|
vm.onAddObjectSetStatusClicked(
|
||||||
ctx = ctx,
|
|
||||||
obj = target,
|
obj = target,
|
||||||
dataview = dataview,
|
relationKey = relationKey,
|
||||||
viewer = viewer,
|
|
||||||
relation = relation,
|
|
||||||
status = status
|
status = status
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionClicked(name: String) {
|
override fun onCreateOptionClicked(name: String) {
|
||||||
vm.onCreateDataViewRelationOptionClicked(
|
vm.onCreateDataViewRelationOptionClicked(
|
||||||
ctx = ctx,
|
relationKey = relationKey,
|
||||||
relation = relation,
|
|
||||||
name = name,
|
name = name,
|
||||||
dataview = dataview,
|
|
||||||
viewer = viewer,
|
|
||||||
target = target
|
target = target
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAddButtonClicked() {
|
override fun onAddButtonClicked() {
|
||||||
vm.onAddSelectedValuesToDataViewClicked(
|
vm.onAddSelectedValuesToDataViewClicked(
|
||||||
ctx = ctx,
|
|
||||||
target = target,
|
target = target,
|
||||||
relation = relation
|
relationKey = relationKey
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,14 +50,16 @@ open class AddOptionsRelationDVFragment : BaseAddOptionsRelationFragment() {
|
||||||
fun new(
|
fun new(
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
target: Id,
|
target: Id,
|
||||||
relation: Id,
|
relationId: Id,
|
||||||
|
relationKey: Key,
|
||||||
dataview: Id,
|
dataview: Id,
|
||||||
viewer: Id
|
viewer: Id
|
||||||
) = AddOptionsRelationDVFragment().apply {
|
) = AddOptionsRelationDVFragment().apply {
|
||||||
arguments = bundleOf(
|
arguments = bundleOf(
|
||||||
CTX_KEY to ctx,
|
CTX_KEY to ctx,
|
||||||
TARGET_KEY to target,
|
TARGET_KEY to target,
|
||||||
RELATION_KEY to relation,
|
RELATION_ID to relationId,
|
||||||
|
RELATION_KEY to relationKey,
|
||||||
DATAVIEW_KEY to dataview,
|
DATAVIEW_KEY to dataview,
|
||||||
VIEWER_KEY to viewer
|
VIEWER_KEY to viewer
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.anytypeio.anytype.ui.relations.add
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.di.common.componentManager
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
import com.anytypeio.anytype.presentation.relations.RelationValueView
|
import com.anytypeio.anytype.presentation.relations.RelationValueView
|
||||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationViewModel
|
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationViewModel
|
||||||
|
@ -17,15 +18,14 @@ class AddOptionsRelationFragment : BaseAddOptionsRelationFragment() {
|
||||||
override fun onStatusClicked(status: RelationValueView.Option.Status) {
|
override fun onStatusClicked(status: RelationValueView.Option.Status) {
|
||||||
vm.onAddObjectStatusClicked(
|
vm.onAddObjectStatusClicked(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relation = relation,
|
relationKey = relationKey,
|
||||||
status = status
|
status = status
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionClicked(name: String) {
|
override fun onCreateOptionClicked(name: String) {
|
||||||
vm.onCreateObjectRelationOptionClicked(
|
vm.onCreateObjectRelationOptionClicked(
|
||||||
ctx = ctx,
|
relationKey = relationKey,
|
||||||
relation = relation,
|
|
||||||
obj = target,
|
obj = target,
|
||||||
name = name
|
name = name
|
||||||
)
|
)
|
||||||
|
@ -33,9 +33,8 @@ class AddOptionsRelationFragment : BaseAddOptionsRelationFragment() {
|
||||||
|
|
||||||
override fun onAddButtonClicked() {
|
override fun onAddButtonClicked() {
|
||||||
vm.onAddSelectedValuesToObjectClicked(
|
vm.onAddSelectedValuesToObjectClicked(
|
||||||
ctx = ctx,
|
|
||||||
obj = target,
|
obj = target,
|
||||||
relation = relation,
|
relationKey = relationKey
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +50,14 @@ class AddOptionsRelationFragment : BaseAddOptionsRelationFragment() {
|
||||||
fun new(
|
fun new(
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id
|
relationId: Id,
|
||||||
|
relationKey: Key
|
||||||
) = AddOptionsRelationFragment().apply {
|
) = AddOptionsRelationFragment().apply {
|
||||||
arguments = bundleOf(
|
arguments = bundleOf(
|
||||||
CTX_KEY to ctx,
|
CTX_KEY to ctx,
|
||||||
TARGET_KEY to objectId,
|
TARGET_KEY to objectId,
|
||||||
RELATION_KEY to relationId
|
RELATION_ID to relationId,
|
||||||
|
RELATION_KEY to relationKey
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,8 @@ abstract class BaseAddOptionsRelationFragment : BaseDialogFragment<AddOptionRela
|
||||||
private val behavior get() = BottomSheetBehavior.from(binding.sheet)
|
private val behavior get() = BottomSheetBehavior.from(binding.sheet)
|
||||||
|
|
||||||
val ctx get() = argString(CTX_KEY)
|
val ctx get() = argString(CTX_KEY)
|
||||||
val relation get() = argString(RELATION_KEY)
|
val relationId get() = argString(RELATION_ID)
|
||||||
|
val relationKey get() = argString(RELATION_KEY)
|
||||||
val target get() = argString(TARGET_KEY)
|
val target get() = argString(TARGET_KEY)
|
||||||
val flow get() = arg<Int>(FLOW_KEY)
|
val flow get() = arg<Int>(FLOW_KEY)
|
||||||
val dataview get() = argString(DATAVIEW_KEY)
|
val dataview get() = argString(DATAVIEW_KEY)
|
||||||
|
@ -178,7 +179,7 @@ abstract class BaseAddOptionsRelationFragment : BaseDialogFragment<AddOptionRela
|
||||||
setupAppearance()
|
setupAppearance()
|
||||||
vm.onStart(
|
vm.onStart(
|
||||||
target = target,
|
target = target,
|
||||||
relationId = relation
|
relationKey = relationKey
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +206,8 @@ abstract class BaseAddOptionsRelationFragment : BaseDialogFragment<AddOptionRela
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val CTX_KEY = "arg.add-object-relation-value.ctx"
|
const val CTX_KEY = "arg.add-object-relation-value.ctx"
|
||||||
const val RELATION_KEY = "arg.add-object-relation-value.relation"
|
const val RELATION_ID = "arg.add-object-relation-value.relation.id"
|
||||||
|
const val RELATION_KEY = "arg.add-object-relation-value.relation.key"
|
||||||
const val TARGET_KEY = "arg.add-object-relation-value.target"
|
const val TARGET_KEY = "arg.add-object-relation-value.target"
|
||||||
const val FLOW_KEY = "arg.add-object-relation-value.flow"
|
const val FLOW_KEY = "arg.add-object-relation-value.flow"
|
||||||
const val DATAVIEW_KEY = "arg.add-object-relation-value.data-view"
|
const val DATAVIEW_KEY = "arg.add-object-relation-value.data-view"
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
package com.anytypeio.anytype.ui.sets
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.viewModels
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import androidx.lifecycle.observe
|
|
||||||
import androidx.recyclerview.widget.ConcatAdapter
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
|
||||||
import com.anytypeio.anytype.R
|
|
||||||
import com.anytypeio.anytype.core_ui.features.sets.CreateSetHeaderAdapter
|
|
||||||
import com.anytypeio.anytype.core_ui.features.sets.CreateSetObjectTypeAdapter
|
|
||||||
import com.anytypeio.anytype.core_utils.ext.argString
|
|
||||||
import com.anytypeio.anytype.databinding.FragmentCreateSetBinding
|
|
||||||
import com.anytypeio.anytype.di.common.componentManager
|
|
||||||
import com.anytypeio.anytype.presentation.sets.CreateObjectSetViewModel
|
|
||||||
import com.anytypeio.anytype.presentation.sets.CreateObjectTypeView
|
|
||||||
import com.anytypeio.anytype.presentation.sets.CreateSetViewState
|
|
||||||
import com.anytypeio.anytype.ui.base.NavigationFragment
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import kotlinx.coroutines.flow.onEach
|
|
||||||
import timber.log.Timber
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class CreateObjectSetFragment : NavigationFragment<FragmentCreateSetBinding>(R.layout.fragment_create_set),
|
|
||||||
CreateObjectTypeCallback {
|
|
||||||
|
|
||||||
private val ctx: String get() = argString(CONTEXT_ID_KEY)
|
|
||||||
|
|
||||||
private val vm: CreateObjectSetViewModel by viewModels { factory }
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var factory: CreateObjectSetViewModel.Factory
|
|
||||||
|
|
||||||
private val headerAdapter by lazy {
|
|
||||||
CreateSetHeaderAdapter { vm.onCreateNewObjectType() }
|
|
||||||
}
|
|
||||||
|
|
||||||
private val typeAdapter by lazy {
|
|
||||||
CreateSetObjectTypeAdapter { type -> vm.onObjectTypeSelected(type, ctx) }
|
|
||||||
}
|
|
||||||
|
|
||||||
private val createSetAdapter by lazy {
|
|
||||||
ConcatAdapter(headerAdapter, typeAdapter)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
vm.state.observe(viewLifecycleOwner) { observe(it) }
|
|
||||||
binding.recycler.apply {
|
|
||||||
layoutManager = LinearLayoutManager(context)
|
|
||||||
adapter = createSetAdapter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
vm.objectTypeViews.onEach {
|
|
||||||
Timber.d("Receiving new views: $it")
|
|
||||||
typeAdapter.views = it
|
|
||||||
typeAdapter.notifyDataSetChanged()
|
|
||||||
createSetAdapter.notifyDataSetChanged()
|
|
||||||
}.launchIn(lifecycleScope)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateObjectTypeClicked(type: CreateObjectTypeView, name: String) {
|
|
||||||
vm.onCreateObjectTypeClicked(type, name)
|
|
||||||
Timber.d("CreateObjectType:$type, $name")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun injectDependencies() {
|
|
||||||
componentManager().createSetComponent.get().inject(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun releaseDependencies() {
|
|
||||||
componentManager().createSetComponent.release()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun observe(state: CreateSetViewState) {
|
|
||||||
when (state) {
|
|
||||||
is CreateSetViewState.AddObjectType -> {
|
|
||||||
CreateObjectTypeFragment.newInstance(state.data).show(childFragmentManager, null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun inflateBinding(
|
|
||||||
inflater: LayoutInflater,
|
|
||||||
container: ViewGroup?
|
|
||||||
): FragmentCreateSetBinding = FragmentCreateSetBinding.inflate(
|
|
||||||
inflater, container, false
|
|
||||||
)
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val CONTEXT_ID_KEY = "arg.create_object_set.context"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CreateObjectTypeCallback {
|
|
||||||
fun onCreateObjectTypeClicked(type: CreateObjectTypeView, name: String)
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
package com.anytypeio.anytype.ui.sets
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.viewModels
|
|
||||||
import androidx.lifecycle.observe
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
|
||||||
import com.anytypeio.anytype.core_ui.features.sets.CreateObjectTypeAdapter
|
|
||||||
import com.anytypeio.anytype.core_utils.ext.hideKeyboard
|
|
||||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment
|
|
||||||
import com.anytypeio.anytype.databinding.FragmentCreateObjectTypeBinding
|
|
||||||
import com.anytypeio.anytype.di.common.componentManager
|
|
||||||
import com.anytypeio.anytype.presentation.sets.CreateObjectTypeView
|
|
||||||
import com.anytypeio.anytype.presentation.sets.CreateObjectTypeViewModel
|
|
||||||
import com.anytypeio.anytype.presentation.sets.CreateObjectTypeViewState
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class CreateObjectTypeFragment : BaseBottomSheetFragment<FragmentCreateObjectTypeBinding>() {
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var factory: CreateObjectTypeViewModel.Factory
|
|
||||||
private val vm by viewModels<CreateObjectTypeViewModel> { factory }
|
|
||||||
private val typesAdapter by lazy { CreateObjectTypeAdapter { vm.onSelectType(it) } }
|
|
||||||
private val types: List<CreateObjectTypeView>
|
|
||||||
get() {
|
|
||||||
val args = requireArguments()
|
|
||||||
val list =
|
|
||||||
args.getParcelableArrayList<CreateObjectTypeView>(ARG_TYPES)
|
|
||||||
checkNotNull(list)
|
|
||||||
return list
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
binding.btnCreate.setOnClickListener { vm.onCreateClicked(binding.edtTypeName.text.toString()) }
|
|
||||||
vm.state.observe(viewLifecycleOwner) { observeData(it) }
|
|
||||||
binding.rvTypes.layoutManager = LinearLayoutManager(requireContext())
|
|
||||||
binding.rvTypes.adapter = typesAdapter
|
|
||||||
vm.init(types)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun observeData(state: CreateObjectTypeViewState) {
|
|
||||||
when (state) {
|
|
||||||
CreateObjectTypeViewState.Loading -> TODO()
|
|
||||||
is CreateObjectTypeViewState.Success -> {
|
|
||||||
typesAdapter.types = state.data
|
|
||||||
typesAdapter.notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
is CreateObjectTypeViewState.Exit -> {
|
|
||||||
(parentFragment as CreateObjectTypeCallback).onCreateObjectTypeClicked(
|
|
||||||
state.type,
|
|
||||||
state.name
|
|
||||||
)
|
|
||||||
binding.edtTypeName.hideKeyboard()
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun injectDependencies() {
|
|
||||||
componentManager().createObjectTypeComponent.get().inject(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun releaseDependencies() {
|
|
||||||
componentManager().createObjectTypeComponent.release()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun inflateBinding(
|
|
||||||
inflater: LayoutInflater,
|
|
||||||
container: ViewGroup?
|
|
||||||
): FragmentCreateObjectTypeBinding = FragmentCreateObjectTypeBinding.inflate(
|
|
||||||
inflater, container, false
|
|
||||||
)
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
private const val ARG_TYPES = "arg.create.object.types"
|
|
||||||
|
|
||||||
fun newInstance(types: ArrayList<CreateObjectTypeView>): CreateObjectTypeFragment =
|
|
||||||
CreateObjectTypeFragment().apply {
|
|
||||||
arguments = Bundle().apply {
|
|
||||||
putParcelableArrayList(ARG_TYPES, types)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -32,6 +32,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.anytypeio.anytype.BuildConfig
|
import com.anytypeio.anytype.BuildConfig
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_models.SyncStatus
|
import com.anytypeio.anytype.core_models.SyncStatus
|
||||||
import com.anytypeio.anytype.core_ui.extensions.setEmojiOrNull
|
import com.anytypeio.anytype.core_ui.extensions.setEmojiOrNull
|
||||||
import com.anytypeio.anytype.core_ui.features.dataview.ViewerGridAdapter
|
import com.anytypeio.anytype.core_ui.features.dataview.ViewerGridAdapter
|
||||||
|
@ -73,7 +74,10 @@ import com.anytypeio.anytype.ui.base.NavigationFragment
|
||||||
import com.anytypeio.anytype.ui.editor.cover.SelectCoverObjectSetFragment
|
import com.anytypeio.anytype.ui.editor.cover.SelectCoverObjectSetFragment
|
||||||
import com.anytypeio.anytype.ui.editor.modals.IconPickerFragmentBase
|
import com.anytypeio.anytype.ui.editor.modals.IconPickerFragmentBase
|
||||||
import com.anytypeio.anytype.ui.editor.sheets.ObjectMenuBaseFragment
|
import com.anytypeio.anytype.ui.editor.sheets.ObjectMenuBaseFragment
|
||||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment
|
import com.anytypeio.anytype.ui.objects.BaseObjectTypeChangeFragment
|
||||||
|
import com.anytypeio.anytype.ui.objects.types.pickers.DataViewSelectSourceFragment
|
||||||
|
import com.anytypeio.anytype.ui.objects.types.pickers.EmptyDataViewSelectSourceFragment
|
||||||
|
import com.anytypeio.anytype.ui.objects.types.pickers.OnDataViewSelectSourceAction
|
||||||
import com.anytypeio.anytype.ui.relations.RelationDateValueFragment
|
import com.anytypeio.anytype.ui.relations.RelationDateValueFragment
|
||||||
import com.anytypeio.anytype.ui.relations.RelationDateValueFragment.DateValueEditReceiver
|
import com.anytypeio.anytype.ui.relations.RelationDateValueFragment.DateValueEditReceiver
|
||||||
import com.anytypeio.anytype.ui.relations.RelationTextValueFragment
|
import com.anytypeio.anytype.ui.relations.RelationTextValueFragment
|
||||||
|
@ -83,8 +87,7 @@ import com.anytypeio.anytype.ui.sets.modals.CreateDataViewViewerFragment
|
||||||
import com.anytypeio.anytype.ui.sets.modals.EditDataViewViewerFragment
|
import com.anytypeio.anytype.ui.sets.modals.EditDataViewViewerFragment
|
||||||
import com.anytypeio.anytype.ui.sets.modals.ManageViewerFragment
|
import com.anytypeio.anytype.ui.sets.modals.ManageViewerFragment
|
||||||
import com.anytypeio.anytype.ui.sets.modals.ObjectSetSettingsFragment
|
import com.anytypeio.anytype.ui.sets.modals.ObjectSetSettingsFragment
|
||||||
import com.anytypeio.anytype.ui.sets.modals.SetObjectCreateBookmarkRecordFragment
|
import com.anytypeio.anytype.ui.sets.modals.SetObjectCreateRecordFragmentBase
|
||||||
import com.anytypeio.anytype.ui.sets.modals.SetObjectSetRecordNameFragment
|
|
||||||
import com.anytypeio.anytype.ui.sets.modals.ViewerBottomSheetRootFragment
|
import com.anytypeio.anytype.ui.sets.modals.ViewerBottomSheetRootFragment
|
||||||
import com.anytypeio.anytype.ui.sets.modals.sort.ViewerSortFragment
|
import com.anytypeio.anytype.ui.sets.modals.sort.ViewerSortFragment
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
@ -96,7 +99,8 @@ import javax.inject.Inject
|
||||||
open class ObjectSetFragment :
|
open class ObjectSetFragment :
|
||||||
NavigationFragment<FragmentObjectSetBinding>(R.layout.fragment_object_set),
|
NavigationFragment<FragmentObjectSetBinding>(R.layout.fragment_object_set),
|
||||||
TextValueEditReceiver,
|
TextValueEditReceiver,
|
||||||
DateValueEditReceiver {
|
DateValueEditReceiver,
|
||||||
|
OnDataViewSelectSourceAction {
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
|
|
||||||
|
@ -187,7 +191,7 @@ open class ObjectSetFragment :
|
||||||
binding.root.setTransitionListener(transitionListener)
|
binding.root.setTransitionListener(transitionListener)
|
||||||
|
|
||||||
with(lifecycleScope) {
|
with(lifecycleScope) {
|
||||||
subscribe(addNewButton.clicks().throttleFirst()) { vm.onCreateNewRecord() }
|
subscribe(addNewButton.clicks().throttleFirst()) { vm.onCreateNewDataViewObject() }
|
||||||
subscribe(title.editorActionEvents(actionHandler)) {
|
subscribe(title.editorActionEvents(actionHandler)) {
|
||||||
title.apply {
|
title.apply {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
|
@ -262,8 +266,8 @@ open class ObjectSetFragment :
|
||||||
DefaultTextWatcher { vm.onTitleChanged(it.toString()) }
|
DefaultTextWatcher { vm.onTitleChanged(it.toString()) }
|
||||||
)
|
)
|
||||||
|
|
||||||
setFragmentResultListener(ObjectTypeChangeFragment.OBJECT_TYPE_REQUEST_KEY) { _, bundle ->
|
setFragmentResultListener(BaseObjectTypeChangeFragment.OBJECT_TYPE_REQUEST_KEY) { _, bundle ->
|
||||||
val source = bundle.getString(ObjectTypeChangeFragment.OBJECT_TYPE_URL_KEY)
|
val source = bundle.getString(BaseObjectTypeChangeFragment.OBJECT_TYPE_URL_KEY)
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
vm.onDataViewSourcePicked(source = source)
|
vm.onDataViewSourcePicked(source = source)
|
||||||
} else {
|
} else {
|
||||||
|
@ -582,20 +586,24 @@ open class ObjectSetFragment :
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is ObjectSetCommand.Modal.EditGridTextCell -> {
|
is ObjectSetCommand.Modal.EditGridTextCell -> {
|
||||||
|
//todo Relation as object, fix relationKey
|
||||||
val fr = RelationTextValueFragment.new(
|
val fr = RelationTextValueFragment.new(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = command.relationId,
|
relationId = "",
|
||||||
objectId = command.recordId,
|
objectId = command.recordId,
|
||||||
flow = RelationTextValueFragment.FLOW_DATAVIEW
|
flow = RelationTextValueFragment.FLOW_DATAVIEW,
|
||||||
|
relationKey = command.relationKey
|
||||||
)
|
)
|
||||||
fr.show(childFragmentManager, EMPTY_TAG)
|
fr.show(childFragmentManager, EMPTY_TAG)
|
||||||
}
|
}
|
||||||
is ObjectSetCommand.Modal.EditGridDateCell -> {
|
is ObjectSetCommand.Modal.EditGridDateCell -> {
|
||||||
|
//todo Relation as object, fix relationKey
|
||||||
val fr = RelationDateValueFragment.new(
|
val fr = RelationDateValueFragment.new(
|
||||||
ctx = ctx,
|
ctx = ctx,
|
||||||
relationId = command.relationId,
|
relationId = command.relationKey,
|
||||||
objectId = command.objectId,
|
objectId = command.objectId,
|
||||||
flow = RelationDateValueFragment.FLOW_DATAVIEW
|
flow = RelationDateValueFragment.FLOW_DATAVIEW,
|
||||||
|
relationKey = ""
|
||||||
)
|
)
|
||||||
fr.show(childFragmentManager, EMPTY_TAG)
|
fr.show(childFragmentManager, EMPTY_TAG)
|
||||||
}
|
}
|
||||||
|
@ -607,7 +615,8 @@ open class ObjectSetFragment :
|
||||||
RelationValueBaseFragment.CTX_KEY to command.ctx,
|
RelationValueBaseFragment.CTX_KEY to command.ctx,
|
||||||
RelationValueBaseFragment.TARGET_KEY to command.target,
|
RelationValueBaseFragment.TARGET_KEY to command.target,
|
||||||
RelationValueBaseFragment.DATAVIEW_KEY to command.dataview,
|
RelationValueBaseFragment.DATAVIEW_KEY to command.dataview,
|
||||||
RelationValueBaseFragment.RELATION_KEY to command.relation,
|
RelationValueBaseFragment.RELATION_KEY to command.relationKey,
|
||||||
|
RelationValueBaseFragment.RELATION_ID to "",
|
||||||
RelationValueBaseFragment.VIEWER_KEY to command.viewer,
|
RelationValueBaseFragment.VIEWER_KEY to command.viewer,
|
||||||
RelationValueBaseFragment.TARGET_TYPES_KEY to command.targetObjectTypes,
|
RelationValueBaseFragment.TARGET_TYPES_KEY to command.targetObjectTypes,
|
||||||
RelationValueBaseFragment.IS_LOCKED_KEY to false
|
RelationValueBaseFragment.IS_LOCKED_KEY to false
|
||||||
|
@ -647,11 +656,14 @@ open class ObjectSetFragment :
|
||||||
)
|
)
|
||||||
fr.show(childFragmentManager, EMPTY_TAG)
|
fr.show(childFragmentManager, EMPTY_TAG)
|
||||||
}
|
}
|
||||||
is ObjectSetCommand.Modal.SetNameForCreatedRecord -> {
|
is ObjectSetCommand.Modal.SetNameForCreatedObject -> {
|
||||||
findNavController().safeNavigate(
|
findNavController().safeNavigate(
|
||||||
R.id.objectSetScreen,
|
R.id.objectSetScreen,
|
||||||
R.id.setNameForNewRecordScreen,
|
R.id.setNameForNewRecordScreen,
|
||||||
bundleOf(SetObjectSetRecordNameFragment.CONTEXT_KEY to command.ctx)
|
bundleOf(
|
||||||
|
SetObjectCreateRecordFragmentBase.CONTEXT_KEY to command.ctx,
|
||||||
|
SetObjectCreateRecordFragmentBase.TARGET_KEY to command.target
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is ObjectSetCommand.Intent.MailTo -> {
|
is ObjectSetCommand.Intent.MailTo -> {
|
||||||
|
@ -717,22 +729,17 @@ open class ObjectSetFragment :
|
||||||
findNavController().safeNavigate(
|
findNavController().safeNavigate(
|
||||||
R.id.objectSetScreen,
|
R.id.objectSetScreen,
|
||||||
R.id.setUrlForNewBookmark,
|
R.id.setUrlForNewBookmark,
|
||||||
bundleOf(
|
bundleOf(SetObjectCreateRecordFragmentBase.CONTEXT_KEY to command.ctx))
|
||||||
SetObjectCreateBookmarkRecordFragment.CTX_KEY to command.ctx
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
is ObjectSetCommand.Modal.OpenSelectSourceScreen -> {
|
is ObjectSetCommand.Modal.OpenDataViewSelectSourceScreen -> {
|
||||||
findNavController()
|
val fr = DataViewSelectSourceFragment.newInstance(
|
||||||
.safeNavigate(
|
selectedTypes = command.selectedTypes
|
||||||
R.id.objectSetScreen,
|
)
|
||||||
R.id.objectTypeChangeScreen,
|
fr.show(childFragmentManager, null)
|
||||||
bundleOf(
|
}
|
||||||
ObjectTypeChangeFragment.ARG_SMART_BLOCK_TYPE to command.smartBlockType,
|
is ObjectSetCommand.Modal.OpenEmptyDataViewSelectSourceScreen -> {
|
||||||
ObjectTypeChangeFragment.ARG_IS_SET_SOURCE to true,
|
val fr = EmptyDataViewSelectSourceFragment()
|
||||||
ObjectTypeChangeFragment.ARG_SOURCES to command.sources
|
fr.show(childFragmentManager, null)
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -864,11 +871,11 @@ open class ObjectSetFragment :
|
||||||
ctx: String,
|
ctx: String,
|
||||||
text: String,
|
text: String,
|
||||||
objectId: String,
|
objectId: String,
|
||||||
relationId: String
|
relationKey: Key
|
||||||
) = vm.onRelationTextValueChanged(
|
) = vm.onRelationTextValueChanged(
|
||||||
value = text,
|
value = text,
|
||||||
objectId = objectId,
|
objectId = objectId,
|
||||||
relationKey = relationId
|
relationKey = relationKey
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun onNumberValueChanged(
|
override fun onNumberValueChanged(
|
||||||
|
@ -886,15 +893,19 @@ open class ObjectSetFragment :
|
||||||
ctx: Id,
|
ctx: Id,
|
||||||
timeInSeconds: Number?,
|
timeInSeconds: Number?,
|
||||||
objectId: Id,
|
objectId: Id,
|
||||||
relationId: Id
|
relationKey: Key
|
||||||
) {
|
) {
|
||||||
vm.onRelationTextValueChanged(
|
vm.onRelationTextValueChanged(
|
||||||
value = timeInSeconds,
|
value = timeInSeconds,
|
||||||
objectId = objectId,
|
objectId = objectId,
|
||||||
relationKey = relationId
|
relationKey = relationKey
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onProceedWithSelectSource(id: Id) {
|
||||||
|
vm.onDataViewSourcePicked(source = id)
|
||||||
|
}
|
||||||
|
|
||||||
override fun injectDependencies() {
|
override fun injectDependencies() {
|
||||||
componentManager().objectSetComponent.get(ctx).inject(this)
|
componentManager().objectSetComponent.get(ctx).inject(this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.view.ViewGroup
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import com.anytypeio.anytype.core_utils.ext.arg
|
|
||||||
import com.anytypeio.anytype.databinding.FragmentSetObjectCreateBookmarkRecordBinding
|
import com.anytypeio.anytype.databinding.FragmentSetObjectCreateBookmarkRecordBinding
|
||||||
import com.anytypeio.anytype.di.common.componentManager
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetCreateBookmarkRecordViewModel
|
import com.anytypeio.anytype.presentation.sets.ObjectSetCreateBookmarkRecordViewModel
|
||||||
|
@ -15,15 +14,12 @@ import javax.inject.Inject
|
||||||
class SetObjectCreateBookmarkRecordFragment :
|
class SetObjectCreateBookmarkRecordFragment :
|
||||||
SetObjectCreateRecordFragmentBase<FragmentSetObjectCreateBookmarkRecordBinding>() {
|
SetObjectCreateRecordFragmentBase<FragmentSetObjectCreateBookmarkRecordBinding>() {
|
||||||
|
|
||||||
|
|
||||||
override val textInputType: Int = TYPE_TEXT_VARIATION_URI
|
override val textInputType: Int = TYPE_TEXT_VARIATION_URI
|
||||||
override val textInputField: EditText
|
override val textInputField: EditText
|
||||||
get() = binding.textInputField
|
get() = binding.textInputField
|
||||||
override val button: TextView
|
override val button: TextView
|
||||||
get() = binding.button
|
get() = binding.button
|
||||||
|
|
||||||
private val ctx: String get() = arg(CTX_KEY)
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var factory: ObjectSetCreateBookmarkRecordViewModel.Factory
|
lateinit var factory: ObjectSetCreateBookmarkRecordViewModel.Factory
|
||||||
override val vm: ObjectSetCreateBookmarkRecordViewModel by viewModels { factory }
|
override val vm: ObjectSetCreateBookmarkRecordViewModel by viewModels { factory }
|
||||||
|
@ -37,15 +33,18 @@ class SetObjectCreateBookmarkRecordFragment :
|
||||||
componentManager().objectSetCreateBookmarkRecordComponent.release(ctx)
|
componentManager().objectSetCreateBookmarkRecordComponent.release(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onButtonClicked() {
|
||||||
|
vm.onButtonClicked(input = textInputField.text.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onKeyboardActionDone() {
|
||||||
|
vm.onActionDone(input = textInputField.text.toString())
|
||||||
|
}
|
||||||
|
|
||||||
override fun inflateBinding(
|
override fun inflateBinding(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?
|
container: ViewGroup?
|
||||||
): FragmentSetObjectCreateBookmarkRecordBinding =
|
): FragmentSetObjectCreateBookmarkRecordBinding = FragmentSetObjectCreateBookmarkRecordBinding.inflate(
|
||||||
FragmentSetObjectCreateBookmarkRecordBinding.inflate(
|
|
||||||
inflater, container, false
|
inflater, container, false
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val CTX_KEY = "arg.object-set-record.context"
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -14,8 +14,7 @@ import com.anytypeio.anytype.core_utils.ext.argString
|
||||||
import com.anytypeio.anytype.core_utils.ext.hideKeyboard
|
import com.anytypeio.anytype.core_utils.ext.hideKeyboard
|
||||||
import com.anytypeio.anytype.core_utils.ext.toast
|
import com.anytypeio.anytype.core_utils.ext.toast
|
||||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment
|
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment
|
||||||
import com.anytypeio.anytype.presentation.sets.ObjectSetCreateRecordViewModelBase
|
import com.anytypeio.anytype.presentation.sets.SetDataViewObjectNameViewModelBase
|
||||||
import com.anytypeio.anytype.ui.sets.modals.SetObjectSetRecordNameFragment.Companion.CONTEXT_KEY
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
@ -23,11 +22,15 @@ abstract class SetObjectCreateRecordFragmentBase<T: ViewBinding> :
|
||||||
BaseBottomSheetFragment<T>() {
|
BaseBottomSheetFragment<T>() {
|
||||||
|
|
||||||
protected abstract val textInputType: Int
|
protected abstract val textInputType: Int
|
||||||
private val ctx: String get() = argString(CONTEXT_KEY)
|
|
||||||
protected abstract val textInputField: EditText
|
protected abstract val textInputField: EditText
|
||||||
protected abstract val button: View
|
protected abstract val button: View
|
||||||
|
|
||||||
protected abstract val vm: ObjectSetCreateRecordViewModelBase
|
protected abstract val vm: SetDataViewObjectNameViewModelBase
|
||||||
|
|
||||||
|
abstract fun onButtonClicked()
|
||||||
|
abstract fun onKeyboardActionDone()
|
||||||
|
|
||||||
|
protected val ctx: String get() = argString(CONTEXT_KEY)
|
||||||
|
|
||||||
private val handler: (Int) -> Boolean = { action ->
|
private val handler: (Int) -> Boolean = { action ->
|
||||||
action == EditorInfo.IME_ACTION_DONE
|
action == EditorInfo.IME_ACTION_DONE
|
||||||
|
@ -35,15 +38,8 @@ abstract class SetObjectCreateRecordFragmentBase<T: ViewBinding> :
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
textInputField.apply {
|
textInputField.apply { setRawInputType(textInputType) }
|
||||||
setRawInputType(textInputType)
|
button.setOnClickListener { onButtonClicked() }
|
||||||
}
|
|
||||||
button.setOnClickListener {
|
|
||||||
vm.onButtonClicked(
|
|
||||||
ctx = ctx,
|
|
||||||
input = textInputField.text.toString()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||||
onStart(this)
|
onStart(this)
|
||||||
|
@ -68,11 +64,16 @@ abstract class SetObjectCreateRecordFragmentBase<T: ViewBinding> :
|
||||||
textInputField.editorActionEvents(handler).collect {
|
textInputField.editorActionEvents(handler).collect {
|
||||||
textInputField.clearFocus()
|
textInputField.clearFocus()
|
||||||
textInputField.hideKeyboard()
|
textInputField.hideKeyboard()
|
||||||
vm.onComplete(ctx, textInputField.text.toString())
|
onKeyboardActionDone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun subscribeIsCompleted() {
|
private suspend fun subscribeIsCompleted() {
|
||||||
vm.isCompleted.collect { isCompleted -> if (isCompleted) dismiss() }
|
vm.isCompleted.collect { isCompleted -> if (isCompleted) dismiss() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val CONTEXT_KEY = "arg.object-set-record.context"
|
||||||
|
const val TARGET_KEY = "arg.object-set-record.target"
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -28,12 +28,13 @@ class SetObjectSetRecordNameFragment : SetObjectCreateRecordFragmentBase<Fragmen
|
||||||
get() = binding.textInputField
|
get() = binding.textInputField
|
||||||
override val button: AppCompatImageButton
|
override val button: AppCompatImageButton
|
||||||
get() = binding.icExpand
|
get() = binding.icExpand
|
||||||
private val ctx: String get() = argString(CONTEXT_KEY)
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var factory: ObjectSetRecordViewModel.Factory
|
lateinit var factory: ObjectSetRecordViewModel.Factory
|
||||||
override val vm: ObjectSetRecordViewModel by viewModels { factory }
|
override val vm: ObjectSetRecordViewModel by viewModels { factory }
|
||||||
|
|
||||||
|
private val target: String get() = argString(TARGET_KEY)
|
||||||
|
|
||||||
override fun onStart(scope: CoroutineScope) {
|
override fun onStart(scope: CoroutineScope) {
|
||||||
super.onStart(scope)
|
super.onStart(scope)
|
||||||
scope.launch { subscribeCommands() }
|
scope.launch { subscribeCommands() }
|
||||||
|
@ -52,6 +53,20 @@ class SetObjectSetRecordNameFragment : SetObjectCreateRecordFragmentBase<Fragmen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onButtonClicked() {
|
||||||
|
vm.onButtonClicked(
|
||||||
|
target = target,
|
||||||
|
input = textInputField.text.toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onKeyboardActionDone() {
|
||||||
|
vm.onActionDone(
|
||||||
|
target = target,
|
||||||
|
input = textInputField.text.toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
override fun injectDependencies() {
|
override fun injectDependencies() {
|
||||||
componentManager().objectSetRecordComponent.get(ctx).inject(this)
|
componentManager().objectSetRecordComponent.get(ctx).inject(this)
|
||||||
}
|
}
|
||||||
|
@ -66,8 +81,4 @@ class SetObjectSetRecordNameFragment : SetObjectCreateRecordFragmentBase<Fragmen
|
||||||
): FragmentSetObjectSetRecordNameBinding = FragmentSetObjectSetRecordNameBinding.inflate(
|
): FragmentSetObjectSetRecordNameBinding = FragmentSetObjectSetRecordNameBinding.inflate(
|
||||||
inflater, container, false
|
inflater, container, false
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val CONTEXT_KEY = "arg.object-set-record.context"
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -12,11 +12,18 @@ import androidx.recyclerview.widget.DividerItemDecoration
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_ui.extensions.relationIcon
|
import com.anytypeio.anytype.core_ui.extensions.relationIcon
|
||||||
import com.anytypeio.anytype.core_ui.features.sets.CreateFilterAdapter
|
import com.anytypeio.anytype.core_ui.features.sets.CreateFilterAdapter
|
||||||
import com.anytypeio.anytype.core_ui.reactive.clicks
|
import com.anytypeio.anytype.core_ui.reactive.clicks
|
||||||
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
import com.anytypeio.anytype.core_ui.reactive.textChanges
|
||||||
import com.anytypeio.anytype.core_utils.ext.*
|
import com.anytypeio.anytype.core_utils.ext.arg
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.drawable
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.gone
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.invisible
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.visible
|
||||||
|
import com.anytypeio.anytype.core_utils.ext.withParent
|
||||||
import com.anytypeio.anytype.core_utils.ui.BaseFragment
|
import com.anytypeio.anytype.core_utils.ui.BaseFragment
|
||||||
import com.anytypeio.anytype.databinding.FragmentCreateOrUpdateFilterBinding
|
import com.anytypeio.anytype.databinding.FragmentCreateOrUpdateFilterBinding
|
||||||
import com.anytypeio.anytype.di.common.componentManager
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
|
@ -118,15 +125,15 @@ open class CreateFilterFromSelectedValueFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextValueChanged(ctx: Id, text: String, objectId: Id, relationId: Id) {}
|
override fun onTextValueChanged(ctx: Id, text: String, objectId: Id, relationKey: Key) {}
|
||||||
|
|
||||||
override fun onNumberValueChanged(ctx: Id, number: Double?, objectId: Id, relationId: Id) {
|
override fun onNumberValueChanged(ctx: Id, number: Double?, objectId: Id, relationKey: Key) {
|
||||||
helper.handleNumberValueChanged(this, number, vm)
|
helper.handleNumberValueChanged(this, number, vm)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
vm.onStart(relationId = relation, filterIndex = FILTER_INDEX_EMPTY)
|
vm.onStart(relationKey = relation, filterIndex = FILTER_INDEX_EMPTY)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import androidx.recyclerview.widget.DividerItemDecoration
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.anytypeio.anytype.R
|
import com.anytypeio.anytype.R
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
|
import com.anytypeio.anytype.core_models.Key
|
||||||
import com.anytypeio.anytype.core_ui.extensions.relationIcon
|
import com.anytypeio.anytype.core_ui.extensions.relationIcon
|
||||||
import com.anytypeio.anytype.core_ui.features.sets.CreateFilterAdapter
|
import com.anytypeio.anytype.core_ui.features.sets.CreateFilterAdapter
|
||||||
import com.anytypeio.anytype.core_ui.reactive.clicks
|
import com.anytypeio.anytype.core_ui.reactive.clicks
|
||||||
|
@ -169,9 +170,9 @@ open class ModifyFilterFromSelectedValueFragment :
|
||||||
vm.onExactDayPicked(timeInSeconds)
|
vm.onExactDayPicked(timeInSeconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextValueChanged(ctx: Id, text: String, objectId: Id, relationId: Id) {}
|
override fun onTextValueChanged(ctx: Id, text: String, objectId: Id, relationKey: Key) {}
|
||||||
|
|
||||||
override fun onNumberValueChanged(ctx: Id, number: Double?, objectId: Id, relationId: Id) {
|
override fun onNumberValueChanged(ctx: Id, number: Double?, objectId: Id, relationKey: Key) {
|
||||||
helper.handleNumberValueChanged(this, number, vm)
|
helper.handleNumberValueChanged(this, number, vm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,9 @@ import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.os.bundleOf
|
|
||||||
import androidx.fragment.app.setFragmentResultListener
|
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.fragment.findNavController
|
import com.anytypeio.anytype.core_models.Id
|
||||||
import com.anytypeio.anytype.R
|
|
||||||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||||
import com.anytypeio.anytype.core_utils.ext.toast
|
import com.anytypeio.anytype.core_utils.ext.toast
|
||||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment
|
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment
|
||||||
|
@ -17,23 +14,19 @@ import com.anytypeio.anytype.databinding.FragmentUserSettingsBinding
|
||||||
import com.anytypeio.anytype.di.common.componentManager
|
import com.anytypeio.anytype.di.common.componentManager
|
||||||
import com.anytypeio.anytype.presentation.settings.OtherSettingsViewModel
|
import com.anytypeio.anytype.presentation.settings.OtherSettingsViewModel
|
||||||
import com.anytypeio.anytype.ui.dashboard.ClearCacheAlertFragment
|
import com.anytypeio.anytype.ui.dashboard.ClearCacheAlertFragment
|
||||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment
|
import com.anytypeio.anytype.ui.objects.types.pickers.AppDefaultObjectTypeFragment
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class OtherSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBinding>() {
|
class OtherSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBinding>(),
|
||||||
|
AppDefaultObjectTypeFragment.OnObjectTypeAction {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var factory: OtherSettingsViewModel.Factory
|
lateinit var factory: OtherSettingsViewModel.Factory
|
||||||
|
|
||||||
private val vm by viewModels<OtherSettingsViewModel> { factory }
|
private val vm by viewModels<OtherSettingsViewModel> { factory }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onProceedWithUpdateType(id: Id, name: String) {
|
||||||
super.onCreate(savedInstanceState)
|
vm.proceedWithUpdateType(type = id, name = name)
|
||||||
setFragmentResultListener(ObjectTypeChangeFragment.OBJECT_TYPE_REQUEST_KEY) { _, bundle ->
|
|
||||||
val id = bundle.getString(ObjectTypeChangeFragment.OBJECT_TYPE_URL_KEY)
|
|
||||||
val name = bundle.getString(ObjectTypeChangeFragment.OBJECT_TYPE_NAME_KEY)
|
|
||||||
vm.proceedWithUpdateType(type = id, name = name)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
@ -55,13 +48,10 @@ class OtherSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBindin
|
||||||
when (command) {
|
when (command) {
|
||||||
is OtherSettingsViewModel.Command.Exit -> dismiss()
|
is OtherSettingsViewModel.Command.Exit -> dismiss()
|
||||||
is OtherSettingsViewModel.Command.NavigateToObjectTypesScreen -> {
|
is OtherSettingsViewModel.Command.NavigateToObjectTypesScreen -> {
|
||||||
findNavController().navigate(
|
val fr = AppDefaultObjectTypeFragment.newInstance(
|
||||||
R.id.objectTypeChangeScreen,
|
excludeTypes = command.excludeTypes
|
||||||
bundleOf(
|
|
||||||
ObjectTypeChangeFragment.ARG_SMART_BLOCK_TYPE to command.smartBlockType,
|
|
||||||
ObjectTypeChangeFragment.ARG_EXCLUDED_TYPES to command.excludedTypes
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
fr.show(childFragmentManager, null)
|
||||||
}
|
}
|
||||||
is OtherSettingsViewModel.Command.Toast -> toast(command.msg)
|
is OtherSettingsViewModel.Command.Toast -> toast(command.msg)
|
||||||
is OtherSettingsViewModel.Command.ShowClearCacheAlert -> {
|
is OtherSettingsViewModel.Command.ShowClearCacheAlert -> {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_marginTop="18dp"
|
android:layout_marginTop="18dp"
|
||||||
android:text="@string/change_type" />
|
tools:text="@string/change_type" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/searchBar"
|
android:id="@+id/searchBar"
|
||||||
|
|
|
@ -286,7 +286,9 @@ data class Block(
|
||||||
data class DataView(
|
data class DataView(
|
||||||
val sources: List<String>,
|
val sources: List<String>,
|
||||||
val viewers: List<Viewer>,
|
val viewers: List<Viewer>,
|
||||||
val relations: List<Relation>
|
@Deprecated("To be deleted")
|
||||||
|
val relations: List<Relation>,
|
||||||
|
val relationsIndex: List<RelationLink> = emptyList()
|
||||||
) : Content() {
|
) : Content() {
|
||||||
|
|
||||||
data class Viewer(
|
data class Viewer(
|
||||||
|
@ -334,12 +336,16 @@ data class Block(
|
||||||
enum class Type { ASC, DESC, CUSTOM }
|
enum class Type { ASC, DESC, CUSTOM }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [relationFormat] optional relation format, which should be specified for date-related filtering.
|
||||||
|
*/
|
||||||
data class Filter(
|
data class Filter(
|
||||||
val relationKey: String,
|
val relationKey: String,
|
||||||
|
val relationFormat: RelationFormat? = null,
|
||||||
val operator: Operator = Operator.AND,
|
val operator: Operator = Operator.AND,
|
||||||
val condition: Condition,
|
val condition: Condition,
|
||||||
val quickOption: QuickOption = QuickOption.EXACT_DATE,
|
val quickOption: QuickOption = QuickOption.EXACT_DATE,
|
||||||
val value: Any?
|
val value: Any? = null
|
||||||
) {
|
) {
|
||||||
enum class Operator { AND, OR }
|
enum class Operator { AND, OR }
|
||||||
enum class Condition {
|
enum class Condition {
|
||||||
|
|
|
@ -26,6 +26,7 @@ sealed class Event {
|
||||||
val type: SmartBlockType = SmartBlockType.PAGE,
|
val type: SmartBlockType = SmartBlockType.PAGE,
|
||||||
val objectTypes: List<ObjectType> = emptyList(),
|
val objectTypes: List<ObjectType> = emptyList(),
|
||||||
val relations: List<Relation> = emptyList(),
|
val relations: List<Relation> = emptyList(),
|
||||||
|
val relationLinks: List<RelationLink> = emptyList(),
|
||||||
val objectRestrictions: List<ObjectRestriction> = emptyList(),
|
val objectRestrictions: List<ObjectRestriction> = emptyList(),
|
||||||
val dataViewRestrictions: List<DataViewRestrictions> = emptyList()
|
val dataViewRestrictions: List<DataViewRestrictions> = emptyList()
|
||||||
) : Command()
|
) : Command()
|
||||||
|
@ -194,24 +195,18 @@ sealed class Event {
|
||||||
val style: Block.Content.Divider.Style
|
val style: Block.Content.Divider.Style
|
||||||
) : Command()
|
) : Command()
|
||||||
|
|
||||||
sealed class ObjectRelations : Command() {
|
sealed class ObjectRelationLinks : Command() {
|
||||||
data class Set(
|
|
||||||
override val context: String,
|
|
||||||
val id: Id,
|
|
||||||
val relations: List<Relation>
|
|
||||||
) : ObjectRelations()
|
|
||||||
|
|
||||||
data class Amend(
|
data class Amend(
|
||||||
override val context: String,
|
override val context: String,
|
||||||
val id: Id,
|
val id: Id,
|
||||||
val relations: List<Relation>
|
val relationLinks: List<RelationLink>
|
||||||
) : ObjectRelations()
|
) : ObjectRelationLinks()
|
||||||
|
|
||||||
data class Remove(
|
data class Remove(
|
||||||
override val context: String,
|
override val context: String,
|
||||||
val id: Id,
|
val id: Id,
|
||||||
val keys: List<Id>
|
val keys: List<Key>
|
||||||
) : ObjectRelations()
|
) : ObjectRelationLinks()
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class ObjectRelation : Command() {
|
sealed class ObjectRelation : Command() {
|
||||||
|
@ -250,14 +245,13 @@ sealed class Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sent when a data-view's relation has been changed or added.
|
* Sent when a data-view's relation has been changed or added.
|
||||||
* @property [id] data view's block id
|
* @property [dv] data view's block id
|
||||||
* @property [key] relation key
|
* @property [links] relations link for this data view
|
||||||
*/
|
*/
|
||||||
data class SetRelation(
|
data class SetRelation(
|
||||||
override val context: Id,
|
override val context: Id,
|
||||||
val id: Id,
|
val dv: Id,
|
||||||
val key: String,
|
val links: List<RelationLink>
|
||||||
val relation: Relation
|
|
||||||
) : DataView()
|
) : DataView()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,17 +9,26 @@ package com.anytypeio.anytype.core_models
|
||||||
* @property [layout] template's layout
|
* @property [layout] template's layout
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Deprecated("Will be deprecated. Object type will be treated as object")
|
|
||||||
data class ObjectType(
|
data class ObjectType(
|
||||||
|
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||||
val url: Url,
|
val url: Url,
|
||||||
|
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||||
val name: String,
|
val name: String,
|
||||||
val relations: List<Relation>,
|
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||||
|
val relationLinks: List<RelationLink>,
|
||||||
|
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||||
val layout: Layout,
|
val layout: Layout,
|
||||||
|
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||||
val emoji: String,
|
val emoji: String,
|
||||||
|
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||||
val description: String,
|
val description: String,
|
||||||
|
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||||
val isHidden: Boolean,
|
val isHidden: Boolean,
|
||||||
|
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||||
val isArchived: Boolean,
|
val isArchived: Boolean,
|
||||||
|
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||||
val isReadOnly: Boolean,
|
val isReadOnly: Boolean,
|
||||||
|
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||||
val smartBlockTypes: List<SmartBlockType>
|
val smartBlockTypes: List<SmartBlockType>
|
||||||
) {
|
) {
|
||||||
enum class Layout(val code: Int) {
|
enum class Layout(val code: Int) {
|
||||||
|
@ -47,54 +56,4 @@ data class ObjectType(
|
||||||
val layout: Layout,
|
val layout: Layout,
|
||||||
val emoji: String
|
val emoji: String
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
|
||||||
* Keys for predefined, bundled object types.
|
|
||||||
*/
|
|
||||||
companion object {
|
|
||||||
const val PAGE_URL = "_otpage"
|
|
||||||
const val OBJECT_TYPE_URL = "_otobjectType"
|
|
||||||
const val RELATION_URL = "_otrelation"
|
|
||||||
const val TEMPLATE_URL = "_ottemplate"
|
|
||||||
const val IMAGE_URL = "_otimage"
|
|
||||||
const val FILE_URL = "_otfile"
|
|
||||||
const val VIDEO_URL = "_otvideo"
|
|
||||||
const val AUDIO_URL = "_otaudio"
|
|
||||||
const val SET_URL = "_otset"
|
|
||||||
const val TASK_URL = "_ottask"
|
|
||||||
const val DATE_URL = "_otdate"
|
|
||||||
const val PROFILE_URL = "_otprofile" //contains User Profile page and Anytype Person page
|
|
||||||
const val NOTE_URL = "_otnote"
|
|
||||||
const val WORKSPACE_URL = "_otspace"
|
|
||||||
const val DASHBOARD_TYPE = "_otdashboard"
|
|
||||||
const val BOOKMARK_TYPE = "_otbookmark"
|
|
||||||
|
|
||||||
const val MAX_SNIPPET_SIZE = 30
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ObjectTypeComparator : Comparator<ObjectType> {
|
|
||||||
|
|
||||||
override fun compare(o1: ObjectType, o2: ObjectType): Int {
|
|
||||||
val o1Url = o1.url
|
|
||||||
val o2Url = o2.url
|
|
||||||
if (o1Url == o2Url) return 0
|
|
||||||
|
|
||||||
if (o1Url == ObjectType.PAGE_URL && o2Url != ObjectType.PAGE_URL) return -1
|
|
||||||
if (o1Url != ObjectType.PAGE_URL && o2Url == ObjectType.PAGE_URL) return 1
|
|
||||||
|
|
||||||
if (o1Url == ObjectType.NOTE_URL && o2Url != ObjectType.NOTE_URL) return -1
|
|
||||||
if (o1Url != ObjectType.NOTE_URL && o2Url == ObjectType.NOTE_URL) return 1
|
|
||||||
|
|
||||||
if (o1Url == ObjectType.SET_URL && o2Url != ObjectType.SET_URL) return -1
|
|
||||||
if (o1Url != ObjectType.SET_URL && o2Url == ObjectType.SET_URL) return 1
|
|
||||||
|
|
||||||
if (o1Url == ObjectType.TASK_URL && o2Url != ObjectType.TASK_URL) return -1
|
|
||||||
if (o1Url != ObjectType.TASK_URL && o2Url == ObjectType.TASK_URL) return 1
|
|
||||||
|
|
||||||
val o1Name = o1.name
|
|
||||||
val o2Name = o2.name
|
|
||||||
|
|
||||||
return o1Name.compareTo(o2Name)
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.anytypeio.anytype.core_models
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keys for predefined, bundled object types.
|
||||||
|
*/
|
||||||
|
object ObjectTypeIds {
|
||||||
|
const val PAGE = "_otpage"
|
||||||
|
const val OBJECT_TYPE = "_otobjectType"
|
||||||
|
const val RELATION = "_otrelation"
|
||||||
|
const val TEMPLATE = "_ottemplate"
|
||||||
|
const val IMAGE = "_otimage"
|
||||||
|
const val FILE = "_otfile"
|
||||||
|
const val VIDEO = "_otvideo"
|
||||||
|
const val AUDIO = "_otaudio"
|
||||||
|
const val SET = "_otset"
|
||||||
|
const val TASK = "_ottask"
|
||||||
|
const val DATE = "_otdate"
|
||||||
|
const val PROFILE = "_otprofile" //contains User Profile page and Anytype Person page
|
||||||
|
const val NOTE = "_otnote"
|
||||||
|
const val WORKSPACE = "_otspace"
|
||||||
|
const val DASHBOARD = "_otdashboard"
|
||||||
|
const val BOOKMARK = "_otbookmark"
|
||||||
|
const val RELATION_OPTION = "_otrelationOption"
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package com.anytypeio.anytype.core_models
|
package com.anytypeio.anytype.core_models
|
||||||
|
|
||||||
|
import com.anytypeio.anytype.core_models.Relations.RELATION_FORMAT_OBJECT_TYPES
|
||||||
import com.anytypeio.anytype.core_models.ext.typeOf
|
import com.anytypeio.anytype.core_models.ext.typeOf
|
||||||
|
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for easily parsing object's relations when object is represented as an untyped structure.
|
* Wrapper for easily parsing object's relations when object is represented as an untyped structure.
|
||||||
|
@ -64,7 +66,7 @@ sealed class ObjectWrapper {
|
||||||
|
|
||||||
val fileMimeType: String? by default
|
val fileMimeType: String? by default
|
||||||
|
|
||||||
inline fun <reified T> getValue(relation: Id) : T? {
|
inline fun <reified T> getValue(relation: Id): T? {
|
||||||
val value = map.getOrDefault(relation, null)
|
val value = map.getOrDefault(relation, null)
|
||||||
return if (value is T)
|
return if (value is T)
|
||||||
value
|
value
|
||||||
|
@ -80,7 +82,42 @@ sealed class ObjectWrapper {
|
||||||
|
|
||||||
val featuredRelations: List<String>? by default
|
val featuredRelations: List<String>? by default
|
||||||
|
|
||||||
|
val smartBlockTypes: List<Double>
|
||||||
|
get() = when (val value = map[Relations.SMARTBLOCKTYPES]) {
|
||||||
|
is Double -> listOf(value)
|
||||||
|
is List<*> -> value.typeOf()
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
fun isEmpty(): Boolean = map.isEmpty()
|
fun isEmpty(): Boolean = map.isEmpty()
|
||||||
|
|
||||||
|
val relationKey: String by default
|
||||||
|
val isFavorite: Boolean? by default
|
||||||
|
val isHidden: Boolean? by default
|
||||||
|
val isReadonly: Boolean? by default
|
||||||
|
|
||||||
|
val relationFormat: RelationFormat?
|
||||||
|
get() = when (val value = map[Relations.RELATION_FORMAT]) {
|
||||||
|
is Double -> RelationFormat.values().singleOrNull { format ->
|
||||||
|
format.code == value.toInt()
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
val restrictions: List<ObjectRestriction>
|
||||||
|
get() = when (val value = map[Relations.RESTRICTIONS]) {
|
||||||
|
is Double -> buildList {
|
||||||
|
ObjectRestriction.values().firstOrNull { it.code == value.toInt() }
|
||||||
|
}
|
||||||
|
is List<*> -> value.typeOf<Double>().mapNotNull { code ->
|
||||||
|
ObjectRestriction.values().firstOrNull { it.code == code.toInt() }
|
||||||
|
}
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
val relationOptionColor: String? by default
|
||||||
|
val relationOptionText: String? by default
|
||||||
|
val relationReadonlyValue: Boolean? by default
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,4 +134,104 @@ sealed class ObjectWrapper {
|
||||||
val isArchived: Boolean? by default
|
val isArchived: Boolean? by default
|
||||||
val isDeleted: Boolean? by default
|
val isDeleted: Boolean? by default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for object types
|
||||||
|
*/
|
||||||
|
data class Type(val map: Map<String, Any?>) : ObjectWrapper() {
|
||||||
|
private val default = map.withDefault { null }
|
||||||
|
val id: Id by default
|
||||||
|
val name: String? by default
|
||||||
|
val description: String? by default
|
||||||
|
val isArchived: Boolean? by default
|
||||||
|
val iconEmoji: String? by default
|
||||||
|
val isDeleted: Boolean? by default
|
||||||
|
val smartBlockTypes: List<SmartBlockType>
|
||||||
|
get() = when (val value = map[Relations.SMARTBLOCKTYPES]) {
|
||||||
|
is Double -> buildList {
|
||||||
|
SmartBlockType.values().firstOrNull { it.code == value.toInt() }
|
||||||
|
}
|
||||||
|
is List<*> -> value.typeOf<Double>().mapNotNull { code ->
|
||||||
|
SmartBlockType.values().firstOrNull { it.code == code.toInt() }
|
||||||
|
}
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data class Relation(val map: Struct) : ObjectWrapper() {
|
||||||
|
|
||||||
|
private val default = map.withDefault { null }
|
||||||
|
|
||||||
|
private val relationKey : Key by default
|
||||||
|
|
||||||
|
val relationFormat: RelationFormat
|
||||||
|
get() {
|
||||||
|
val value = map[Relations.RELATION_FORMAT]
|
||||||
|
return if (value is Double) {
|
||||||
|
RelationFormat.values().firstOrNull { f ->
|
||||||
|
f.code == value.toInt()
|
||||||
|
} ?: RelationFormat.UNDEFINED
|
||||||
|
} else {
|
||||||
|
RelationFormat.UNDEFINED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val relationOptionsDict: List<Id>
|
||||||
|
get() = when (val value = map[Relations.RELATION_OPTION_DICT]) {
|
||||||
|
is Id -> listOf(id)
|
||||||
|
is List<*> -> value.typeOf()
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val relationReadonlyValue: Boolean? by default
|
||||||
|
|
||||||
|
val id: Id by default
|
||||||
|
val key: Key get() = relationKey
|
||||||
|
val format: RelationFormat get() = relationFormat
|
||||||
|
val name: String? by default
|
||||||
|
val isHidden: Boolean? by default
|
||||||
|
val isReadOnly: Boolean? by default
|
||||||
|
val isArchived: Boolean? by default
|
||||||
|
val isDeleted: Boolean? by default
|
||||||
|
val isReadonly: Boolean? by default
|
||||||
|
val isReadonlyValue: Boolean = relationReadonlyValue ?: false
|
||||||
|
|
||||||
|
val restrictions: List<ObjectRestriction>
|
||||||
|
get() = when (val value = map[Relations.RESTRICTIONS]) {
|
||||||
|
is Double -> buildList {
|
||||||
|
ObjectRestriction.values().firstOrNull { it.code == value.toInt() }
|
||||||
|
}
|
||||||
|
is List<*> -> value.typeOf<Double>().mapNotNull { code ->
|
||||||
|
ObjectRestriction.values().firstOrNull { it.code == code.toInt() }
|
||||||
|
}
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
val relationFormatObjectTypes
|
||||||
|
get() = when (val value = map[RELATION_FORMAT_OBJECT_TYPES]) {
|
||||||
|
is Id -> listOf(value)
|
||||||
|
is List<*> -> value.typeOf()
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
val type: List<Id>
|
||||||
|
get() = when (val value = map[Relations.TYPE]) {
|
||||||
|
is Id -> listOf(value)
|
||||||
|
is List<*> -> value.typeOf()
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
val isValid get() = map.containsKey(Relations.RELATION_KEY) && map.containsKey(Relations.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
data class Option(val map: Struct) {
|
||||||
|
private val default = map.withDefault { null }
|
||||||
|
private val relationOptionText : String? by default
|
||||||
|
private val relationOptionColor : String? by default
|
||||||
|
|
||||||
|
val id: Id by default
|
||||||
|
val title: String = relationOptionText.orEmpty()
|
||||||
|
val color: String = relationOptionColor.orEmpty()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -7,35 +7,46 @@ package com.anytypeio.anytype.core_models
|
||||||
* @property [isReadOnly] editable by user or not
|
* @property [isReadOnly] editable by user or not
|
||||||
* @property [isHidden] whether this type is internal (not displayed to user)
|
* @property [isHidden] whether this type is internal (not displayed to user)
|
||||||
*/
|
*/
|
||||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
|
||||||
data class Relation(
|
data class Relation(
|
||||||
|
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||||
val key: String,
|
val key: String,
|
||||||
|
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||||
val name: String,
|
val name: String,
|
||||||
|
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||||
val format: Format,
|
val format: Format,
|
||||||
|
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||||
val source: Source,
|
val source: Source,
|
||||||
|
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||||
val isHidden: Boolean = false,
|
val isHidden: Boolean = false,
|
||||||
|
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||||
val isReadOnly: Boolean = false,
|
val isReadOnly: Boolean = false,
|
||||||
|
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||||
val isMulti: Boolean = false,
|
val isMulti: Boolean = false,
|
||||||
|
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||||
val selections: List<Option> = emptyList(),
|
val selections: List<Option> = emptyList(),
|
||||||
|
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||||
val objectTypes: List<String> = emptyList(),
|
val objectTypes: List<String> = emptyList(),
|
||||||
|
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||||
val defaultValue: Any? = null
|
val defaultValue: Any? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
enum class Format(val prettyName: String) {
|
enum class Format(val code: Int) {
|
||||||
LONG_TEXT("Text"),
|
LONG_TEXT(0),
|
||||||
SHORT_TEXT("Short text"),
|
SHORT_TEXT(1),
|
||||||
NUMBER("Number"),
|
NUMBER(2),
|
||||||
STATUS("Status"),
|
STATUS(3),
|
||||||
TAG("Tag"),
|
TAG(11),
|
||||||
DATE("Date"),
|
DATE(4),
|
||||||
FILE("File & Media"),
|
FILE(5),
|
||||||
CHECKBOX("Checkbox"),
|
CHECKBOX(6),
|
||||||
URL("URL"),
|
URL(7),
|
||||||
EMAIL("Email"),
|
EMAIL(8),
|
||||||
PHONE("Phone"),
|
PHONE(9),
|
||||||
EMOJI("Emoji"),
|
EMOJI(10),
|
||||||
OBJECT("Object"),
|
OBJECT(100),
|
||||||
RELATIONS("Relations")
|
RELATIONS(101),
|
||||||
|
|
||||||
|
UNDEFINED(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Source {
|
enum class Source {
|
||||||
|
@ -45,14 +56,9 @@ data class Relation(
|
||||||
data class Option(
|
data class Option(
|
||||||
val id: String,
|
val id: String,
|
||||||
val text: String,
|
val text: String,
|
||||||
val color: String,
|
val color: String
|
||||||
val scope: OptionScope = OptionScope.LOCAL
|
|
||||||
)
|
)
|
||||||
|
|
||||||
enum class OptionScope {
|
|
||||||
LOCAL, RELATION, FORMAT
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun orderedFormatList(): List<Format> = listOf(
|
fun orderedFormatList(): List<Format> = listOf(
|
||||||
Format.OBJECT,
|
Format.OBJECT,
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.anytypeio.anytype.core_models
|
||||||
|
|
||||||
|
data class RelationLink(val key: Key, val format: RelationFormat)
|
|
@ -33,6 +33,18 @@ object Relations {
|
||||||
const val IS_HIGHLIGHTED = "isHighlighted"
|
const val IS_HIGHLIGHTED = "isHighlighted"
|
||||||
const val URL = "url"
|
const val URL = "url"
|
||||||
const val SOURCE = "source"
|
const val SOURCE = "source"
|
||||||
|
const val SMARTBLOCKTYPES = "smartblockTypes"
|
||||||
|
const val RELATION_KEY = "relationKey"
|
||||||
|
const val RELATION_OPTION_TEXT = "relationOptionText"
|
||||||
|
const val RELATION_OPTION_COLOR = "relationOptionColor"
|
||||||
|
const val RELATION_OPTION_DICT = "relationOptionsDict"
|
||||||
|
const val SCOPE = "scope"
|
||||||
|
const val RESTRICTIONS = "restrictions"
|
||||||
|
const val MAX_COUNT = "relationMaxCount"
|
||||||
|
const val RELATION_IS_READ_ONLY = "relationReadonly"
|
||||||
|
const val RELATION_DEFAULT_VALUE = "relationDefaultValue"
|
||||||
|
const val RELATION_FORMAT_OBJECT_TYPES = "relationFormatObjectTypes"
|
||||||
|
|
||||||
|
|
||||||
const val PAGE_COVER = "pageCover"
|
const val PAGE_COVER = "pageCover"
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,27 @@
|
||||||
package com.anytypeio.anytype.core_models
|
package com.anytypeio.anytype.core_models
|
||||||
|
|
||||||
enum class SmartBlockType {
|
enum class SmartBlockType(val code: Int) {
|
||||||
BREADCRUMBS,
|
ACCOUNT_OLD(code = 0),
|
||||||
PAGE,
|
BREADCRUMBS(code = 1),
|
||||||
PROFILE_PAGE,
|
PAGE(code = 16),
|
||||||
HOME,
|
PROFILE_PAGE(code = 17),
|
||||||
ARCHIVE,
|
HOME(code = 32),
|
||||||
SET,
|
ARCHIVE(code = 48),
|
||||||
BUNDLED_OBJECT_TYPE,
|
DATABASE(code = 64),
|
||||||
CUSTOM_OBJECT_TYPE,
|
SET(code = 65),
|
||||||
FILE,
|
CUSTOM_OBJECT_TYPE(code = 96),
|
||||||
TEMPLATE,
|
FILE(code = 256),
|
||||||
MARKETPLACE_TYPE,
|
TEMPLATE(code = 288),
|
||||||
MARKETPLACE_RELATION,
|
BUNDLED_TEMPLATE(code = 289),
|
||||||
MARKETPLACE_TEMPLATE,
|
MARKETPLACE_TYPE(code = 272),
|
||||||
BUNDLED_RELATION,
|
MARKETPLACE_RELATION(code = 273),
|
||||||
INDEXED_RELATION,
|
MARKETPLACE_TEMPLATE(code = 274),
|
||||||
ANYTYPE_PROFILE,
|
@Deprecated("")
|
||||||
DATABASE,
|
BUNDLED_RELATION(code = 512),
|
||||||
BUNDLED_TEMPLATE,
|
SUB_OBJECT(code = 513),
|
||||||
DATE,
|
BUNDLED_OBJECT_TYPE(code = 514),
|
||||||
WORKSPACE,
|
ANYTYPE_PROFILE(code = 515),
|
||||||
WORKSPACE_OLD,
|
DATE(code = 516),
|
||||||
ACCOUNT_OLD
|
WORKSPACE_OLD(code = 517),
|
||||||
|
WORKSPACE(code = 518)
|
||||||
}
|
}
|
|
@ -2,29 +2,25 @@ package com.anytypeio.anytype.core_models.ext
|
||||||
|
|
||||||
import com.anytypeio.anytype.core_models.Event
|
import com.anytypeio.anytype.core_models.Event
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.Key
|
||||||
|
import com.anytypeio.anytype.core_models.RelationLink
|
||||||
|
|
||||||
fun List<Relation>.process(
|
fun List<RelationLink>.process(
|
||||||
event: Event.Command.ObjectRelations
|
event: Event.Command.ObjectRelationLinks
|
||||||
) : List<Relation> = when(event) {
|
): List<RelationLink> = when (event) {
|
||||||
is Event.Command.ObjectRelations.Amend -> amend(event.relations)
|
is Event.Command.ObjectRelationLinks.Amend -> amend(event.relationLinks)
|
||||||
is Event.Command.ObjectRelations.Remove -> remove(event.keys)
|
is Event.Command.ObjectRelationLinks.Remove -> remove(event.keys)
|
||||||
is Event.Command.ObjectRelations.Set -> set(event.relations)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun List<Relation>.set(relations: List<Relation>) : List<Relation> {
|
fun List<RelationLink>.amend(relationLinks: List<RelationLink>): List<RelationLink> {
|
||||||
return relations
|
|
||||||
}
|
|
||||||
|
|
||||||
fun List<Relation>.amend(relations: List<Relation>) : List<Relation> {
|
|
||||||
val map = this.associateBy { it.key }.toMutableMap()
|
val map = this.associateBy { it.key }.toMutableMap()
|
||||||
relations.forEach { relation ->
|
relationLinks.forEach { relation ->
|
||||||
map[relation.key] = relation
|
map[relation.key] = relation
|
||||||
}
|
}
|
||||||
return map.values.toList()
|
return map.values.toList()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun List<Relation>.remove(keys: List<Id>) : List<Relation> {
|
fun List<RelationLink>.remove(keys: List<Key>): List<RelationLink> {
|
||||||
return filter { !keys.contains(it.key) }
|
return filter { !keys.contains(it.key) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.anytypeio.anytype.core_models.inline
|
||||||
|
|
||||||
|
@JvmInline
|
||||||
|
value class Id(private val id: String)
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.anytypeio.anytype.core_models.inline
|
||||||
|
|
||||||
|
@JvmInline
|
||||||
|
value class Key(private val key: String)
|
|
@ -3,40 +3,42 @@ package com.anytypeio.anytype.core_models.restrictions
|
||||||
/**
|
/**
|
||||||
* restricts for some actions, if present then this action is forbidden
|
* restricts for some actions, if present then this action is forbidden
|
||||||
*/
|
*/
|
||||||
enum class ObjectRestriction {
|
enum class ObjectRestriction(val code: Int) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restricts delete
|
* restricts delete
|
||||||
*/
|
*/
|
||||||
DELETE,
|
DELETE(1),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restricts work with relations
|
* restricts work with relations
|
||||||
*/
|
*/
|
||||||
RELATIONS,
|
RELATIONS(2),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restricts work with details
|
* restricts work with details
|
||||||
*/
|
*/
|
||||||
DETAILS,
|
DETAILS(4),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restricts work with blocks
|
* restricts work with blocks
|
||||||
*/
|
*/
|
||||||
BLOCKS,
|
BLOCKS(3),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restricts changing type
|
* restricts changing type
|
||||||
*/
|
*/
|
||||||
TYPE_CHANGE,
|
TYPE_CHANGE(5),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restricts changing layout
|
* restricts changing layout
|
||||||
*/
|
*/
|
||||||
LAYOUT_CHANGE,
|
LAYOUT_CHANGE(6),
|
||||||
|
|
||||||
TEMPLATE,
|
TEMPLATE(7),
|
||||||
|
|
||||||
DUPLICATE
|
DUPLICATE(8),
|
||||||
|
|
||||||
|
NONE(0)
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,9 +5,10 @@ import android.graphics.drawable.Drawable
|
||||||
import android.webkit.MimeTypeMap
|
import android.webkit.MimeTypeMap
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.anytypeio.anytype.core_models.DVSortType
|
import com.anytypeio.anytype.core_models.DVSortType
|
||||||
import com.anytypeio.anytype.core_models.Relation
|
import com.anytypeio.anytype.core_models.RelationFormat
|
||||||
import com.anytypeio.anytype.core_ui.R
|
import com.anytypeio.anytype.core_ui.R
|
||||||
import com.anytypeio.anytype.core_utils.const.MimeTypes
|
import com.anytypeio.anytype.core_utils.const.MimeTypes
|
||||||
import com.anytypeio.anytype.presentation.objects.ObjectLayoutView
|
import com.anytypeio.anytype.presentation.objects.ObjectLayoutView
|
||||||
|
@ -146,69 +147,69 @@ fun ColumnView.Format.relationIconSmall(): Int? = when (this) {
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Relation.Format.icon(isMedium: Boolean = false): Int = when (this) {
|
fun RelationFormat.icon(isMedium: Boolean = false): Int = when (this) {
|
||||||
Relation.Format.SHORT_TEXT, Relation.Format.LONG_TEXT -> {
|
RelationFormat.SHORT_TEXT, RelationFormat.LONG_TEXT -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_text_48
|
R.drawable.ic_relation_text_48
|
||||||
else
|
else
|
||||||
R.drawable.ic_relation_text_32
|
R.drawable.ic_relation_text_32
|
||||||
}
|
}
|
||||||
Relation.Format.NUMBER -> {
|
RelationFormat.NUMBER -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_number_48
|
R.drawable.ic_relation_number_48
|
||||||
else
|
else
|
||||||
R.drawable.ic_relation_number_32
|
R.drawable.ic_relation_number_32
|
||||||
}
|
}
|
||||||
Relation.Format.STATUS -> {
|
RelationFormat.STATUS -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_status_48
|
R.drawable.ic_relation_status_48
|
||||||
else
|
else
|
||||||
R.drawable.ic_relation_status_32
|
R.drawable.ic_relation_status_32
|
||||||
}
|
}
|
||||||
Relation.Format.DATE -> {
|
RelationFormat.DATE -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_date_48
|
R.drawable.ic_relation_date_48
|
||||||
else
|
else
|
||||||
R.drawable.ic_relation_date_32
|
R.drawable.ic_relation_date_32
|
||||||
}
|
}
|
||||||
Relation.Format.FILE -> {
|
RelationFormat.FILE -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_attachment_48
|
R.drawable.ic_relation_attachment_48
|
||||||
else
|
else
|
||||||
R.drawable.ic_relation_attachment_32
|
R.drawable.ic_relation_attachment_32
|
||||||
}
|
}
|
||||||
Relation.Format.CHECKBOX -> {
|
RelationFormat.CHECKBOX -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_checkbox_48
|
R.drawable.ic_relation_checkbox_48
|
||||||
else
|
else
|
||||||
R.drawable.ic_relation_checkbox_32
|
R.drawable.ic_relation_checkbox_32
|
||||||
}
|
}
|
||||||
Relation.Format.URL -> {
|
RelationFormat.URL -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_url_48
|
R.drawable.ic_relation_url_48
|
||||||
else
|
else
|
||||||
R.drawable.ic_relation_url_32
|
R.drawable.ic_relation_url_32
|
||||||
}
|
}
|
||||||
Relation.Format.EMAIL -> {
|
RelationFormat.EMAIL -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_email_48
|
R.drawable.ic_relation_email_48
|
||||||
else
|
else
|
||||||
R.drawable.ic_relation_email_32
|
R.drawable.ic_relation_email_32
|
||||||
}
|
}
|
||||||
Relation.Format.PHONE -> {
|
RelationFormat.PHONE -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_phone_number_48
|
R.drawable.ic_relation_phone_number_48
|
||||||
else
|
else
|
||||||
R.drawable.ic_relation_phone_number_32
|
R.drawable.ic_relation_phone_number_32
|
||||||
}
|
}
|
||||||
Relation.Format.EMOJI -> R.drawable.ic_relation_object_32
|
RelationFormat.EMOJI -> R.drawable.ic_relation_object_32
|
||||||
Relation.Format.OBJECT -> {
|
RelationFormat.OBJECT -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_object_48
|
R.drawable.ic_relation_object_48
|
||||||
else
|
else
|
||||||
R.drawable.ic_relation_object_32
|
R.drawable.ic_relation_object_32
|
||||||
}
|
}
|
||||||
Relation.Format.TAG -> {
|
RelationFormat.TAG -> {
|
||||||
if (isMedium)
|
if (isMedium)
|
||||||
R.drawable.ic_relation_tag_48
|
R.drawable.ic_relation_tag_48
|
||||||
else
|
else
|
||||||
|
@ -220,20 +221,20 @@ fun Relation.Format.icon(isMedium: Boolean = false): Int = when (this) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun DVSortType.text(format: Relation.Format): Int = when (format) {
|
fun DVSortType.text(format: RelationFormat): Int = when (format) {
|
||||||
Relation.Format.TAG, Relation.Format.STATUS -> {
|
RelationFormat.TAG, RelationFormat.STATUS -> {
|
||||||
if (this == DVSortType.ASC)
|
if (this == DVSortType.ASC)
|
||||||
R.string.sort_from_first_to_last
|
R.string.sort_from_first_to_last
|
||||||
else
|
else
|
||||||
R.string.sort_from_last_to_first
|
R.string.sort_from_last_to_first
|
||||||
}
|
}
|
||||||
Relation.Format.NUMBER, Relation.Format.DATE -> {
|
RelationFormat.NUMBER, RelationFormat.DATE -> {
|
||||||
if (this == DVSortType.ASC)
|
if (this == DVSortType.ASC)
|
||||||
R.string.sort_from_one_to_nine
|
R.string.sort_from_one_to_nine
|
||||||
else
|
else
|
||||||
R.string.sort_from_nine_to_one
|
R.string.sort_from_nine_to_one
|
||||||
}
|
}
|
||||||
Relation.Format.CHECKBOX -> {
|
RelationFormat.CHECKBOX -> {
|
||||||
if (this == DVSortType.ASC)
|
if (this == DVSortType.ASC)
|
||||||
R.string.sort_from_unchecked_to_checked
|
R.string.sort_from_unchecked_to_checked
|
||||||
else
|
else
|
||||||
|
@ -280,4 +281,23 @@ fun ObjectLayoutView.getName(): Int? = when (this) {
|
||||||
is ObjectLayoutView.Relation -> null
|
is ObjectLayoutView.Relation -> null
|
||||||
is ObjectLayoutView.Space -> null
|
is ObjectLayoutView.Space -> null
|
||||||
is ObjectLayoutView.Bookmark -> null
|
is ObjectLayoutView.Bookmark -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
@StringRes
|
||||||
|
fun RelationFormat.getPrettyName(): Int = when (this) {
|
||||||
|
RelationFormat.LONG_TEXT -> R.string.relation_format_long_text
|
||||||
|
RelationFormat.SHORT_TEXT -> R.string.relation_format_short_text
|
||||||
|
RelationFormat.NUMBER -> R.string.relation_format_number
|
||||||
|
RelationFormat.STATUS -> R.string.relation_format_status
|
||||||
|
RelationFormat.TAG -> R.string.relation_format_tag
|
||||||
|
RelationFormat.DATE -> R.string.relation_format_date
|
||||||
|
RelationFormat.FILE -> R.string.relation_format_file
|
||||||
|
RelationFormat.CHECKBOX -> R.string.relation_format_checkbox
|
||||||
|
RelationFormat.URL -> R.string.relation_format_url
|
||||||
|
RelationFormat.EMAIL -> R.string.relation_format_email
|
||||||
|
RelationFormat.PHONE -> R.string.relation_format_phone
|
||||||
|
RelationFormat.EMOJI -> R.string.relation_format_emoji
|
||||||
|
RelationFormat.OBJECT -> R.string.relation_format_object
|
||||||
|
RelationFormat.RELATIONS -> R.string.relation_format_relation
|
||||||
|
RelationFormat.UNDEFINED -> R.string.undefined
|
||||||
}
|
}
|
|
@ -11,17 +11,18 @@ class ObjectTypeMenuHolder(
|
||||||
) : RecyclerView.ViewHolder(binding.root) {
|
) : RecyclerView.ViewHolder(binding.root) {
|
||||||
|
|
||||||
fun bind(item: SlashItem.ObjectType) = with(binding) {
|
fun bind(item: SlashItem.ObjectType) = with(binding) {
|
||||||
|
val objectType = item.objectTypeView
|
||||||
ivIcon.setIcon(
|
ivIcon.setIcon(
|
||||||
emoji = item.emoji,
|
emoji = objectType.emoji,
|
||||||
image = null,
|
image = null,
|
||||||
name = item.name
|
name = objectType.name
|
||||||
)
|
)
|
||||||
tvTitle.text = item.name
|
tvTitle.text = objectType.name
|
||||||
if (item.description.isNullOrBlank()) {
|
if (objectType.description.isNullOrBlank()) {
|
||||||
tvSubtitle.gone()
|
tvSubtitle.gone()
|
||||||
} else {
|
} else {
|
||||||
tvSubtitle.visible()
|
tvSubtitle.visible()
|
||||||
tvSubtitle.text = item.description
|
tvSubtitle.text = objectType.description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,18 +4,14 @@ import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.anytypeio.anytype.core_models.Id
|
import com.anytypeio.anytype.core_models.Id
|
||||||
import com.anytypeio.anytype.core_ui.R
|
|
||||||
import com.anytypeio.anytype.core_ui.databinding.ItemObjectTypeHorizontalItemBinding
|
|
||||||
import com.anytypeio.anytype.core_ui.databinding.ItemObjectTypeItemBinding
|
import com.anytypeio.anytype.core_ui.databinding.ItemObjectTypeItemBinding
|
||||||
import com.anytypeio.anytype.core_ui.features.objects.holders.ObjectTypeHolder
|
import com.anytypeio.anytype.core_ui.features.objects.holders.ObjectTypeHolder
|
||||||
import com.anytypeio.anytype.core_ui.features.objects.holders.ObjectTypeHorizontalHolder
|
import com.anytypeio.anytype.core_ui.features.objects.holders.ObjectTypeHorizontalHolder
|
||||||
import com.anytypeio.anytype.core_ui.features.objects.holders.ObjectTypeSearchHolder
|
|
||||||
import com.anytypeio.anytype.presentation.objects.ObjectTypeView
|
import com.anytypeio.anytype.presentation.objects.ObjectTypeView
|
||||||
|
|
||||||
abstract class ObjectTypeBaseAdapter(
|
class ObjectTypeVerticalAdapter(
|
||||||
private var data: ArrayList<ObjectTypeView>,
|
private var data: ArrayList<ObjectTypeView>,
|
||||||
private val onItemClick: (Id, String) -> Unit,
|
private val onItemClick: (Id, String) -> Unit
|
||||||
private val onSearchClick: (() -> Unit)? = null
|
|
||||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||||
|
|
||||||
fun update(data: List<ObjectTypeView>) {
|
fun update(data: List<ObjectTypeView>) {
|
||||||
|
@ -26,82 +22,31 @@ abstract class ObjectTypeBaseAdapter(
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||||
val inflater = LayoutInflater.from(parent.context)
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
val viewHolder: RecyclerView.ViewHolder = when (viewType) {
|
val viewHolder: RecyclerView.ViewHolder = ObjectTypeHolder(
|
||||||
R.layout.item_object_type_item -> {
|
binding = ItemObjectTypeItemBinding.inflate(
|
||||||
ObjectTypeHolder(
|
inflater, parent, false
|
||||||
binding = ItemObjectTypeItemBinding.inflate(
|
)
|
||||||
inflater, parent, false
|
).apply {
|
||||||
)
|
itemView.setOnClickListener {
|
||||||
).apply {
|
if (bindingAdapterPosition != RecyclerView.NO_POSITION) {
|
||||||
itemView.setOnClickListener {
|
val item = data[bindingAdapterPosition] as ObjectTypeView
|
||||||
if (bindingAdapterPosition != RecyclerView.NO_POSITION) {
|
onItemClick(item.id, item.name)
|
||||||
val item = data[bindingAdapterPosition] as ObjectTypeView.Item
|
|
||||||
onItemClick(item.id, item.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.layout.item_object_type_horizontal_item -> {
|
|
||||||
ObjectTypeHorizontalHolder(
|
|
||||||
binding = ItemObjectTypeHorizontalItemBinding.inflate(
|
|
||||||
inflater, parent, false
|
|
||||||
)
|
|
||||||
).apply {
|
|
||||||
itemView.setOnClickListener {
|
|
||||||
if (bindingAdapterPosition != RecyclerView.NO_POSITION) {
|
|
||||||
val item = data[bindingAdapterPosition] as ObjectTypeView.Item
|
|
||||||
onItemClick(item.id, item.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
R.layout.item_object_type_search -> {
|
|
||||||
ObjectTypeSearchHolder(parent).apply {
|
|
||||||
itemView.setOnClickListener {
|
|
||||||
onSearchClick?.invoke()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> throw IllegalStateException("Unexpected view type: $viewType")
|
|
||||||
}
|
}
|
||||||
return viewHolder
|
return viewHolder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||||
when (holder) {
|
when (holder) {
|
||||||
is ObjectTypeHolder -> {
|
is ObjectTypeHolder -> {
|
||||||
holder.bind(data[position] as ObjectTypeView.Item)
|
holder.bind(data[position] as ObjectTypeView)
|
||||||
}
|
}
|
||||||
is ObjectTypeHorizontalHolder -> {
|
is ObjectTypeHorizontalHolder -> {
|
||||||
holder.bind(data[position] as ObjectTypeView.Item)
|
holder.bind(data[position] as ObjectTypeView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int = data.size
|
override fun getItemCount(): Int = data.size
|
||||||
}
|
|
||||||
|
|
||||||
class ObjectTypeVerticalAdapter(
|
|
||||||
data: ArrayList<ObjectTypeView>,
|
|
||||||
onItemClick: (Id, String) -> Unit
|
|
||||||
) : ObjectTypeBaseAdapter(data, onItemClick) {
|
|
||||||
|
|
||||||
override fun getItemViewType(position: Int): Int = R.layout.item_object_type_item
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ObjectTypeHorizontalListAdapter(
|
|
||||||
private var data: ArrayList<ObjectTypeView>,
|
|
||||||
onItemClick: (Id, String) -> Unit,
|
|
||||||
onSearchClick: () -> Unit
|
|
||||||
) : ObjectTypeBaseAdapter(data, onItemClick, onSearchClick) {
|
|
||||||
|
|
||||||
override fun getItemViewType(position: Int): Int {
|
|
||||||
return when (data[position]) {
|
|
||||||
is ObjectTypeView.Item -> R.layout.item_object_type_horizontal_item
|
|
||||||
is ObjectTypeView.Search -> R.layout.item_object_type_search
|
|
||||||
else -> throw IllegalStateException("Unexpected ObjectTypeView!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user