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
|
@ -13,7 +13,8 @@
|
|||
/analytics/gradle.properties
|
||||
.DS_Store
|
||||
**/build
|
||||
/libs
|
||||
/libs/build
|
||||
/libs/lib.aar
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
ktlint
|
||||
|
|
2
Makefile
2
Makefile
|
@ -15,3 +15,5 @@ enable_analytics_for_debug:
|
|||
|
||||
pr_check: compile_android_test_sources test_debug_all
|
||||
|
||||
setup_local_mw:
|
||||
./gradlew libs:publishToMavenLocal
|
||||
|
|
|
@ -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.core_models.Block
|
||||
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.Relation
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
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.MediaMenuHolder
|
||||
|
@ -478,29 +479,15 @@ class SlashWidgetTesting : EditorTestSetup() {
|
|||
val document = listOf(page, header, title, paragraph)
|
||||
|
||||
val objectTypes = listOf(
|
||||
ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = MockDataFactory.randomString(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.BASIC,
|
||||
relations = emptyList(),
|
||||
description = MockDataFactory.randomString(),
|
||||
isHidden = false,
|
||||
smartBlockTypes = listOf(),
|
||||
isArchived = false,
|
||||
isReadOnly = false
|
||||
ObjectWrapper.Type(
|
||||
mapOf(
|
||||
Relations.ID to MockDataFactory.randomUuid()
|
||||
)
|
||||
),
|
||||
ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = MockDataFactory.randomString(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.BASIC,
|
||||
relations = emptyList(),
|
||||
description = MockDataFactory.randomString(),
|
||||
isHidden = false,
|
||||
smartBlockTypes = listOf(),
|
||||
isArchived = false,
|
||||
isReadOnly = false
|
||||
ObjectWrapper.Type(
|
||||
mapOf(
|
||||
Relations.ID to MockDataFactory.randomUuid()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -11,12 +11,11 @@ import com.anytypeio.anytype.core_models.Command
|
|||
import com.anytypeio.anytype.core_models.DocumentInfo
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
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.Relation
|
||||
import com.anytypeio.anytype.core_utils.tools.FeatureToggles
|
||||
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.base.AppCoroutineDispatchers
|
||||
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.cover.RemoveDocCover
|
||||
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.event.interactor.InterceptEvents
|
||||
import com.anytypeio.anytype.domain.icon.DocumentEmojiIconProvider
|
||||
import com.anytypeio.anytype.domain.icon.SetDocumentImageIcon
|
||||
import com.anytypeio.anytype.domain.launch.GetDefaultEditorType
|
||||
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.CreateDocument
|
||||
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.bookmark.CreateBookmarkBlock
|
||||
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.status.InterceptThreadStatus
|
||||
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.EditorTemplateDelegate
|
||||
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.Dispatcher
|
||||
import com.anytypeio.anytype.presentation.util.downloader.MiddlewareShareDownloader
|
||||
|
@ -133,8 +136,6 @@ open class EditorTestSetup {
|
|||
lateinit var move: Move
|
||||
lateinit var setRelationKey: SetRelationKey
|
||||
lateinit var updateDetail: UpdateDetail
|
||||
lateinit var getCompatibleObjectTypes: GetCompatibleObjectTypes
|
||||
|
||||
|
||||
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
||||
|
||||
|
@ -242,9 +243,6 @@ open class EditorTestSetup {
|
|||
@Mock
|
||||
lateinit var documentEmojiIconProvider: DocumentEmojiIconProvider
|
||||
|
||||
@Mock
|
||||
lateinit var objectTypesProvider: ObjectTypesProvider
|
||||
|
||||
@Mock
|
||||
lateinit var createTable: CreateTable
|
||||
|
||||
|
@ -270,6 +268,9 @@ open class EditorTestSetup {
|
|||
intents = intents
|
||||
)
|
||||
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||
|
||||
open fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
|
@ -322,7 +323,6 @@ open class EditorTestSetup {
|
|||
removeDocCover = RemoveDocCover(repo)
|
||||
turnIntoStyle = TurnIntoStyle(repo)
|
||||
updateDetail = UpdateDetail(repo)
|
||||
getCompatibleObjectTypes = GetCompatibleObjectTypes(repo)
|
||||
getDefaultEditorType = GetDefaultEditorType(userSettingsRepository)
|
||||
createObjectSet = CreateObjectSet(repo)
|
||||
findObjectSetForType = FindObjectSetForType(repo)
|
||||
|
@ -357,7 +357,8 @@ open class EditorTestSetup {
|
|||
renderer = DefaultBlockViewRenderer(
|
||||
urlBuilder = urlBuilder,
|
||||
toggleStateHolder = ToggleStateHolder.Default(),
|
||||
coverImageHashProvider = coverImageHashProvider
|
||||
coverImageHashProvider = coverImageHashProvider,
|
||||
storeOfRelations = storeOfRelations
|
||||
),
|
||||
orchestrator = Orchestrator(
|
||||
createBlock = createBlock,
|
||||
|
@ -411,8 +412,6 @@ open class EditorTestSetup {
|
|||
dispatcher = Dispatcher.Default(),
|
||||
detailModificationManager = InternalDetailModificationManager(stores.details),
|
||||
updateDetail = updateDetail,
|
||||
getCompatibleObjectTypes = getCompatibleObjectTypes,
|
||||
objectTypesProvider = objectTypesProvider,
|
||||
searchObjects = getSearchObjects,
|
||||
getDefaultEditorType = getDefaultEditorType,
|
||||
createObjectSet = createObjectSet,
|
||||
|
@ -425,6 +424,8 @@ open class EditorTestSetup {
|
|||
editorTemplateDelegate = editorTemplateDelegate,
|
||||
createNewObject = createNewObject,
|
||||
objectToSet = objectToSet,
|
||||
storeOfRelations = storeOfRelations,
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
featureToggles = featureToggles,
|
||||
tableDelegate = tableDelegate
|
||||
)
|
||||
|
@ -505,9 +506,18 @@ open class EditorTestSetup {
|
|||
}
|
||||
}
|
||||
|
||||
fun stubGetObjectTypes(objectTypes: List<ObjectType>) {
|
||||
fun stubGetObjectTypes(objectTypes: List<ObjectWrapper.Type>) {
|
||||
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.core_models.Block
|
||||
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.Relation
|
||||
import com.anytypeio.anytype.core_models.StubRelationOptionObject
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_ui.extensions.dark
|
||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
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.objects.DefaultObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||
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.add.AddOptionsRelationDVViewModel
|
||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
|
@ -74,9 +78,12 @@ class AddRelationStatusValueTest {
|
|||
@Mock
|
||||
lateinit var analytics: Analytics
|
||||
|
||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
||||
private lateinit var addObjectRelationOption: AddObjectRelationOption
|
||||
@Mock
|
||||
lateinit var objectDetailProvider: ObjectDetailProvider
|
||||
|
||||
private lateinit var createRelationOption: CreateRelationOption
|
||||
private lateinit var updateDetail: UpdateDetail
|
||||
private lateinit var getOptions: GetOptions
|
||||
private lateinit var urlBuilder: UrlBuilder
|
||||
|
||||
@get:Rule
|
||||
|
@ -88,25 +95,31 @@ class AddRelationStatusValueTest {
|
|||
private val ctx = MockDataFactory.randomUuid()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
private val store : ObjectStore = DefaultObjectStore()
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
private val db = ObjectSetDatabase(store = store)
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
addRelationOption = AddDataViewRelationOption(repo)
|
||||
addObjectRelationOption = AddObjectRelationOption(repo)
|
||||
createRelationOption = CreateRelationOption(repo)
|
||||
getOptions = GetOptions(repo)
|
||||
updateDetail = UpdateDetail(repo)
|
||||
urlBuilder = UrlBuilder(gateway)
|
||||
TestRelationOptionValueDVAddFragment.testVmFactory = AddOptionsRelationDVViewModel.Factory(
|
||||
relations = DataViewObjectRelationProvider(state),
|
||||
relations = DataViewObjectRelationProvider(
|
||||
objectSetState = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
),
|
||||
values = DataViewObjectValueProvider(
|
||||
db = db
|
||||
),
|
||||
addDataViewRelationOption = addRelationOption,
|
||||
dispatcher = dispatcher,
|
||||
optionsProvider = AddOptionsRelationProvider(),
|
||||
setObjectDetail = updateDetail,
|
||||
analytics = analytics
|
||||
analytics = analytics,
|
||||
createRelationOption = createRelationOption,
|
||||
detailsProvider = objectDetailProvider,
|
||||
getOptions = getOptions
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -156,34 +169,9 @@ class AddRelationStatusValueTest {
|
|||
)
|
||||
)
|
||||
|
||||
state.value = ObjectSet(
|
||||
blocks = listOf(dv),
|
||||
// viewerDb = mapOf(
|
||||
// viewer.id to ObjectSet.ViewerData(
|
||||
// records = listOf(record),
|
||||
// total = 1
|
||||
// )
|
||||
// )
|
||||
)
|
||||
state.value = ObjectSet(blocks = listOf(dv))
|
||||
|
||||
repo.stub {
|
||||
onBlocking {
|
||||
addDataViewRelationOption(
|
||||
ctx = any(),
|
||||
dataview = any(),
|
||||
relation = any(),
|
||||
color = any(),
|
||||
name = any(),
|
||||
record = any()
|
||||
)
|
||||
} doReturn Pair(
|
||||
Payload(
|
||||
context = ctx,
|
||||
events = emptyList()
|
||||
),
|
||||
MockDataFactory.randomUuid()
|
||||
)
|
||||
}
|
||||
stubCreateRelationOption()
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -213,16 +201,7 @@ class AddRelationStatusValueTest {
|
|||
|
||||
// Verifying that the request is made.
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
addDataViewRelationOption(
|
||||
ctx = any(),
|
||||
dataview = any(),
|
||||
relation = any(),
|
||||
color = any(),
|
||||
name = any(),
|
||||
record = any()
|
||||
)
|
||||
}
|
||||
verifyCreateRelationOptionCalled()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -281,24 +260,7 @@ class AddRelationStatusValueTest {
|
|||
// )
|
||||
)
|
||||
|
||||
repo.stub {
|
||||
onBlocking {
|
||||
addDataViewRelationOption(
|
||||
ctx = any(),
|
||||
dataview = any(),
|
||||
relation = any(),
|
||||
color = any(),
|
||||
name = any(),
|
||||
record = any()
|
||||
)
|
||||
} doReturn Pair(
|
||||
Payload(
|
||||
context = ctx,
|
||||
events = emptyList()
|
||||
),
|
||||
MockDataFactory.randomUuid()
|
||||
)
|
||||
}
|
||||
stubCreateRelationOption()
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -610,14 +572,10 @@ class AddRelationStatusValueTest {
|
|||
// Veryfying UI
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
updateDataViewRecord(
|
||||
context = ctx,
|
||||
target = dv.id,
|
||||
record = target,
|
||||
values = mapOf(
|
||||
ObjectSetConfig.ID_KEY to target,
|
||||
relationKey to listOf(option2.id)
|
||||
)
|
||||
updateDetail(
|
||||
ctx = target,
|
||||
key = relationKey,
|
||||
value = listOf(option2.id)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -628,4 +586,35 @@ class AddRelationStatusValueTest {
|
|||
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.Payload
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.StubRelationOptionObject
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
import com.anytypeio.anytype.core_ui.extensions.dark
|
||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
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.objects.DefaultObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||
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.add.AddOptionsRelationDVViewModel
|
||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectDetailProvider
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.checkHasText
|
||||
|
@ -73,9 +76,12 @@ class AddRelationTagValueTest {
|
|||
@Mock
|
||||
lateinit var analytics: Analytics
|
||||
|
||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
||||
private lateinit var addObjectRelationOption: AddObjectRelationOption
|
||||
@Mock
|
||||
lateinit var objectDetailProvider: ObjectDetailProvider
|
||||
|
||||
private lateinit var createRelationOption: CreateRelationOption
|
||||
private lateinit var updateDetail: UpdateDetail
|
||||
private lateinit var getOptions: GetOptions
|
||||
private lateinit var urlBuilder: UrlBuilder
|
||||
|
||||
@get:Rule
|
||||
|
@ -87,23 +93,29 @@ class AddRelationTagValueTest {
|
|||
private val ctx = MockDataFactory.randomUuid()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
private val store : ObjectStore = DefaultObjectStore()
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
private val db = ObjectSetDatabase(store = store)
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
addRelationOption = AddDataViewRelationOption(repo)
|
||||
addObjectRelationOption = AddObjectRelationOption(repo)
|
||||
createRelationOption = CreateRelationOption(repo)
|
||||
getOptions = GetOptions(repo)
|
||||
updateDetail = UpdateDetail(repo)
|
||||
urlBuilder = UrlBuilder(gateway)
|
||||
TestRelationOptionValueDVAddFragment.testVmFactory = AddOptionsRelationDVViewModel.Factory(
|
||||
relations = DataViewObjectRelationProvider(state),
|
||||
relations = DataViewObjectRelationProvider(
|
||||
objectSetState = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
),
|
||||
values = DataViewObjectValueProvider(db = db),
|
||||
addDataViewRelationOption = addRelationOption,
|
||||
createRelationOption = createRelationOption,
|
||||
dispatcher = dispatcher,
|
||||
optionsProvider = AddOptionsRelationProvider(),
|
||||
analytics = analytics,
|
||||
setObjectDetail = updateDetail
|
||||
setObjectDetail = updateDetail,
|
||||
detailsProvider = objectDetailProvider,
|
||||
getOptions = getOptions
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -163,24 +175,7 @@ class AddRelationTagValueTest {
|
|||
// )
|
||||
)
|
||||
|
||||
repo.stub {
|
||||
onBlocking {
|
||||
addDataViewRelationOption(
|
||||
ctx = any(),
|
||||
dataview = any(),
|
||||
relation = any(),
|
||||
color = any(),
|
||||
name = any(),
|
||||
record = any()
|
||||
)
|
||||
} doReturn Pair(
|
||||
Payload(
|
||||
context = ctx,
|
||||
events = emptyList()
|
||||
),
|
||||
MockDataFactory.randomUuid()
|
||||
)
|
||||
}
|
||||
stubCreateRelationOption()
|
||||
|
||||
// TESTING
|
||||
|
||||
|
@ -212,16 +207,7 @@ class AddRelationTagValueTest {
|
|||
|
||||
// Verifying that the request is made.
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
addDataViewRelationOption(
|
||||
ctx = any(),
|
||||
dataview = any(),
|
||||
relation = any(),
|
||||
color = any(),
|
||||
name = any(),
|
||||
record = any()
|
||||
)
|
||||
}
|
||||
verifyCreateRelationOptionCalled()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -533,14 +519,10 @@ class AddRelationTagValueTest {
|
|||
R.id.btnAdd.performClick()
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
updateDataViewRecord(
|
||||
context = ctx,
|
||||
target = dv.id,
|
||||
record = target,
|
||||
values = mapOf(
|
||||
ObjectSetConfig.ID_KEY to target,
|
||||
relationKey to listOf(option1.id, option2.id)
|
||||
)
|
||||
updateDetail(
|
||||
ctx = target,
|
||||
key = relationKey,
|
||||
value = listOf(option1.id, option2.id)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -551,4 +533,34 @@ class AddRelationTagValueTest {
|
|||
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.domain.`object`.ReloadObject
|
||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.RelationTextValueViewModel
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import com.anytypeio.anytype.test_utils.utils.espresso.TextLineCountMatcher
|
||||
|
@ -61,13 +62,17 @@ class DisplayObjectRelationTextValueTest {
|
|||
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
private val store: ObjectStore = DefaultObjectStore()
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
private val db = ObjectSetDatabase(store = store)
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
TestRelationTextValueFragment.testVmFactory = RelationTextValueViewModel.Factory(
|
||||
relations = DataViewObjectRelationProvider(state),
|
||||
relations = DataViewObjectRelationProvider(
|
||||
objectSetState = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
),
|
||||
values = DataViewObjectValueProvider(db = db),
|
||||
reloadObject = reloadObject,
|
||||
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.config.Gateway
|
||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.RelationTextValueViewModel
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
|
@ -69,13 +70,17 @@ class DisplayRelationNumberValueTest {
|
|||
private val root = MockDataFactory.randomUuid()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
private val store: ObjectStore = DefaultObjectStore()
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
private val db = ObjectSetDatabase(store = store)
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
TestRelationTextValueFragment.testVmFactory = RelationTextValueViewModel.Factory(
|
||||
relations = DataViewObjectRelationProvider(state),
|
||||
relations = DataViewObjectRelationProvider(
|
||||
objectSetState = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
),
|
||||
values = DataViewObjectValueProvider(db = db),
|
||||
reloadObject = reloadObject,
|
||||
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.Payload
|
||||
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.block.repo.BlockRepository
|
||||
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.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.relations.AddFileToObject
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
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.sets.ObjectSet
|
||||
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.util.CopyFileToCacheDirectory
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -53,6 +56,11 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.stub
|
||||
import org.mockito.kotlin.times
|
||||
import org.mockito.kotlin.verifyBlocking
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
|
@ -73,7 +81,6 @@ class DisplayRelationObjectValueTest {
|
|||
@Mock
|
||||
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
||||
|
||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
||||
private lateinit var updateDetail: UpdateDetail
|
||||
private lateinit var urlBuilder: UrlBuilder
|
||||
private lateinit var addFileToObject: AddFileToObject
|
||||
|
@ -87,31 +94,32 @@ class DisplayRelationObjectValueTest {
|
|||
private val root = MockDataFactory.randomUuid()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
private val store: ObjectStore = DefaultObjectStore()
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||
private val db = ObjectSetDatabase(store = store)
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
addRelationOption = AddDataViewRelationOption(repo)
|
||||
updateDetail = UpdateDetail(repo)
|
||||
addFileToObject = AddFileToObject(repo)
|
||||
urlBuilder = UrlBuilder(gateway)
|
||||
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
||||
relations = DataViewObjectRelationProvider(state),
|
||||
relations = DataViewObjectRelationProvider(
|
||||
objectSetState = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
),
|
||||
values = DataViewObjectValueProvider(db = db),
|
||||
details = object: ObjectDetailProvider {
|
||||
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,
|
||||
copyFileToCache = copyFileToCacheDirectory,
|
||||
analytics = analytics,
|
||||
addFileToObject = addFileToObject,
|
||||
setObjectDetails = updateDetail,
|
||||
dispatcher = dispatcher
|
||||
dispatcher = dispatcher,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -348,7 +356,7 @@ class DisplayRelationObjectValueTest {
|
|||
val objectType1 = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Director",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = "",
|
||||
layout = ObjectType.Layout.values().random(),
|
||||
description = "",
|
||||
|
@ -361,7 +369,7 @@ class DisplayRelationObjectValueTest {
|
|||
val objectType2 = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Actor",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = "",
|
||||
layout = ObjectType.Layout.values().random(),
|
||||
description = "",
|
||||
|
@ -473,7 +481,7 @@ class DisplayRelationObjectValueTest {
|
|||
val objectType1 = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Writer",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = "",
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -486,7 +494,7 @@ class DisplayRelationObjectValueTest {
|
|||
val objectType2 = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Writer",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = "",
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -600,7 +608,7 @@ class DisplayRelationObjectValueTest {
|
|||
val objectType1 = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Writer",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = "",
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -613,7 +621,7 @@ class DisplayRelationObjectValueTest {
|
|||
val objectType2 = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Writer",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = "",
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
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.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
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.block.repo.BlockRepository
|
||||
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.core_models.ThemeColor
|
||||
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.relations.AddFileToObject
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
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.sets.ObjectSet
|
||||
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.util.CopyFileToCacheDirectory
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -75,7 +75,6 @@ class DisplayRelationStatusValueTest {
|
|||
@Mock
|
||||
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
||||
|
||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
||||
private lateinit var updateDetail: UpdateDetail
|
||||
private lateinit var addFileToObject: AddFileToObject
|
||||
private lateinit var urlBuilder: UrlBuilder
|
||||
|
@ -89,33 +88,34 @@ class DisplayRelationStatusValueTest {
|
|||
private val root = MockDataFactory.randomUuid()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
private val store: ObjectStore = DefaultObjectStore()
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||
private val db = ObjectSetDatabase(store)
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
addRelationOption = AddDataViewRelationOption(repo)
|
||||
updateDetail = UpdateDetail(repo)
|
||||
addFileToObject = AddFileToObject(repo)
|
||||
urlBuilder = UrlBuilder(gateway)
|
||||
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
||||
relations = DataViewObjectRelationProvider(state),
|
||||
relations = DataViewObjectRelationProvider(
|
||||
objectSetState = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
),
|
||||
values = DataViewObjectValueProvider(
|
||||
db = db
|
||||
),
|
||||
details = object : ObjectDetailProvider {
|
||||
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,
|
||||
copyFileToCache = copyFileToCacheDirectory,
|
||||
dispatcher = dispatcher,
|
||||
analytics = analytics,
|
||||
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.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
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.block.repo.BlockRepository
|
||||
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.core_models.ThemeColor
|
||||
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.relations.AddFileToObject
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
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.sets.ObjectSet
|
||||
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.util.CopyFileToCacheDirectory
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -75,7 +75,6 @@ class DisplayRelationTagValueTest {
|
|||
@Mock
|
||||
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
||||
|
||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
||||
private lateinit var updateDetail: UpdateDetail
|
||||
private lateinit var addFileToObject: AddFileToObject
|
||||
private lateinit var urlBuilder: UrlBuilder
|
||||
|
@ -89,31 +88,32 @@ class DisplayRelationTagValueTest {
|
|||
private val root = MockDataFactory.randomUuid()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
private val store: ObjectStore = DefaultObjectStore()
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
private val db = ObjectSetDatabase(store)
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
addRelationOption = AddDataViewRelationOption(repo)
|
||||
updateDetail = UpdateDetail(repo)
|
||||
addFileToObject = AddFileToObject(repo)
|
||||
urlBuilder = UrlBuilder(gateway)
|
||||
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
||||
relations = DataViewObjectRelationProvider(state),
|
||||
relations = DataViewObjectRelationProvider(
|
||||
objectSetState = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
),
|
||||
values = DataViewObjectValueProvider(db = db),
|
||||
details = object: ObjectDetailProvider {
|
||||
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,
|
||||
copyFileToCache = copyFileToCacheDirectory,
|
||||
dispatcher = dispatcher,
|
||||
analytics = analytics,
|
||||
setObjectDetails = updateDetail,
|
||||
addFileToObject = addFileToObject
|
||||
addFileToObject = addFileToObject,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -537,7 +537,7 @@ class DisplayRelationTagValueTest {
|
|||
}
|
||||
|
||||
private fun launchFragment(args: Bundle): FragmentScenario<TestRelationValueDVFragment> {
|
||||
return launchFragmentInContainer<TestRelationValueDVFragment>(
|
||||
return launchFragmentInContainer(
|
||||
fragmentArgs = args,
|
||||
themeResId = R.style.AppTheme
|
||||
)
|
||||
|
|
|
@ -10,19 +10,20 @@ import com.anytypeio.anytype.R
|
|||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.ThemeColor
|
||||
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.block.repo.BlockRepository
|
||||
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.core_models.ThemeColor
|
||||
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.relations.AddFileToObject
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
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.sets.ObjectSet
|
||||
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.util.CopyFileToCacheDirectory
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -77,7 +77,6 @@ class EditRelationTagValueTest {
|
|||
@Mock
|
||||
lateinit var copyFileToCacheDirectory: CopyFileToCacheDirectory
|
||||
|
||||
private lateinit var addRelationOption: AddDataViewRelationOption
|
||||
private lateinit var updateDetail: UpdateDetail
|
||||
private lateinit var urlBuilder: UrlBuilder
|
||||
private lateinit var addFileToObject: AddFileToObject
|
||||
|
@ -91,31 +90,32 @@ class EditRelationTagValueTest {
|
|||
private val ctx = MockDataFactory.randomUuid()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
private val store: ObjectStore = DefaultObjectStore()
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
private val db = ObjectSetDatabase(store = store)
|
||||
private val storeOfObjectTypes: StoreOfObjectTypes = DefaultStoreOfObjectTypes()
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
addRelationOption = AddDataViewRelationOption(repo)
|
||||
updateDetail = UpdateDetail(repo)
|
||||
urlBuilder = UrlBuilder(gateway)
|
||||
addFileToObject = AddFileToObject(repo)
|
||||
TestRelationValueDVFragment.testVmFactory = RelationValueDVViewModel.Factory(
|
||||
relations = DataViewObjectRelationProvider(state),
|
||||
relations = DataViewObjectRelationProvider(
|
||||
objectSetState = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
),
|
||||
values = DataViewObjectValueProvider(db = db),
|
||||
details = object : ObjectDetailProvider {
|
||||
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,
|
||||
copyFileToCache = copyFileToCacheDirectory,
|
||||
addFileToObject = addFileToObject,
|
||||
dispatcher = dispatcher,
|
||||
analytics = analytics,
|
||||
setObjectDetails = updateDetail
|
||||
setObjectDetails = updateDetail,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -337,13 +337,10 @@ class EditRelationTagValueTest {
|
|||
rvMatcher.onItemView(1, R.id.btnRemoveTag).performClick()
|
||||
|
||||
verifyBlocking(repo, times(1)) {
|
||||
updateDataViewRecord(
|
||||
context = ctx,
|
||||
target = dv.id,
|
||||
record = target,
|
||||
values = mapOf(
|
||||
relationKey to listOf(option2.id)
|
||||
)
|
||||
updateDetail(
|
||||
ctx= target,
|
||||
key = relationKey,
|
||||
value = 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.ext.formatTimeInMillis
|
||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetConfig
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.DataViewObjectValueProvider
|
||||
|
@ -52,12 +54,16 @@ class ObjectRelationDateValueTest {
|
|||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
private val store: ObjectStore = DefaultObjectStore()
|
||||
private val db = ObjectSetDatabase(store)
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
TestRelationDateValueFragment.testVmFactory = RelationDateValueViewModel.Factory(
|
||||
relations = DataViewObjectRelationProvider(state),
|
||||
relations = DataViewObjectRelationProvider(
|
||||
objectSetState = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
),
|
||||
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.Payload
|
||||
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_utils.const.DateConst
|
||||
import com.anytypeio.anytype.core_utils.ext.toTimeSeconds
|
||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
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.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.relations.AddToFeaturedRelations
|
||||
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.presentation.editor.Editor
|
||||
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.util.Dispatcher
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
|
@ -76,6 +77,9 @@ class ObjectRelationListTest {
|
|||
@Mock
|
||||
lateinit var analytics: Analytics
|
||||
|
||||
@Mock
|
||||
lateinit var storeOfRelations: StoreOfRelations
|
||||
|
||||
private lateinit var objectRelationList: ObjectRelationList
|
||||
private lateinit var updateDetail: UpdateDetail
|
||||
private lateinit var addToFeaturedRelations: AddToFeaturedRelations
|
||||
|
@ -106,7 +110,8 @@ class ObjectRelationListTest {
|
|||
addToFeaturedRelations = addToFeaturedRelations,
|
||||
removeFromFeaturedRelations = removeFromFeaturedRelations,
|
||||
deleteRelationFromObject = deleteRelationFromObject,
|
||||
analytics = analytics
|
||||
analytics = analytics,
|
||||
storeOfRelations = storeOfRelations
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class ObjectSetGridColumnRenderingTest : TestObjectSetSetup() {
|
|||
name = MockDataFactory.randomString(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.BASIC,
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
description = "",
|
||||
isHidden = false,
|
||||
smartBlockTypes = listOf(),
|
||||
|
@ -150,15 +150,10 @@ class ObjectSetGridColumnRenderingTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation1, relation2, relation3, relation4, relation5),
|
||||
details = defaultDetails,
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = emptyList(),
|
||||
total = 1,
|
||||
objectTypes = listOf(type)
|
||||
)
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class ObjectSetGridFileCellRenderingTest : TestObjectSetSetup() {
|
|||
val objectType = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Movie",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -159,15 +159,10 @@ class ObjectSetGridFileCellRenderingTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
details = details,
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1, record2),
|
||||
total = 1,
|
||||
objectTypes = listOf(objectType)
|
||||
)
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
val objectType = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Movie",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -125,14 +125,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1),
|
||||
total = 1,
|
||||
objectTypes = listOf(objectType)
|
||||
)
|
||||
|
||||
|
@ -166,7 +161,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
val objectType = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Movie",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -229,14 +224,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1),
|
||||
total = 1,
|
||||
objectTypes = listOf(objectType)
|
||||
)
|
||||
|
||||
|
@ -270,7 +260,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
val objectType = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Movie",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -333,14 +323,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1),
|
||||
total = 1,
|
||||
objectTypes = listOf(objectType)
|
||||
)
|
||||
|
||||
|
@ -374,7 +359,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
val objectType = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Movie",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -437,14 +422,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1),
|
||||
total = 1,
|
||||
objectTypes = listOf(objectType)
|
||||
)
|
||||
|
||||
|
@ -478,7 +458,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
val objectType = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Movie",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -541,14 +521,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1),
|
||||
total = 1,
|
||||
objectTypes = listOf(objectType)
|
||||
)
|
||||
|
||||
|
@ -582,7 +557,7 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
val objectType = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Movie",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -645,14 +620,9 @@ class ObjectSetGridNumberCellRenderingTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1),
|
||||
total = 1,
|
||||
objectTypes = listOf(objectType)
|
||||
)
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
|||
val objectType = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Movie",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -158,15 +158,10 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
details = details,
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1, record2),
|
||||
total = 1,
|
||||
objectTypes = listOf(objectType)
|
||||
)
|
||||
|
||||
|
@ -197,7 +192,7 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
|||
val objectType = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Movie",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.PROFILE,
|
||||
description = "",
|
||||
|
@ -282,15 +277,10 @@ class ObjectSetGridObjectCellRenderingTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
details = details,
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1),
|
||||
total = 1,
|
||||
objectTypes = listOf(objectType)
|
||||
)
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class ObjectSetGridPrimitiveRelationTest : TestObjectSetSetup() {
|
|||
name = MockDataFactory.randomString(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.BASIC,
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
description = "",
|
||||
isHidden = false,
|
||||
smartBlockTypes = listOf(),
|
||||
|
@ -190,15 +190,10 @@ class ObjectSetGridPrimitiveRelationTest : TestObjectSetSetup() {
|
|||
|
||||
stubInterceptEvents()
|
||||
stubInterceptThreadStatus()
|
||||
stubSetActiveViewer()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation1, relation2, relation3, relation4, relation5),
|
||||
details = defaultDetails,
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1, record2),
|
||||
total = 1,
|
||||
objectTypes = listOf(type)
|
||||
)
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class ObjectSetGridTagCellRenderingTest : TestObjectSetSetup() {
|
|||
val objectType = ObjectType(
|
||||
url = MockDataFactory.randomUuid(),
|
||||
name = "Film",
|
||||
relations = emptyList(),
|
||||
relationLinks = emptyList(),
|
||||
emoji = MockDataFactory.randomString(),
|
||||
layout = ObjectType.Layout.BASIC ,
|
||||
description = "",
|
||||
|
@ -152,16 +152,11 @@ class ObjectSetGridTagCellRenderingTest : TestObjectSetSetup() {
|
|||
val set = listOf(root, header, title, dataview)
|
||||
|
||||
stubInterceptEvents()
|
||||
stubSetActiveViewer()
|
||||
stubInterceptThreadStatus()
|
||||
stubOpenObjectSetWithRecord(
|
||||
set = set,
|
||||
relations = listOf(relation),
|
||||
details = details,
|
||||
viewer = viewer.id,
|
||||
dataview = dataview.id,
|
||||
records = listOf(record1, record2),
|
||||
total = 1,
|
||||
objectTypes = listOf(objectType)
|
||||
)
|
||||
|
||||
|
|
|
@ -6,12 +6,8 @@ import androidx.fragment.app.testing.launchFragmentInContainer
|
|||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Block
|
||||
import com.anytypeio.anytype.core_models.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.Id
|
||||
import com.anytypeio.anytype.core_models.Key
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
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.cover.SetDocCoverImage
|
||||
import com.anytypeio.anytype.domain.dataview.SetDataViewSource
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.AddNewRelationToDataView
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewRecord
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewObject
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.domain.objects.DefaultObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.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.status.InterceptThreadStatus
|
||||
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.presentation.common.Action
|
||||
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.sets.ObjectSetDatabase
|
||||
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.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory
|
||||
|
@ -68,11 +64,10 @@ import org.mockito.kotlin.stub
|
|||
abstract class TestObjectSetSetup {
|
||||
|
||||
private lateinit var openObjectSet: OpenObjectSet
|
||||
private lateinit var addDataViewRelation: AddNewRelationToDataView
|
||||
private lateinit var updateDataViewViewer: UpdateDataViewViewer
|
||||
private lateinit var setObjectDetails: UpdateDetail
|
||||
private lateinit var updateText: UpdateText
|
||||
private lateinit var createDataViewRecord: CreateDataViewRecord
|
||||
private lateinit var createDataViewObject: CreateDataViewObject
|
||||
private lateinit var closeBlock: CloseBlock
|
||||
private lateinit var interceptThreadStatus: InterceptThreadStatus
|
||||
private lateinit var setDocCoverImage: SetDocCoverImage
|
||||
|
@ -109,17 +104,17 @@ abstract class TestObjectSetSetup {
|
|||
@Mock
|
||||
lateinit var createNewObject: CreateNewObject
|
||||
|
||||
lateinit var getTemplates: GetTemplates
|
||||
private lateinit var getTemplates: GetTemplates
|
||||
|
||||
private val session = ObjectSetSession()
|
||||
private val reducer = ObjectSetReducer()
|
||||
private val dispatcher: Dispatcher<Payload> = Dispatcher.Default()
|
||||
private val objectSetRecordCache = ObjectSetRecordCache()
|
||||
private val paginator = ObjectSetPaginator()
|
||||
private val store: ObjectStore = DefaultObjectStore()
|
||||
private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations()
|
||||
|
||||
lateinit var database: ObjectSetDatabase
|
||||
lateinit var dataViewSubscriptionContainer: DataViewSubscriptionContainer
|
||||
private lateinit var database: ObjectSetDatabase
|
||||
private lateinit var dataViewSubscriptionContainer: DataViewSubscriptionContainer
|
||||
|
||||
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() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
setDataViewSource = SetDataViewSource(repo)
|
||||
addDataViewRelation = AddNewRelationToDataView(repo)
|
||||
updateText = UpdateText(repo)
|
||||
openObjectSet = OpenObjectSet(repo, auth)
|
||||
createDataViewRecord = CreateDataViewRecord(repo)
|
||||
createDataViewObject = CreateDataViewObject(repo)
|
||||
setObjectDetails = UpdateDetail(repo)
|
||||
updateDataViewViewer = UpdateDataViewViewer(repo)
|
||||
interceptThreadStatus = InterceptThreadStatus(channel = threadStatusChannel)
|
||||
|
@ -183,11 +177,10 @@ abstract class TestObjectSetSetup {
|
|||
TestObjectSetFragment.testVmFactory = ObjectSetViewModelFactory(
|
||||
openObjectSet = openObjectSet,
|
||||
closeBlock = closeBlock,
|
||||
addDataViewRelation = addDataViewRelation,
|
||||
interceptEvents = interceptEvents,
|
||||
interceptThreadStatus = interceptThreadStatus,
|
||||
updateDataViewViewer = updateDataViewViewer,
|
||||
createDataViewRecord = createDataViewRecord,
|
||||
createDataViewObject = createDataViewObject,
|
||||
setObjectDetails = setObjectDetails,
|
||||
updateText = updateText,
|
||||
urlBuilder = urlBuilder,
|
||||
|
@ -195,7 +188,6 @@ abstract class TestObjectSetSetup {
|
|||
session = session,
|
||||
dispatcher = dispatcher,
|
||||
reducer = reducer,
|
||||
objectSetRecordCache = objectSetRecordCache,
|
||||
analytics = analytics,
|
||||
downloadUnsplashImage = downloadUnsplashImage,
|
||||
setDocCoverImage = setDocCoverImage,
|
||||
|
@ -206,7 +198,8 @@ abstract class TestObjectSetSetup {
|
|||
cancelSearchSubscription = cancelSearchSubscription,
|
||||
paginator = paginator,
|
||||
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() {
|
||||
threadStatusChannel.stub {
|
||||
onBlocking { observe(any()) } doReturn emptyFlow()
|
||||
|
@ -263,15 +238,10 @@ abstract class TestObjectSetSetup {
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated("To be deleted")
|
||||
fun stubOpenObjectSetWithRecord(
|
||||
set: List<Block>,
|
||||
details: Block.Details = Block.Details(),
|
||||
relations: List<Relation> = emptyList(),
|
||||
dataview: Id,
|
||||
viewer: Id,
|
||||
total: Int,
|
||||
records: List<DVRecord>,
|
||||
objectTypes: List<ObjectType>
|
||||
) {
|
||||
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() {
|
||||
repo.stub {
|
||||
onBlocking {
|
||||
|
@ -334,7 +275,9 @@ abstract class TestObjectSetSetup {
|
|||
source = any(),
|
||||
keys = any(),
|
||||
limit = any(),
|
||||
offset = any()
|
||||
offset = any(),
|
||||
ignoreWorkspace = any(),
|
||||
noDepSubscription = any()
|
||||
)
|
||||
} doReturn SearchResult(
|
||||
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.Payload
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.Gateway
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
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.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -58,9 +64,6 @@ class CreateSelectedFilterTest {
|
|||
@Mock
|
||||
lateinit var gateway: Gateway
|
||||
|
||||
@Mock
|
||||
lateinit var objectTypesProvider: ObjectTypesProvider
|
||||
|
||||
@Mock
|
||||
lateinit var analytics: Analytics
|
||||
|
||||
|
@ -72,6 +75,10 @@ class CreateSelectedFilterTest {
|
|||
private val session = ObjectSetSession()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
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
|
||||
fun setup() {
|
||||
|
@ -86,8 +93,10 @@ class CreateSelectedFilterTest {
|
|||
urlBuilder = urlBuilder,
|
||||
searchObjects = searchObjects,
|
||||
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.Payload
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.Gateway
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
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.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -60,9 +66,6 @@ class ModifyInputValueFilterTest {
|
|||
@Mock
|
||||
lateinit var repo: BlockRepository
|
||||
|
||||
@Mock
|
||||
lateinit var objectTypesProvider: ObjectTypesProvider
|
||||
|
||||
@Mock
|
||||
lateinit var gateway: Gateway
|
||||
|
||||
|
@ -77,6 +80,10 @@ class ModifyInputValueFilterTest {
|
|||
private val session = ObjectSetSession()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
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
|
||||
fun setup() {
|
||||
|
@ -91,8 +98,10 @@ class ModifyInputValueFilterTest {
|
|||
dispatcher = dispatcher,
|
||||
searchObjects = searchObjects,
|
||||
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.Payload
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.config.Gateway
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
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.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -60,8 +66,6 @@ class ModifyStatusFilterTest {
|
|||
lateinit var repo: BlockRepository
|
||||
@Mock
|
||||
lateinit var gateway: Gateway
|
||||
@Mock
|
||||
lateinit var objectTypesProvider: ObjectTypesProvider
|
||||
|
||||
@Mock
|
||||
lateinit var analytics: Analytics
|
||||
|
@ -74,6 +78,10 @@ class ModifyStatusFilterTest {
|
|||
private val session = ObjectSetSession()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
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
|
||||
fun setup() {
|
||||
|
@ -88,8 +96,10 @@ class ModifyStatusFilterTest {
|
|||
dispatcher = dispatcher,
|
||||
searchObjects = searchObjects,
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypesProvider = objectTypesProvider,
|
||||
analytics = analytics
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
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.block.repo.BlockRepository
|
||||
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.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.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -72,6 +79,10 @@ class ModifyTagFilterTest {
|
|||
private val session = ObjectSetSession()
|
||||
private val state = MutableStateFlow(ObjectSet.init())
|
||||
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
|
||||
fun setup() {
|
||||
|
@ -86,8 +97,10 @@ class ModifyTagFilterTest {
|
|||
dispatcher = dispatcher,
|
||||
searchObjects = searchObjects,
|
||||
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.CreateDataViewViewerModule
|
||||
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.DebugSettingsModule
|
||||
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.ObjectMenuModule
|
||||
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.ObjectSetCreateBookmarkRecordModule
|
||||
import com.anytypeio.anytype.di.feature.ObjectSetIconPickerModule
|
||||
import com.anytypeio.anytype.di.feature.ObjectSetMenuModule
|
||||
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.ObjectSetSettingsModule
|
||||
import com.anytypeio.anytype.di.feature.ObjectTypeChangeModule
|
||||
|
@ -338,18 +337,6 @@ class ComponentManager(
|
|||
.build()
|
||||
}
|
||||
|
||||
val createSetComponent = Component {
|
||||
main.createSetComponentBuilder()
|
||||
.module(CreateSetModule)
|
||||
.build()
|
||||
}
|
||||
|
||||
val createObjectTypeComponent = Component {
|
||||
main.createObjectTypeComponentBuilder()
|
||||
.module(CreateObjectTypeModule)
|
||||
.build()
|
||||
}
|
||||
|
||||
val objectSetComponent = ComponentMap {
|
||||
main.objectSetComponentBuilder()
|
||||
.module(ObjectSetModule)
|
||||
|
@ -456,7 +443,7 @@ class ComponentManager(
|
|||
objectSetComponent
|
||||
.get(ctx)
|
||||
.objectRelationValueComponent()
|
||||
.module(ObjectRelationValueModule)
|
||||
.module(ObjectSetObjectRelationValueModule)
|
||||
.build()
|
||||
}
|
||||
|
||||
|
@ -472,7 +459,7 @@ class ComponentManager(
|
|||
editorComponent
|
||||
.get(ctx)
|
||||
.editDocRelationComponent()
|
||||
.module(ObjectRelationValueModule)
|
||||
.module(ObjectObjectRelationValueModule)
|
||||
.build()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.anytypeio.anytype.di.feature
|
||||
|
||||
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.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.relations.add.AddObjectRelationViewModel
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectValueProvider
|
||||
|
@ -34,11 +34,11 @@ object AddObjectRelationModule {
|
|||
fun provideViewModelFactory(
|
||||
relations: ObjectRelationProvider,
|
||||
values: ObjectValueProvider,
|
||||
objectTypesProvider: ObjectTypesProvider,
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
searchObjects: SearchObjects,
|
||||
urlBuilder: UrlBuilder
|
||||
): 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.domain.`object`.UpdateDetail
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewRelationOption
|
||||
import com.anytypeio.anytype.domain.relations.AddObjectRelationOption
|
||||
import com.anytypeio.anytype.domain.objects.options.GetOptions
|
||||
import com.anytypeio.anytype.domain.relations.CreateRelationOption
|
||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel
|
||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider
|
||||
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.ObjectValueProvider
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -42,17 +43,21 @@ object AddObjectRelationValueModule {
|
|||
relations: ObjectRelationProvider,
|
||||
values: ObjectValueProvider,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
addDataViewRelationOption: AddDataViewRelationOption,
|
||||
createRelationOption: CreateRelationOption,
|
||||
analytics: Analytics,
|
||||
setObjectDetail: UpdateDetail,
|
||||
detailsProvider: ObjectDetailProvider,
|
||||
getOptions: GetOptions
|
||||
): AddOptionsRelationDVViewModel.Factory = AddOptionsRelationDVViewModel.Factory(
|
||||
relations = relations,
|
||||
values = values,
|
||||
dispatcher = dispatcher,
|
||||
addDataViewRelationOption = addDataViewRelationOption,
|
||||
createRelationOption = createRelationOption,
|
||||
optionsProvider = AddOptionsRelationProvider(),
|
||||
analytics = analytics,
|
||||
setObjectDetail = setObjectDetail
|
||||
setObjectDetail = setObjectDetail,
|
||||
detailsProvider = detailsProvider,
|
||||
getOptions = getOptions
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
@ -62,23 +67,32 @@ object AddObjectRelationValueModule {
|
|||
relations: ObjectRelationProvider,
|
||||
values: ObjectValueProvider,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
addObjectRelationOption: AddObjectRelationOption,
|
||||
createRelationOption: CreateRelationOption,
|
||||
updateDetail: UpdateDetail,
|
||||
analytics: Analytics
|
||||
analytics: Analytics,
|
||||
detailsProvider: ObjectDetailProvider,
|
||||
getOptions: GetOptions
|
||||
): AddOptionsRelationViewModel.Factory = AddOptionsRelationViewModel.Factory(
|
||||
relations = relations,
|
||||
values = values,
|
||||
dispatcher = dispatcher,
|
||||
addObjectRelationOption = addObjectRelationOption,
|
||||
createRelationOption = createRelationOption,
|
||||
updateDetail = updateDetail,
|
||||
analytics = analytics,
|
||||
optionsProvider = AddOptionsRelationProvider()
|
||||
optionsProvider = AddOptionsRelationProvider(),
|
||||
detailProvider = detailsProvider,
|
||||
getOptions = getOptions
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerDialog
|
||||
fun provideAddObjectRelationOptionUseCase(
|
||||
fun createRelationOption(
|
||||
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.dashboard.interactor.CloseDashboard
|
||||
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.InterceptEvents
|
||||
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.ObjectStore
|
||||
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.search.CancelSearchSubscription
|
||||
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.templates.GetTemplates
|
||||
import com.anytypeio.anytype.domain.page.CreateNewObject
|
||||
import com.anytypeio.anytype.presentation.dashboard.HomeDashboardEventConverter
|
||||
import com.anytypeio.anytype.presentation.dashboard.HomeDashboardViewModelFactory
|
||||
import com.anytypeio.anytype.ui.dashboard.DashboardFragment
|
||||
|
@ -77,8 +78,9 @@ object HomeDashboardModule {
|
|||
objectSearchSubscriptionContainer: ObjectSearchSubscriptionContainer,
|
||||
cancelSearchSubscription: CancelSearchSubscription,
|
||||
objectStore: ObjectStore,
|
||||
featureToggles: FeatureToggles,
|
||||
createNewObject: CreateNewObject,
|
||||
featureToggles: FeatureToggles
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): HomeDashboardViewModelFactory = HomeDashboardViewModelFactory(
|
||||
getProfile = getProfile,
|
||||
openDashboard = openDashboard,
|
||||
|
@ -97,7 +99,8 @@ object HomeDashboardModule {
|
|||
cancelSearchSubscription = cancelSearchSubscription,
|
||||
objectStore = objectStore,
|
||||
createNewObject = createNewObject,
|
||||
featureToggles = featureToggles
|
||||
featureToggles = featureToggles,
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
|
||||
@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.RelationCreateFromScratchForObjectBlockSubComponent
|
||||
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`.ObjectTypesProvider
|
||||
import com.anytypeio.anytype.domain.`object`.DuplicateObject
|
||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
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.config.UserSettingsRepository
|
||||
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.Downloader
|
||||
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.misc.UrlBuilder
|
||||
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.CreateDocument
|
||||
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.SetupBookmark
|
||||
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.search.SearchObjects
|
||||
import com.anytypeio.anytype.domain.sets.FindObjectSetForType
|
||||
|
@ -217,8 +218,6 @@ object EditorSessionModule {
|
|||
delegator: Delegator<Action>,
|
||||
detailModificationManager: DetailModificationManager,
|
||||
updateDetail: UpdateDetail,
|
||||
getCompatibleObjectTypes: GetCompatibleObjectTypes,
|
||||
objectTypesProvider: ObjectTypesProvider,
|
||||
searchObjects: SearchObjects,
|
||||
getDefaultEditorType: GetDefaultEditorType,
|
||||
findObjectSetForType: FindObjectSetForType,
|
||||
|
@ -228,6 +227,8 @@ object EditorSessionModule {
|
|||
setDocImageIcon: SetDocumentImageIcon,
|
||||
editorTemplateDelegate: EditorTemplateDelegate,
|
||||
createNewObject: CreateNewObject,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
objectToSet: ConvertObjectToSet,
|
||||
featureToggles: FeatureToggles,
|
||||
tableDelegate: EditorTableDelegate
|
||||
|
@ -250,8 +251,6 @@ object EditorSessionModule {
|
|||
delegator = delegator,
|
||||
detailModificationManager = detailModificationManager,
|
||||
updateDetail = updateDetail,
|
||||
getCompatibleObjectTypes = getCompatibleObjectTypes,
|
||||
objectTypesProvider = objectTypesProvider,
|
||||
searchObjects = searchObjects,
|
||||
getDefaultEditorType = getDefaultEditorType,
|
||||
findObjectSetForType = findObjectSetForType,
|
||||
|
@ -262,6 +261,8 @@ object EditorSessionModule {
|
|||
setDocImageIcon = setDocImageIcon,
|
||||
editorTemplateDelegate = editorTemplateDelegate,
|
||||
createNewObject = createNewObject,
|
||||
storeOfRelations = storeOfRelations,
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
objectToSet = objectToSet,
|
||||
featureToggles = featureToggles,
|
||||
tableDelegate = tableDelegate
|
||||
|
@ -307,11 +308,13 @@ object EditorSessionModule {
|
|||
fun provideDefaultBlockViewRenderer(
|
||||
urlBuilder: UrlBuilder,
|
||||
toggleStateHolder: ToggleStateHolder,
|
||||
coverImageHashProvider: CoverImageHashProvider
|
||||
coverImageHashProvider: CoverImageHashProvider,
|
||||
storeOfRelations: StoreOfRelations
|
||||
): DefaultBlockViewRenderer = DefaultBlockViewRenderer(
|
||||
urlBuilder = urlBuilder,
|
||||
toggleStateHolder = toggleStateHolder,
|
||||
coverImageHashProvider = coverImageHashProvider
|
||||
coverImageHashProvider = coverImageHashProvider,
|
||||
storeOfRelations = storeOfRelations
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
@ -831,8 +834,12 @@ object EditorUseCaseModule {
|
|||
@Provides
|
||||
@PerScreen
|
||||
fun provideDefaultObjectRelationProvider(
|
||||
storage: Editor.Storage
|
||||
): ObjectRelationProvider = DefaultObjectRelationProvider(storage.relations)
|
||||
storage: Editor.Storage,
|
||||
storeOfRelations: StoreOfRelations
|
||||
): ObjectRelationProvider = DefaultObjectRelationProvider(
|
||||
storage = storage,
|
||||
storeOfRelations = storeOfRelations
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
@ -924,13 +931,6 @@ object EditorUseCaseModule {
|
|||
fun provideGetDefaultPageType(repo: UserSettingsRepository): GetDefaultEditorType =
|
||||
GetDefaultEditorType(repo)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideGetCompatibleObjectTypesUseCase(
|
||||
repository: BlockRepository
|
||||
): GetCompatibleObjectTypes = GetCompatibleObjectTypes(repository)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
|
@ -997,6 +997,11 @@ object EditorUseCaseModule {
|
|||
)
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideAddRelationToObject(repo: BlockRepository) = AddRelationToObject(repo)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
|
|
|
@ -3,9 +3,9 @@ package com.anytypeio.anytype.di.feature
|
|||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||
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.objects.StoreOfObjectTypes
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.presentation.editor.Editor
|
||||
import com.anytypeio.anytype.presentation.linking.LinkToObjectOrWebViewModelFactory
|
||||
import com.anytypeio.anytype.ui.linking.LinkToObjectOrWebPagesFragment
|
||||
|
@ -36,14 +36,14 @@ object LinkToObjectOrWebModule {
|
|||
@Provides
|
||||
fun provideLinkToObjectViewModelFactory(
|
||||
urlBuilder: UrlBuilder,
|
||||
objectTypesProvider: ObjectTypesProvider,
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
searchObjects: SearchObjects,
|
||||
analytics: Analytics,
|
||||
stores: Editor.Storage,
|
||||
urlValidator: UrlValidator
|
||||
): LinkToObjectOrWebViewModelFactory = LinkToObjectOrWebViewModelFactory(
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypesProvider = objectTypesProvider,
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
searchObjects = searchObjects,
|
||||
analytics = analytics,
|
||||
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.UserSettingsRepository
|
||||
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.wallpaper.ObserveWallpaper
|
||||
import com.anytypeio.anytype.domain.wallpaper.RestoreWallpaper
|
||||
|
@ -49,14 +50,16 @@ object MainEntryModule {
|
|||
observeWallpaper: ObserveWallpaper,
|
||||
restoreWallpaper: RestoreWallpaper,
|
||||
interceptAccountStatus: InterceptAccountStatus,
|
||||
logout: Logout
|
||||
logout: Logout,
|
||||
relationsSubscriptionManager: RelationsSubscriptionManager
|
||||
): MainViewModelFactory = MainViewModelFactory(
|
||||
resumeAccount = resumeAccount,
|
||||
analytics = analytics,
|
||||
observeWallpaper = observeWallpaper,
|
||||
restoreWallpaper = restoreWallpaper,
|
||||
interceptAccountStatus = interceptAccountStatus,
|
||||
logout = logout
|
||||
logout = logout,
|
||||
relationsSubscriptionManager = relationsSubscriptionManager
|
||||
)
|
||||
|
||||
@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.domain.`object`.UpdateDetail
|
||||
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.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.relations.AddToFeaturedRelations
|
||||
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.presentation.editor.Editor
|
||||
import com.anytypeio.anytype.presentation.editor.editor.DetailModificationManager
|
||||
|
@ -47,7 +48,8 @@ object DocumentRelationModule {
|
|||
addToFeaturedRelations: AddToFeaturedRelations,
|
||||
removeFromFeaturedRelations: RemoveFromFeaturedRelations,
|
||||
deleteRelationFromObject: DeleteRelationFromObject,
|
||||
analytics: Analytics
|
||||
analytics: Analytics,
|
||||
storeOfRelations: StoreOfRelations
|
||||
): ObjectRelationListViewModelFactory {
|
||||
return ObjectRelationListViewModelFactory(
|
||||
stores = stores,
|
||||
|
@ -59,7 +61,8 @@ object DocumentRelationModule {
|
|||
addToFeaturedRelations = addToFeaturedRelations,
|
||||
removeFromFeaturedRelations = removeFromFeaturedRelations,
|
||||
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.core_models.Payload
|
||||
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.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewRelationOption
|
||||
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.presentation.relations.providers.ObjectDetailProvider
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
||||
|
@ -24,12 +22,12 @@ import dagger.Module
|
|||
import dagger.Provides
|
||||
import dagger.Subcomponent
|
||||
|
||||
@Subcomponent(modules = [ObjectRelationValueModule::class, ObjectSetObjectRelationValueModule::class])
|
||||
@Subcomponent(modules = [ObjectSetObjectRelationValueModule::class])
|
||||
@PerModal
|
||||
interface ObjectSetObjectRelationValueSubComponent {
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
fun module(module: ObjectRelationValueModule): Builder
|
||||
fun module(module: ObjectSetObjectRelationValueModule): Builder
|
||||
fun build(): ObjectSetObjectRelationValueSubComponent
|
||||
}
|
||||
|
||||
|
@ -40,12 +38,12 @@ interface ObjectSetObjectRelationValueSubComponent {
|
|||
fun addRelationFileValueAddComponent() : AddFileRelationSubComponent.Builder
|
||||
}
|
||||
|
||||
@Subcomponent(modules = [ObjectRelationValueModule::class, ObjectObjectRelationValueModule::class])
|
||||
@Subcomponent(modules = [ObjectObjectRelationValueModule::class])
|
||||
@PerModal
|
||||
interface ObjectObjectRelationValueSubComponent {
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
fun module(module: ObjectRelationValueModule): Builder
|
||||
fun module(module: ObjectObjectRelationValueModule): Builder
|
||||
fun build(): ObjectObjectRelationValueSubComponent
|
||||
}
|
||||
|
||||
|
@ -56,17 +54,6 @@ interface ObjectObjectRelationValueSubComponent {
|
|||
fun addRelationFileValueAddComponent() : AddFileRelationSubComponent.Builder
|
||||
}
|
||||
|
||||
@Module
|
||||
object ObjectRelationValueModule {
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerModal
|
||||
fun provideAddRelationOptionUseCase(
|
||||
repo: BlockRepository
|
||||
): AddDataViewRelationOption = AddDataViewRelationOption(repo = repo)
|
||||
}
|
||||
|
||||
@Module
|
||||
object ObjectSetObjectRelationValueModule {
|
||||
|
||||
|
@ -84,7 +71,7 @@ object ObjectSetObjectRelationValueModule {
|
|||
relations: ObjectRelationProvider,
|
||||
values: ObjectValueProvider,
|
||||
details: ObjectDetailProvider,
|
||||
types: ObjectTypesProvider,
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
urlBuilder: UrlBuilder,
|
||||
setObjectDetails: UpdateDetail,
|
||||
addFileToObject: AddFileToObject,
|
||||
|
@ -95,7 +82,7 @@ object ObjectSetObjectRelationValueModule {
|
|||
relations = relations,
|
||||
values = values,
|
||||
details = details,
|
||||
types = types,
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
urlBuilder = urlBuilder,
|
||||
addFileToObject = addFileToObject,
|
||||
copyFileToCache = copyFileToCacheDirectory,
|
||||
|
@ -115,7 +102,7 @@ object ObjectObjectRelationValueModule {
|
|||
relations: ObjectRelationProvider,
|
||||
values: ObjectValueProvider,
|
||||
details: ObjectDetailProvider,
|
||||
types: ObjectTypesProvider,
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
urlBuilder: UrlBuilder,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
updateDetail: UpdateDetail,
|
||||
|
@ -126,7 +113,7 @@ object ObjectObjectRelationValueModule {
|
|||
relations = relations,
|
||||
values = values,
|
||||
details = details,
|
||||
types = types,
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
urlBuilder = urlBuilder,
|
||||
dispatcher = dispatcher,
|
||||
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.cover.SetDocCoverImage
|
||||
import com.anytypeio.anytype.domain.dataview.SetDataViewSource
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.AddNewRelationToDataView
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewRecord
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.CreateDataViewObject
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.event.interactor.EventChannel
|
||||
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.ObjectStore
|
||||
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.CreateNewObject
|
||||
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.ObjectSetDatabase
|
||||
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.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory
|
||||
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.DefaultUriFileProvider
|
||||
import com.anytypeio.anytype.ui.sets.ObjectSetFragment
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
|
@ -138,17 +135,16 @@ object ObjectSetModule {
|
|||
fun provideObjectSetViewModelFactory(
|
||||
openObjectSet: OpenObjectSet,
|
||||
closeBlock: CloseBlock,
|
||||
addDataViewRelation: AddNewRelationToDataView,
|
||||
updateDataViewViewer: UpdateDataViewViewer,
|
||||
setObjectDetails: UpdateDetail,
|
||||
updateText: UpdateText,
|
||||
interceptEvents: InterceptEvents,
|
||||
interceptThreadStatus: InterceptThreadStatus,
|
||||
createDataViewRecord: CreateDataViewRecord,
|
||||
createDataViewObject: CreateDataViewObject,
|
||||
createNewObject: CreateNewObject,
|
||||
reducer: ObjectSetReducer,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
delegator: Delegator<Action>,
|
||||
objectSetRecordCache: ObjectSetRecordCache,
|
||||
urlBuilder: UrlBuilder,
|
||||
coverImageHashProvider: CoverImageHashProvider,
|
||||
session: ObjectSetSession,
|
||||
|
@ -158,24 +154,22 @@ object ObjectSetModule {
|
|||
getTemplates: GetTemplates,
|
||||
dataViewSubscriptionContainer: DataViewSubscriptionContainer,
|
||||
cancelSearchSubscription: CancelSearchSubscription,
|
||||
createNewObject: CreateNewObject,
|
||||
setDataViewSource: SetDataViewSource,
|
||||
database: ObjectSetDatabase,
|
||||
paginator: ObjectSetPaginator
|
||||
paginator: ObjectSetPaginator,
|
||||
storeOfRelations: StoreOfRelations
|
||||
): ObjectSetViewModelFactory = ObjectSetViewModelFactory(
|
||||
openObjectSet = openObjectSet,
|
||||
closeBlock = closeBlock,
|
||||
addDataViewRelation = addDataViewRelation,
|
||||
updateDataViewViewer = updateDataViewViewer,
|
||||
setObjectDetails = setObjectDetails,
|
||||
createDataViewRecord = createDataViewRecord,
|
||||
createDataViewObject = createDataViewObject,
|
||||
updateText = updateText,
|
||||
interceptEvents = interceptEvents,
|
||||
interceptThreadStatus = interceptThreadStatus,
|
||||
reducer = reducer,
|
||||
dispatcher = dispatcher,
|
||||
delegator = delegator,
|
||||
objectSetRecordCache = objectSetRecordCache,
|
||||
coverImageHashProvider = coverImageHashProvider,
|
||||
urlBuilder = urlBuilder,
|
||||
session = session,
|
||||
|
@ -188,7 +182,8 @@ object ObjectSetModule {
|
|||
cancelSearchSubscription = cancelSearchSubscription,
|
||||
setDataViewSource = setDataViewSource,
|
||||
database = database,
|
||||
paginator = paginator
|
||||
paginator = paginator,
|
||||
storeOfRelations = storeOfRelations
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
@ -234,13 +229,6 @@ object ObjectSetModule {
|
|||
auth: AuthRepository
|
||||
): OpenObjectSet = OpenObjectSet(repo = repo, auth = auth)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideAddDataViewRelationUseCase(
|
||||
repo: BlockRepository
|
||||
): AddNewRelationToDataView = AddNewRelationToDataView(repo = repo)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
|
@ -253,7 +241,7 @@ object ObjectSetModule {
|
|||
@PerScreen
|
||||
fun provideCreateDataViewRecordUseCase(
|
||||
repo: BlockRepository
|
||||
): CreateDataViewRecord = CreateDataViewRecord(repo = repo)
|
||||
): CreateDataViewObject = CreateDataViewObject(repo = repo)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
@ -315,17 +303,16 @@ object ObjectSetModule {
|
|||
@PerScreen
|
||||
fun provideDelegator(): Delegator<Action> = Delegator.Default()
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideObjectSetRecordCache(): ObjectSetRecordCache = ObjectSetRecordCache()
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideDataViewObjectRelationProvider(
|
||||
state: StateFlow<ObjectSet>
|
||||
): ObjectRelationProvider = DataViewObjectRelationProvider(state)
|
||||
state: StateFlow<ObjectSet>,
|
||||
storeOfRelations: StoreOfRelations
|
||||
): ObjectRelationProvider = DataViewObjectRelationProvider(
|
||||
objectSetState = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package com.anytypeio.anytype.di.feature;
|
||||
|
||||
import com.anytypeio.anytype.domain.`object`.UpdateDetail
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetRecordCache
|
||||
import com.anytypeio.anytype.domain.objects.ObjectStore
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetRecordViewModel
|
||||
import com.anytypeio.anytype.ui.sets.modals.SetObjectSetRecordNameFragment
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.Subcomponent
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import javax.inject.Named
|
||||
import javax.inject.Scope
|
||||
|
||||
@Subcomponent(modules = [ObjectSetRecordModule::class])
|
||||
|
@ -25,20 +24,18 @@ interface ObjectSetRecordSubComponent {
|
|||
|
||||
@Module
|
||||
object ObjectSetRecordModule {
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@ObjectSetRecordScope
|
||||
fun provideObjectSetRecordViewModelFactory(
|
||||
setObjectDetails: UpdateDetail,
|
||||
objectSetState: StateFlow<ObjectSet>,
|
||||
objectSetRecordCache: ObjectSetRecordCache
|
||||
@Named("object-set-store") objectStore: ObjectStore
|
||||
): ObjectSetRecordViewModel.Factory = ObjectSetRecordViewModel.Factory(
|
||||
setObjectDetails = setObjectDetails,
|
||||
objectSetRecordCache = objectSetRecordCache
|
||||
objectStore = objectStore
|
||||
)
|
||||
}
|
||||
|
||||
@Scope
|
||||
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
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.dataview.interactor.ModifyDataViewViewerRelationOrder
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.domain.relations.DeleteRelationFromDataView
|
||||
import com.anytypeio.anytype.presentation.relations.ObjectSetSettingsViewModel
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||
|
@ -42,6 +43,7 @@ object ObjectSetSettingsModule {
|
|||
modifyViewerRelationOrder: ModifyDataViewViewerRelationOrder,
|
||||
updateDataViewViewer: UpdateDataViewViewer,
|
||||
deleteRelationFromDataView: DeleteRelationFromDataView,
|
||||
store: StoreOfRelations,
|
||||
analytics: Analytics
|
||||
): ObjectSetSettingsViewModel.Factory = ObjectSetSettingsViewModel.Factory(
|
||||
state = state,
|
||||
|
@ -50,7 +52,8 @@ object ObjectSetSettingsModule {
|
|||
modifyViewerRelationOrder = modifyViewerRelationOrder,
|
||||
updateDataViewViewer = updateDataViewViewer,
|
||||
deleteRelationFromDataView = deleteRelationFromDataView,
|
||||
analytics = analytics
|
||||
analytics = analytics,
|
||||
store = store,
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
|
|
@ -2,9 +2,14 @@ package com.anytypeio.anytype.di.feature
|
|||
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
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.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.Provides
|
||||
import dagger.Subcomponent
|
||||
|
@ -19,7 +24,11 @@ interface 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
|
||||
|
@ -29,17 +38,17 @@ object ObjectTypeChangeModule {
|
|||
@Provides
|
||||
@PerScreen
|
||||
fun provideObjectTypeViewModelFactory(
|
||||
getCompatibleObjectTypes: GetCompatibleObjectTypes
|
||||
storeOfObjectTypes: StoreOfObjectTypes
|
||||
): ObjectTypeChangeViewModelFactory {
|
||||
return ObjectTypeChangeViewModelFactory(
|
||||
getCompatibleObjectTypes = getCompatibleObjectTypes
|
||||
storeOfObjectTypes = storeOfObjectTypes
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideGetCompatibleObjectTypesUseCase(
|
||||
fun provideSearchObjectsUseCase(
|
||||
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.domain.block.repo.BlockRepository
|
||||
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.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.SelectSortRelationViewModel
|
||||
|
@ -37,12 +38,14 @@ object SelectSortRelationModule {
|
|||
session: ObjectSetSession,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
addDataViewViewerSort: AddDataViewViewerSort,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
analytics: Analytics
|
||||
): SelectSortRelationViewModel.Factory = SelectSortRelationViewModel.Factory(
|
||||
state = state,
|
||||
session = session,
|
||||
dispatcher = dispatcher,
|
||||
addDataViewViewerSort = addDataViewViewerSort,
|
||||
storeOfRelations = storeOfRelations,
|
||||
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.misc.AppActionManager
|
||||
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.ui.splash.SplashFragment
|
||||
import dagger.Module
|
||||
|
@ -48,23 +50,25 @@ object SplashModule {
|
|||
launchAccount: LaunchAccount,
|
||||
launchWallet: LaunchWallet,
|
||||
analytics: Analytics,
|
||||
storeObjectTypes: StoreObjectTypes,
|
||||
getLastOpenedObject: GetLastOpenedObject,
|
||||
getDefaultEditorType: GetDefaultEditorType,
|
||||
setDefaultEditorType: SetDefaultEditorType,
|
||||
createPage: CreatePage,
|
||||
appActionManager: AppActionManager
|
||||
appActionManager: AppActionManager,
|
||||
relationsSubscriptionManager: RelationsSubscriptionManager,
|
||||
objectTypesSubscriptionManager: ObjectTypesSubscriptionManager
|
||||
): SplashViewModelFactory = SplashViewModelFactory(
|
||||
checkAuthorizationStatus = checkAuthorizationStatus,
|
||||
launchAccount = launchAccount,
|
||||
launchWallet = launchWallet,
|
||||
analytics = analytics,
|
||||
storeObjectTypes = storeObjectTypes,
|
||||
getLastOpenedObject = getLastOpenedObject,
|
||||
setDefaultEditorType = setDefaultEditorType,
|
||||
getDefaultEditorType = getDefaultEditorType,
|
||||
createPage = createPage,
|
||||
appActionManager = appActionManager
|
||||
appActionManager = appActionManager,
|
||||
relationsSubscriptionManager = relationsSubscriptionManager,
|
||||
objectTypesSubscriptionManager = objectTypesSubscriptionManager
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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.ViewerSortByViewModel
|
||||
import com.anytypeio.anytype.ui.sets.ViewerSortByFragment
|
||||
|
@ -29,8 +30,12 @@ object ViewerSortByModule {
|
|||
@Provides
|
||||
@ViewerSortByScope
|
||||
fun provideViewerSortByViewModelFactory(
|
||||
state: StateFlow<ObjectSet>
|
||||
): ViewerSortByViewModel.Factory = ViewerSortByViewModel.Factory(state)
|
||||
state: StateFlow<ObjectSet>,
|
||||
storeOfRelations: StoreOfRelations
|
||||
): ViewerSortByViewModel.Factory = ViewerSortByViewModel.Factory(
|
||||
state = state,
|
||||
storeOfRelations = storeOfRelations
|
||||
)
|
||||
}
|
||||
|
||||
@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.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.config.ConfigStorage
|
||||
import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager
|
||||
import com.anytypeio.anytype.ext.DefaultDateHelper
|
||||
import com.anytypeio.anytype.presentation.auth.account.DeletedAccountViewModel
|
||||
import com.anytypeio.anytype.ui.auth.account.DeletedAccountFragment
|
||||
|
@ -35,12 +36,14 @@ object DeletedAccountModule {
|
|||
restoreAccount: RestoreAccount,
|
||||
logout: Logout,
|
||||
helper: DateHelper,
|
||||
analytics: Analytics
|
||||
analytics: Analytics,
|
||||
relationsSubscriptionManager: RelationsSubscriptionManager
|
||||
): DeletedAccountViewModel.Factory = DeletedAccountViewModel.Factory(
|
||||
restoreAccount = restoreAccount,
|
||||
logout = logout,
|
||||
helper = helper,
|
||||
analytics = analytics
|
||||
analytics = analytics,
|
||||
relationsSubscriptionManager = relationsSubscriptionManager
|
||||
)
|
||||
|
||||
@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.domain.block.repo.BlockRepository
|
||||
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.objects.StoreOfRelations
|
||||
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.RelationAddToObjectViewModel
|
||||
import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider
|
||||
|
@ -43,12 +44,12 @@ object RelationAddToObjectModule {
|
|||
@PerDialog
|
||||
fun provideViewModelFactory(
|
||||
addRelationToObject: AddRelationToObject,
|
||||
objectRelationList: ObjectRelationList,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
analytics: Analytics,
|
||||
relationsProvider: ObjectRelationProvider,
|
||||
): RelationAddToObjectViewModel.Factory = RelationAddToObjectViewModel.Factory(
|
||||
objectRelationList = objectRelationList,
|
||||
storeOfRelations = storeOfRelations,
|
||||
addRelationToObject = addRelationToObject,
|
||||
dispatcher = dispatcher,
|
||||
analytics = analytics,
|
||||
|
@ -61,13 +62,6 @@ object RelationAddToObjectModule {
|
|||
fun provideObjectRelationListUseCase(
|
||||
repo: BlockRepository
|
||||
): ObjectRelationList = ObjectRelationList(repo)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerDialog
|
||||
fun provideAddRelationToObjectUseCase(
|
||||
repo: BlockRepository
|
||||
): AddRelationToObject = AddRelationToObject(repo)
|
||||
}
|
||||
|
||||
@Subcomponent(modules = [RelationAddToDataViewModule::class])
|
||||
|
@ -90,7 +84,7 @@ object RelationAddToDataViewModule {
|
|||
@PerDialog
|
||||
fun provideViewModelFactory(
|
||||
addRelationToDataView: AddRelationToDataView,
|
||||
objectRelationList: ObjectRelationList,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
state: StateFlow<ObjectSet>,
|
||||
session: ObjectSetSession,
|
||||
|
@ -98,7 +92,7 @@ object RelationAddToDataViewModule {
|
|||
analytics: Analytics,
|
||||
relationsProvider: ObjectRelationProvider,
|
||||
): RelationAddToDataViewViewModel.Factory = RelationAddToDataViewViewModel.Factory(
|
||||
objectRelationList = objectRelationList,
|
||||
storeOfRelations = storeOfRelations,
|
||||
addRelationToDataView = addRelationToDataView,
|
||||
dispatcher = dispatcher,
|
||||
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.PerDialog
|
||||
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.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.RelationCreateFromScratchForObjectBlockViewModel
|
||||
import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForObjectViewModel
|
||||
|
@ -48,24 +50,29 @@ object RelationCreateFromScratchForObjectModule {
|
|||
@Provides
|
||||
@CreateFromScratch
|
||||
fun provideViewModelFactory(
|
||||
addNewRelationToObject: AddNewRelationToObject,
|
||||
addRelationToObject: AddRelationToObject,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
analytics: Analytics,
|
||||
createFromScratchState: StateHolder<CreateFromScratchState>
|
||||
): RelationCreateFromScratchForObjectViewModel.Factory =
|
||||
RelationCreateFromScratchForObjectViewModel.Factory(
|
||||
addNewRelationToObject = addNewRelationToObject,
|
||||
createFromScratchState: StateHolder<CreateFromScratchState>,
|
||||
createRelation: CreateRelation
|
||||
) = RelationCreateFromScratchForObjectViewModel.Factory(
|
||||
addRelationToObject = addRelationToObject,
|
||||
createRelation = createRelation,
|
||||
dispatcher = dispatcher,
|
||||
analytics = analytics,
|
||||
createFromScratchState = createFromScratchState
|
||||
)
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@CreateFromScratch
|
||||
fun provideAddNewRelationToObjectUseCase(
|
||||
repo: BlockRepository
|
||||
): AddNewRelationToObject = AddNewRelationToObject(repo)
|
||||
fun createRelation(
|
||||
repo: BlockRepository,
|
||||
storeOfRelations: StoreOfRelations
|
||||
) = CreateRelation(
|
||||
repo = repo,
|
||||
storeOfRelations = storeOfRelations
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
@ -95,6 +102,7 @@ interface RelationCreateFromScratchForDataViewSubComponent {
|
|||
|
||||
@Module
|
||||
object RelationCreateFromScratchForDataViewModule {
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@CreateFromScratch
|
||||
|
@ -102,20 +110,21 @@ object RelationCreateFromScratchForDataViewModule {
|
|||
state: StateFlow<ObjectSet>,
|
||||
session: ObjectSetSession,
|
||||
updateDataViewViewer: UpdateDataViewViewer,
|
||||
addNewRelationToDataView: AddNewRelationToDataView,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
analytics: Analytics,
|
||||
createFromScratchState: StateHolder<CreateFromScratchState>
|
||||
): RelationCreateFromScratchForDataViewViewModel.Factory =
|
||||
RelationCreateFromScratchForDataViewViewModel.Factory(
|
||||
addNewRelationToDataView = addNewRelationToDataView,
|
||||
createFromScratchState: StateHolder<CreateFromScratchState>,
|
||||
createRelation: CreateRelation,
|
||||
addRelationToDataView: AddRelationToDataView
|
||||
) = RelationCreateFromScratchForDataViewViewModel.Factory(
|
||||
addRelationToDataView = addRelationToDataView,
|
||||
dispatcher = dispatcher,
|
||||
state = state,
|
||||
session = session,
|
||||
updateDataViewViewer = updateDataViewViewer,
|
||||
analytics = analytics,
|
||||
createFromScratchState = createFromScratchState
|
||||
)
|
||||
createFromScratchState = createFromScratchState,
|
||||
createRelation = createRelation
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
@ -126,6 +135,22 @@ object RelationCreateFromScratchForDataViewModule {
|
|||
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])
|
||||
|
@ -145,28 +170,23 @@ interface RelationCreateFromScratchForObjectBlockSubComponent {
|
|||
|
||||
@Module
|
||||
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
|
||||
@Provides
|
||||
@CreateFromScratch
|
||||
fun provideAddNewRelationToObjectUseCase(
|
||||
repo: BlockRepository
|
||||
): AddNewRelationToObject = AddNewRelationToObject(repo)
|
||||
fun provideViewModelFactory(
|
||||
addRelationToObject: AddRelationToObject,
|
||||
createRelation: CreateRelation,
|
||||
dispatcher: Dispatcher<Payload>,
|
||||
analytics: Analytics,
|
||||
createFromScratchState: StateHolder<CreateFromScratchState>
|
||||
) = RelationCreateFromScratchForObjectBlockViewModel.Factory(
|
||||
addRelationToObject = addRelationToObject,
|
||||
createRelation = createRelation,
|
||||
dispatcher = dispatcher,
|
||||
analytics = analytics,
|
||||
createFromScratchState = createFromScratchState
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
@ -177,6 +197,17 @@ object RelationCreateFromScratchForObjectBlockModule {
|
|||
limitObjectTypes = emptyList()
|
||||
)
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@CreateFromScratch
|
||||
fun createRelation(
|
||||
repo: BlockRepository,
|
||||
storeOfRelations: StoreOfRelations
|
||||
) = CreateRelation(
|
||||
repo = repo,
|
||||
storeOfRelations = storeOfRelations
|
||||
)
|
||||
}
|
||||
|
||||
@Subcomponent
|
||||
|
|
|
@ -3,11 +3,13 @@ package com.anytypeio.anytype.di.feature.sets;
|
|||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
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.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -45,7 +47,9 @@ object CreateFilterModule {
|
|||
updateDataViewViewer: UpdateDataViewViewer,
|
||||
searchObjects: SearchObjects,
|
||||
urlBuilder: UrlBuilder,
|
||||
objectTypesProvider: ObjectTypesProvider,
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
storeOfRelations: StoreOfRelations,
|
||||
objectSetDatabase: ObjectSetDatabase,
|
||||
analytics: Analytics
|
||||
): FilterViewModel.Factory = FilterViewModel.Factory(
|
||||
objectSetState = state,
|
||||
|
@ -54,7 +58,9 @@ object CreateFilterModule {
|
|||
updateDataViewViewer = updateDataViewViewer,
|
||||
searchObjects = searchObjects,
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypesProvider = objectTypesProvider,
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
storeOfRelations = storeOfRelations,
|
||||
objectSetDatabase = objectSetDatabase,
|
||||
analytics = analytics
|
||||
)
|
||||
}
|
||||
|
|
|
@ -3,11 +3,13 @@ package com.anytypeio.anytype.di.feature.sets;
|
|||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||
import com.anytypeio.anytype.domain.`object`.ObjectTypesProvider
|
||||
import com.anytypeio.anytype.domain.search.SearchObjects
|
||||
import com.anytypeio.anytype.domain.dataview.interactor.UpdateDataViewViewer
|
||||
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.ObjectSetDatabase
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel
|
||||
import com.anytypeio.anytype.presentation.util.Dispatcher
|
||||
|
@ -45,8 +47,10 @@ object ModifyFilterModule {
|
|||
updateDataViewViewer: UpdateDataViewViewer,
|
||||
searchObjects: SearchObjects,
|
||||
urlBuilder: UrlBuilder,
|
||||
objectTypesProvider: ObjectTypesProvider,
|
||||
analytics: Analytics
|
||||
storeOfObjectTypes: StoreOfObjectTypes,
|
||||
analytics: Analytics,
|
||||
objectSetDatabase: ObjectSetDatabase,
|
||||
storeOfRelations: StoreOfRelations
|
||||
): FilterViewModel.Factory = FilterViewModel.Factory(
|
||||
objectSetState = state,
|
||||
session = session,
|
||||
|
@ -54,7 +58,9 @@ object ModifyFilterModule {
|
|||
updateDataViewViewer = updateDataViewViewer,
|
||||
searchObjects = searchObjects,
|
||||
urlBuilder = urlBuilder,
|
||||
objectTypesProvider = objectTypesProvider,
|
||||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
objectSetDatabase = objectSetDatabase,
|
||||
storeOfRelations = storeOfRelations,
|
||||
analytics = analytics
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.anytypeio.anytype.di.feature.sets
|
||||
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerModal
|
||||
import com.anytypeio.anytype.domain.objects.StoreOfRelations
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSet
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetSession
|
||||
import com.anytypeio.anytype.presentation.sets.SelectFilterRelationViewModel
|
||||
|
@ -29,9 +30,11 @@ object SelectFilterRelationModule {
|
|||
@PerModal
|
||||
fun provideSelectSortRelationViewModelFactory(
|
||||
state: StateFlow<ObjectSet>,
|
||||
session: ObjectSetSession
|
||||
session: ObjectSetSession,
|
||||
storeOfRelations: StoreOfRelations
|
||||
): SelectFilterRelationViewModel.Factory = SelectFilterRelationViewModel.Factory(
|
||||
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.repo.AuthRepository
|
||||
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.account.LogoutWarningViewModel
|
||||
import dagger.Module
|
||||
|
@ -32,8 +33,13 @@ object LogoutWarningModule {
|
|||
@PerScreen
|
||||
fun provideViewModelFactory(
|
||||
logout: Logout,
|
||||
analytics: Analytics
|
||||
): LogoutWarningViewModel.Factory = LogoutWarningViewModel.Factory(logout, analytics)
|
||||
analytics: Analytics,
|
||||
relationsSubscriptionManager: RelationsSubscriptionManager
|
||||
): LogoutWarningViewModel.Factory = LogoutWarningViewModel.Factory(
|
||||
logout = logout,
|
||||
analytics = analytics,
|
||||
relationsSubscriptionManager = relationsSubscriptionManager
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@PerScreen
|
||||
|
|
|
@ -3,7 +3,23 @@ package com.anytypeio.anytype.di.main
|
|||
import com.anytypeio.anytype.app.AndroidApplication
|
||||
import com.anytypeio.anytype.di.common.ComponentDependencies
|
||||
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.settings.AboutAppSubComponent
|
||||
import com.anytypeio.anytype.di.feature.settings.AccountAndDataSubComponent
|
||||
|
@ -32,7 +48,8 @@ import javax.inject.Singleton
|
|||
EmojiModule::class,
|
||||
ClipboardModule::class,
|
||||
AnalyticsModule::class,
|
||||
LocalNetworkAddressModule::class
|
||||
LocalNetworkAddressModule::class,
|
||||
SubscriptionsModule::class
|
||||
]
|
||||
)
|
||||
interface MainComponent : AppearanceDependencies {
|
||||
|
@ -48,8 +65,6 @@ interface MainComponent : AppearanceDependencies {
|
|||
fun moveToBuilder(): MoveToSubComponent.Builder
|
||||
fun objectSearchComponentBuilder(): ObjectSearchSubComponent.Builder
|
||||
fun mainEntryComponentBuilder(): MainEntrySubComponent.Builder
|
||||
fun createSetComponentBuilder(): CreateSetSubComponent.Builder
|
||||
fun createObjectTypeComponentBuilder(): CreateObjectTypeSubComponent.Builder
|
||||
fun objectSetComponentBuilder(): ObjectSetSubComponent.Builder
|
||||
fun objectTypeChangeComponent(): ObjectTypeChangeSubComponent.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.editor.EditorFragment
|
||||
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.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() {
|
||||
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.ExitToDesktopAndOpenPage -> navigation.exitToDesktopAndOpenPage(command.pageId)
|
||||
is Command.OpenPageSearch -> navigation.openPageSearch()
|
||||
is Command.OpenCreateSetScreen -> navigation.openCreateSetScreen(command.ctx)
|
||||
is Command.OpenUpdateAppScreen -> navigation.openUpdateAppScreen()
|
||||
is Command.DeletedAccountScreen -> navigation.deletedAccountScreen(command.deadline)
|
||||
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.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.fragment.app.setFragmentResultListener
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
|
@ -48,6 +47,7 @@ import androidx.viewbinding.ViewBinding
|
|||
import com.anytypeio.anytype.BuildConfig
|
||||
import com.anytypeio.anytype.R
|
||||
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.ThemeColor
|
||||
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.moving.MoveToFragment
|
||||
import com.anytypeio.anytype.ui.moving.OnMoveToAction
|
||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment
|
||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment.Companion.OBJECT_IS_DRAFT_KEY
|
||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment.Companion.OBJECT_TYPE_REQUEST_KEY
|
||||
import com.anytypeio.anytype.ui.objects.ObjectTypeChangeFragment.Companion.OBJECT_TYPE_URL_KEY
|
||||
import com.anytypeio.anytype.ui.objects.types.pickers.DraftObjectSelectTypeFragment
|
||||
import com.anytypeio.anytype.ui.objects.types.pickers.ObjectSelectTypeFragment
|
||||
import com.anytypeio.anytype.ui.objects.types.pickers.OnObjectSelectTypeAction
|
||||
import com.anytypeio.anytype.ui.objects.appearance.ObjectAppearanceSettingFragment
|
||||
import com.anytypeio.anytype.ui.relations.RelationAddBaseFragment.Companion.CTX_KEY
|
||||
import com.anytypeio.anytype.ui.relations.RelationAddResult
|
||||
|
@ -172,7 +171,8 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
DocumentMenuActionReceiver,
|
||||
ClipboardInterceptor,
|
||||
OnMoveToAction,
|
||||
OnLinkToAction {
|
||||
OnLinkToAction,
|
||||
OnObjectSelectTypeAction {
|
||||
|
||||
private val keyboardDelayJobs = mutableListOf<Job>()
|
||||
|
||||
|
@ -413,15 +413,6 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
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()
|
||||
getEditorSettings()
|
||||
}
|
||||
|
@ -886,10 +877,6 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
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>) {
|
||||
event.getContentIfNotHandled()?.let { command ->
|
||||
when (command) {
|
||||
|
@ -1031,7 +1018,8 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
val fr = RelationValueFragment.new(
|
||||
ctx = command.ctx,
|
||||
target = command.target,
|
||||
relation = command.relation,
|
||||
relationId = command.relationId,
|
||||
relationKey = command.relationKey,
|
||||
targetObjectTypes = command.targetObjectTypes,
|
||||
isLocked = command.isLocked
|
||||
)
|
||||
|
@ -1041,8 +1029,9 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
hideKeyboard()
|
||||
val fr = RelationTextValueFragment.new(
|
||||
ctx = command.ctx,
|
||||
relationId = command.relationId,
|
||||
relationKey = command.relationKey,
|
||||
objectId = command.target,
|
||||
relationId = command.relation,
|
||||
isLocked = command.isLocked
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
|
@ -1052,25 +1041,27 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
val fr = RelationDateValueFragment.new(
|
||||
ctx = command.ctx,
|
||||
objectId = command.target,
|
||||
relationId = command.relation
|
||||
relationId = command.relationId,
|
||||
relationKey = command.relationKey
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
Command.AddSlashWidgetTriggerToFocusedBlock -> {
|
||||
binding.recycler.addTextFromSelectedStart(text = "/")
|
||||
}
|
||||
is Command.OpenChangeObjectTypeScreen -> {
|
||||
is Command.OpenDraftObjectSelectTypeScreen -> {
|
||||
hideKeyboard()
|
||||
findNavController()
|
||||
.safeNavigate(
|
||||
R.id.pageScreen,
|
||||
R.id.objectTypeChangeScreen,
|
||||
bundleOf(
|
||||
ObjectTypeChangeFragment.ARG_SMART_BLOCK_TYPE to command.smartBlockType,
|
||||
ObjectTypeChangeFragment.ARG_EXCLUDED_TYPES to command.excludedTypes,
|
||||
ObjectTypeChangeFragment.OBJECT_IS_DRAFT_KEY to command.isDraft
|
||||
)
|
||||
)
|
||||
val fr = DraftObjectSelectTypeFragment.newInstance(
|
||||
excludeTypes = command.excludedTypes
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
is Command.OpenObjectSelectTypeScreen -> {
|
||||
hideKeyboard()
|
||||
val fr = ObjectSelectTypeFragment.newInstance(
|
||||
excludeTypes = command.excludedTypes
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
is Command.OpenMoveToScreen -> {
|
||||
jobs += lifecycleScope.launch {
|
||||
|
@ -1999,19 +1990,19 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
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(
|
||||
ctx = ctx,
|
||||
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(
|
||||
ctx = ctx,
|
||||
value = number,
|
||||
relationId = relationId
|
||||
relationKey = relationKey
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2019,11 +2010,11 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
ctx: Id,
|
||||
timeInSeconds: Number?,
|
||||
objectId: Id,
|
||||
relationId: Id
|
||||
relationKey: Key
|
||||
) {
|
||||
vm.onRelationTextValueChanged(
|
||||
ctx = ctx,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
value = timeInSeconds
|
||||
)
|
||||
}
|
||||
|
@ -2090,6 +2081,14 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
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() {
|
||||
findNavController().run {
|
||||
val navBackStackEntry = getBackStackEntry(R.id.pageScreen)
|
||||
|
@ -2115,7 +2114,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
if (resultRelationAdd != null) {
|
||||
vm.proceedWithAddingRelationToTarget(
|
||||
target = resultRelationAdd.target,
|
||||
relation = resultRelationAdd.relation
|
||||
relationKey = resultRelationAdd.relation
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -2125,7 +2124,7 @@ open class EditorFragment : NavigationFragment<FragmentEditorBinding>(R.layout.f
|
|||
if (resultRelationNew != null) {
|
||||
vm.proceedWithAddingRelationToTarget(
|
||||
target = resultRelationNew.target,
|
||||
relation = resultRelationNew.relation
|
||||
relationKey = resultRelationNew.relation
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,46 +5,36 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.anytypeio.anytype.R
|
||||
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.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.hideKeyboard
|
||||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetTextInputFragment
|
||||
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.ObjectTypeChangeViewModelFactory
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectTypeView
|
||||
import javax.inject.Inject
|
||||
|
||||
class ObjectTypeChangeFragment :
|
||||
abstract class BaseObjectTypeChangeFragment :
|
||||
BaseBottomSheetTextInputFragment<FragmentObjectTypeChangeBinding>() {
|
||||
|
||||
private val smartBlockType: SmartBlockType get() = arg(ARG_SMART_BLOCK_TYPE)
|
||||
private val excludedTypes: List<Id>
|
||||
get() = argOrNull<List<Id>>(ARG_EXCLUDED_TYPES) ?: emptyList()
|
||||
|
||||
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()
|
||||
abstract fun setTitle()
|
||||
abstract fun startWithParams()
|
||||
abstract fun onItemClicked(id: Id, name: String)
|
||||
|
||||
@Inject
|
||||
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 {
|
||||
ObjectTypeVerticalAdapter(
|
||||
|
@ -57,31 +47,19 @@ class ObjectTypeChangeFragment :
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
if (isSetSource) {
|
||||
binding.tvTitle.text = getString(R.string.select_source)
|
||||
}
|
||||
setTitle()
|
||||
binding.recycler.apply {
|
||||
adapter = objectTypeAdapter
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeViews(views: List<ObjectTypeView.Item>) {
|
||||
private fun observeViews(views: List<ObjectTypeView>) {
|
||||
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() {
|
||||
super.onStart()
|
||||
expand()
|
||||
with(lifecycleScope) {
|
||||
jobs += subscribe(vm.results) { observeViews(it) }
|
||||
|
@ -89,22 +67,7 @@ class ObjectTypeChangeFragment :
|
|||
vm.onQueryChanged(it.toString())
|
||||
}
|
||||
}
|
||||
super.onStart()
|
||||
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()
|
||||
startWithParams()
|
||||
}
|
||||
|
||||
override fun inflateBinding(
|
||||
|
@ -115,13 +78,9 @@ class ObjectTypeChangeFragment :
|
|||
)
|
||||
|
||||
companion object {
|
||||
const val ARG_SMART_BLOCK_TYPE = "arg.object-type.smart-block-type"
|
||||
const val ARG_EXCLUDED_TYPES = "arg.object-type.excluded-types"
|
||||
const val ARG_IS_SET_SOURCE = "arg.object-type.is-set-source"
|
||||
const val ARG_SOURCES = "arg.object-type.sources"
|
||||
const val ARG_EXCLUDE_TYPES = "arg.object-type-change.exclude-types"
|
||||
const val ARG_SELECTED_TYPES = "arg.object-type-change.selected-types"
|
||||
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_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.reactive.focusChanges
|
||||
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.databinding.FragmentRelationAddBinding
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
|
@ -104,7 +110,7 @@ abstract class RelationAddBaseFragment : BaseBottomSheetTextInputFragment<Fragme
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
vm.onStart(ctx)
|
||||
vm.onStart()
|
||||
}
|
||||
|
||||
abstract fun onRelationSelected(ctx: Id, relation: RelationView.Existing)
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.core.os.bundleOf
|
|||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
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.ui.BaseBottomSheetFragment
|
||||
import com.anytypeio.anytype.databinding.FragmentRelationDateValueBinding
|
||||
|
@ -28,6 +29,7 @@ open class RelationDateValueFragment : BaseBottomSheetFragment<FragmentRelationD
|
|||
private val ctx get() = argString(CONTEXT_ID)
|
||||
private val objectId get() = argString(OBJECT_ID)
|
||||
private val relationId get() = argString(RELATION_ID)
|
||||
private val relationKey get() = argString(RELATION_KEY)
|
||||
private val flow get() = arg<Int>(FLOW_KEY)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -105,7 +107,7 @@ open class RelationDateValueFragment : BaseBottomSheetFragment<FragmentRelationD
|
|||
onDateValueChanged(
|
||||
ctx = ctx,
|
||||
objectId = objectId,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
timeInSeconds = timeInSeconds
|
||||
)
|
||||
}
|
||||
|
@ -148,12 +150,14 @@ open class RelationDateValueFragment : BaseBottomSheetFragment<FragmentRelationD
|
|||
fun new(
|
||||
ctx: Id,
|
||||
relationId: Id,
|
||||
relationKey: Key,
|
||||
objectId: Id,
|
||||
flow: Int = FLOW_DEFAULT
|
||||
) = RelationDateValueFragment().apply {
|
||||
arguments = bundleOf(
|
||||
CONTEXT_ID to ctx,
|
||||
RELATION_ID to relationId,
|
||||
RELATION_KEY to relationKey,
|
||||
OBJECT_ID to objectId,
|
||||
FLOW_KEY to flow
|
||||
)
|
||||
|
@ -161,6 +165,7 @@ open class RelationDateValueFragment : BaseBottomSheetFragment<FragmentRelationD
|
|||
|
||||
const val CONTEXT_ID = "arg.relation.date.context"
|
||||
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 FLOW_KEY = "arg.relation.date.flow"
|
||||
|
@ -173,7 +178,7 @@ open class RelationDateValueFragment : BaseBottomSheetFragment<FragmentRelationD
|
|||
ctx: Id,
|
||||
timeInSeconds: Number?,
|
||||
objectId: Id,
|
||||
relationId: Id
|
||||
relationKey: Key
|
||||
)
|
||||
}
|
||||
}
|
|
@ -8,11 +8,11 @@ import android.widget.EditText
|
|||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.anytypeio.anytype.R
|
||||
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.reactive.textChanges
|
||||
import com.anytypeio.anytype.core_utils.ext.*
|
||||
|
@ -98,55 +98,14 @@ open class RelationListFragment : BaseBottomSheetFragment<FragmentRelationListBi
|
|||
}
|
||||
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) {
|
||||
when (command) {
|
||||
is Command.EditTextRelationValue -> {
|
||||
val fr = RelationTextValueFragment.new(
|
||||
ctx = ctx,
|
||||
relationId = command.relation,
|
||||
relationId = command.relationId,
|
||||
relationKey = command.relationKey,
|
||||
objectId = command.target,
|
||||
isLocked = command.isLocked
|
||||
)
|
||||
|
@ -155,22 +114,22 @@ open class RelationListFragment : BaseBottomSheetFragment<FragmentRelationListBi
|
|||
is Command.EditDateRelationValue -> {
|
||||
val fr = RelationDateValueFragment.new(
|
||||
ctx = ctx,
|
||||
relationId = command.relation,
|
||||
relationId = command.relationId,
|
||||
relationKey = command.relationKey,
|
||||
objectId = command.target
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
is Command.EditRelationValue -> {
|
||||
findNavController().navigate(
|
||||
R.id.objectRelationValueScreen,
|
||||
bundleOf(
|
||||
RelationValueBaseFragment.CTX_KEY to command.ctx,
|
||||
RelationValueBaseFragment.TARGET_KEY to command.target,
|
||||
RelationValueBaseFragment.RELATION_KEY to command.relation,
|
||||
RelationValueBaseFragment.TARGET_TYPES_KEY to command.targetObjectTypes,
|
||||
RelationValueBaseFragment.IS_LOCKED_KEY to command.isLocked
|
||||
)
|
||||
val fr = RelationValueFragment.new(
|
||||
ctx = ctx,
|
||||
target = command.target,
|
||||
relationId = command.relationId,
|
||||
relationKey = command.relationKey,
|
||||
targetObjectTypes = command.targetObjectTypes,
|
||||
isLocked = command.isLocked
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
is Command.SetRelationKey -> {
|
||||
withParent<OnFragmentInteractionListener> {
|
||||
|
@ -185,6 +144,42 @@ open class RelationListFragment : BaseBottomSheetFragment<FragmentRelationListBi
|
|||
}
|
||||
|
||||
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()
|
||||
if (mode == MODE_LIST) {
|
||||
vm.onStartListMode(ctx)
|
||||
|
@ -198,19 +193,19 @@ open class RelationListFragment : BaseBottomSheetFragment<FragmentRelationListBi
|
|||
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(
|
||||
ctx = ctx,
|
||||
value = text,
|
||||
relationId = relationId
|
||||
relationKey = relationKey,
|
||||
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(
|
||||
ctx = ctx,
|
||||
value = number,
|
||||
relationId = relationId
|
||||
relationKey = relationKey,
|
||||
value = number
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -218,11 +213,11 @@ open class RelationListFragment : BaseBottomSheetFragment<FragmentRelationListBi
|
|||
ctx: Id,
|
||||
timeInSeconds: Number?,
|
||||
objectId: Id,
|
||||
relationId: Id
|
||||
relationKey: Key
|
||||
) {
|
||||
vm.onRelationTextValueChanged(
|
||||
ctx = ctx,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
value = timeInSeconds
|
||||
)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.os.bundleOf
|
||||
|
@ -15,6 +14,7 @@ import androidx.recyclerview.widget.DividerItemDecoration
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.anytypeio.anytype.R
|
||||
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.RelationTextValueAdapter
|
||||
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 relationId get() = arg<String>(RELATION_ID)
|
||||
private val relationKey get() = arg<Key>(RELATION_KEY)
|
||||
private val objectId get() = arg<String>(OBJECT_ID)
|
||||
private val flow get() = arg<Int>(FLOW_KEY)
|
||||
private val isLocked get() = arg<Boolean>(LOCKED_KEY)
|
||||
|
@ -82,7 +83,7 @@ open class RelationTextValueFragment :
|
|||
withParent<TextValueEditReceiver> {
|
||||
onTextValueChanged(
|
||||
ctx = ctx,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
objectId = objectId,
|
||||
text = parsed
|
||||
)
|
||||
|
@ -122,7 +123,7 @@ open class RelationTextValueFragment :
|
|||
|
||||
override fun onStart() {
|
||||
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.title) { binding.tvRelationHeader.text = it }
|
||||
jobs += lifecycleScope.subscribe(vm.isDismissed) { isDismissed ->
|
||||
|
@ -138,6 +139,7 @@ open class RelationTextValueFragment :
|
|||
} else {
|
||||
vm.onStart(
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
recordId = objectId,
|
||||
isLocked = isLocked,
|
||||
)
|
||||
|
@ -154,7 +156,7 @@ open class RelationTextValueFragment :
|
|||
withParent<TextValueEditReceiver> {
|
||||
onTextValueChanged(
|
||||
ctx = ctx,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
objectId = objectId,
|
||||
text = txt
|
||||
)
|
||||
|
@ -167,7 +169,7 @@ open class RelationTextValueFragment :
|
|||
withParent<TextValueEditReceiver> {
|
||||
onNumberValueChanged(
|
||||
ctx = ctx,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
objectId = objectId,
|
||||
number = number
|
||||
)
|
||||
|
@ -221,6 +223,7 @@ open class RelationTextValueFragment :
|
|||
fun new(
|
||||
ctx: Id,
|
||||
relationId: Id,
|
||||
relationKey: Key,
|
||||
objectId: Id,
|
||||
flow: Int = FLOW_DEFAULT,
|
||||
isLocked: Boolean = false,
|
||||
|
@ -228,6 +231,7 @@ open class RelationTextValueFragment :
|
|||
arguments = bundleOf(
|
||||
CONTEXT_ID to ctx,
|
||||
RELATION_ID to relationId,
|
||||
RELATION_KEY to relationKey,
|
||||
OBJECT_ID to objectId,
|
||||
FLOW_KEY to flow,
|
||||
LOCKED_KEY to isLocked
|
||||
|
@ -238,7 +242,7 @@ open class RelationTextValueFragment :
|
|||
ctx: Id,
|
||||
name: String = "",
|
||||
value: Long? = null
|
||||
) = new(ctx, "", "", FLOW_CHANGE_DATE)
|
||||
) = new(ctx, "", "", "", FLOW_CHANGE_DATE)
|
||||
.apply {
|
||||
arguments?.apply {
|
||||
putString(KEY_NAME, name)
|
||||
|
@ -248,6 +252,7 @@ open class RelationTextValueFragment :
|
|||
|
||||
const val CONTEXT_ID = "arg.edit-relation-value.context"
|
||||
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 FLOW_KEY = "arg.edit-relation-value.flow"
|
||||
const val LOCKED_KEY = "arg.edit-relation-value.locked"
|
||||
|
@ -264,14 +269,14 @@ open class RelationTextValueFragment :
|
|||
ctx: Id,
|
||||
text: String,
|
||||
objectId: Id,
|
||||
relationId: Id
|
||||
relationKey: Key
|
||||
)
|
||||
|
||||
fun onNumberValueChanged(
|
||||
ctx: Id,
|
||||
number: Double?,
|
||||
objectId: Id,
|
||||
relationId: Id
|
||||
relationKey: Key
|
||||
)
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.anytypeio.anytype.BuildConfig
|
||||
import com.anytypeio.anytype.R
|
||||
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.reactive.clicks
|
||||
import com.anytypeio.anytype.core_ui.tools.DefaultDragAndDropBehavior
|
||||
|
@ -73,12 +74,13 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
|||
PickiTCallbacks {
|
||||
|
||||
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 dataview get() = argString(DATAVIEW_KEY)
|
||||
protected val viewer get() = argString(VIEWER_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
|
||||
|
||||
|
@ -92,7 +94,7 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
|||
onItemDropped = {
|
||||
vm.onObjectValueOrderChanged(
|
||||
target = target,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
order = relationValueAdapter.order()
|
||||
)
|
||||
}
|
||||
|
@ -118,14 +120,14 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
|||
onRemoveStatusClicked = { status ->
|
||||
vm.onRemoveStatusFromObjectClicked(
|
||||
target = target,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
status = status.id
|
||||
)
|
||||
},
|
||||
onRemoveTagClicked = { tag ->
|
||||
vm.onRemoveTagFromObjectClicked(
|
||||
target = target,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
tag = tag.id
|
||||
)
|
||||
},
|
||||
|
@ -146,7 +148,7 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
|||
onRemoveObjectClicked = { obj ->
|
||||
vm.onRemoveObjectFromObjectClicked(
|
||||
target = target,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
objectId = obj
|
||||
)
|
||||
},
|
||||
|
@ -154,7 +156,7 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
|||
onRemoveFileClicked = { file ->
|
||||
vm.onRemoveFileFromObjectClicked(
|
||||
target = target,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
fileId = file
|
||||
)
|
||||
}
|
||||
|
@ -190,7 +192,10 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
|||
jobs += lifecycleScope.subscribe(vm.isLoading) { isLoading -> observeLoading(isLoading) }
|
||||
jobs += lifecycleScope.subscribe(vm.copyFileStatus) { command -> onCopyFileCommand(command) }
|
||||
super.onStart()
|
||||
vm.onStart(relationId = relation, objectId = target)
|
||||
vm.onStart(
|
||||
relationKey = relationKey,
|
||||
objectId = target
|
||||
)
|
||||
}
|
||||
|
||||
private fun observeLoading(isLoading: Boolean) {
|
||||
|
@ -451,7 +456,8 @@ abstract class RelationValueBaseFragment : BaseBottomSheetFragment<FragmentRelat
|
|||
companion object {
|
||||
const val CTX_KEY = "arg.edit-cell-tag.ctx"
|
||||
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 DATAVIEW_KEY = "arg.edit-cell-tag.dataview"
|
||||
const val VIEWER_KEY = "arg.edit-cell-tag.viewer"
|
||||
|
@ -468,20 +474,20 @@ open class RelationValueDVFragment : RelationValueBaseFragment() {
|
|||
override fun onObjectValueChanged(
|
||||
ctx: Id,
|
||||
objectId: Id,
|
||||
relationId: Id,
|
||||
relationKey: Key,
|
||||
ids: List<Id>
|
||||
) {
|
||||
vm.onAddObjectsOrFilesValueToRecord(
|
||||
record = target,
|
||||
relation = relation,
|
||||
record = objectId,
|
||||
relationKey = relationKey,
|
||||
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(
|
||||
record = target,
|
||||
relation = relation,
|
||||
record = objectId,
|
||||
relationKey = relationKey,
|
||||
ids = ids
|
||||
)
|
||||
}
|
||||
|
@ -492,7 +498,8 @@ open class RelationValueDVFragment : RelationValueBaseFragment() {
|
|||
val fragmentFlow = AddObjectRelationFragment.FLOW_DATAVIEW
|
||||
val fr = AddObjectRelationFragment.new(
|
||||
ctx = ctx,
|
||||
relationId = relation,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
objectId = target,
|
||||
types = types,
|
||||
flow = fragmentFlow
|
||||
|
@ -503,7 +510,8 @@ open class RelationValueDVFragment : RelationValueBaseFragment() {
|
|||
val fr = AddOptionsRelationDVFragment.new(
|
||||
ctx = ctx,
|
||||
target = target,
|
||||
relation = relation,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
dataview = dataview,
|
||||
viewer = viewer
|
||||
)
|
||||
|
@ -512,9 +520,10 @@ open class RelationValueDVFragment : RelationValueBaseFragment() {
|
|||
RelationValueBaseViewModel.ObjectRelationValueCommand.ShowAddFileScreen -> {
|
||||
val fr = AddFileRelationFragment.new(
|
||||
ctx = ctx,
|
||||
relationId = relation,
|
||||
relationId = relationId,
|
||||
objectId = target,
|
||||
flow = AddFileRelationFragment.FLOW_DATAVIEW
|
||||
flow = AddFileRelationFragment.FLOW_DATAVIEW,
|
||||
relationKey = relationKey
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
|
@ -543,7 +552,7 @@ open class RelationValueDVFragment : RelationValueBaseFragment() {
|
|||
vm.onAddFileToObject(
|
||||
ctx = ctx,
|
||||
target = target,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
filePath = filePath
|
||||
)
|
||||
} else {
|
||||
|
@ -582,22 +591,22 @@ class RelationValueFragment : RelationValueBaseFragment() {
|
|||
override fun onObjectValueChanged(
|
||||
ctx: Id,
|
||||
objectId: Id,
|
||||
relationId: Id,
|
||||
relationKey: Key,
|
||||
ids: List<Id>
|
||||
) {
|
||||
vm.onAddObjectsOrFilesValueToObject(
|
||||
ctx = ctx,
|
||||
target = target,
|
||||
relation = relation,
|
||||
target = objectId,
|
||||
relationKey = relationKey,
|
||||
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(
|
||||
ctx = ctx,
|
||||
target = target,
|
||||
relation = relation,
|
||||
target = objectId,
|
||||
relationKey = relationKey,
|
||||
ids = ids
|
||||
)
|
||||
}
|
||||
|
@ -615,7 +624,8 @@ class RelationValueFragment : RelationValueBaseFragment() {
|
|||
RelationValueBaseViewModel.ObjectRelationValueCommand.ShowAddObjectScreen -> {
|
||||
val fr = AddObjectRelationFragment.new(
|
||||
ctx = ctx,
|
||||
relationId = relation,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
objectId = target,
|
||||
types = types
|
||||
)
|
||||
|
@ -625,14 +635,16 @@ class RelationValueFragment : RelationValueBaseFragment() {
|
|||
val fr = AddOptionsRelationFragment.new(
|
||||
ctx = ctx,
|
||||
objectId = target,
|
||||
relationId = relation
|
||||
relationId = relationId,
|
||||
relationKey = relationKey
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
RelationValueBaseViewModel.ObjectRelationValueCommand.ShowAddFileScreen -> {
|
||||
val fr = AddFileRelationFragment.new(
|
||||
ctx = ctx,
|
||||
relationId = relation,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
objectId = target,
|
||||
flow = AddFileRelationFragment.FLOW_DEFAULT
|
||||
)
|
||||
|
@ -668,7 +680,7 @@ class RelationValueFragment : RelationValueBaseFragment() {
|
|||
vm.onAddFileToObject(
|
||||
ctx = ctx,
|
||||
target = target,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
filePath = filePath
|
||||
)
|
||||
} else {
|
||||
|
@ -688,14 +700,16 @@ class RelationValueFragment : RelationValueBaseFragment() {
|
|||
fun new(
|
||||
ctx: Id,
|
||||
target: Id,
|
||||
relation: Id,
|
||||
relationId: Id,
|
||||
relationKey: Key,
|
||||
targetObjectTypes: List<Id>,
|
||||
isLocked: Boolean = false
|
||||
) = RelationValueFragment().apply {
|
||||
arguments = bundleOf(
|
||||
CTX_KEY to ctx,
|
||||
TARGET_KEY to target,
|
||||
RELATION_KEY to relation,
|
||||
RELATION_ID to relationId,
|
||||
RELATION_KEY to relationKey,
|
||||
TARGET_TYPES_KEY to targetObjectTypes,
|
||||
IS_LOCKED_KEY to isLocked
|
||||
)
|
||||
|
|
|
@ -11,6 +11,7 @@ import androidx.lifecycle.lifecycleScope
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.anytypeio.anytype.R
|
||||
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.reactive.textChanges
|
||||
import com.anytypeio.anytype.core_utils.ext.arg
|
||||
|
@ -37,6 +38,7 @@ class AddFileRelationFragment :
|
|||
private val ctx get() = argString(CONTEXT_ID)
|
||||
private val objectId get() = argString(OBJECT_ID)
|
||||
private val relationId get() = argString(RELATION_ID)
|
||||
private val relationKey get() = argString(RELATION_KEY)
|
||||
private val flow get() = arg<Int>(FLOW_KEY)
|
||||
|
||||
private lateinit var searchRelationInput: EditText
|
||||
|
@ -104,7 +106,7 @@ class AddFileRelationFragment :
|
|||
onFileValueChanged(
|
||||
ctx = ctx,
|
||||
objectId = objectId,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
ids = ids
|
||||
)
|
||||
}
|
||||
|
@ -144,18 +146,21 @@ class AddFileRelationFragment :
|
|||
ctx: Id,
|
||||
objectId: Id,
|
||||
relationId: Id,
|
||||
relationKey: Key,
|
||||
flow: Int = FLOW_DEFAULT
|
||||
) = AddFileRelationFragment().apply {
|
||||
arguments = bundleOf(
|
||||
CONTEXT_ID to ctx,
|
||||
OBJECT_ID to objectId,
|
||||
RELATION_ID to relationId,
|
||||
RELATION_KEY to relationKey,
|
||||
FLOW_KEY to flow
|
||||
)
|
||||
}
|
||||
|
||||
const val CONTEXT_ID = "arg.relation.add.file.context"
|
||||
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 FLOW_KEY = "arg.relation.add.file.flow"
|
||||
const val FLOW_DEFAULT = 0
|
||||
|
@ -166,7 +171,7 @@ class AddFileRelationFragment :
|
|||
fun onFileValueChanged(
|
||||
ctx: Id,
|
||||
objectId: Id,
|
||||
relationId: Id,
|
||||
relationKey: Key,
|
||||
ids: List<Id>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import androidx.lifecycle.lifecycleScope
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.anytypeio.anytype.R
|
||||
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.reactive.clicks
|
||||
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 objectId get() = argString(OBJECT_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 flow get() = arg<Int>(FLOW_KEY)
|
||||
|
||||
|
@ -116,7 +118,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
|||
}
|
||||
super.onStart()
|
||||
setupAppearance()
|
||||
vm.onStart(objectId = objectId, relationId = relationId, targetTypes = types)
|
||||
vm.onStart(objectId = objectId, relationKey = relationKey, targetTypes = types)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
@ -142,7 +144,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
|||
onObjectValueChanged(
|
||||
ctx = ctx,
|
||||
objectId = objectId,
|
||||
relationId = relationId,
|
||||
relationKey = relationKey,
|
||||
ids = ids
|
||||
)
|
||||
}
|
||||
|
@ -187,6 +189,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
|||
ctx: Id,
|
||||
objectId: Id,
|
||||
relationId: Id,
|
||||
relationKey: Key,
|
||||
types: List<Id>,
|
||||
flow: Int = FLOW_DEFAULT
|
||||
) = AddObjectRelationFragment().apply {
|
||||
|
@ -194,6 +197,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
|||
CONTEXT_ID to ctx,
|
||||
OBJECT_ID to objectId,
|
||||
RELATION_ID to relationId,
|
||||
RELATION_KEY to relationKey,
|
||||
TARGET_TYPES to types,
|
||||
FLOW_KEY to flow
|
||||
)
|
||||
|
@ -201,6 +205,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
|||
|
||||
const val CONTEXT_ID = "arg.relation.add.object.context"
|
||||
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 TARGET_TYPES = "arg.relation.add.object.target_types"
|
||||
const val FLOW_KEY = "arg.relation.add.object.flow"
|
||||
|
@ -212,7 +217,7 @@ class AddObjectRelationFragment : BaseDialogFragment<FragmentRelationObjectValue
|
|||
fun onObjectValueChanged(
|
||||
ctx: Id,
|
||||
objectId: Id,
|
||||
relationId: Id,
|
||||
relationKey: Key,
|
||||
ids: List<Id>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.anytypeio.anytype.ui.relations.add
|
|||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.viewModels
|
||||
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.presentation.relations.RelationValueView
|
||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel
|
||||
|
@ -16,31 +17,24 @@ open class AddOptionsRelationDVFragment : BaseAddOptionsRelationFragment() {
|
|||
|
||||
override fun onStatusClicked(status: RelationValueView.Option.Status) {
|
||||
vm.onAddObjectSetStatusClicked(
|
||||
ctx = ctx,
|
||||
obj = target,
|
||||
dataview = dataview,
|
||||
viewer = viewer,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
status = status
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCreateOptionClicked(name: String) {
|
||||
vm.onCreateDataViewRelationOptionClicked(
|
||||
ctx = ctx,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
name = name,
|
||||
dataview = dataview,
|
||||
viewer = viewer,
|
||||
target = target
|
||||
)
|
||||
}
|
||||
|
||||
override fun onAddButtonClicked() {
|
||||
vm.onAddSelectedValuesToDataViewClicked(
|
||||
ctx = ctx,
|
||||
target = target,
|
||||
relation = relation
|
||||
relationKey = relationKey
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -56,14 +50,16 @@ open class AddOptionsRelationDVFragment : BaseAddOptionsRelationFragment() {
|
|||
fun new(
|
||||
ctx: Id,
|
||||
target: Id,
|
||||
relation: Id,
|
||||
relationId: Id,
|
||||
relationKey: Key,
|
||||
dataview: Id,
|
||||
viewer: Id
|
||||
) = AddOptionsRelationDVFragment().apply {
|
||||
arguments = bundleOf(
|
||||
CTX_KEY to ctx,
|
||||
TARGET_KEY to target,
|
||||
RELATION_KEY to relation,
|
||||
RELATION_ID to relationId,
|
||||
RELATION_KEY to relationKey,
|
||||
DATAVIEW_KEY to dataview,
|
||||
VIEWER_KEY to viewer
|
||||
)
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.anytypeio.anytype.ui.relations.add
|
|||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.viewModels
|
||||
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.presentation.relations.RelationValueView
|
||||
import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationViewModel
|
||||
|
@ -17,15 +18,14 @@ class AddOptionsRelationFragment : BaseAddOptionsRelationFragment() {
|
|||
override fun onStatusClicked(status: RelationValueView.Option.Status) {
|
||||
vm.onAddObjectStatusClicked(
|
||||
ctx = ctx,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
status = status
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCreateOptionClicked(name: String) {
|
||||
vm.onCreateObjectRelationOptionClicked(
|
||||
ctx = ctx,
|
||||
relation = relation,
|
||||
relationKey = relationKey,
|
||||
obj = target,
|
||||
name = name
|
||||
)
|
||||
|
@ -33,9 +33,8 @@ class AddOptionsRelationFragment : BaseAddOptionsRelationFragment() {
|
|||
|
||||
override fun onAddButtonClicked() {
|
||||
vm.onAddSelectedValuesToObjectClicked(
|
||||
ctx = ctx,
|
||||
obj = target,
|
||||
relation = relation,
|
||||
relationKey = relationKey
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -51,12 +50,14 @@ class AddOptionsRelationFragment : BaseAddOptionsRelationFragment() {
|
|||
fun new(
|
||||
ctx: Id,
|
||||
objectId: Id,
|
||||
relationId: Id
|
||||
relationId: Id,
|
||||
relationKey: Key
|
||||
) = AddOptionsRelationFragment().apply {
|
||||
arguments = bundleOf(
|
||||
CTX_KEY to ctx,
|
||||
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)
|
||||
|
||||
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 flow get() = arg<Int>(FLOW_KEY)
|
||||
val dataview get() = argString(DATAVIEW_KEY)
|
||||
|
@ -178,7 +179,7 @@ abstract class BaseAddOptionsRelationFragment : BaseDialogFragment<AddOptionRela
|
|||
setupAppearance()
|
||||
vm.onStart(
|
||||
target = target,
|
||||
relationId = relation
|
||||
relationKey = relationKey
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -205,7 +206,8 @@ abstract class BaseAddOptionsRelationFragment : BaseDialogFragment<AddOptionRela
|
|||
|
||||
companion object {
|
||||
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 FLOW_KEY = "arg.add-object-relation-value.flow"
|
||||
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.R
|
||||
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_ui.extensions.setEmojiOrNull
|
||||
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.modals.IconPickerFragmentBase
|
||||
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.DateValueEditReceiver
|
||||
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.ManageViewerFragment
|
||||
import com.anytypeio.anytype.ui.sets.modals.ObjectSetSettingsFragment
|
||||
import com.anytypeio.anytype.ui.sets.modals.SetObjectCreateBookmarkRecordFragment
|
||||
import com.anytypeio.anytype.ui.sets.modals.SetObjectSetRecordNameFragment
|
||||
import com.anytypeio.anytype.ui.sets.modals.SetObjectCreateRecordFragmentBase
|
||||
import com.anytypeio.anytype.ui.sets.modals.ViewerBottomSheetRootFragment
|
||||
import com.anytypeio.anytype.ui.sets.modals.sort.ViewerSortFragment
|
||||
import com.bumptech.glide.Glide
|
||||
|
@ -96,7 +99,8 @@ import javax.inject.Inject
|
|||
open class ObjectSetFragment :
|
||||
NavigationFragment<FragmentObjectSetBinding>(R.layout.fragment_object_set),
|
||||
TextValueEditReceiver,
|
||||
DateValueEditReceiver {
|
||||
DateValueEditReceiver,
|
||||
OnDataViewSelectSourceAction {
|
||||
|
||||
// Controls
|
||||
|
||||
|
@ -187,7 +191,7 @@ open class ObjectSetFragment :
|
|||
binding.root.setTransitionListener(transitionListener)
|
||||
|
||||
with(lifecycleScope) {
|
||||
subscribe(addNewButton.clicks().throttleFirst()) { vm.onCreateNewRecord() }
|
||||
subscribe(addNewButton.clicks().throttleFirst()) { vm.onCreateNewDataViewObject() }
|
||||
subscribe(title.editorActionEvents(actionHandler)) {
|
||||
title.apply {
|
||||
hideKeyboard()
|
||||
|
@ -262,8 +266,8 @@ open class ObjectSetFragment :
|
|||
DefaultTextWatcher { vm.onTitleChanged(it.toString()) }
|
||||
)
|
||||
|
||||
setFragmentResultListener(ObjectTypeChangeFragment.OBJECT_TYPE_REQUEST_KEY) { _, bundle ->
|
||||
val source = bundle.getString(ObjectTypeChangeFragment.OBJECT_TYPE_URL_KEY)
|
||||
setFragmentResultListener(BaseObjectTypeChangeFragment.OBJECT_TYPE_REQUEST_KEY) { _, bundle ->
|
||||
val source = bundle.getString(BaseObjectTypeChangeFragment.OBJECT_TYPE_URL_KEY)
|
||||
if (source != null) {
|
||||
vm.onDataViewSourcePicked(source = source)
|
||||
} else {
|
||||
|
@ -582,20 +586,24 @@ open class ObjectSetFragment :
|
|||
)
|
||||
}
|
||||
is ObjectSetCommand.Modal.EditGridTextCell -> {
|
||||
//todo Relation as object, fix relationKey
|
||||
val fr = RelationTextValueFragment.new(
|
||||
ctx = ctx,
|
||||
relationId = command.relationId,
|
||||
relationId = "",
|
||||
objectId = command.recordId,
|
||||
flow = RelationTextValueFragment.FLOW_DATAVIEW
|
||||
flow = RelationTextValueFragment.FLOW_DATAVIEW,
|
||||
relationKey = command.relationKey
|
||||
)
|
||||
fr.show(childFragmentManager, EMPTY_TAG)
|
||||
}
|
||||
is ObjectSetCommand.Modal.EditGridDateCell -> {
|
||||
//todo Relation as object, fix relationKey
|
||||
val fr = RelationDateValueFragment.new(
|
||||
ctx = ctx,
|
||||
relationId = command.relationId,
|
||||
relationId = command.relationKey,
|
||||
objectId = command.objectId,
|
||||
flow = RelationDateValueFragment.FLOW_DATAVIEW
|
||||
flow = RelationDateValueFragment.FLOW_DATAVIEW,
|
||||
relationKey = ""
|
||||
)
|
||||
fr.show(childFragmentManager, EMPTY_TAG)
|
||||
}
|
||||
|
@ -607,7 +615,8 @@ open class ObjectSetFragment :
|
|||
RelationValueBaseFragment.CTX_KEY to command.ctx,
|
||||
RelationValueBaseFragment.TARGET_KEY to command.target,
|
||||
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.TARGET_TYPES_KEY to command.targetObjectTypes,
|
||||
RelationValueBaseFragment.IS_LOCKED_KEY to false
|
||||
|
@ -647,11 +656,14 @@ open class ObjectSetFragment :
|
|||
)
|
||||
fr.show(childFragmentManager, EMPTY_TAG)
|
||||
}
|
||||
is ObjectSetCommand.Modal.SetNameForCreatedRecord -> {
|
||||
is ObjectSetCommand.Modal.SetNameForCreatedObject -> {
|
||||
findNavController().safeNavigate(
|
||||
R.id.objectSetScreen,
|
||||
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 -> {
|
||||
|
@ -717,22 +729,17 @@ open class ObjectSetFragment :
|
|||
findNavController().safeNavigate(
|
||||
R.id.objectSetScreen,
|
||||
R.id.setUrlForNewBookmark,
|
||||
bundleOf(
|
||||
SetObjectCreateBookmarkRecordFragment.CTX_KEY to command.ctx
|
||||
)
|
||||
)
|
||||
bundleOf(SetObjectCreateRecordFragmentBase.CONTEXT_KEY to command.ctx))
|
||||
}
|
||||
is ObjectSetCommand.Modal.OpenSelectSourceScreen -> {
|
||||
findNavController()
|
||||
.safeNavigate(
|
||||
R.id.objectSetScreen,
|
||||
R.id.objectTypeChangeScreen,
|
||||
bundleOf(
|
||||
ObjectTypeChangeFragment.ARG_SMART_BLOCK_TYPE to command.smartBlockType,
|
||||
ObjectTypeChangeFragment.ARG_IS_SET_SOURCE to true,
|
||||
ObjectTypeChangeFragment.ARG_SOURCES to command.sources
|
||||
)
|
||||
)
|
||||
is ObjectSetCommand.Modal.OpenDataViewSelectSourceScreen -> {
|
||||
val fr = DataViewSelectSourceFragment.newInstance(
|
||||
selectedTypes = command.selectedTypes
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
is ObjectSetCommand.Modal.OpenEmptyDataViewSelectSourceScreen -> {
|
||||
val fr = EmptyDataViewSelectSourceFragment()
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -864,11 +871,11 @@ open class ObjectSetFragment :
|
|||
ctx: String,
|
||||
text: String,
|
||||
objectId: String,
|
||||
relationId: String
|
||||
relationKey: Key
|
||||
) = vm.onRelationTextValueChanged(
|
||||
value = text,
|
||||
objectId = objectId,
|
||||
relationKey = relationId
|
||||
relationKey = relationKey
|
||||
)
|
||||
|
||||
override fun onNumberValueChanged(
|
||||
|
@ -886,15 +893,19 @@ open class ObjectSetFragment :
|
|||
ctx: Id,
|
||||
timeInSeconds: Number?,
|
||||
objectId: Id,
|
||||
relationId: Id
|
||||
relationKey: Key
|
||||
) {
|
||||
vm.onRelationTextValueChanged(
|
||||
value = timeInSeconds,
|
||||
objectId = objectId,
|
||||
relationKey = relationId
|
||||
relationKey = relationKey
|
||||
)
|
||||
}
|
||||
|
||||
override fun onProceedWithSelectSource(id: Id) {
|
||||
vm.onDataViewSourcePicked(source = id)
|
||||
}
|
||||
|
||||
override fun injectDependencies() {
|
||||
componentManager().objectSetComponent.get(ctx).inject(this)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.ViewGroup
|
|||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.anytypeio.anytype.core_utils.ext.arg
|
||||
import com.anytypeio.anytype.databinding.FragmentSetObjectCreateBookmarkRecordBinding
|
||||
import com.anytypeio.anytype.di.common.componentManager
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetCreateBookmarkRecordViewModel
|
||||
|
@ -15,15 +14,12 @@ import javax.inject.Inject
|
|||
class SetObjectCreateBookmarkRecordFragment :
|
||||
SetObjectCreateRecordFragmentBase<FragmentSetObjectCreateBookmarkRecordBinding>() {
|
||||
|
||||
|
||||
override val textInputType: Int = TYPE_TEXT_VARIATION_URI
|
||||
override val textInputField: EditText
|
||||
get() = binding.textInputField
|
||||
override val button: TextView
|
||||
get() = binding.button
|
||||
|
||||
private val ctx: String get() = arg(CTX_KEY)
|
||||
|
||||
@Inject
|
||||
lateinit var factory: ObjectSetCreateBookmarkRecordViewModel.Factory
|
||||
override val vm: ObjectSetCreateBookmarkRecordViewModel by viewModels { factory }
|
||||
|
@ -37,15 +33,18 @@ class SetObjectCreateBookmarkRecordFragment :
|
|||
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(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?
|
||||
): FragmentSetObjectCreateBookmarkRecordBinding =
|
||||
FragmentSetObjectCreateBookmarkRecordBinding.inflate(
|
||||
): FragmentSetObjectCreateBookmarkRecordBinding = FragmentSetObjectCreateBookmarkRecordBinding.inflate(
|
||||
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.toast
|
||||
import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment
|
||||
import com.anytypeio.anytype.presentation.sets.ObjectSetCreateRecordViewModelBase
|
||||
import com.anytypeio.anytype.ui.sets.modals.SetObjectSetRecordNameFragment.Companion.CONTEXT_KEY
|
||||
import com.anytypeio.anytype.presentation.sets.SetDataViewObjectNameViewModelBase
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
@ -23,11 +22,15 @@ abstract class SetObjectCreateRecordFragmentBase<T: ViewBinding> :
|
|||
BaseBottomSheetFragment<T>() {
|
||||
|
||||
protected abstract val textInputType: Int
|
||||
private val ctx: String get() = argString(CONTEXT_KEY)
|
||||
protected abstract val textInputField: EditText
|
||||
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 ->
|
||||
action == EditorInfo.IME_ACTION_DONE
|
||||
|
@ -35,15 +38,8 @@ abstract class SetObjectCreateRecordFragmentBase<T: ViewBinding> :
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
textInputField.apply {
|
||||
setRawInputType(textInputType)
|
||||
}
|
||||
button.setOnClickListener {
|
||||
vm.onButtonClicked(
|
||||
ctx = ctx,
|
||||
input = textInputField.text.toString()
|
||||
)
|
||||
}
|
||||
textInputField.apply { setRawInputType(textInputType) }
|
||||
button.setOnClickListener { onButtonClicked() }
|
||||
lifecycleScope.launch {
|
||||
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
onStart(this)
|
||||
|
@ -68,11 +64,16 @@ abstract class SetObjectCreateRecordFragmentBase<T: ViewBinding> :
|
|||
textInputField.editorActionEvents(handler).collect {
|
||||
textInputField.clearFocus()
|
||||
textInputField.hideKeyboard()
|
||||
vm.onComplete(ctx, textInputField.text.toString())
|
||||
onKeyboardActionDone()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun subscribeIsCompleted() {
|
||||
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
|
||||
override val button: AppCompatImageButton
|
||||
get() = binding.icExpand
|
||||
private val ctx: String get() = argString(CONTEXT_KEY)
|
||||
|
||||
@Inject
|
||||
lateinit var factory: ObjectSetRecordViewModel.Factory
|
||||
override val vm: ObjectSetRecordViewModel by viewModels { factory }
|
||||
|
||||
private val target: String get() = argString(TARGET_KEY)
|
||||
|
||||
override fun onStart(scope: CoroutineScope) {
|
||||
super.onStart(scope)
|
||||
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() {
|
||||
componentManager().objectSetRecordComponent.get(ctx).inject(this)
|
||||
}
|
||||
|
@ -66,8 +81,4 @@ class SetObjectSetRecordNameFragment : SetObjectCreateRecordFragmentBase<Fragmen
|
|||
): FragmentSetObjectSetRecordNameBinding = FragmentSetObjectSetRecordNameBinding.inflate(
|
||||
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 com.anytypeio.anytype.R
|
||||
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.features.sets.CreateFilterAdapter
|
||||
import com.anytypeio.anytype.core_ui.reactive.clicks
|
||||
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.databinding.FragmentCreateOrUpdateFilterBinding
|
||||
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)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
vm.onStart(relationId = relation, filterIndex = FILTER_INDEX_EMPTY)
|
||||
vm.onStart(relationKey = relation, filterIndex = FILTER_INDEX_EMPTY)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.recyclerview.widget.DividerItemDecoration
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.anytypeio.anytype.R
|
||||
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.features.sets.CreateFilterAdapter
|
||||
import com.anytypeio.anytype.core_ui.reactive.clicks
|
||||
|
@ -169,9 +170,9 @@ open class ModifyFilterFromSelectedValueFragment :
|
|||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,9 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.setFragmentResultListener
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.anytypeio.anytype.R
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_utils.ext.subscribe
|
||||
import com.anytypeio.anytype.core_utils.ext.toast
|
||||
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.presentation.settings.OtherSettingsViewModel
|
||||
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
|
||||
|
||||
class OtherSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBinding>() {
|
||||
class OtherSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBinding>(),
|
||||
AppDefaultObjectTypeFragment.OnObjectTypeAction {
|
||||
|
||||
@Inject
|
||||
lateinit var factory: OtherSettingsViewModel.Factory
|
||||
|
||||
private val vm by viewModels<OtherSettingsViewModel> { factory }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
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 onProceedWithUpdateType(id: Id, name: String) {
|
||||
vm.proceedWithUpdateType(type = id, name = name)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -55,13 +48,10 @@ class OtherSettingsFragment : BaseBottomSheetFragment<FragmentUserSettingsBindin
|
|||
when (command) {
|
||||
is OtherSettingsViewModel.Command.Exit -> dismiss()
|
||||
is OtherSettingsViewModel.Command.NavigateToObjectTypesScreen -> {
|
||||
findNavController().navigate(
|
||||
R.id.objectTypeChangeScreen,
|
||||
bundleOf(
|
||||
ObjectTypeChangeFragment.ARG_SMART_BLOCK_TYPE to command.smartBlockType,
|
||||
ObjectTypeChangeFragment.ARG_EXCLUDED_TYPES to command.excludedTypes
|
||||
)
|
||||
val fr = AppDefaultObjectTypeFragment.newInstance(
|
||||
excludeTypes = command.excludeTypes
|
||||
)
|
||||
fr.show(childFragmentManager, null)
|
||||
}
|
||||
is OtherSettingsViewModel.Command.Toast -> toast(command.msg)
|
||||
is OtherSettingsViewModel.Command.ShowClearCacheAlert -> {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="18dp"
|
||||
android:text="@string/change_type" />
|
||||
tools:text="@string/change_type" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/searchBar"
|
||||
|
|
|
@ -286,7 +286,9 @@ data class Block(
|
|||
data class DataView(
|
||||
val sources: List<String>,
|
||||
val viewers: List<Viewer>,
|
||||
val relations: List<Relation>
|
||||
@Deprecated("To be deleted")
|
||||
val relations: List<Relation>,
|
||||
val relationsIndex: List<RelationLink> = emptyList()
|
||||
) : Content() {
|
||||
|
||||
data class Viewer(
|
||||
|
@ -334,12 +336,16 @@ data class Block(
|
|||
enum class Type { ASC, DESC, CUSTOM }
|
||||
}
|
||||
|
||||
/**
|
||||
* [relationFormat] optional relation format, which should be specified for date-related filtering.
|
||||
*/
|
||||
data class Filter(
|
||||
val relationKey: String,
|
||||
val relationFormat: RelationFormat? = null,
|
||||
val operator: Operator = Operator.AND,
|
||||
val condition: Condition,
|
||||
val quickOption: QuickOption = QuickOption.EXACT_DATE,
|
||||
val value: Any?
|
||||
val value: Any? = null
|
||||
) {
|
||||
enum class Operator { AND, OR }
|
||||
enum class Condition {
|
||||
|
|
|
@ -26,6 +26,7 @@ sealed class Event {
|
|||
val type: SmartBlockType = SmartBlockType.PAGE,
|
||||
val objectTypes: List<ObjectType> = emptyList(),
|
||||
val relations: List<Relation> = emptyList(),
|
||||
val relationLinks: List<RelationLink> = emptyList(),
|
||||
val objectRestrictions: List<ObjectRestriction> = emptyList(),
|
||||
val dataViewRestrictions: List<DataViewRestrictions> = emptyList()
|
||||
) : Command()
|
||||
|
@ -194,24 +195,18 @@ sealed class Event {
|
|||
val style: Block.Content.Divider.Style
|
||||
) : Command()
|
||||
|
||||
sealed class ObjectRelations : Command() {
|
||||
data class Set(
|
||||
override val context: String,
|
||||
val id: Id,
|
||||
val relations: List<Relation>
|
||||
) : ObjectRelations()
|
||||
|
||||
sealed class ObjectRelationLinks : Command() {
|
||||
data class Amend(
|
||||
override val context: String,
|
||||
val id: Id,
|
||||
val relations: List<Relation>
|
||||
) : ObjectRelations()
|
||||
val relationLinks: List<RelationLink>
|
||||
) : ObjectRelationLinks()
|
||||
|
||||
data class Remove(
|
||||
override val context: String,
|
||||
val id: Id,
|
||||
val keys: List<Id>
|
||||
) : ObjectRelations()
|
||||
val keys: List<Key>
|
||||
) : ObjectRelationLinks()
|
||||
}
|
||||
|
||||
sealed class ObjectRelation : Command() {
|
||||
|
@ -250,14 +245,13 @@ sealed class Event {
|
|||
|
||||
/**
|
||||
* Sent when a data-view's relation has been changed or added.
|
||||
* @property [id] data view's block id
|
||||
* @property [key] relation key
|
||||
* @property [dv] data view's block id
|
||||
* @property [links] relations link for this data view
|
||||
*/
|
||||
data class SetRelation(
|
||||
override val context: Id,
|
||||
val id: Id,
|
||||
val key: String,
|
||||
val relation: Relation
|
||||
val dv: Id,
|
||||
val links: List<RelationLink>
|
||||
) : DataView()
|
||||
|
||||
|
||||
|
|
|
@ -9,17 +9,26 @@ package com.anytypeio.anytype.core_models
|
|||
* @property [layout] template's layout
|
||||
*
|
||||
*/
|
||||
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||
data class ObjectType(
|
||||
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||
val url: Url,
|
||||
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||
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,
|
||||
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||
val emoji: String,
|
||||
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||
val description: String,
|
||||
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||
val isHidden: Boolean,
|
||||
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||
val isArchived: Boolean,
|
||||
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||
val isReadOnly: Boolean,
|
||||
@Deprecated("Will be deprecated. Object type will be treated as object")
|
||||
val smartBlockTypes: List<SmartBlockType>
|
||||
) {
|
||||
enum class Layout(val code: Int) {
|
||||
|
@ -47,54 +56,4 @@ data class ObjectType(
|
|||
val layout: Layout,
|
||||
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
|
||||
|
||||
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.restrictions.ObjectRestriction
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
inline fun <reified T> getValue(relation: Id) : T? {
|
||||
inline fun <reified T> getValue(relation: Id): T? {
|
||||
val value = map.getOrDefault(relation, null)
|
||||
return if (value is T)
|
||||
value
|
||||
|
@ -80,7 +82,42 @@ sealed class ObjectWrapper {
|
|||
|
||||
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()
|
||||
|
||||
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 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 [isHidden] whether this type is internal (not displayed to user)
|
||||
*/
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
data class Relation(
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
val key: String,
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
val name: String,
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
val format: Format,
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
val source: Source,
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
val isHidden: Boolean = false,
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
val isReadOnly: Boolean = false,
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
val isMulti: Boolean = false,
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
val selections: List<Option> = emptyList(),
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
val objectTypes: List<String> = emptyList(),
|
||||
@Deprecated("Will be deprecated. Relations will be treated as objects")
|
||||
val defaultValue: Any? = null
|
||||
) {
|
||||
|
||||
enum class Format(val prettyName: String) {
|
||||
LONG_TEXT("Text"),
|
||||
SHORT_TEXT("Short text"),
|
||||
NUMBER("Number"),
|
||||
STATUS("Status"),
|
||||
TAG("Tag"),
|
||||
DATE("Date"),
|
||||
FILE("File & Media"),
|
||||
CHECKBOX("Checkbox"),
|
||||
URL("URL"),
|
||||
EMAIL("Email"),
|
||||
PHONE("Phone"),
|
||||
EMOJI("Emoji"),
|
||||
OBJECT("Object"),
|
||||
RELATIONS("Relations")
|
||||
enum class Format(val code: Int) {
|
||||
LONG_TEXT(0),
|
||||
SHORT_TEXT(1),
|
||||
NUMBER(2),
|
||||
STATUS(3),
|
||||
TAG(11),
|
||||
DATE(4),
|
||||
FILE(5),
|
||||
CHECKBOX(6),
|
||||
URL(7),
|
||||
EMAIL(8),
|
||||
PHONE(9),
|
||||
EMOJI(10),
|
||||
OBJECT(100),
|
||||
RELATIONS(101),
|
||||
|
||||
UNDEFINED(-1)
|
||||
}
|
||||
|
||||
enum class Source {
|
||||
|
@ -45,14 +56,9 @@ data class Relation(
|
|||
data class Option(
|
||||
val id: String,
|
||||
val text: String,
|
||||
val color: String,
|
||||
val scope: OptionScope = OptionScope.LOCAL
|
||||
val color: String
|
||||
)
|
||||
|
||||
enum class OptionScope {
|
||||
LOCAL, RELATION, FORMAT
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun orderedFormatList(): List<Format> = listOf(
|
||||
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 URL = "url"
|
||||
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"
|
||||
|
||||
|
|
|
@ -1,26 +1,27 @@
|
|||
package com.anytypeio.anytype.core_models
|
||||
|
||||
enum class SmartBlockType {
|
||||
BREADCRUMBS,
|
||||
PAGE,
|
||||
PROFILE_PAGE,
|
||||
HOME,
|
||||
ARCHIVE,
|
||||
SET,
|
||||
BUNDLED_OBJECT_TYPE,
|
||||
CUSTOM_OBJECT_TYPE,
|
||||
FILE,
|
||||
TEMPLATE,
|
||||
MARKETPLACE_TYPE,
|
||||
MARKETPLACE_RELATION,
|
||||
MARKETPLACE_TEMPLATE,
|
||||
BUNDLED_RELATION,
|
||||
INDEXED_RELATION,
|
||||
ANYTYPE_PROFILE,
|
||||
DATABASE,
|
||||
BUNDLED_TEMPLATE,
|
||||
DATE,
|
||||
WORKSPACE,
|
||||
WORKSPACE_OLD,
|
||||
ACCOUNT_OLD
|
||||
enum class SmartBlockType(val code: Int) {
|
||||
ACCOUNT_OLD(code = 0),
|
||||
BREADCRUMBS(code = 1),
|
||||
PAGE(code = 16),
|
||||
PROFILE_PAGE(code = 17),
|
||||
HOME(code = 32),
|
||||
ARCHIVE(code = 48),
|
||||
DATABASE(code = 64),
|
||||
SET(code = 65),
|
||||
CUSTOM_OBJECT_TYPE(code = 96),
|
||||
FILE(code = 256),
|
||||
TEMPLATE(code = 288),
|
||||
BUNDLED_TEMPLATE(code = 289),
|
||||
MARKETPLACE_TYPE(code = 272),
|
||||
MARKETPLACE_RELATION(code = 273),
|
||||
MARKETPLACE_TEMPLATE(code = 274),
|
||||
@Deprecated("")
|
||||
BUNDLED_RELATION(code = 512),
|
||||
SUB_OBJECT(code = 513),
|
||||
BUNDLED_OBJECT_TYPE(code = 514),
|
||||
ANYTYPE_PROFILE(code = 515),
|
||||
DATE(code = 516),
|
||||
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.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(
|
||||
event: Event.Command.ObjectRelations
|
||||
) : List<Relation> = when(event) {
|
||||
is Event.Command.ObjectRelations.Amend -> amend(event.relations)
|
||||
is Event.Command.ObjectRelations.Remove -> remove(event.keys)
|
||||
is Event.Command.ObjectRelations.Set -> set(event.relations)
|
||||
fun List<RelationLink>.process(
|
||||
event: Event.Command.ObjectRelationLinks
|
||||
): List<RelationLink> = when (event) {
|
||||
is Event.Command.ObjectRelationLinks.Amend -> amend(event.relationLinks)
|
||||
is Event.Command.ObjectRelationLinks.Remove -> remove(event.keys)
|
||||
}
|
||||
|
||||
fun List<Relation>.set(relations: List<Relation>) : List<Relation> {
|
||||
return relations
|
||||
}
|
||||
|
||||
fun List<Relation>.amend(relations: List<Relation>) : List<Relation> {
|
||||
fun List<RelationLink>.amend(relationLinks: List<RelationLink>): List<RelationLink> {
|
||||
val map = this.associateBy { it.key }.toMutableMap()
|
||||
relations.forEach { relation ->
|
||||
relationLinks.forEach { relation ->
|
||||
map[relation.key] = relation
|
||||
}
|
||||
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) }
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
enum class ObjectRestriction {
|
||||
enum class ObjectRestriction(val code: Int) {
|
||||
|
||||
/**
|
||||
* restricts delete
|
||||
*/
|
||||
DELETE,
|
||||
DELETE(1),
|
||||
|
||||
/**
|
||||
* restricts work with relations
|
||||
*/
|
||||
RELATIONS,
|
||||
RELATIONS(2),
|
||||
|
||||
/**
|
||||
* restricts work with details
|
||||
*/
|
||||
DETAILS,
|
||||
DETAILS(4),
|
||||
|
||||
/**
|
||||
* restricts work with blocks
|
||||
*/
|
||||
BLOCKS,
|
||||
BLOCKS(3),
|
||||
|
||||
/**
|
||||
* restricts changing type
|
||||
*/
|
||||
TYPE_CHANGE,
|
||||
TYPE_CHANGE(5),
|
||||
|
||||
/**
|
||||
* 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 androidx.annotation.ColorRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.content.ContextCompat
|
||||
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_utils.const.MimeTypes
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectLayoutView
|
||||
|
@ -146,69 +147,69 @@ fun ColumnView.Format.relationIconSmall(): Int? = when (this) {
|
|||
else -> null
|
||||
}
|
||||
|
||||
fun Relation.Format.icon(isMedium: Boolean = false): Int = when (this) {
|
||||
Relation.Format.SHORT_TEXT, Relation.Format.LONG_TEXT -> {
|
||||
fun RelationFormat.icon(isMedium: Boolean = false): Int = when (this) {
|
||||
RelationFormat.SHORT_TEXT, RelationFormat.LONG_TEXT -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_text_48
|
||||
else
|
||||
R.drawable.ic_relation_text_32
|
||||
}
|
||||
Relation.Format.NUMBER -> {
|
||||
RelationFormat.NUMBER -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_number_48
|
||||
else
|
||||
R.drawable.ic_relation_number_32
|
||||
}
|
||||
Relation.Format.STATUS -> {
|
||||
RelationFormat.STATUS -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_status_48
|
||||
else
|
||||
R.drawable.ic_relation_status_32
|
||||
}
|
||||
Relation.Format.DATE -> {
|
||||
RelationFormat.DATE -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_date_48
|
||||
else
|
||||
R.drawable.ic_relation_date_32
|
||||
}
|
||||
Relation.Format.FILE -> {
|
||||
RelationFormat.FILE -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_attachment_48
|
||||
else
|
||||
R.drawable.ic_relation_attachment_32
|
||||
}
|
||||
Relation.Format.CHECKBOX -> {
|
||||
RelationFormat.CHECKBOX -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_checkbox_48
|
||||
else
|
||||
R.drawable.ic_relation_checkbox_32
|
||||
}
|
||||
Relation.Format.URL -> {
|
||||
RelationFormat.URL -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_url_48
|
||||
else
|
||||
R.drawable.ic_relation_url_32
|
||||
}
|
||||
Relation.Format.EMAIL -> {
|
||||
RelationFormat.EMAIL -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_email_48
|
||||
else
|
||||
R.drawable.ic_relation_email_32
|
||||
}
|
||||
Relation.Format.PHONE -> {
|
||||
RelationFormat.PHONE -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_phone_number_48
|
||||
else
|
||||
R.drawable.ic_relation_phone_number_32
|
||||
}
|
||||
Relation.Format.EMOJI -> R.drawable.ic_relation_object_32
|
||||
Relation.Format.OBJECT -> {
|
||||
RelationFormat.EMOJI -> R.drawable.ic_relation_object_32
|
||||
RelationFormat.OBJECT -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_object_48
|
||||
else
|
||||
R.drawable.ic_relation_object_32
|
||||
}
|
||||
Relation.Format.TAG -> {
|
||||
RelationFormat.TAG -> {
|
||||
if (isMedium)
|
||||
R.drawable.ic_relation_tag_48
|
||||
else
|
||||
|
@ -220,20 +221,20 @@ fun Relation.Format.icon(isMedium: Boolean = false): Int = when (this) {
|
|||
}
|
||||
}
|
||||
|
||||
fun DVSortType.text(format: Relation.Format): Int = when (format) {
|
||||
Relation.Format.TAG, Relation.Format.STATUS -> {
|
||||
fun DVSortType.text(format: RelationFormat): Int = when (format) {
|
||||
RelationFormat.TAG, RelationFormat.STATUS -> {
|
||||
if (this == DVSortType.ASC)
|
||||
R.string.sort_from_first_to_last
|
||||
else
|
||||
R.string.sort_from_last_to_first
|
||||
}
|
||||
Relation.Format.NUMBER, Relation.Format.DATE -> {
|
||||
RelationFormat.NUMBER, RelationFormat.DATE -> {
|
||||
if (this == DVSortType.ASC)
|
||||
R.string.sort_from_one_to_nine
|
||||
else
|
||||
R.string.sort_from_nine_to_one
|
||||
}
|
||||
Relation.Format.CHECKBOX -> {
|
||||
RelationFormat.CHECKBOX -> {
|
||||
if (this == DVSortType.ASC)
|
||||
R.string.sort_from_unchecked_to_checked
|
||||
else
|
||||
|
@ -280,4 +281,23 @@ fun ObjectLayoutView.getName(): Int? = when (this) {
|
|||
is ObjectLayoutView.Relation -> null
|
||||
is ObjectLayoutView.Space -> 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) {
|
||||
|
||||
fun bind(item: SlashItem.ObjectType) = with(binding) {
|
||||
val objectType = item.objectTypeView
|
||||
ivIcon.setIcon(
|
||||
emoji = item.emoji,
|
||||
emoji = objectType.emoji,
|
||||
image = null,
|
||||
name = item.name
|
||||
name = objectType.name
|
||||
)
|
||||
tvTitle.text = item.name
|
||||
if (item.description.isNullOrBlank()) {
|
||||
tvTitle.text = objectType.name
|
||||
if (objectType.description.isNullOrBlank()) {
|
||||
tvSubtitle.gone()
|
||||
} else {
|
||||
tvSubtitle.visible()
|
||||
tvSubtitle.text = item.description
|
||||
tvSubtitle.text = objectType.description
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,18 +4,14 @@ import android.view.LayoutInflater
|
|||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
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.features.objects.holders.ObjectTypeHolder
|
||||
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
|
||||
|
||||
abstract class ObjectTypeBaseAdapter(
|
||||
class ObjectTypeVerticalAdapter(
|
||||
private var data: ArrayList<ObjectTypeView>,
|
||||
private val onItemClick: (Id, String) -> Unit,
|
||||
private val onSearchClick: (() -> Unit)? = null
|
||||
private val onItemClick: (Id, String) -> Unit
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
fun update(data: List<ObjectTypeView>) {
|
||||
|
@ -26,82 +22,31 @@ abstract class ObjectTypeBaseAdapter(
|
|||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
val viewHolder: RecyclerView.ViewHolder = when (viewType) {
|
||||
R.layout.item_object_type_item -> {
|
||||
ObjectTypeHolder(
|
||||
binding = ItemObjectTypeItemBinding.inflate(
|
||||
inflater, parent, false
|
||||
)
|
||||
).apply {
|
||||
itemView.setOnClickListener {
|
||||
if (bindingAdapterPosition != RecyclerView.NO_POSITION) {
|
||||
val item = data[bindingAdapterPosition] as ObjectTypeView.Item
|
||||
onItemClick(item.id, item.name)
|
||||
}
|
||||
}
|
||||
val viewHolder: RecyclerView.ViewHolder = ObjectTypeHolder(
|
||||
binding = ItemObjectTypeItemBinding.inflate(
|
||||
inflater, parent, false
|
||||
)
|
||||
).apply {
|
||||
itemView.setOnClickListener {
|
||||
if (bindingAdapterPosition != RecyclerView.NO_POSITION) {
|
||||
val item = data[bindingAdapterPosition] as ObjectTypeView
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
when (holder) {
|
||||
is ObjectTypeHolder -> {
|
||||
holder.bind(data[position] as ObjectTypeView.Item)
|
||||
holder.bind(data[position] as ObjectTypeView)
|
||||
}
|
||||
is ObjectTypeHorizontalHolder -> {
|
||||
holder.bind(data[position] as ObjectTypeView.Item)
|
||||
holder.bind(data[position] as ObjectTypeView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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