From 5886fc1ae57152dc96e97c1f6ecba2294fc5d739 Mon Sep 17 00:00:00 2001 From: Evgenii Kozlov Date: Tue, 24 Oct 2023 12:41:32 +0200 Subject: [PATCH] DROID-1654 App | Feature | Multispaces + Misc. enhancements (#300) Co-authored-by: Konstantin Ivanov <54908981+konstantiniiv@users.noreply.github.com> --- app/gradle.properties | 2 +- .../features/auth/SetupSelectedAccountTest.kt | 8 - .../features/editor/base/EditorTestSetup.kt | 30 +- .../relations/AddRelationStatusValueTest.kt | 13 +- .../relations/AddRelationTagValueTest.kt | 13 +- .../features/sets/dv/TestObjectSetSetup.kt | 22 +- .../sets/filter/CreateSelectedFilterTest.kt | 15 +- .../sets/filter/ModifyInputValueFilterTest.kt | 15 +- .../sets/filter/ModifyStatusFilterTest.kt | 15 +- .../sets/filter/ModifyTagFilterTest.kt | 15 +- .../anytype/app/DefaultAppActionManager.kt | 7 +- .../anytype/app/DefaultFeatureToggles.kt | 3 +- .../anytype/di/common/ComponentManager.kt | 21 + .../feature/AddObjectRelationObjectValuDI.kt | 11 +- .../di/feature/AddObjectRelationValueDI.kt | 13 +- .../anytypeio/anytype/di/feature/AuthDI.kt | 5 - .../di/feature/BacklinkOrAddToObjectDI.kt | 2 + .../anytype/di/feature/CreateObjectDI.kt | 26 +- .../anytypeio/anytype/di/feature/EditorDI.kt | 35 +- .../anytype/di/feature/LinkToObjectDI.kt | 12 +- .../anytype/di/feature/LinkToObjectOrWebDi.kt | 6 +- .../anytype/di/feature/MainEntryDI.kt | 22 +- .../anytypeio/anytype/di/feature/MoveToDi.kt | 8 +- .../ObjectSetCreateBookmarkRecordDI.kt | 11 +- .../anytype/di/feature/ObjectSetDI.kt | 33 +- .../anytype/di/feature/ObjectTypeDI.kt | 27 +- .../anytype/di/feature/OtherSettingsDI.kt | 34 +- .../anytypeio/anytype/di/feature/SearchDI.kt | 8 +- .../anytypeio/anytype/di/feature/SplashDi.kt | 45 +- .../di/feature/auth/DeletedAccountDI.kt | 8 +- .../anytype/di/feature/home/HomescreenDI.kt | 20 +- .../anytype/di/feature/library/LibraryDI.kt | 41 +- .../signup/OnboardingSoulCreationDI.kt | 17 - .../onboarding/signup/OnboardingVoidDI.kt | 4 +- .../di/feature/relations/RelationAddDI.kt | 13 +- .../relations/RelationCreateFromLibraryDI.kt | 2 + .../relations/RelationCreateFromScratchDI.kt | 53 +- .../anytype/di/feature/sets/CreateFilter.kt | 6 +- .../anytype/di/feature/sets/ModifyFilter.kt | 6 +- .../di/feature/settings/FilesStorageDI.kt | 7 +- .../di/feature/settings/LogoutWarningDI.kt | 7 +- .../di/feature/settings/MainSettingsDi.kt | 15 +- .../anytype/di/feature/settings/ProfileDI.kt | 7 +- .../di/feature/spaces/CreateSpaceDI.kt | 56 + .../di/feature/spaces/SelectSpaceDI.kt | 72 + .../di/feature/spaces/SpaceSettingsDI.kt | 59 + .../di/feature/types/TypeCreationDI.kt | 2 + .../di/feature/wallpaper/WallpaperSelectDI.kt | 7 +- .../feature/widgets/SelectWidgetSourceDI.kt | 11 +- .../anytypeio/anytype/di/main/ConfigModule.kt | 11 +- .../anytype/di/main/MainComponent.kt | 23 +- .../anytype/di/main/SubscriptionsModule.kt | 11 +- .../anytype/di/main/TemplatesModule.kt | 8 +- .../anytype/di/main/WorkspaceModule.kt | 19 + .../anytypeio/anytype/navigation/Navigator.kt | 9 +- .../anytypeio/anytype/other/BasicLogger.kt | 2 +- .../anytype/ui/base/NavigationRouter.kt | 6 +- .../anytype/ui/editor/CreateObjectFragment.kt | 3 +- .../anytype/ui/editor/EditorFragment.kt | 16 +- .../anytype/ui/editor/EditorModalFragment.kt | 9 +- .../anytypeio/anytype/ui/home/HomeScreen.kt | 39 +- .../anytype/ui/home/HomeScreenFragment.kt | 8 +- .../ui/objects/ObjectTypeChangeFragment.kt | 5 +- .../pickers/AppDefaultObjectTypeFragment.kt | 6 +- .../pickers/DataViewSelectSourceFragment.kt | 3 +- .../pickers/DraftObjectSelectTypeFragment.kt | 8 +- .../EmptyDataViewSelectSourceFragment.kt | 3 +- .../types/pickers/ObjectSelectTypeFragment.kt | 5 +- .../types/pickers/OnObjectSelectTypeAction.kt | 5 +- .../anytype/ui/sets/ObjectSetFragment.kt | 30 +- .../sets/modals/EditDataViewViewerFragment.kt | 7 +- .../ui/settings/OtherSettingsFragment.kt | 5 +- .../anytype/ui/settings/ProfileFragment.kt | 7 + .../settings/space/SpaceSettingsFragment.kt | 244 +++ .../anytype/ui/spaces/CreateSpaceFragment.kt | 66 + .../anytype/ui/spaces/CreateSpaceScreen.kt | 279 ++++ .../anytype/ui/spaces/SelectSpaceFragment.kt | 99 ++ .../anytype/ui/spaces/SelectSpaceScreen.kt | 288 ++++ .../anytype/ui/splash/SplashFragment.kt | 37 +- .../ui/templates/EditorTemplateFragment.kt | 14 +- .../ui/widgets/collection/CollectionDI.kt | 26 +- .../ui/widgets/types/SpaceWidgetCard.kt | 76 + app/src/main/res/layout/fragment_splash.xml | 2 +- .../layout/fragment_viewer_relations_list.xml | 5 +- app/src/main/res/navigation/graph.xml | 20 +- app/src/main/res/values/strings.xml | 10 + .../anytypeio/anytype/core_models/Block.kt | 3 +- .../anytypeio/anytype/core_models/Command.kt | 8 +- .../anytypeio/anytype/core_models/Config.kt | 5 +- .../anytype/core_models/Constants.kt | 3 + .../anytype/core_models/ObjectType.kt | 8 +- .../anytype/core_models/ObjectTypeIds.kt | 10 +- .../anytype/core_models/ObjectWrapper.kt | 19 +- .../anytype/core_models/Relations.kt | 12 +- .../exceptions/CreateAccountException.kt | 1 + .../core_models/primitives/Primitives.kt | 22 + .../features/objects/ObjectTypeBaseAdapter.kt | 9 +- .../ObjectTypeHorizontalListAdapter.kt | 5 +- .../anytype/core_ui/foundation/Foundation.kt | 5 +- .../core_ui/widgets/TypeTemplatesWidget.kt | 313 ++-- .../widgets/dv/ViewerLayoutCoverWidget.kt | 9 +- .../core_ui/widgets/dv/ViewerLayoutWidget.kt | 96 +- .../core_ui/widgets/dv/ViewersWidget.kt | 4 +- .../widgets/toolbar/ObjectTypesWidget.kt | 9 +- core-ui/src/main/res/drawable/ic_plus_32.xml | 10 + .../main/res/drawable/ic_plus_32_white.xml | 10 + .../main/res/drawable/ic_space_settings.xml | 10 + .../res/drawable/ic_space_type_private.xml | 33 + .../drawable/rounded_dialog_select_spaces.xml | 8 + core-ui/src/main/res/values-night/colors.xml | 2 + core-ui/src/main/res/values/colors.xml | 3 + core-ui/src/main/res/values/styles.xml | 13 + .../core_utils/tools/FeatureToggles.kt | 1 + .../data/auth/repo/UserSettingsCache.kt | 13 +- .../auth/repo/UserSettingsDataRepository.kt | 28 +- .../auth/repo/block/BlockDataRepository.kt | 60 +- .../data/auth/repo/block/BlockRemote.kt | 25 +- .../data/auth/repo/config/GatewayProvider.kt | 15 +- docs/Setup_For_Middleware.md | 11 +- .../domain/auth/interactor/CreateAccount.kt | 3 - .../domain/auth/interactor/LaunchAccount.kt | 18 +- .../anytype/domain/auth/interactor/Logout.kt | 3 + .../domain/auth/interactor/ResumeAccount.kt | 3 - .../domain/auth/interactor/SelectAccount.kt | 3 - .../anytype/domain/base/Interactor.kt | 8 + .../anytypeio/anytype/domain/base/Resultat.kt | 2 +- .../anytypeio/anytype/domain/bin/EmptyBin.kt | 8 +- .../domain/block/interactor/SetObjectType.kt | 8 +- .../block/interactor/sets/CreateObjectSet.kt | 3 +- .../domain/block/repo/BlockRepository.kt | 23 +- .../domain/config/UserSettingsRepository.kt | 19 +- .../interactor/CreateDataViewObject.kt | 68 +- .../anytype/domain/debugging/Logger.kt | 2 +- .../domain/launch/GetDefaultPageType.kt | 133 +- .../domain/launch/SetDefaultEditorType.kt | 23 - .../domain/launch/SetDefaultObjectType.kt | 25 + .../anytype/domain/misc/AppActionManager.kt | 4 +- .../anytype/domain/object/SetObjectDetails.kt | 5 +- .../domain/object/SetupMobileUseCaseSkip.kt | 8 +- .../domain/objects/CreateBookmarkObject.kt | 15 +- .../domain/objects/SetObjectIsArchived.kt | 2 +- .../domain/objects/StoreOfObjectTypes.kt | 5 + .../domain/objects/options/GetOptions.kt | 17 +- .../domain/page/CreateBlockLinkWithObject.kt | 19 +- .../anytype/domain/page/CreateObject.kt | 26 +- .../page/CreateObjectAsMentionOrLink.kt | 24 +- .../domain/relations/CreateRelation.kt | 2 + .../domain/relations/CreateRelationOption.kt | 2 + .../search/ObjectTypesSubscriptionManager.kt | 25 +- .../search/RelationsSubscriptionManager.kt | 15 +- .../anytype/domain/spaces/AddObjectToSpace.kt | 28 + .../anytype/domain/spaces/CreateSpace.kt | 20 + .../anytype/domain/spaces/GetSpaceConfig.kt | 18 + .../anytype/domain/spaces/SaveCurrentSpace.kt | 19 + .../anytype/domain/spaces/SetSpaceDetails.kt | 23 + .../domain/templates/CreateTemplate.kt | 12 +- .../anytype/domain/templates/GetTemplates.kt | 12 +- .../anytype/domain/types/CreateType.kt | 19 +- .../domain/wallpaper/ObserveWallpaper.kt | 2 +- .../domain/wallpaper/RestoreWallpaper.kt | 32 +- .../anytype/domain/wallpaper/SetWallpaper.kt | 11 +- .../domain/workspace/AddObjectToWorkspace.kt | 11 +- .../domain/workspace/FileSpaceUsage.kt | 4 +- .../domain/workspace/WorkspaceManager.kt | 85 + .../anytype/domain/auth/CreateAccountTest.kt | 26 - .../anytype/domain/auth/ResumeAccountTest.kt | 42 - .../anytype/domain/auth/StartAccountTest.kt | 41 - .../page/CreateBlockLinkWithObjectTest.kt | 38 +- .../page/CreateObjectAsMentionOrLinkTest.kt | 88 +- .../anytype/domain/page/CreateObjectTest.kt | 85 +- gradle/libs.versions.toml | 2 +- libs/build.gradle | 2 +- .../anytype/middleware/auth/AuthMappers.kt | 16 +- .../middleware/block/BlockMiddleware.kt | 67 +- .../middleware/interactor/Middleware.kt | 116 +- .../middleware/mappers/ToCoreModelMappers.kt | 24 +- .../mappers/ToMiddlewareModelMappers.kt | 7 + .../middleware/service/MiddlewareService.kt | 14 + .../MiddlewareServiceImplementation.kt | 63 + .../com/anytypeio/anytype/MiddlewareTest.kt | 17 +- persistence/build.gradle | 1 + .../anytype/persistence/common/Converters.kt | 20 + .../persistence/model/WallpaperSetting.kt | 65 + .../repo/DefaultUserSettingsCache.kt | 147 +- .../anytype/persistence/SerializationTest.kt | 38 + .../persistence/UserSettingsCacheTest.kt | 264 +++ .../auth/account/SetupNewAccountViewModel.kt | 5 +- .../presentation/editor/EditorViewModel.kt | 135 +- .../editor/EditorViewModelFactory.kt | 6 +- .../presentation/editor/editor/Intent.kt | 2 + .../editor/editor/Orchestrator.kt | 2 +- .../editor/template/EditorTemplateDelegate.kt | 4 +- .../presentation/extension/AnalyticsExt.kt | 2 + .../presentation/home/HomeScreenViewModel.kt | 507 +++--- .../presentation/library/LibraryViewModel.kt | 19 +- .../delegates/LibraryRelationsDelegate.kt | 4 +- .../library/delegates/LibraryTypesDelegate.kt | 14 +- .../library/delegates/MyRelationsDelegate.kt | 16 +- .../library/delegates/MyTypesDelegate.kt | 24 +- .../linking/BackLinkOrAddToObjectViewModel.kt | 8 +- .../linking/LinkToObjectOrWebViewModel.kt | 6 +- .../linking/LinkToObjectViewModel.kt | 8 +- .../linking/LinkToObjectViewModelFactory.kt | 20 +- .../presentation/main/MainViewModel.kt | 8 +- .../presentation/mapper/MapperExtension.kt | 11 +- .../presentation/moving/MoveToViewModel.kt | 8 +- .../moving/MoveToViewModelFactory.kt | 8 +- .../presentation/navigation/AppNavigation.kt | 6 +- .../objects/CreateObjectViewModel.kt | 8 +- .../presentation/objects/ObjectIcon.kt | 2 +- .../objects/ObjectTypeChangeViewModel.kt | 66 +- .../ObjectTypeChangeViewModelFactory.kt | 12 +- .../objects/ObjectTypeExtensions.kt | 2 +- .../presentation/objects/ObjectTypeView.kt | 28 +- .../objects/ObjectWrapperMapper.kt | 92 +- .../menu/ObjectMenuOptionsProviderImpl.kt | 1 + .../OnboardingSoulCreationAnimViewModel.kt | 2 +- .../signup/OnboardingSoulCreationViewModel.kt | 11 +- .../signup/OnboardingVoidViewModel.kt | 11 +- .../presentation/profile/ProfileIconView.kt | 18 +- .../RelationAddToDataViewViewModel.kt | 10 +- .../relations/RelationAddToObjectViewModel.kt | 11 +- .../relations/RelationAddViewModelBase.kt | 23 +- .../RelationCreateFromLibraryViewModel.kt | 5 + .../RelationCreateFromScratchBaseViewModel.kt | 25 +- .../add/AddObjectRelationViewModel.kt | 31 +- .../add/AddOptionsRelationDVViewModel.kt | 14 +- .../add/AddOptionsRelationViewModel.kt | 14 +- .../add/BaseAddOptionsRelationViewModel.kt | 10 +- .../relations/model/RelationView.kt | 2 +- .../search/ObjectSearchConstants.kt | 313 ++-- .../search/ObjectSearchViewModel.kt | 8 +- .../search/ObjectSearchViewModelFactory.kt | 8 +- .../sets/EditDataViewViewerViewModel.kt | 2 + .../ObjectSetCreateBookmarkRecordViewModel.kt | 16 +- .../presentation/sets/ObjectSetExtension.kt | 25 +- .../presentation/sets/ObjectSetViewModel.kt | 232 ++- .../sets/ObjectSetViewModelFactory.kt | 10 +- .../presentation/sets/ViewerEditWidgetUi.kt | 3 +- .../sets/filter/FilterViewModel.kt | 18 +- .../sets/subscription/DataViewSubscription.kt | 14 +- .../settings/FilesStorageViewModel.kt | 2 +- .../settings/MainSettingsViewModel.kt | 133 +- .../settings/OtherSettingsViewModel.kt | 50 +- .../spaces/CreateSpaceViewModel.kt | 113 ++ .../spaces/SelectSpaceViewModel.kt | 276 ++++ .../spaces/SpaceSettingsViewModel.kt | 141 ++ .../presentation/splash/SplashViewModel.kt | 31 +- .../templates/ObjectTypeTemplatesContainer.kt | 27 +- .../templates/TemplateSelectViewModel.kt | 5 +- .../presentation/templates/TemplateView.kt | 15 +- .../types/TypeCreationViewModel.kt | 11 +- .../wallpaper/WallpaperSelectViewModel.kt | 16 +- .../widgets/DataViewListWidgetContainer.kt | 4 +- .../widgets/ListWidgetContainer.kt | 19 +- .../widgets/SelectWidgetSourceViewModel.kt | 16 +- .../widgets/SpaceWidgetContainer.kt | 56 + .../widgets/TreeWidgetContainer.kt | 4 +- .../widgets/TypeTemplatesWidgetUI.kt | 7 +- .../presentation/widgets/WidgetView.kt | 12 + .../widgets/collection/CollectionViewModel.kt | 54 +- .../widgets/collection/Subscription.kt | 18 +- .../anytype/presentation/MockObjectTypes.kt | 64 +- .../MockTypicalDocumentFactory.kt | 14 - .../auth/ChoosePinCodeViewModelTest.kt | 76 - .../auth/DeleteAccountViewModelTest.kt | 7 +- .../auth/SetupSelectedAccountViewModelTest.kt | 9 - .../collections/CollectionAddRelationTest.kt | 11 +- .../CollectionDataViewUpdateTest.kt | 6 +- .../collections/MockCollection.kt | 2 +- .../presentation/collections/MockSet.kt | 18 +- .../collections/ObjectCreateTest.kt | 362 +++-- .../ObjectStateCollectionViewTest.kt | 99 +- .../collections/ObjectStateSetViewTest.kt | 76 +- .../editor/EditorViewModelTest.kt | 59 +- .../editor/editor/EditorMarkupObjectTest.kt | 10 +- .../editor/editor/EditorMentionTest.kt | 68 +- .../EditorObjectTypeChangeWidgetTest.kt | 1 + .../editor/EditorPresentationTestSetup.kt | 43 +- .../editor/EditorSlashWidgetClicksTest.kt | 6 +- .../editor/EditorSlashWidgetFilterTest.kt | 15 +- .../editor/EditorSlashWidgetObjectTypeTest.kt | 30 +- .../home/HomeScreenViewModelTest.kt | 877 +++++----- .../home/TreeWidgetContainerTest.kt | 12 +- .../linking/LinkToObjectOrWebViewModelTest.kt | 33 +- .../objects/ObjectTypeExtensionsKtTest.kt | 14 +- .../BaseAddOptionsRelationViewModelTest.kt | 19 +- .../relations/RelationAddViewModelBaseTest.kt | 66 +- .../presentation/sets/ObjectSetReducerTest.kt | 5 +- .../sets/ViewerDefaultObjectTypeTest.kt | 40 +- ...ilterViewModelInputFieldValueCreateTest.kt | 15 +- ...ilterViewModelInputFieldValueModifyTest.kt | 15 +- .../sets/main/ObjectSetCellTest.kt | 4 +- .../main/ObjectSetConvertToCollectionTest.kt | 6 +- .../main/ObjectSetDataViewObjectCreateTest.kt | 9 +- .../sets/main/ObjectSetHeaderTest.kt | 8 +- .../sets/main/ObjectSetInitializationTest.kt | 23 +- .../sets/main/ObjectSetNavigationTest.kt | 16 +- .../sets/main/ObjectSetRestrictionsTest.kt | 20 +- .../sets/main/ObjectSetViewModelTestSetup.kt | 69 +- .../sets/main/SetByRelationTest.kt | 10 +- .../splash/SplashViewModelTest.kt | 4 +- .../CollectionViewerTypeAndTemplateTest.kt | 104 +- .../SetByRelationViewerTypeAndTemplateTest.kt | 107 +- .../SetByTypeViewerTypeAndTemplateTest.kt | 72 +- .../types/ObjectTypeChangeViewModelTest.kt | 111 +- protocol/src/main/proto/changes.proto | 36 +- protocol/src/main/proto/commands.proto | 215 ++- protocol/src/main/proto/events.proto | 2 +- protocol/src/main/proto/localstore.proto | 1 - protocol/src/main/proto/models.proto | 1446 +++++++++-------- .../com/anytypeio/anytype/core_models/Auth.kt | 6 +- .../anytypeio/anytype/core_models/Object.kt | 8 +- .../anytypeio/anytype/core_models/Relation.kt | 6 +- .../ui_settings/account/ProfileViewModel.kt | 9 +- .../ui_settings/main/MainSettingScreen.kt | 42 +- .../anytype/ui_settings/main/Views.kt | 17 +- .../ui_settings/space/SpaceSettingsScreen.kt | 65 + ui-settings/src/main/res/values/strings.xml | 1 + 319 files changed, 8198 insertions(+), 4258 deletions(-) create mode 100644 app/src/main/java/com/anytypeio/anytype/di/feature/spaces/CreateSpaceDI.kt create mode 100644 app/src/main/java/com/anytypeio/anytype/di/feature/spaces/SelectSpaceDI.kt create mode 100644 app/src/main/java/com/anytypeio/anytype/di/feature/spaces/SpaceSettingsDI.kt create mode 100644 app/src/main/java/com/anytypeio/anytype/ui/settings/space/SpaceSettingsFragment.kt create mode 100644 app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceFragment.kt create mode 100644 app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceScreen.kt create mode 100644 app/src/main/java/com/anytypeio/anytype/ui/spaces/SelectSpaceFragment.kt create mode 100644 app/src/main/java/com/anytypeio/anytype/ui/spaces/SelectSpaceScreen.kt create mode 100644 app/src/main/java/com/anytypeio/anytype/ui/widgets/types/SpaceWidgetCard.kt create mode 100644 core-models/src/main/java/com/anytypeio/anytype/core_models/Constants.kt create mode 100644 core-models/src/main/java/com/anytypeio/anytype/core_models/primitives/Primitives.kt create mode 100644 core-ui/src/main/res/drawable/ic_plus_32.xml create mode 100644 core-ui/src/main/res/drawable/ic_plus_32_white.xml create mode 100644 core-ui/src/main/res/drawable/ic_space_settings.xml create mode 100644 core-ui/src/main/res/drawable/ic_space_type_private.xml create mode 100644 core-ui/src/main/res/drawable/rounded_dialog_select_spaces.xml delete mode 100644 domain/src/main/java/com/anytypeio/anytype/domain/launch/SetDefaultEditorType.kt create mode 100644 domain/src/main/java/com/anytypeio/anytype/domain/launch/SetDefaultObjectType.kt create mode 100644 domain/src/main/java/com/anytypeio/anytype/domain/spaces/AddObjectToSpace.kt create mode 100644 domain/src/main/java/com/anytypeio/anytype/domain/spaces/CreateSpace.kt create mode 100644 domain/src/main/java/com/anytypeio/anytype/domain/spaces/GetSpaceConfig.kt create mode 100644 domain/src/main/java/com/anytypeio/anytype/domain/spaces/SaveCurrentSpace.kt create mode 100644 domain/src/main/java/com/anytypeio/anytype/domain/spaces/SetSpaceDetails.kt create mode 100644 persistence/src/main/java/com/anytypeio/anytype/persistence/model/WallpaperSetting.kt create mode 100644 persistence/src/test/java/com/anytypeio/anytype/persistence/SerializationTest.kt create mode 100644 persistence/src/test/java/com/anytypeio/anytype/persistence/UserSettingsCacheTest.kt create mode 100644 presentation/src/main/java/com/anytypeio/anytype/presentation/spaces/CreateSpaceViewModel.kt create mode 100644 presentation/src/main/java/com/anytypeio/anytype/presentation/spaces/SelectSpaceViewModel.kt create mode 100644 presentation/src/main/java/com/anytypeio/anytype/presentation/spaces/SpaceSettingsViewModel.kt create mode 100644 presentation/src/main/java/com/anytypeio/anytype/presentation/widgets/SpaceWidgetContainer.kt delete mode 100644 presentation/src/test/java/com/anytypeio/anytype/presentation/auth/ChoosePinCodeViewModelTest.kt create mode 100644 ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/space/SpaceSettingsScreen.kt diff --git a/app/gradle.properties b/app/gradle.properties index 4f854fbf2d..9707f5ded4 100644 --- a/app/gradle.properties +++ b/app/gradle.properties @@ -1,4 +1,4 @@ version.versionMajor=0 version.versionMinor=26 version.versionPatch=0 -version.useDatedVersionName=false +version.useDatedVersionName=false \ No newline at end of file diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/auth/SetupSelectedAccountTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/auth/SetupSelectedAccountTest.kt index 6b241e5e54..cc2545dad5 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/auth/SetupSelectedAccountTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/auth/SetupSelectedAccountTest.kt @@ -18,7 +18,6 @@ import com.anytypeio.anytype.domain.device.PathProvider import com.anytypeio.anytype.domain.platform.MetricsProvider import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager -import com.anytypeio.anytype.domain.workspace.WorkspaceManager import com.anytypeio.anytype.features.auth.fragments.TestSetupSelectedAccountFragment import com.anytypeio.anytype.presentation.auth.account.SetupSelectedAccountViewModel import com.anytypeio.anytype.presentation.auth.account.SetupSelectedAccountViewModelFactory @@ -72,9 +71,6 @@ class SetupSelectedAccountTest { @Mock lateinit var configStorage: ConfigStorage - @Mock - lateinit var workspaceManager: WorkspaceManager - @Mock private lateinit var relationsSubscriptionManager: RelationsSubscriptionManager @@ -87,9 +83,6 @@ class SetupSelectedAccountTest { @Mock private lateinit var metricsProvider: MetricsProvider - @Mock - private lateinit var config: ConfigStorage - @Before fun setup() { MockitoAnnotations.openMocks(this) @@ -97,7 +90,6 @@ class SetupSelectedAccountTest { repository = authRepository, featuresConfigProvider = featuresConfigProvider, configStorage = configStorage, - workspaceManager = workspaceManager, metricsProvider = metricsProvider ) TestSetupSelectedAccountFragment.testViewModelFactory = diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/base/EditorTestSetup.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/base/EditorTestSetup.kt index 5a23ebc672..6f74165bc3 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/editor/base/EditorTestSetup.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/editor/base/EditorTestSetup.kt @@ -48,6 +48,7 @@ import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.clipboard.Clipboard import com.anytypeio.anytype.domain.clipboard.Copy import com.anytypeio.anytype.domain.clipboard.Paste +import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.Gateway import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.cover.RemoveDocCover @@ -89,6 +90,7 @@ import com.anytypeio.anytype.domain.unsplash.DownloadUnsplashImage import com.anytypeio.anytype.domain.unsplash.UnsplashRepository import com.anytypeio.anytype.domain.workspace.FileLimitsEventChannel import com.anytypeio.anytype.domain.workspace.InterceptFileLimitEvents +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.domain.workspace.WorkspaceManager import com.anytypeio.anytype.presentation.common.Delegator import com.anytypeio.anytype.presentation.editor.DocumentExternalEventReducer @@ -273,6 +275,12 @@ open class EditorTestSetup { @Mock lateinit var setObjectInternalFlags: SetObjectInternalFlags + @Mock + lateinit var spaceManager: SpaceManager + + @Mock + lateinit var configStorage: ConfigStorage + lateinit var interceptFileLimitEvents: InterceptFileLimitEvents lateinit var addRelationToObject: AddRelationToObject @@ -319,8 +327,13 @@ open class EditorTestSetup { turnIntoDocument = TurnIntoDocument(repo) updateFields = UpdateFields(repo) setObjectType = SetObjectType(repo) - createObjectAsMentionOrLink = - CreateObjectAsMentionOrLink(repo, getDefaultPageType, getTemplates, dispatchers) + createObjectAsMentionOrLink = CreateObjectAsMentionOrLink( + repo = repo, + getDefaultPageType = getDefaultPageType, + getTemplates = getTemplates, + dispatchers = dispatchers, + spaceManager = spaceManager + ) getSearchObjects = SearchObjects(repo) interceptThreadStatus = InterceptThreadStatus(channel = threadStatusChannel) downloadUnsplashImage = DownloadUnsplashImage(unsplashRepository) @@ -351,10 +364,11 @@ open class EditorTestSetup { turnIntoStyle = TurnIntoStyle(repo) updateDetail = UpdateDetail(repo) getDefaultPageType = GetDefaultPageType( - userSettingsRepository, - repo, - workspaceManager, - dispatchers + userSettingsRepository = userSettingsRepository, + blockRepository = repo, + dispatchers = dispatchers, + spaceManager = spaceManager, + configStorage = configStorage ) createObjectSet = CreateObjectSet(repo) findObjectSetForType = FindObjectSetForType(repo) @@ -466,12 +480,12 @@ open class EditorTestSetup { storeOfObjectTypes = storeOfObjectTypes, featureToggles = featureToggles, tableDelegate = tableDelegate, - workspaceManager = workspaceManager, getObjectTypes = getObjectTypes, objectToCollection = objectToCollection, interceptFileLimitEvents = interceptFileLimitEvents, addRelationToObject = addRelationToObject, - setObjectInternalFlags = setObjectInternalFlags + setObjectInternalFlags = setObjectInternalFlags, + spaceManager = spaceManager ) } diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationStatusValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationStatusValueTest.kt index c60ce39095..0d188f8cb1 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationStatusValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationStatusValueTest.kt @@ -26,6 +26,7 @@ import com.anytypeio.anytype.domain.objects.ObjectStore 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.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.relations.ObjectSetConfig import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider @@ -81,6 +82,9 @@ class AddRelationStatusValueTest { @Mock lateinit var objectDetailProvider: ObjectDetailProvider + @Mock + lateinit var spaceManager: SpaceManager + private lateinit var createRelationOption: CreateRelationOption private lateinit var updateDetail: UpdateDetail private lateinit var getOptions: GetOptions @@ -120,7 +124,8 @@ class AddRelationStatusValueTest { analytics = analytics, createRelationOption = createRelationOption, detailsProvider = objectDetailProvider, - getOptions = getOptions + getOptions = getOptions, + spaceManager = spaceManager ) } @@ -541,7 +546,8 @@ class AddRelationStatusValueTest { createRelationOption( relation = any(), color = any(), - name = any() + name = any(), + space = any() ) } } @@ -557,7 +563,8 @@ class AddRelationStatusValueTest { createRelationOption( relation = relation, color = color, - name = name + name = name, + space = any() ) } doReturn StubRelationOptionObject( id = id, diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationTagValueTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationTagValueTest.kt index 4df855875c..ed9c809e1b 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationTagValueTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/relations/AddRelationTagValueTest.kt @@ -25,6 +25,7 @@ import com.anytypeio.anytype.domain.objects.ObjectStore 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.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.relations.ObjectSetConfig import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider @@ -79,6 +80,9 @@ class AddRelationTagValueTest { @Mock lateinit var objectDetailProvider: ObjectDetailProvider + @Mock + lateinit var spaceManager: SpaceManager + private lateinit var createRelationOption: CreateRelationOption private lateinit var updateDetail: UpdateDetail private lateinit var getOptions: GetOptions @@ -115,7 +119,8 @@ class AddRelationTagValueTest { analytics = analytics, setObjectDetail = updateDetail, detailsProvider = objectDetailProvider, - getOptions = getOptions + getOptions = getOptions, + spaceManager = spaceManager ) } @@ -491,7 +496,8 @@ class AddRelationTagValueTest { createRelationOption( relation = any(), color = any(), - name = any() + name = any(), + space = any() ) } } @@ -506,7 +512,8 @@ class AddRelationTagValueTest { createRelationOption( relation = any(), color = any(), - name = any() + name = any(), + space = any() ) } doReturn StubRelationOptionObject( id = id, diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/TestObjectSetSetup.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/TestObjectSetSetup.kt index dbe0e32286..75434d125a 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/TestObjectSetSetup.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/dv/TestObjectSetSetup.kt @@ -18,6 +18,7 @@ import com.anytypeio.anytype.domain.base.Result import com.anytypeio.anytype.domain.block.interactor.UpdateText import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.collections.AddObjectToCollection +import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.Gateway import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.cover.SetDocCoverImage @@ -49,6 +50,7 @@ import com.anytypeio.anytype.domain.templates.CreateTemplate import com.anytypeio.anytype.domain.templates.GetTemplates import com.anytypeio.anytype.domain.unsplash.DownloadUnsplashImage import com.anytypeio.anytype.domain.unsplash.UnsplashRepository +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.domain.workspace.WorkspaceManager import com.anytypeio.anytype.emojifier.data.DefaultDocumentEmojiIconProvider import com.anytypeio.anytype.presentation.common.Action @@ -144,6 +146,12 @@ abstract class TestObjectSetSetup { @Mock lateinit var viewerDelegate: ViewerDelegate + @Mock + lateinit var spaceManager: SpaceManager + + @Mock + lateinit var configStorage: ConfigStorage + @Mock lateinit var createTemplate: CreateTemplate @@ -155,7 +163,6 @@ abstract class TestObjectSetSetup { private val paginator = ObjectSetPaginator() private val store: ObjectStore = DefaultObjectStore() private val storeOfRelations: StoreOfRelations = DefaultStoreOfRelations() - private val workspaceManager: WorkspaceManager = WorkspaceManager.DefaultWorkspaceManager() private lateinit var database: ObjectSetDatabase private lateinit var dataViewSubscriptionContainer: DataViewSubscriptionContainer @@ -199,19 +206,18 @@ abstract class TestObjectSetSetup { setDataViewQuery = SetDataViewQuery(repo) updateText = UpdateText(repo) openObjectSet = OpenObjectSet(repo, auth) - runBlocking { - workspaceManager.setCurrentWorkspace(workspaceId) - } getDefaultPageType = GetDefaultPageType( userSettingsRepository = userSettingsRepository, blockRepository = repo, - workspaceManager = workspaceManager, - dispatchers = dispatchers + spaceManager = spaceManager, + dispatchers = dispatchers, + configStorage = configStorage ) createDataViewObject = CreateDataViewObject( repo = repo, storeOfRelations = storeOfRelations, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) setObjectDetails = UpdateDetail(repo) updateDataViewViewer = UpdateDataViewViewer(repo, dispatchers) @@ -255,7 +261,6 @@ abstract class TestObjectSetSetup { storeOfRelations = storeOfRelations, objectStateReducer = DefaultObjectStateReducer(), dataViewSubscription = DefaultDataViewSubscription(dataViewSubscriptionContainer), - workspaceManager = workspaceManager, objectToCollection = convertObjectToCollection, setQueryToObjectSet = setQueryToObjectSet, objectStore = objectStore, @@ -267,6 +272,7 @@ abstract class TestObjectSetSetup { setObjectListIsArchived = setObjectListIsArchived, duplicateObjects = duplicateObjects, viewerDelegate = viewerDelegate, + spaceManager = spaceManager, createTemplate = createTemplate ) } diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/CreateSelectedFilterTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/CreateSelectedFilterTest.kt index a48a3db8eb..63b7a4b4d1 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/CreateSelectedFilterTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/CreateSelectedFilterTest.kt @@ -26,7 +26,7 @@ import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel import com.anytypeio.anytype.presentation.sets.state.ObjectState @@ -41,7 +41,6 @@ import com.anytypeio.anytype.ui.sets.modals.filter.CreateFilterFromSelectedValue import com.anytypeio.anytype.utils.CoroutinesTestRule import com.bartoszlipinski.disableanimationsrule.DisableAnimationsRule import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.runBlocking import org.junit.Before import org.junit.Rule import org.junit.Test @@ -68,6 +67,9 @@ class CreateSelectedFilterTest { @Mock lateinit var analytics: Analytics + @Mock + lateinit var spaceManager: SpaceManager + @Mock lateinit var dispatchers: AppCoroutineDispatchers @@ -84,9 +86,6 @@ class CreateSelectedFilterTest { private val objectStore: ObjectStore = DefaultObjectStore() private val db = ObjectSetDatabase(store = objectStore) - lateinit var workspaceManager: WorkspaceManager - val workspaceId = MockDataFactory.randomString() - @Before fun setup() { MockitoAnnotations.openMocks(this) @@ -94,10 +93,6 @@ class CreateSelectedFilterTest { searchObjects = SearchObjects(repo) getOptions = GetOptions(repo) urlBuilder = UrlBuilder(gateway) - workspaceManager = WorkspaceManager.DefaultWorkspaceManager() - runBlocking { - workspaceManager.setCurrentWorkspace(workspaceId) - } TestCreateSelectedFilterFragment.testVmFactory = FilterViewModel.Factory( updateDataViewViewer = updateDataViewViewer, dispatcher = dispatcher, @@ -109,7 +104,7 @@ class CreateSelectedFilterTest { storeOfRelations = storeOfRelations, objectSetDatabase = db, getOptions = getOptions, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyInputValueFilterTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyInputValueFilterTest.kt index 70f80bcd8e..e43474d80d 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyInputValueFilterTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyInputValueFilterTest.kt @@ -34,7 +34,7 @@ import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel import com.anytypeio.anytype.presentation.sets.state.ObjectState @@ -44,7 +44,6 @@ import com.anytypeio.anytype.ui.sets.modals.filter.ModifyFilterFromInputFieldVal import com.anytypeio.anytype.utils.CoroutinesTestRule import com.bartoszlipinski.disableanimationsrule.DisableAnimationsRule import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.runBlocking import org.junit.Before import org.junit.Rule import org.junit.Test @@ -76,6 +75,9 @@ class ModifyInputValueFilterTest { @Mock lateinit var dispatchers: AppCoroutineDispatchers + @Mock + lateinit var spaceManager: SpaceManager + private lateinit var updateDataViewViewer: UpdateDataViewViewer private lateinit var searchObjects: SearchObjects private lateinit var getOptions: GetOptions @@ -89,19 +91,12 @@ class ModifyInputValueFilterTest { private val objectStore: ObjectStore = DefaultObjectStore() private val db = ObjectSetDatabase(store = objectStore) - lateinit var workspaceManager: WorkspaceManager - val workspaceId = MockDataFactory.randomString() - @Before fun setup() { MockitoAnnotations.openMocks(this) updateDataViewViewer = UpdateDataViewViewer(repo, dispatchers) searchObjects = SearchObjects(repo) urlBuilder = UrlBuilder(gateway) - workspaceManager = WorkspaceManager.DefaultWorkspaceManager() - runBlocking { - workspaceManager.setCurrentWorkspace(workspaceId) - } TestModifyFilterFromInputFieldValueFragment.testVmFactory = FilterViewModel.Factory( objectState = state, updateDataViewViewer = updateDataViewViewer, @@ -113,7 +108,7 @@ class ModifyInputValueFilterTest { storeOfRelations = storeOfRelations, objectSetDatabase = db, getOptions = getOptions, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyStatusFilterTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyStatusFilterTest.kt index b0ff660107..bc577e1ca6 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyStatusFilterTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyStatusFilterTest.kt @@ -32,7 +32,7 @@ import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel import com.anytypeio.anytype.presentation.sets.state.ObjectState @@ -43,7 +43,6 @@ import com.anytypeio.anytype.ui.sets.modals.filter.ModifyFilterFromSelectedValue import com.anytypeio.anytype.utils.CoroutinesTestRule import com.bartoszlipinski.disableanimationsrule.DisableAnimationsRule import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.runBlocking import org.hamcrest.CoreMatchers.not import org.junit.Before import org.junit.Rule @@ -75,6 +74,9 @@ class ModifyStatusFilterTest { @Mock lateinit var analytics: Analytics + @Mock + lateinit var spaceManager: SpaceManager + private lateinit var updateDataViewViewer: UpdateDataViewViewer private lateinit var searchObjects: SearchObjects private lateinit var getOptions: GetOptions @@ -88,9 +90,6 @@ class ModifyStatusFilterTest { private val objectStore: ObjectStore = DefaultObjectStore() private val db = ObjectSetDatabase(store = objectStore) - lateinit var workspaceManager: WorkspaceManager - val workspaceId = MockDataFactory.randomString() - @Before fun setup() { MockitoAnnotations.openMocks(this) @@ -98,10 +97,6 @@ class ModifyStatusFilterTest { searchObjects = SearchObjects(repo) getOptions = GetOptions(repo) urlBuilder = UrlBuilder(gateway) - workspaceManager = WorkspaceManager.DefaultWorkspaceManager() - runBlocking { - workspaceManager.setCurrentWorkspace(workspaceId) - } TestModifyFilterFromSelectedValueFragment.testVmFactory = FilterViewModel.Factory( objectState = state, updateDataViewViewer = updateDataViewViewer, @@ -113,7 +108,7 @@ class ModifyStatusFilterTest { analytics = analytics, storeOfRelations = storeOfRelations, objectSetDatabase = db, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } diff --git a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyTagFilterTest.kt b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyTagFilterTest.kt index 59d9fb5c41..bf01326f99 100644 --- a/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyTagFilterTest.kt +++ b/app/src/androidTest/java/com/anytypeio/anytype/features/sets/filter/ModifyTagFilterTest.kt @@ -32,7 +32,7 @@ import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel import com.anytypeio.anytype.presentation.sets.state.ObjectState @@ -43,7 +43,6 @@ import com.anytypeio.anytype.ui.sets.modals.filter.ModifyFilterFromSelectedValue import com.anytypeio.anytype.utils.CoroutinesTestRule import com.bartoszlipinski.disableanimationsrule.DisableAnimationsRule import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.runBlocking import org.hamcrest.CoreMatchers.not import org.junit.Before import org.junit.Rule @@ -74,6 +73,9 @@ class ModifyTagFilterTest { @Mock lateinit var analytics: Analytics + @Mock + lateinit var spaceManager: SpaceManager + private lateinit var updateDataViewViewer: UpdateDataViewViewer private lateinit var searchObjects: SearchObjects private lateinit var getOptions: GetOptions @@ -87,9 +89,6 @@ class ModifyTagFilterTest { private val objectStore: ObjectStore = DefaultObjectStore() private val db = ObjectSetDatabase(store = objectStore) - lateinit var workspaceManager: WorkspaceManager - val workspaceId = MockDataFactory.randomString() - @Before fun setup() { MockitoAnnotations.openMocks(this) @@ -97,10 +96,6 @@ class ModifyTagFilterTest { searchObjects = SearchObjects(repo) getOptions = GetOptions(repo) urlBuilder = UrlBuilder(gateway) - workspaceManager = WorkspaceManager.DefaultWorkspaceManager() - runBlocking { - workspaceManager.setCurrentWorkspace(workspaceId) - } TestModifyFilterFromSelectedValueFragment.testVmFactory = FilterViewModel.Factory( objectState = state, updateDataViewViewer = updateDataViewViewer, @@ -112,7 +107,7 @@ class ModifyTagFilterTest { storeOfRelations = storeOfRelations, objectSetDatabase = db, getOptions = getOptions, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } diff --git a/app/src/main/java/com/anytypeio/anytype/app/DefaultAppActionManager.kt b/app/src/main/java/com/anytypeio/anytype/app/DefaultAppActionManager.kt index 3ac288be67..08120adb86 100644 --- a/app/src/main/java/com/anytypeio/anytype/app/DefaultAppActionManager.kt +++ b/app/src/main/java/com/anytypeio/anytype/app/DefaultAppActionManager.kt @@ -20,7 +20,10 @@ class DefaultAppActionManager(val context: Context) : AppActionManager { try { when (action) { is AppActionManager.Action.CreateNew -> { - val label = context.resources.getString(R.string.shortcut_create_new, action.name) + val name = action.name.ifEmpty { + context.resources.getString(R.string.unknown_type) + } + val label = context.resources.getString(R.string.shortcut_create_new, name) val shortcut = ShortcutInfoCompat.Builder(context, ACTION_CREATE_NEW_ID) .setShortLabel(label) .setLongLabel(label) @@ -28,7 +31,7 @@ class DefaultAppActionManager(val context: Context) : AppActionManager { .setIntent( Intent(Intent.ACTION_VIEW, null).apply { setClass(context, MainActivity::class.java) - putExtra(ACTION_CREATE_NEW_TYPE_KEY, action.type) + putExtra(ACTION_CREATE_NEW_TYPE_KEY, action.type.key) } ) .build() diff --git a/app/src/main/java/com/anytypeio/anytype/app/DefaultFeatureToggles.kt b/app/src/main/java/com/anytypeio/anytype/app/DefaultFeatureToggles.kt index b2d52b743d..96f46b1923 100644 --- a/app/src/main/java/com/anytypeio/anytype/app/DefaultFeatureToggles.kt +++ b/app/src/main/java/com/anytypeio/anytype/app/DefaultFeatureToggles.kt @@ -3,7 +3,6 @@ package com.anytypeio.anytype.app import android.content.Context import android.content.SharedPreferences import com.anytypeio.anytype.BuildConfig -import com.anytypeio.anytype.R import com.anytypeio.anytype.core_utils.tools.FeatureToggles import com.anytypeio.anytype.device.BuildProvider import javax.inject.Inject @@ -33,4 +32,6 @@ class DefaultFeatureToggles @Inject constructor( override val isAutoUpdateEnabled: Boolean = false override val isConciseLogging: Boolean = true + + override val enableSpaces: Boolean = true } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/common/ComponentManager.kt b/app/src/main/java/com/anytypeio/anytype/di/common/ComponentManager.kt index 14b1df80b4..235e145c87 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/common/ComponentManager.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/common/ComponentManager.kt @@ -92,6 +92,9 @@ import com.anytypeio.anytype.di.feature.settings.DaggerFilesStorageComponent import com.anytypeio.anytype.di.feature.settings.LogoutWarningModule import com.anytypeio.anytype.di.feature.settings.MainSettingsModule import com.anytypeio.anytype.di.feature.settings.ProfileModule +import com.anytypeio.anytype.di.feature.spaces.DaggerCreateSpaceComponent +import com.anytypeio.anytype.di.feature.spaces.DaggerSelectSpaceComponent +import com.anytypeio.anytype.di.feature.spaces.DaggerSpaceSettingsComponent import com.anytypeio.anytype.di.feature.templates.DaggerTemplateBlankComponent import com.anytypeio.anytype.di.feature.templates.DaggerTemplateSelectComponent import com.anytypeio.anytype.di.feature.types.DaggerTypeCreationComponent @@ -961,6 +964,24 @@ class ComponentManager( .create(findComponentDependencies()) } + val selectSpaceComponent = Component { + DaggerSelectSpaceComponent + .factory() + .create(findComponentDependencies()) + } + + val createSpaceComponent = Component { + DaggerCreateSpaceComponent + .factory() + .create(findComponentDependencies()) + } + + val spaceSettingsComponent = Component { + DaggerSpaceSettingsComponent + .factory() + .create(findComponentDependencies()) + } + class Component(private val builder: () -> T) { private var instance: T? = null diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/AddObjectRelationObjectValuDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/AddObjectRelationObjectValuDI.kt index cabe9da441..0de662c74f 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/AddObjectRelationObjectValuDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/AddObjectRelationObjectValuDI.kt @@ -4,7 +4,7 @@ import com.anytypeio.anytype.core_utils.di.scope.PerDialog 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.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.relations.add.AddObjectRelationViewModel import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider import com.anytypeio.anytype.presentation.relations.providers.ObjectValueProvider @@ -39,8 +39,13 @@ object AddObjectRelationModule { storeOfObjectTypes: StoreOfObjectTypes, searchObjects: SearchObjects, urlBuilder: UrlBuilder, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): AddObjectRelationViewModel.Factory = AddObjectRelationViewModel.Factory( - relations, values, searchObjects, urlBuilder, storeOfObjectTypes, workspaceManager + relations = relations, + values = values, + searchObjects = searchObjects, + urlBuilder = urlBuilder, + storeOfObjectTypes = storeOfObjectTypes, + spaceManager = spaceManager ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/AddObjectRelationValueDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/AddObjectRelationValueDI.kt index 84fe7db3b7..64aac65dcc 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/AddObjectRelationValueDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/AddObjectRelationValueDI.kt @@ -7,6 +7,7 @@ import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.`object`.UpdateDetail import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.relations.CreateRelationOption +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationDVViewModel import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationProvider import com.anytypeio.anytype.presentation.relations.add.AddOptionsRelationViewModel @@ -49,7 +50,8 @@ object AddObjectRelationValueModule { analytics: Analytics, setObjectDetail: UpdateDetail, detailsProvider: ObjectDetailProvider, - getOptions: GetOptions + getOptions: GetOptions, + spaceManager: SpaceManager ): AddOptionsRelationDVViewModel.Factory = AddOptionsRelationDVViewModel.Factory( relations = relations, values = values, @@ -59,7 +61,8 @@ object AddObjectRelationValueModule { analytics = analytics, setObjectDetail = setObjectDetail, detailsProvider = detailsProvider, - getOptions = getOptions + getOptions = getOptions, + spaceManager = spaceManager ) @JvmStatic @@ -73,7 +76,8 @@ object AddObjectRelationValueModule { updateDetail: UpdateDetail, analytics: Analytics, detailsProvider: ObjectDetailProvider, - getOptions: GetOptions + getOptions: GetOptions, + spaceManager: SpaceManager ): AddOptionsRelationViewModel.Factory = AddOptionsRelationViewModel.Factory( relations = relations, values = values, @@ -83,7 +87,8 @@ object AddObjectRelationValueModule { analytics = analytics, optionsProvider = AddOptionsRelationProvider(), detailProvider = detailsProvider, - getOptions = getOptions + getOptions = getOptions, + spaceManager = spaceManager ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/AuthDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/AuthDI.kt index 2ec0b9083c..e1b5253ecd 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/AuthDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/AuthDI.kt @@ -23,7 +23,6 @@ import com.anytypeio.anytype.domain.`object`.SetupMobileUseCaseSkip import com.anytypeio.anytype.domain.platform.MetricsProvider import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager -import com.anytypeio.anytype.domain.workspace.WorkspaceManager import com.anytypeio.anytype.presentation.auth.account.CreateAccountViewModelFactory import com.anytypeio.anytype.presentation.auth.account.SelectAccountViewModelFactory import com.anytypeio.anytype.presentation.auth.account.SetupNewAccountViewModelFactory @@ -244,12 +243,10 @@ object SetupNewAccountModule { fun provideCreateAccountUseCase( repository: AuthRepository, configStorage: ConfigStorage, - workspaceManager: WorkspaceManager, metricsProvider: MetricsProvider ): CreateAccount = CreateAccount( repository = repository, configStorage = configStorage, - workspaceManager = workspaceManager, metricsProvider = metricsProvider ) @@ -299,14 +296,12 @@ object SetupSelectedAccountModule { repository: AuthRepository, configStorage: ConfigStorage, featuresConfigProvider: FeaturesConfigProvider, - workspaceManager: WorkspaceManager, metricsProvider: MetricsProvider ): SelectAccount { return SelectAccount( repository = repository, configStorage = configStorage, featuresConfigProvider = featuresConfigProvider, - workspaceManager = workspaceManager, metricsProvider = metricsProvider ) } diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/BacklinkOrAddToObjectDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/BacklinkOrAddToObjectDI.kt index 7087dd049c..88558908d0 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/BacklinkOrAddToObjectDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/BacklinkOrAddToObjectDI.kt @@ -11,6 +11,7 @@ import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.misc.UrlBuilder import com.anytypeio.anytype.domain.search.SearchObjects +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.domain.workspace.WorkspaceManager import com.anytypeio.anytype.presentation.linking.BackLinkOrAddToObjectViewModelFactory import com.anytypeio.anytype.ui.linking.BacklinkOrAddToObjectFragment @@ -77,4 +78,5 @@ interface BacklinkOrAddToObjectDependencies : ComponentDependencies { fun urlBuilder(): UrlBuilder fun dispatchers(): AppCoroutineDispatchers fun analytics(): Analytics + fun spaceManager(): SpaceManager } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/CreateObjectDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/CreateObjectDI.kt index da156b6ffb..49b5330ac9 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/CreateObjectDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/CreateObjectDI.kt @@ -1,14 +1,14 @@ package com.anytypeio.anytype.di.feature -import com.anytypeio.anytype.core_models.Block import com.anytypeio.anytype.core_utils.di.scope.PerScreen import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.repo.BlockRepository +import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.launch.GetDefaultPageType import com.anytypeio.anytype.domain.page.CreateObject import com.anytypeio.anytype.domain.templates.GetTemplates -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.objects.CreateObjectViewModel import com.anytypeio.anytype.ui.editor.CreateObjectFragment import dagger.Module @@ -36,14 +36,14 @@ object CreateObjectModule { @PerScreen fun getCreateObject( repo: BlockRepository, - getTemplates: GetTemplates, getDefaultPageType: GetDefaultPageType, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager ): CreateObject = CreateObject( repo = repo, - getTemplates = getTemplates, getDefaultPageType = getDefaultPageType, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @JvmStatic @@ -52,13 +52,15 @@ object CreateObjectModule { fun provideGetDefaultPageType( blockRepository: BlockRepository, userSettingsRepository: UserSettingsRepository, - workspaceManager: WorkspaceManager, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager, + configStorage: ConfigStorage ): GetDefaultPageType = GetDefaultPageType( - userSettingsRepository, - blockRepository, - workspaceManager, - dispatchers + userSettingsRepository = userSettingsRepository, + blockRepository = blockRepository, + dispatchers = dispatchers, + spaceManager = spaceManager, + configStorage = configStorage ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/EditorDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/EditorDI.kt index 02dfcec075..8e17664f4d 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/EditorDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/EditorDI.kt @@ -44,6 +44,7 @@ import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.clipboard.Clipboard import com.anytypeio.anytype.domain.clipboard.Copy import com.anytypeio.anytype.domain.clipboard.Paste +import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.cover.SetDocCoverImage import com.anytypeio.anytype.domain.download.DownloadFile @@ -97,7 +98,7 @@ import com.anytypeio.anytype.domain.unsplash.DownloadUnsplashImage import com.anytypeio.anytype.domain.unsplash.UnsplashRepository import com.anytypeio.anytype.domain.workspace.FileLimitsEventChannel import com.anytypeio.anytype.domain.workspace.InterceptFileLimitEvents -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.common.Action import com.anytypeio.anytype.presentation.common.Delegator import com.anytypeio.anytype.presentation.editor.DocumentExternalEventReducer @@ -276,7 +277,7 @@ object EditorSessionModule { objectToSet: ConvertObjectToSet, featureToggles: FeatureToggles, tableDelegate: EditorTableDelegate, - workspaceManager: WorkspaceManager, + spaceManager: SpaceManager, getObjectTypes: GetObjectTypes, objectToCollection: ConvertObjectToCollection, interceptFileLimitEvents: InterceptFileLimitEvents, @@ -314,7 +315,7 @@ object EditorSessionModule { objectToSet = objectToSet, featureToggles = featureToggles, tableDelegate = tableDelegate, - workspaceManager = workspaceManager, + spaceManager = spaceManager, getObjectTypes = getObjectTypes, objectToCollection = objectToCollection, interceptFileLimitEvents = interceptFileLimitEvents, @@ -730,12 +731,14 @@ object EditorUseCaseModule { repo: BlockRepository, getDefaultPageType: GetDefaultPageType, getTemplates: GetTemplates, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager ): CreateObjectAsMentionOrLink = CreateObjectAsMentionOrLink( repo = repo, getDefaultPageType = getDefaultPageType, getTemplates = getTemplates, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @JvmStatic @@ -983,13 +986,15 @@ object EditorUseCaseModule { fun provideGetDefaultPageType( repo: UserSettingsRepository, blockRepository: BlockRepository, - workspaceManager: WorkspaceManager, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager, + configStorage: ConfigStorage ): GetDefaultPageType = GetDefaultPageType( - repo, - blockRepository, - workspaceManager, - dispatchers + userSettingsRepository = repo, + blockRepository = blockRepository, + spaceManager = spaceManager, + dispatchers = dispatchers, + configStorage = configStorage ) @JvmStatic @@ -1181,14 +1186,14 @@ object EditorUseCaseModule { @PerScreen fun getCreateObject( repo: BlockRepository, - getTemplates: GetTemplates, getDefaultPageType: GetDefaultPageType, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager ): CreateObject = CreateObject( repo = repo, - getTemplates = getTemplates, getDefaultPageType = getDefaultPageType, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @Module diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/LinkToObjectDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/LinkToObjectDI.kt index 3c10092c41..b94f1ed49e 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/LinkToObjectDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/LinkToObjectDI.kt @@ -5,9 +5,9 @@ import com.anytypeio.anytype.core_utils.di.scope.PerScreen import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes import com.anytypeio.anytype.domain.block.repo.BlockRepository -import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.domain.misc.UrlBuilder -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.search.SearchObjects +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.linking.LinkToObjectViewModelFactory import com.anytypeio.anytype.ui.linking.LinkToObjectFragment import dagger.Module @@ -39,14 +39,14 @@ object LinkToObjectModule { urlBuilder: UrlBuilder, getObjectTypes: GetObjectTypes, searchObjects: SearchObjects, - workspaceManager: WorkspaceManager, - analytics: Analytics + analytics: Analytics, + spaceManager: SpaceManager ): LinkToObjectViewModelFactory = LinkToObjectViewModelFactory( urlBuilder = urlBuilder, getObjectTypes = getObjectTypes, searchObjects = searchObjects, - workspaceManager = workspaceManager, - analytics = analytics + analytics = analytics, + spaceManager = spaceManager ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/LinkToObjectOrWebDi.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/LinkToObjectOrWebDi.kt index 4f42b63b4f..0ecefcb990 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/LinkToObjectOrWebDi.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/LinkToObjectOrWebDi.kt @@ -6,7 +6,7 @@ import com.anytypeio.anytype.core_utils.tools.UrlValidator 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.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.editor.Editor import com.anytypeio.anytype.presentation.linking.LinkToObjectOrWebViewModelFactory import com.anytypeio.anytype.ui.linking.LinkToObjectOrWebPagesFragment @@ -42,7 +42,7 @@ object LinkToObjectOrWebModule { analytics: Analytics, stores: Editor.Storage, urlValidator: UrlValidator, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): LinkToObjectOrWebViewModelFactory = LinkToObjectOrWebViewModelFactory( urlBuilder = urlBuilder, storeOfObjectTypes = storeOfObjectTypes, @@ -50,6 +50,6 @@ object LinkToObjectOrWebModule { analytics = analytics, stores = stores, urlValidator = urlValidator, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/MainEntryDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/MainEntryDI.kt index 3784c23f9a..fb15623e96 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/MainEntryDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/MainEntryDI.kt @@ -19,7 +19,8 @@ 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 -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.wallpaper.WallpaperStore +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.main.MainViewModelFactory import com.anytypeio.anytype.ui.main.MainActivity import com.anytypeio.anytype.ui_settings.appearance.ThemeApplicator @@ -79,14 +80,12 @@ object MainEntryModule { pathProvider: PathProvider, configStorage: ConfigStorage, featuresConfigProvider: FeaturesConfigProvider, - workspaceManager: WorkspaceManager, metricsProvider: MetricsProvider ): ResumeAccount = ResumeAccount( repository = authRepository, pathProvider = pathProvider, configStorage = configStorage, featuresConfigProvider = featuresConfigProvider, - workspaceManager = workspaceManager, metricsProvider = metricsProvider ) @@ -99,8 +98,15 @@ object MainEntryModule { @PerScreen @Provides fun provideRestoreWallpaperUseCase( - repo: UserSettingsRepository - ): RestoreWallpaper = RestoreWallpaper(repo) + repo: UserSettingsRepository, + spaceManager: SpaceManager, + dispatchers: AppCoroutineDispatchers + ): RestoreWallpaper = RestoreWallpaper( + repo = repo, + spaceManager = spaceManager, + store = WallpaperStore.Default, + dispatchers = dispatchers + ) @JvmStatic @PerScreen @@ -132,12 +138,14 @@ object MainEntryModule { repo: AuthRepository, provider: ConfigStorage, user: UserSettingsRepository, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager ): Logout = Logout( repo = repo, user = user, config = provider, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/MoveToDi.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/MoveToDi.kt index 02a3e1ab95..d9fedc2bf7 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/MoveToDi.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/MoveToDi.kt @@ -5,9 +5,9 @@ import com.anytypeio.anytype.core_utils.di.scope.PerScreen import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes import com.anytypeio.anytype.domain.block.repo.BlockRepository -import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.domain.misc.UrlBuilder -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.search.SearchObjects +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.moving.MoveToViewModelFactory import com.anytypeio.anytype.ui.moving.MoveToFragment import dagger.Module @@ -53,12 +53,12 @@ object MoveToModule { getObjectTypes: GetObjectTypes, searchObjects: SearchObjects, analytics: Analytics, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): MoveToViewModelFactory = MoveToViewModelFactory( urlBuilder = urlBuilder, getObjectTypes = getObjectTypes, searchObjects = searchObjects, analytics = analytics, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetCreateBookmarkRecordDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetCreateBookmarkRecordDI.kt index a37389ac83..99928df6c5 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetCreateBookmarkRecordDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetCreateBookmarkRecordDI.kt @@ -4,6 +4,7 @@ import com.anytypeio.anytype.core_utils.di.scope.PerDialog import com.anytypeio.anytype.core_utils.tools.UrlValidator import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.objects.CreateBookmarkObject +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.sets.ObjectSetCreateBookmarkRecordViewModel import com.anytypeio.anytype.ui.sets.modals.SetObjectCreateBookmarkRecordFragment import dagger.Module @@ -30,10 +31,12 @@ object ObjectSetCreateBookmarkRecordModule { @PerDialog fun provideObjectSetRecordViewModelFactory( createBookmarkObject: CreateBookmarkObject, - urlValidator: UrlValidator - ): ObjectSetCreateBookmarkRecordViewModel.Factory = ObjectSetCreateBookmarkRecordViewModel.Factory( - createBookmarkObject = createBookmarkObject, - urlValidator = urlValidator + urlValidator: UrlValidator, + spaceManager: SpaceManager + ) = ObjectSetCreateBookmarkRecordViewModel.Factory( + createBookmarkObject = createBookmarkObject, + urlValidator = urlValidator, + spaceManager = spaceManager ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetDI.kt index 1076aee726..9915b9a16e 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectSetDI.kt @@ -21,6 +21,7 @@ import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.interactor.UpdateText import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.collections.AddObjectToCollection +import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.cover.SetDocCoverImage import com.anytypeio.anytype.domain.dataview.interactor.AddDataViewViewer @@ -62,7 +63,7 @@ import com.anytypeio.anytype.domain.templates.CreateTemplate import com.anytypeio.anytype.domain.templates.GetTemplates import com.anytypeio.anytype.domain.unsplash.DownloadUnsplashImage import com.anytypeio.anytype.domain.unsplash.UnsplashRepository -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.common.Action import com.anytypeio.anytype.presentation.common.Delegator import com.anytypeio.anytype.presentation.editor.cover.CoverImageHashProvider @@ -213,7 +214,6 @@ object ObjectSetModule { storeOfRelations: StoreOfRelations, objectStateReducer: ObjectStateReducer, dataViewSubscription: DataViewSubscription, - workspaceManager: WorkspaceManager, @Named("object-set-store") objectStore: ObjectStore, addObjectToCollection: AddObjectToCollection, convertObjectToCollection: ConvertObjectToCollection, @@ -223,8 +223,9 @@ object ObjectSetModule { duplicateObjects: DuplicateObjects, templatesContainer: ObjectTypeTemplatesContainer, setObjectListIsArchived: SetObjectListIsArchived, + createTemplate: CreateTemplate, viewerDelegate: ViewerDelegate, - createTemplate: CreateTemplate + spaceManager: SpaceManager ): ObjectSetViewModelFactory = ObjectSetViewModelFactory( openObjectSet = openObjectSet, closeBlock = closeBlock, @@ -250,7 +251,6 @@ object ObjectSetModule { storeOfRelations = storeOfRelations, objectStateReducer = objectStateReducer, dataViewSubscription = dataViewSubscription, - workspaceManager = workspaceManager, objectStore = objectStore, addObjectToCollection = addObjectToCollection, objectToCollection = convertObjectToCollection, @@ -261,6 +261,7 @@ object ObjectSetModule { templatesContainer = templatesContainer, setObjectListIsArchived = setObjectListIsArchived, viewerDelegate = viewerDelegate, + spaceManager = spaceManager, createTemplate = createTemplate ) @@ -280,14 +281,14 @@ object ObjectSetModule { @PerScreen fun getCreateObject( repo: BlockRepository, - getTemplates: GetTemplates, getDefaultPageType: GetDefaultPageType, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager ): CreateObject = CreateObject( repo = repo, - getTemplates = getTemplates, getDefaultPageType = getDefaultPageType, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @JvmStatic @@ -304,13 +305,15 @@ object ObjectSetModule { fun provideGetDefaultPageType( userSettingsRepository: UserSettingsRepository, blockRepository: BlockRepository, - workspaceManager: WorkspaceManager, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager, + configStorage: ConfigStorage ): GetDefaultPageType = GetDefaultPageType( userSettingsRepository = userSettingsRepository, blockRepository = blockRepository, - workspaceManager = workspaceManager, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager, + configStorage = configStorage ) @JvmStatic @@ -327,11 +330,15 @@ object ObjectSetModule { fun provideCreateDataViewRecordUseCase( repo: BlockRepository, storeOfRelations: StoreOfRelations, + getDefaultPageType: GetDefaultPageType, + getTemplates: GetTemplates, + spaceManager: SpaceManager, dispatchers: AppCoroutineDispatchers ): CreateDataViewObject = CreateDataViewObject( repo = repo, storeOfRelations = storeOfRelations, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectTypeDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectTypeDI.kt index 3840fbd776..4f7ec0412a 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectTypeDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/ObjectTypeDI.kt @@ -4,10 +4,11 @@ import com.anytypeio.anytype.core_utils.di.scope.PerScreen import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes import com.anytypeio.anytype.domain.block.repo.BlockRepository +import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.launch.GetDefaultPageType -import com.anytypeio.anytype.domain.workspace.AddObjectToWorkspace -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.spaces.AddObjectTypeToSpace +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.objects.ObjectTypeChangeViewModelFactory import com.anytypeio.anytype.ui.objects.types.pickers.AppDefaultObjectTypeFragment import com.anytypeio.anytype.ui.objects.types.pickers.DataViewSelectSourceFragment @@ -43,16 +44,16 @@ object ObjectTypeChangeModule { @PerScreen fun provideObjectTypeViewModelFactory( getObjectTypes: GetObjectTypes, - addObjectToWorkspace: AddObjectToWorkspace, + addObjectTypeToSpace: AddObjectTypeToSpace, dispatchers: AppCoroutineDispatchers, - workspaceManager: WorkspaceManager, + spaceManager: SpaceManager, getDefaultPageType: GetDefaultPageType ): ObjectTypeChangeViewModelFactory { return ObjectTypeChangeViewModelFactory( getObjectTypes = getObjectTypes, - addObjectToWorkspace = addObjectToWorkspace, + addObjectTypeToSpace = addObjectTypeToSpace, dispatchers = dispatchers, - workspaceManager = workspaceManager, + spaceManager = spaceManager, getDefaultPageType = getDefaultPageType ) } @@ -68,10 +69,10 @@ object ObjectTypeChangeModule { @JvmStatic @Provides @PerScreen - fun addObjectToWorkspace( + fun provideAddObjectTypeToSpace( repo: BlockRepository, dispatchers: AppCoroutineDispatchers - ) : AddObjectToWorkspace = AddObjectToWorkspace( + ) : AddObjectTypeToSpace = AddObjectTypeToSpace( repo = repo, dispatchers = dispatchers ) @@ -82,13 +83,15 @@ object ObjectTypeChangeModule { fun provideGetDefaultPageType( userSettingsRepository: UserSettingsRepository, blockRepository: BlockRepository, - workspaceManager: WorkspaceManager, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager, + configStorage: ConfigStorage ): GetDefaultPageType = GetDefaultPageType( userSettingsRepository = userSettingsRepository, blockRepository = blockRepository, - workspaceManager = workspaceManager, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager, + configStorage = configStorage ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/OtherSettingsDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/OtherSettingsDI.kt index 7b457066f1..1d158c7720 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/OtherSettingsDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/OtherSettingsDI.kt @@ -4,12 +4,13 @@ import com.anytypeio.anytype.analytics.base.Analytics import com.anytypeio.anytype.core_utils.di.scope.PerScreen import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.repo.BlockRepository +import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.device.ClearFileCache import com.anytypeio.anytype.domain.launch.GetDefaultPageType -import com.anytypeio.anytype.domain.launch.SetDefaultEditorType +import com.anytypeio.anytype.domain.launch.SetDefaultObjectType import com.anytypeio.anytype.domain.misc.AppActionManager -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.settings.OtherSettingsViewModel import com.anytypeio.anytype.ui.settings.OtherSettingsFragment import dagger.Module @@ -38,20 +39,27 @@ object OtherSettingsModule { fun provideGetDefaultPageType( userSettingsRepository: UserSettingsRepository, blockRepository: BlockRepository, - workspaceManager: WorkspaceManager, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager, + configStorage: ConfigStorage ): GetDefaultPageType = GetDefaultPageType( userSettingsRepository = userSettingsRepository, blockRepository = blockRepository, - workspaceManager = workspaceManager, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager, + configStorage = configStorage ) @JvmStatic @PerScreen @Provides - fun provideSetDefaultPageType(repo: UserSettingsRepository): SetDefaultEditorType = - SetDefaultEditorType(repo) + fun provideSetDefaultPageType( + repo: UserSettingsRepository, + dispatchers: AppCoroutineDispatchers + ): SetDefaultObjectType = SetDefaultObjectType( + repo = repo, + dispatchers = dispatchers + ) @JvmStatic @PerScreen @@ -63,15 +71,17 @@ object OtherSettingsModule { @PerScreen fun provideOtherSettingsFactory( getDefaultPageType: GetDefaultPageType, - setDefaultEditorType: SetDefaultEditorType, + setDefaultObjectType: SetDefaultObjectType, clearFileCache: ClearFileCache, appActionManager: AppActionManager, - analytics: Analytics + analytics: Analytics, + spaceManager: SpaceManager ): OtherSettingsViewModel.Factory = OtherSettingsViewModel.Factory( getDefaultPageType = getDefaultPageType, - setDefaultEditorType = setDefaultEditorType, + setDefaultObjectType = setDefaultObjectType, clearFileCache = clearFileCache, appActionManager = appActionManager, - analytics = analytics + analytics = analytics, + spaceManager = spaceManager ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/SearchDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/SearchDI.kt index 216fd24a24..b3d65ee8ba 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/SearchDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/SearchDI.kt @@ -5,9 +5,9 @@ import com.anytypeio.anytype.core_utils.di.scope.PerScreen import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes import com.anytypeio.anytype.domain.block.repo.BlockRepository -import com.anytypeio.anytype.domain.search.SearchObjects import com.anytypeio.anytype.domain.misc.UrlBuilder -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.search.SearchObjects +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.search.ObjectSearchViewModelFactory import com.anytypeio.anytype.ui.search.ObjectSearchFragment import dagger.Module @@ -51,12 +51,12 @@ object ObjectSearchModule { getObjectTypes: GetObjectTypes, searchObjects: SearchObjects, analytics: Analytics, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): ObjectSearchViewModelFactory = ObjectSearchViewModelFactory( urlBuilder = urlBuilder, searchObjects = searchObjects, getObjectTypes = getObjectTypes, analytics = analytics, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/SplashDi.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/SplashDi.kt index 0caa7d9264..331f6037ab 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/SplashDi.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/SplashDi.kt @@ -18,13 +18,14 @@ 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.launch.GetDefaultPageType -import com.anytypeio.anytype.domain.launch.SetDefaultEditorType +import com.anytypeio.anytype.domain.launch.SetDefaultObjectType import com.anytypeio.anytype.domain.misc.UrlBuilder import com.anytypeio.anytype.domain.page.CreateObject import com.anytypeio.anytype.domain.platform.MetricsProvider import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager import com.anytypeio.anytype.domain.templates.GetTemplates +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.domain.workspace.WorkspaceManager import com.anytypeio.anytype.presentation.splash.SplashViewModelFactory import com.anytypeio.anytype.ui.splash.SplashFragment @@ -71,15 +72,17 @@ object SplashModule { pathProvider: PathProvider, featuresConfigProvider: FeaturesConfigProvider, configStorage: ConfigStorage, - workspaceManager: WorkspaceManager, - metricsProvider: MetricsProvider + spaceManager: SpaceManager, + metricsProvider: MetricsProvider, + userSettings: UserSettingsRepository ): LaunchAccount = LaunchAccount( repository = authRepository, pathProvider = pathProvider, featuresConfigProvider = featuresConfigProvider, configStorage = configStorage, - workspaceManager = workspaceManager, - metricsProvider = metricsProvider + spaceManager = spaceManager, + metricsProvider = metricsProvider, + settings = userSettings ) @JvmStatic @@ -111,34 +114,41 @@ object SplashModule { fun provideGetDefaultPageType( userSettingsRepository: UserSettingsRepository, blockRepository: BlockRepository, - workspaceManager: WorkspaceManager, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager, + configStorage: ConfigStorage ): GetDefaultPageType = GetDefaultPageType( - userSettingsRepository, - blockRepository, - workspaceManager, - dispatchers + userSettingsRepository = userSettingsRepository, + blockRepository = blockRepository, + spaceManager = spaceManager, + dispatchers = dispatchers, + configStorage = configStorage ) @JvmStatic @PerScreen @Provides - fun provideSetDefaultPageType(repo: UserSettingsRepository): SetDefaultEditorType = - SetDefaultEditorType(repo) + fun provideSetDefaultPageType( + repo: UserSettingsRepository, + dispatchers: AppCoroutineDispatchers + ): SetDefaultObjectType = SetDefaultObjectType( + repo = repo, + dispatchers = dispatchers + ) @JvmStatic @Provides @PerScreen fun getCreateObject( repo: BlockRepository, - getTemplates: GetTemplates, getDefaultPageType: GetDefaultPageType, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager ): CreateObject = CreateObject( repo = repo, - getTemplates = getTemplates, getDefaultPageType = getDefaultPageType, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @JvmStatic @@ -177,4 +187,5 @@ interface SplashDependencies : ComponentDependencies { fun dispatchers(): AppCoroutineDispatchers fun crashReporter(): CrashReporter fun metricsProvider(): MetricsProvider + fun spaceManager(): SpaceManager } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/auth/DeletedAccountDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/auth/DeletedAccountDI.kt index de28219116..0e20f416e3 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/auth/DeletedAccountDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/auth/DeletedAccountDI.kt @@ -13,6 +13,7 @@ import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.misc.AppActionManager import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.ext.DefaultDateHelper import com.anytypeio.anytype.presentation.auth.account.DeletedAccountViewModel import com.anytypeio.anytype.ui.auth.account.DeletedAccountFragment @@ -60,12 +61,14 @@ object DeletedAccountModule { repo: AuthRepository, provider: ConfigStorage, dispatchers: AppCoroutineDispatchers, - user: UserSettingsRepository + user: UserSettingsRepository, + spaceManager: SpaceManager ): Logout = Logout( repo = repo, config = provider, user = user, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @JvmStatic @@ -93,4 +96,5 @@ interface DeletedAccountDependencies : ComponentDependencies { fun configStorage(): ConfigStorage fun authRepository(): AuthRepository fun userSettingsRepository(): UserSettingsRepository + fun spaceManager(): SpaceManager } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/home/HomescreenDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/home/HomescreenDI.kt index 12296621b2..e7665bbeb1 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/home/HomescreenDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/home/HomescreenDI.kt @@ -31,6 +31,7 @@ import com.anytypeio.anytype.domain.page.CloseBlock import com.anytypeio.anytype.domain.page.CreateObject import com.anytypeio.anytype.domain.search.SubscriptionEventChannel import com.anytypeio.anytype.domain.templates.GetTemplates +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.domain.workspace.WorkspaceManager import com.anytypeio.anytype.presentation.home.HomeScreenViewModel import com.anytypeio.anytype.presentation.home.Unsubscriber @@ -124,11 +125,11 @@ object HomeScreenModule { fun emptyBin( repo: BlockRepository, dispatchers: AppCoroutineDispatchers, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ) : EmptyBin = EmptyBin( repo = repo, dispatchers = dispatchers, - workspaceManager = workspaceManager + spaceManager = spaceManager ) @JvmStatic @@ -149,12 +150,12 @@ object HomeScreenModule { repo: BlockRepository, dispatchers: AppCoroutineDispatchers, getDefaultEditorType: GetDefaultPageType, - getTemplates: GetTemplates + spaceManager: SpaceManager ): CreateObject = CreateObject( repo = repo, dispatchers = dispatchers, - getTemplates = getTemplates, - getDefaultPageType = getDefaultEditorType + getDefaultPageType = getDefaultEditorType, + spaceManager = spaceManager ) @JvmStatic @@ -163,13 +164,15 @@ object HomeScreenModule { fun getDefaultPageType( userSettingsRepository: UserSettingsRepository, blockRepository: BlockRepository, - workspaceManager: WorkspaceManager, dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager, + configStorage: ConfigStorage ) : GetDefaultPageType = GetDefaultPageType( userSettingsRepository = userSettingsRepository, blockRepository = blockRepository, - workspaceManager = workspaceManager, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager, + configStorage = configStorage ) @JvmStatic @@ -259,4 +262,5 @@ interface HomeScreenDependencies : ComponentDependencies { fun appActionManager(): AppActionManager fun storeOfObjectTypes(): StoreOfObjectTypes fun logger(): Logger + fun spaceManager(): SpaceManager } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/library/LibraryDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/library/LibraryDI.kt index 077853e0e9..2d92c44866 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/library/LibraryDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/library/LibraryDI.kt @@ -7,6 +7,7 @@ import com.anytypeio.anytype.core_utils.di.scope.PerScreen import com.anytypeio.anytype.di.common.ComponentDependencies import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.repo.BlockRepository +import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.debugging.Logger import com.anytypeio.anytype.domain.launch.GetDefaultPageType @@ -18,6 +19,7 @@ import com.anytypeio.anytype.domain.search.SubscriptionEventChannel import com.anytypeio.anytype.domain.templates.GetTemplates import com.anytypeio.anytype.domain.workspace.AddObjectToWorkspace import com.anytypeio.anytype.domain.workspace.RemoveObjectsFromWorkspace +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.domain.workspace.WorkspaceManager import com.anytypeio.anytype.presentation.library.LibraryListDelegate import com.anytypeio.anytype.presentation.library.LibraryResourceManager @@ -64,11 +66,16 @@ object LibraryModule { @JvmStatic fun provideMyTypesDelegate( container: StorelessSubscriptionContainer, - workspaceManager: WorkspaceManager, + spaceManager: SpaceManager, urlBuilder: UrlBuilder, dispatchers: AppCoroutineDispatchers ): LibraryListDelegate { - return MyTypesDelegate(container, workspaceManager, urlBuilder, dispatchers) + return MyTypesDelegate( + container = container, + spaceManager = spaceManager, + urlBuilder = urlBuilder, + dispatchers = dispatchers + ) } @PerScreen @@ -87,11 +94,16 @@ object LibraryModule { @JvmStatic fun provideMyRelationsDelegate( container: StorelessSubscriptionContainer, - workspaceManager: WorkspaceManager, + spaceManager: SpaceManager, urlBuilder: UrlBuilder, dispatchers: AppCoroutineDispatchers ): LibraryListDelegate { - return MyRelationsDelegate(container, workspaceManager, urlBuilder, dispatchers) + return MyRelationsDelegate( + container = container, + spaceManager = spaceManager, + urlBuilder = urlBuilder, + dispatchers = dispatchers + ) } @PerScreen @@ -129,14 +141,14 @@ object LibraryModule { @PerScreen fun getCreateObject( repo: BlockRepository, - getTemplates: GetTemplates, getDefaultPageType: GetDefaultPageType, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager, ): CreateObject = CreateObject( repo = repo, - getTemplates = getTemplates, getDefaultPageType = getDefaultPageType, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @JvmStatic @@ -145,13 +157,15 @@ object LibraryModule { fun provideGetDefaultPageType( userSettingsRepository: UserSettingsRepository, blockRepository: BlockRepository, - workspaceManager: WorkspaceManager, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager, + configStorage: ConfigStorage ): GetDefaultPageType = GetDefaultPageType( userSettingsRepository = userSettingsRepository, blockRepository = blockRepository, - workspaceManager = workspaceManager, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager, + configStorage = configStorage ) @JvmStatic @@ -199,7 +213,8 @@ interface LibraryDependencies : ComponentDependencies { fun channel(): SubscriptionEventChannel fun dispatchers(): AppCoroutineDispatchers fun userSettingsRepository(): UserSettingsRepository - fun analytics(): Analytics + fun spaceManager(): SpaceManager + fun config(): ConfigStorage fun logger(): Logger } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/onboarding/signup/OnboardingSoulCreationDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/onboarding/signup/OnboardingSoulCreationDI.kt index c35f9173a6..6b063d8fa6 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/onboarding/signup/OnboardingSoulCreationDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/onboarding/signup/OnboardingSoulCreationDI.kt @@ -6,12 +6,10 @@ import com.anytypeio.anytype.di.common.ComponentDependencies import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.config.ConfigStorage -import com.anytypeio.anytype.domain.`object`.SetObjectDetails import com.anytypeio.anytype.presentation.onboarding.signup.OnboardingSoulCreationViewModel import dagger.Binds import dagger.Component import dagger.Module -import dagger.Provides import javax.inject.Scope @Component( @@ -34,26 +32,11 @@ interface OnboardingSoulCreationComponent { @Module object OnboardingSoulCreationModule { - - - @JvmStatic - @Provides - @SoulCreationScreenScope - fun provideSetObjectDetailsUseCase( - repository: BlockRepository, - dispatchers: AppCoroutineDispatchers - ): SetObjectDetails = SetObjectDetails( - repo = repository, - dispatchers = dispatchers - ) - @Module interface Declarations { - @Binds @SoulCreationScreenScope fun bindViewModelFactory(factory: OnboardingSoulCreationViewModel.Factory): ViewModelProvider.Factory - } } diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/onboarding/signup/OnboardingVoidDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/onboarding/signup/OnboardingVoidDI.kt index f9b4e8ba49..86ce7e24b9 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/onboarding/signup/OnboardingVoidDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/onboarding/signup/OnboardingVoidDI.kt @@ -17,6 +17,7 @@ import com.anytypeio.anytype.domain.`object`.SetupMobileUseCaseSkip import com.anytypeio.anytype.domain.platform.MetricsProvider import com.anytypeio.anytype.domain.search.ObjectTypesSubscriptionManager import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.domain.workspace.WorkspaceManager import com.anytypeio.anytype.presentation.onboarding.signup.OnboardingVoidViewModel import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider @@ -57,12 +58,10 @@ object OnboardingVoidModule { fun provideCreateAccountUseCase( authRepository: AuthRepository, configStorage: ConfigStorage, - workspaceManager: WorkspaceManager, metricsProvider: MetricsProvider ): CreateAccount = CreateAccount( repository = authRepository, configStorage = configStorage, - workspaceManager = workspaceManager, metricsProvider = metricsProvider ) @@ -107,4 +106,5 @@ interface OnboardingVoidDependencies : ComponentDependencies { fun dispatchers(): AppCoroutineDispatchers fun analytics(): Analytics fun crashReporter(): CrashReporter + fun spaceManager(): SpaceManager } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationAddDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationAddDI.kt index b3ec112a31..66d76b1871 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationAddDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationAddDI.kt @@ -11,10 +11,11 @@ import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.relations.AddRelationToObject import com.anytypeio.anytype.domain.relations.GetRelations import com.anytypeio.anytype.domain.workspace.AddObjectToWorkspace -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.relations.RelationAddToDataViewViewModel import com.anytypeio.anytype.presentation.relations.RelationAddToObjectViewModel import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider +import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider.Companion.DATA_VIEW_PROVIDER_TYPE import com.anytypeio.anytype.presentation.relations.providers.ObjectRelationProvider.Companion.INTRINSIC_PROVIDER_TYPE import com.anytypeio.anytype.presentation.sets.state.ObjectState import com.anytypeio.anytype.presentation.util.Dispatcher @@ -55,7 +56,7 @@ object RelationAddToObjectModule { getRelations: GetRelations, appCoroutineDispatchers: AppCoroutineDispatchers, addObjectToWorkspace: AddObjectToWorkspace, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): RelationAddToObjectViewModel.Factory = RelationAddToObjectViewModel.Factory( storeOfRelations = storeOfRelations, addRelationToObject = addRelationToObject, @@ -65,7 +66,7 @@ object RelationAddToObjectModule { getRelations = getRelations, appCoroutineDispatchers = appCoroutineDispatchers, addObjectToWorkspace = addObjectToWorkspace, - workspaceManager = workspaceManager + spaceManager = spaceManager ) @JvmStatic @@ -110,11 +111,11 @@ object RelationAddToDataViewModule { state: MutableStateFlow, updateDataViewViewer: UpdateDataViewViewer, analytics: Analytics, - @Named(INTRINSIC_PROVIDER_TYPE) relationsProvider: ObjectRelationProvider, + @Named(DATA_VIEW_PROVIDER_TYPE) relationsProvider: ObjectRelationProvider, appCoroutineDispatchers: AppCoroutineDispatchers, getRelations: GetRelations, addObjectToWorkspace: AddObjectToWorkspace, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): RelationAddToDataViewViewModel.Factory = RelationAddToDataViewViewModel.Factory( addRelationToDataView = addRelationToDataView, dispatcher = dispatcher, @@ -125,7 +126,7 @@ object RelationAddToDataViewModule { appCoroutineDispatchers = appCoroutineDispatchers, getRelations = getRelations, addObjectToWorkspace = addObjectToWorkspace, - workspaceManager = workspaceManager + spaceManager = spaceManager ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromLibraryDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromLibraryDI.kt index f34b57be01..bc043388cd 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromLibraryDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromLibraryDI.kt @@ -11,6 +11,7 @@ import com.anytypeio.anytype.domain.objects.DefaultStoreOfRelations import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.relations.CreateRelation import com.anytypeio.anytype.domain.search.SearchObjects +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.relations.RelationCreateFromLibraryViewModel import com.anytypeio.anytype.presentation.relations.model.CreateFromScratchState import com.anytypeio.anytype.presentation.relations.model.StateHolder @@ -91,4 +92,5 @@ object RelationCreateFromLibraryModule { interface RelationCreateFromLibraryDependencies : ComponentDependencies { fun blockRepository(): BlockRepository fun urlBuilder(): UrlBuilder + fun spaceManager(): SpaceManager } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromScratchDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromScratchDI.kt index 93ad61a517..8e27324e27 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromScratchDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/relations/RelationCreateFromScratchDI.kt @@ -11,6 +11,7 @@ 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.CreateRelation +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForDataViewViewModel import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForObjectBlockViewModel import com.anytypeio.anytype.presentation.relations.RelationCreateFromScratchForObjectViewModel @@ -39,7 +40,7 @@ interface RelationCreateFromScratchForObjectSubComponent { fun inject(fragment: RelationCreateFromScratchForObjectFragment) fun relationFormatPickerComponent(): RelationFormatPickerSubcomponent.Builder - fun limitObjectTypeComponent() : LimitObjectTypeSubComponent.Builder + fun limitObjectTypeComponent(): LimitObjectTypeSubComponent.Builder } @Module @@ -53,13 +54,15 @@ object RelationCreateFromScratchForObjectModule { dispatcher: Dispatcher, analytics: Analytics, createFromScratchState: StateHolder, - createRelation: CreateRelation + createRelation: CreateRelation, + spaceManager: SpaceManager ) = RelationCreateFromScratchForObjectViewModel.Factory( - addRelationToObject = addRelationToObject, - createRelation = createRelation, - dispatcher = dispatcher, - analytics = analytics, - createFromScratchState = createFromScratchState + addRelationToObject = addRelationToObject, + createRelation = createRelation, + dispatcher = dispatcher, + analytics = analytics, + createFromScratchState = createFromScratchState, + spaceManager = spaceManager ) @JvmStatic @@ -96,7 +99,7 @@ interface RelationCreateFromScratchForDataViewSubComponent { fun inject(fragment: RelationCreateFromScratchForDataViewFragment) fun relationFormatPickerComponent(): RelationFormatPickerSubcomponent.Builder - fun limitObjectTypeComponent() : LimitObjectTypeSubComponent.Builder + fun limitObjectTypeComponent(): LimitObjectTypeSubComponent.Builder } @Module @@ -112,15 +115,17 @@ object RelationCreateFromScratchForDataViewModule { analytics: Analytics, createFromScratchState: StateHolder, createRelation: CreateRelation, - addRelationToDataView: AddRelationToDataView + addRelationToDataView: AddRelationToDataView, + spaceManager: SpaceManager ) = RelationCreateFromScratchForDataViewViewModel.Factory( - addRelationToDataView = addRelationToDataView, - dispatcher = dispatcher, - objectState = state, - updateDataViewViewer = updateDataViewViewer, - analytics = analytics, - createFromScratchState = createFromScratchState, - createRelation = createRelation + addRelationToDataView = addRelationToDataView, + dispatcher = dispatcher, + objectState = state, + updateDataViewViewer = updateDataViewViewer, + analytics = analytics, + createFromScratchState = createFromScratchState, + createRelation = createRelation, + spaceManager = spaceManager ) @JvmStatic @@ -162,7 +167,7 @@ interface RelationCreateFromScratchForObjectBlockSubComponent { fun inject(fragment: RelationCreateFromScratchForObjectBlockFragment) fun relationFormatPickerComponent(): RelationFormatPickerSubcomponent.Builder - fun limitObjectTypeComponent() : LimitObjectTypeSubComponent.Builder + fun limitObjectTypeComponent(): LimitObjectTypeSubComponent.Builder } @Module @@ -176,13 +181,15 @@ object RelationCreateFromScratchForObjectBlockModule { createRelation: CreateRelation, dispatcher: Dispatcher, analytics: Analytics, - createFromScratchState: StateHolder + createFromScratchState: StateHolder, + spaceManager: SpaceManager ) = RelationCreateFromScratchForObjectBlockViewModel.Factory( - addRelationToObject = addRelationToObject, - createRelation = createRelation, - dispatcher = dispatcher, - analytics = analytics, - createFromScratchState = createFromScratchState + addRelationToObject = addRelationToObject, + createRelation = createRelation, + dispatcher = dispatcher, + analytics = analytics, + createFromScratchState = createFromScratchState, + spaceManager = spaceManager ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/CreateFilter.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/CreateFilter.kt index 835071d8d3..0081f65998 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/CreateFilter.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/CreateFilter.kt @@ -9,7 +9,7 @@ import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel import com.anytypeio.anytype.presentation.sets.state.ObjectState @@ -52,7 +52,7 @@ object CreateFilterModule { objectSetDatabase: ObjectSetDatabase, analytics: Analytics, getOptions: GetOptions, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): FilterViewModel.Factory = FilterViewModel.Factory( objectState = state, dispatcher = dispatcher, @@ -64,6 +64,6 @@ object CreateFilterModule { objectSetDatabase = objectSetDatabase, analytics = analytics, getOptions = getOptions, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/ModifyFilter.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/ModifyFilter.kt index 06c079ac58..749e666825 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/sets/ModifyFilter.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/sets/ModifyFilter.kt @@ -9,7 +9,7 @@ import com.anytypeio.anytype.domain.objects.StoreOfObjectTypes import com.anytypeio.anytype.domain.objects.StoreOfRelations import com.anytypeio.anytype.domain.objects.options.GetOptions import com.anytypeio.anytype.domain.search.SearchObjects -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.sets.ObjectSetDatabase import com.anytypeio.anytype.presentation.sets.filter.FilterViewModel import com.anytypeio.anytype.presentation.sets.state.ObjectState @@ -52,7 +52,7 @@ object ModifyFilterModule { objectSetDatabase: ObjectSetDatabase, getOptions: GetOptions, storeOfRelations: StoreOfRelations, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): FilterViewModel.Factory = FilterViewModel.Factory( objectState = state, dispatcher = dispatcher, @@ -64,6 +64,6 @@ object ModifyFilterModule { storeOfRelations = storeOfRelations, analytics = analytics, getOptions = getOptions, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/settings/FilesStorageDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/settings/FilesStorageDI.kt index 9c4697f4a7..3b03c3a502 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/settings/FilesStorageDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/settings/FilesStorageDI.kt @@ -18,6 +18,7 @@ import com.anytypeio.anytype.domain.search.SubscriptionEventChannel import com.anytypeio.anytype.domain.workspace.FileLimitsEventChannel import com.anytypeio.anytype.domain.workspace.FileSpaceUsage import com.anytypeio.anytype.domain.workspace.InterceptFileLimitEvents +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.settings.FilesStorageViewModel import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider import com.anytypeio.anytype.ui.settings.FilesStorageFragment @@ -79,8 +80,9 @@ object FilesStorageModule { @PerScreen fun provideSpaceUsage( repo: BlockRepository, - dispatchers: AppCoroutineDispatchers - ): FileSpaceUsage = FileSpaceUsage(repo, dispatchers) + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager + ): FileSpaceUsage = FileSpaceUsage(repo, spaceManager, dispatchers) @JvmStatic @Provides @@ -118,4 +120,5 @@ interface FilesStorageDependencies : ComponentDependencies { fun buildProvider(): BuildProvider fun authRepo(): AuthRepository fun logger(): Logger + fun spaceManager(): SpaceManager } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/settings/LogoutWarningDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/settings/LogoutWarningDI.kt index 8ab59e32d9..bf552b8c78 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/settings/LogoutWarningDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/settings/LogoutWarningDI.kt @@ -9,6 +9,7 @@ import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.misc.AppActionManager import com.anytypeio.anytype.domain.search.RelationsSubscriptionManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.ui.settings.LogoutWarningFragment import com.anytypeio.anytype.ui_settings.account.LogoutWarningViewModel import dagger.Module @@ -53,11 +54,13 @@ object LogoutWarningModule { repo: AuthRepository, provider: ConfigStorage, user: UserSettingsRepository, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager ): Logout = Logout( repo = repo, config = provider, user = user, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/settings/MainSettingsDi.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/settings/MainSettingsDi.kt index c4847054cb..7f99325444 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/settings/MainSettingsDi.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/settings/MainSettingsDi.kt @@ -5,12 +5,13 @@ import com.anytypeio.anytype.core_utils.di.scope.PerScreen import com.anytypeio.anytype.device.share.debug.DebugSpaceDeviceFileContentSaver import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.repo.BlockRepository -import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.debugging.DebugSpaceContentSaver import com.anytypeio.anytype.domain.debugging.DebugSpaceShareDownloader import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer import com.anytypeio.anytype.domain.misc.UrlBuilder import com.anytypeio.anytype.domain.`object`.SetObjectDetails +import com.anytypeio.anytype.domain.spaces.SetSpaceDetails +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.settings.MainSettingsViewModel import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider import com.anytypeio.anytype.presentation.util.downloader.UriFileProvider @@ -64,19 +65,19 @@ object MainSettingsModule { fun provideViewModelFactory( analytics: Analytics, storelessSubscriptionContainer: StorelessSubscriptionContainer, - configStorage: ConfigStorage, urlBuilder: UrlBuilder, - setObjectDetails: SetObjectDetails, spaceGradientProvider: SpaceGradientProvider, - debugSpaceShareDownloader: DebugSpaceShareDownloader + debugSpaceShareDownloader: DebugSpaceShareDownloader, + spaceManager: SpaceManager, + setSpaceDetails: SetSpaceDetails ): MainSettingsViewModel.Factory = MainSettingsViewModel.Factory( analytics = analytics, storelessSubscriptionContainer = storelessSubscriptionContainer, - configStorage = configStorage, urlBuilder = urlBuilder, - setObjectDetails = setObjectDetails, + setSpaceDetails = setSpaceDetails, spaceGradientProvider = spaceGradientProvider, - debugSpaceShareDownloader = debugSpaceShareDownloader + debugSpaceShareDownloader = debugSpaceShareDownloader, + spaceManager = spaceManager ) @Module diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/settings/ProfileDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/settings/ProfileDI.kt index 737a67099c..e0ed243555 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/settings/ProfileDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/settings/ProfileDI.kt @@ -14,6 +14,7 @@ import com.anytypeio.anytype.domain.icon.SetDocumentImageIcon import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer import com.anytypeio.anytype.domain.misc.UrlBuilder import com.anytypeio.anytype.domain.`object`.SetObjectDetails +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider import com.anytypeio.anytype.ui.settings.ProfileFragment import com.anytypeio.anytype.ui_settings.account.ProfileViewModel @@ -78,12 +79,14 @@ object ProfileModule { repo: AuthRepository, provider: ConfigStorage, user: UserSettingsRepository, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager ): Logout = Logout( repo = repo, config = provider, user = user, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/spaces/CreateSpaceDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/spaces/CreateSpaceDI.kt new file mode 100644 index 0000000000..441f264f12 --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/spaces/CreateSpaceDI.kt @@ -0,0 +1,56 @@ +package com.anytypeio.anytype.di.feature.spaces + +import androidx.lifecycle.ViewModelProvider +import com.anytypeio.anytype.analytics.base.Analytics +import com.anytypeio.anytype.core_utils.di.scope.PerScreen +import com.anytypeio.anytype.di.common.ComponentDependencies +import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers +import com.anytypeio.anytype.domain.block.repo.BlockRepository +import com.anytypeio.anytype.domain.workspace.SpaceManager +import com.anytypeio.anytype.presentation.spaces.CreateSpaceViewModel +import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider +import com.anytypeio.anytype.ui.spaces.CreateSpaceFragment +import dagger.Binds +import dagger.Component +import dagger.Module +import dagger.Provides + +@Component( + dependencies = [CreateSpaceDependencies::class], + modules = [ + CreateSpaceModule::class, + CreateSpaceModule.Declarations::class + ] +) +@PerScreen +interface CreateSpaceComponent { + @Component.Factory + interface Builder { + fun create(dependencies: CreateSpaceDependencies): CreateSpaceComponent + } + + fun inject(fragment: CreateSpaceFragment) +} + +@Module +object CreateSpaceModule { + + @JvmStatic + @Provides + @PerScreen + fun provideSpaceGradientProvider(): SpaceGradientProvider = SpaceGradientProvider.Default + + @Module + interface Declarations { + @Binds + @PerScreen + fun bindViewModelFactory(factory: CreateSpaceViewModel.Factory): ViewModelProvider.Factory + } +} + +interface CreateSpaceDependencies : ComponentDependencies { + fun repo(): BlockRepository + fun analytics(): Analytics + fun dispatchers(): AppCoroutineDispatchers + fun spaceManager(): SpaceManager +} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/spaces/SelectSpaceDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/spaces/SelectSpaceDI.kt new file mode 100644 index 0000000000..8e81f39319 --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/spaces/SelectSpaceDI.kt @@ -0,0 +1,72 @@ +package com.anytypeio.anytype.di.feature.spaces + +import androidx.lifecycle.ViewModelProvider +import com.anytypeio.anytype.analytics.base.Analytics +import com.anytypeio.anytype.core_utils.di.scope.PerScreen +import com.anytypeio.anytype.di.common.ComponentDependencies +import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers +import com.anytypeio.anytype.domain.block.repo.BlockRepository +import com.anytypeio.anytype.domain.config.ConfigStorage +import com.anytypeio.anytype.domain.config.UserSettingsRepository +import com.anytypeio.anytype.domain.debugging.Logger +import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer +import com.anytypeio.anytype.domain.misc.AppActionManager +import com.anytypeio.anytype.domain.misc.UrlBuilder +import com.anytypeio.anytype.domain.search.SubscriptionEventChannel +import com.anytypeio.anytype.domain.workspace.SpaceManager +import com.anytypeio.anytype.presentation.spaces.SelectSpaceViewModel +import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider +import com.anytypeio.anytype.ui.spaces.SelectSpaceFragment +import dagger.Binds +import dagger.Component +import dagger.Module +import dagger.Provides + +@Component( + dependencies = [SelectSpaceDependencies::class], + modules = [ + SelectSpaceModule::class, + SelectSpaceModule.Declarations::class + ] +) +@PerScreen +interface SelectSpaceComponent { + @Component.Factory + interface Builder { + fun create(dependencies: SelectSpaceDependencies): SelectSpaceComponent + } + + fun inject(fragment: SelectSpaceFragment) +} + +@Module +object SelectSpaceModule { + + @JvmStatic + @Provides + @PerScreen + fun provideSpaceGradientProvider(): SpaceGradientProvider = SpaceGradientProvider.Default + + @Module + interface Declarations { + @PerScreen + @Binds + fun container(container: StorelessSubscriptionContainer.Impl): StorelessSubscriptionContainer + @Binds + @PerScreen + fun bindViewModelFactory(factory: SelectSpaceViewModel.Factory): ViewModelProvider.Factory + } +} + +interface SelectSpaceDependencies : ComponentDependencies { + fun repo(): BlockRepository + fun subscriptionEventChannel(): SubscriptionEventChannel + fun analytics(): Analytics + fun dispatchers(): AppCoroutineDispatchers + fun spaceManager(): SpaceManager + fun urlBuilder(): UrlBuilder + fun userSettings(): UserSettingsRepository + fun logger(): Logger + fun appActionManager(): AppActionManager + fun configStorage(): ConfigStorage +} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/spaces/SpaceSettingsDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/spaces/SpaceSettingsDI.kt new file mode 100644 index 0000000000..3b5a6fafc0 --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/spaces/SpaceSettingsDI.kt @@ -0,0 +1,59 @@ +package com.anytypeio.anytype.di.feature.spaces + +import androidx.lifecycle.ViewModelProvider +import com.anytypeio.anytype.analytics.base.Analytics +import com.anytypeio.anytype.core_utils.di.scope.PerScreen +import com.anytypeio.anytype.di.common.ComponentDependencies +import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers +import com.anytypeio.anytype.domain.block.repo.BlockRepository +import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer +import com.anytypeio.anytype.domain.misc.UrlBuilder +import com.anytypeio.anytype.domain.workspace.SpaceManager +import com.anytypeio.anytype.presentation.spaces.SpaceGradientProvider +import com.anytypeio.anytype.presentation.spaces.SpaceSettingsViewModel +import com.anytypeio.anytype.ui.settings.space.SpaceSettingsFragment +import dagger.Binds +import dagger.Component +import dagger.Module +import dagger.Provides + +@Component( + dependencies = [SpaceSettingsDependencies::class], + modules = [ + SpaceSettingsModule::class, + SpaceSettingsModule.Bindings::class + ] +) +@PerScreen +interface SpaceSettingsComponent { + @Component.Factory + interface Builder { + fun create(dependencies: SpaceSettingsDependencies): SpaceSettingsComponent + } + fun inject(fragment: SpaceSettingsFragment) +} + +@Module +object SpaceSettingsModule { + + @JvmStatic + @Provides + @PerScreen + fun provideSpaceGradientProvider(): SpaceGradientProvider = SpaceGradientProvider.Default + + @Module + interface Bindings { + @PerScreen + @Binds + fun factory(factory: SpaceSettingsViewModel.Factory): ViewModelProvider.Factory + } +} + +interface SpaceSettingsDependencies : ComponentDependencies { + fun blockRepo(): BlockRepository + fun urlBuilder(): UrlBuilder + fun analytics(): Analytics + fun dispatchers(): AppCoroutineDispatchers + fun spaceManager(): SpaceManager + fun container(): StorelessSubscriptionContainer +} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/types/TypeCreationDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/types/TypeCreationDI.kt index 4284f46014..9f0896ac03 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/types/TypeCreationDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/types/TypeCreationDI.kt @@ -8,6 +8,7 @@ import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.misc.UrlBuilder import com.anytypeio.anytype.domain.types.CreateType +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.emojifier.data.Emoji import com.anytypeio.anytype.emojifier.data.EmojiProvider import com.anytypeio.anytype.presentation.types.TypeCreationViewModel @@ -67,4 +68,5 @@ interface TypeCreationDependencies : ComponentDependencies { fun dispatchers(): AppCoroutineDispatchers fun urlBuilder(): UrlBuilder fun analytics(): Analytics + fun spaceManager(): SpaceManager } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/wallpaper/WallpaperSelectDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/wallpaper/WallpaperSelectDI.kt index 4a6c9698af..9348fab232 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/wallpaper/WallpaperSelectDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/wallpaper/WallpaperSelectDI.kt @@ -6,6 +6,7 @@ import com.anytypeio.anytype.device.DefaultGradientCollectionProvider import com.anytypeio.anytype.domain.config.UserSettingsRepository import com.anytypeio.anytype.domain.cover.GetCoverGradientCollection import com.anytypeio.anytype.domain.wallpaper.SetWallpaper +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.wallpaper.WallpaperSelectViewModel import com.anytypeio.anytype.ui.dashboard.WallpaperSelectFragment import dagger.Module @@ -35,11 +36,13 @@ object WallpaperSelectModule { @PerScreen fun provideViewModelFactory( setWallpaper: SetWallpaper, - analytics: Analytics + analytics: Analytics, + spaceManager: SpaceManager ): WallpaperSelectViewModel.Factory = WallpaperSelectViewModel.Factory( setWallpaper = setWallpaper, analytics = analytics, - getGradients = GetCoverGradientCollection(DefaultGradientCollectionProvider) + getGradients = GetCoverGradientCollection(DefaultGradientCollectionProvider), + spaceManager = spaceManager ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/feature/widgets/SelectWidgetSourceDI.kt b/app/src/main/java/com/anytypeio/anytype/di/feature/widgets/SelectWidgetSourceDI.kt index 91a454b74f..aff034b28e 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/feature/widgets/SelectWidgetSourceDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/feature/widgets/SelectWidgetSourceDI.kt @@ -2,13 +2,12 @@ package com.anytypeio.anytype.di.feature.widgets import com.anytypeio.anytype.analytics.base.Analytics import com.anytypeio.anytype.core_utils.di.scope.PerModal -import com.anytypeio.anytype.core_utils.di.scope.PerScreen import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.interactor.sets.GetObjectTypes import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.misc.UrlBuilder import com.anytypeio.anytype.domain.search.SearchObjects -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.presentation.widgets.SelectWidgetSourceViewModel import com.anytypeio.anytype.presentation.widgets.WidgetDispatchEvent @@ -41,17 +40,17 @@ object SelectWidgetSourceModule { fun factory( urlBuilder: UrlBuilder, analytics: Analytics, - workspaceManager: WorkspaceManager, searchObjects: SearchObjects, getObjectTypes: GetObjectTypes, - dispatcher: Dispatcher + dispatcher: Dispatcher, + spaceManager: SpaceManager ): SelectWidgetSourceViewModel.Factory = SelectWidgetSourceViewModel.Factory( urlBuilder = urlBuilder, searchObjects = searchObjects, analytics = analytics, - workspaceManager = workspaceManager, getObjectTypes = getObjectTypes, - dispatcher = dispatcher + dispatcher = dispatcher, + spaceManager = spaceManager ) @JvmStatic diff --git a/app/src/main/java/com/anytypeio/anytype/di/main/ConfigModule.kt b/app/src/main/java/com/anytypeio/anytype/di/main/ConfigModule.kt index 78481c7d9f..927621686e 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/main/ConfigModule.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/main/ConfigModule.kt @@ -1,10 +1,11 @@ package com.anytypeio.anytype.di.main -import com.anytypeio.anytype.core_utils.di.scope.PerScreen import com.anytypeio.anytype.data.auth.repo.config.GatewayProvider import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.Gateway +import com.anytypeio.anytype.domain.debugging.Logger +import com.anytypeio.anytype.domain.workspace.SpaceManager import dagger.Module import dagger.Provides import javax.inject.Singleton @@ -17,8 +18,12 @@ object ConfigModule { @Provides @Singleton fun provideGateway( - provider: ConfigStorage - ): Gateway = GatewayProvider(provider) + spaceManager: SpaceManager, + logger: Logger + ): Gateway = GatewayProvider( + spaceManager = spaceManager, + logger = logger + ) @JvmStatic @Provides diff --git a/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt b/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt index 2d40f0c32e..68dab160e2 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/main/MainComponent.kt @@ -37,6 +37,9 @@ import com.anytypeio.anytype.di.feature.settings.FilesStorageDependencies import com.anytypeio.anytype.di.feature.settings.LogoutWarningSubComponent import com.anytypeio.anytype.di.feature.settings.MainSettingsSubComponent import com.anytypeio.anytype.di.feature.settings.ProfileSubComponent +import com.anytypeio.anytype.di.feature.spaces.CreateSpaceDependencies +import com.anytypeio.anytype.di.feature.spaces.SelectSpaceDependencies +import com.anytypeio.anytype.di.feature.spaces.SpaceSettingsDependencies import com.anytypeio.anytype.di.feature.templates.TemplateBlankDependencies import com.anytypeio.anytype.di.feature.templates.TemplateSelectDependencies import com.anytypeio.anytype.di.feature.templates.TemplateSubComponent @@ -97,7 +100,10 @@ interface MainComponent : AboutAppDependencies, OnboardingSoulCreationAnimDependencies, TemplateBlankDependencies, - TemplateSelectDependencies { + TemplateSelectDependencies, + SelectSpaceDependencies, + CreateSpaceDependencies, + SpaceSettingsDependencies { fun inject(app: AndroidApplication) @@ -257,4 +263,19 @@ private abstract class ComponentDependenciesModule private constructor() { @IntoMap @ComponentDependenciesKey(TemplateSelectDependencies::class) abstract fun provideTemplateSelectDependencies(component: MainComponent): ComponentDependencies + + @Binds + @IntoMap + @ComponentDependenciesKey(SelectSpaceDependencies::class) + abstract fun provideSelectSpaceDependencies(component: MainComponent): ComponentDependencies + + @Binds + @IntoMap + @ComponentDependenciesKey(CreateSpaceDependencies::class) + abstract fun provideCreateSpaceDependencies(component: MainComponent): ComponentDependencies + + @Binds + @IntoMap + @ComponentDependenciesKey(SpaceSettingsDependencies::class) + abstract fun provideSpaceSettingsDependencies(component: MainComponent): ComponentDependencies } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/main/SubscriptionsModule.kt b/app/src/main/java/com/anytypeio/anytype/di/main/SubscriptionsModule.kt index b997c1d678..7681d9cea4 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/main/SubscriptionsModule.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/main/SubscriptionsModule.kt @@ -11,10 +11,9 @@ 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 com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import dagger.Module import dagger.Provides -import kotlinx.coroutines.Dispatchers import javax.inject.Singleton @Module @@ -65,10 +64,10 @@ object SubscriptionsModule { @Singleton fun relationsSubscriptionManager( subscription: RelationsSubscriptionContainer, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): RelationsSubscriptionManager = RelationsSubscriptionManager( subscription = subscription, - workspaceManager = workspaceManager + spaceManager = spaceManager ) @JvmStatic @@ -76,9 +75,9 @@ object SubscriptionsModule { @Singleton fun objectTypesSubscriptionManager( subscription: ObjectTypesSubscriptionContainer, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): ObjectTypesSubscriptionManager = ObjectTypesSubscriptionManager( subscription = subscription, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/main/TemplatesModule.kt b/app/src/main/java/com/anytypeio/anytype/di/main/TemplatesModule.kt index 53bd7c85aa..dc086b2ce3 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/main/TemplatesModule.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/main/TemplatesModule.kt @@ -4,14 +4,12 @@ import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers import com.anytypeio.anytype.domain.block.repo.BlockRepository import com.anytypeio.anytype.domain.debugging.Logger import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer -import com.anytypeio.anytype.domain.library.StorelessSubscriptionContainer.Companion.SUBSCRIPTION_TEMPLATES import com.anytypeio.anytype.domain.search.SubscriptionEventChannel -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.templates.DefaultObjectTypeTemplatesContainer import com.anytypeio.anytype.presentation.templates.ObjectTypeTemplatesContainer import dagger.Module import dagger.Provides -import javax.inject.Named import javax.inject.Singleton @Module @@ -33,10 +31,10 @@ object TemplatesModule { @Singleton fun provideTemplatesContainer( storage: StorelessSubscriptionContainer, - workspaceManager: WorkspaceManager + spaceManager: SpaceManager ): ObjectTypeTemplatesContainer = DefaultObjectTypeTemplatesContainer( storage = storage, - workspaceManager = workspaceManager + spaceManager = spaceManager ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/di/main/WorkspaceModule.kt b/app/src/main/java/com/anytypeio/anytype/di/main/WorkspaceModule.kt index 7942cb5e47..53c8305349 100644 --- a/app/src/main/java/com/anytypeio/anytype/di/main/WorkspaceModule.kt +++ b/app/src/main/java/com/anytypeio/anytype/di/main/WorkspaceModule.kt @@ -1,5 +1,10 @@ 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.config.ConfigStorage +import com.anytypeio.anytype.domain.debugging.Logger +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.domain.workspace.WorkspaceManager import dagger.Module import dagger.Provides @@ -10,4 +15,18 @@ object WorkspaceModule { @Provides @Singleton fun manager() : WorkspaceManager = WorkspaceManager.DefaultWorkspaceManager() + + @Provides + @Singleton + fun spaces( + repo: BlockRepository, + dispatchers: AppCoroutineDispatchers, + configStorage: ConfigStorage, + logger: Logger + ) : SpaceManager = SpaceManager.Impl( + dispatchers = dispatchers, + repo = repo, + configStorage = configStorage, + logger = logger + ) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt b/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt index 5ccbc09f65..3e6570ae92 100644 --- a/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt +++ b/app/src/main/java/com/anytypeio/anytype/navigation/Navigator.kt @@ -72,9 +72,9 @@ class Navigator : AppNavigation { override fun workspace() {} - override fun openSettings() { + override fun openSpaceSettings() { try { - navController?.navigate(R.id.action_open_settings) + navController?.navigate(R.id.action_open_space_settings) } catch (e: Exception) { Timber.e(e, "Error while opening settings") } @@ -89,12 +89,13 @@ class Navigator : AppNavigation { ) } - override fun openModalEditor(id: String, targetObjectType: Id) { + override fun openModalEditor(id: String, targetTypeId: Id, targetTypeKey: Id) { navController?.navigate( R.id.nav_editor_modal, bundleOf( EditorModalFragment.ARG_ID to id, - EditorModalFragment.ARG_TARGET_OBJECT_TYPE to targetObjectType + EditorModalFragment.ARG_TARGET_TYPE_ID to targetTypeId, + EditorModalFragment.ARG_TARGET_TYPE_KEY to targetTypeKey ) ) } diff --git a/app/src/main/java/com/anytypeio/anytype/other/BasicLogger.kt b/app/src/main/java/com/anytypeio/anytype/other/BasicLogger.kt index 1813eff17d..288f0358be 100644 --- a/app/src/main/java/com/anytypeio/anytype/other/BasicLogger.kt +++ b/app/src/main/java/com/anytypeio/anytype/other/BasicLogger.kt @@ -9,7 +9,7 @@ class BasicLogger @Inject constructor() : Logger { Timber.w(msg) } - override fun logException(e: Exception) { + override fun logException(e: Throwable) { Timber.e(e) } } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/base/NavigationRouter.kt b/app/src/main/java/com/anytypeio/anytype/ui/base/NavigationRouter.kt index 027b740ebe..c73bc29a08 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/base/NavigationRouter.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/base/NavigationRouter.kt @@ -30,10 +30,12 @@ class NavigationRouter( ) is AppNavigation.Command.ConfirmPinCodeScreen -> navigation.confirmPinCode(command.code) - is AppNavigation.Command.OpenSettings -> navigation.openSettings() + is AppNavigation.Command.OpenSettings -> navigation.openSpaceSettings() is AppNavigation.Command.OpenObject -> navigation.openDocument(command.id) is AppNavigation.Command.OpenModalEditor -> navigation.openModalEditor( - id = command.id, targetObjectType = command.targetObjectType + id = command.id, + targetTypeId = command.targetTypeId, + targetTypeKey = command.targetTypeKey ) is AppNavigation.Command.OpenSetOrCollection -> navigation.openObjectSet( command.target, diff --git a/app/src/main/java/com/anytypeio/anytype/ui/editor/CreateObjectFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/editor/CreateObjectFragment.kt index 9ebbda9132..d9fcc507fd 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/editor/CreateObjectFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/editor/CreateObjectFragment.kt @@ -8,6 +8,7 @@ import androidx.lifecycle.lifecycleScope import androidx.navigation.NavOptions import androidx.navigation.fragment.findNavController import com.anytypeio.anytype.R +import com.anytypeio.anytype.core_models.Key import com.anytypeio.anytype.core_utils.ext.arg import com.anytypeio.anytype.core_utils.ext.subscribe import com.anytypeio.anytype.core_utils.ext.toast @@ -23,7 +24,7 @@ class CreateObjectFragment : BaseFragment(R.layout. lateinit var factory: CreateObjectViewModel.Factory private val vm by viewModels { factory } - private val mType get() = arg(TYPE_KEY) + private val mType get() = arg(TYPE_KEY) override fun onStart() { jobs += lifecycleScope.subscribe(vm.createObjectStatus) { state -> diff --git a/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt index 5746deac82..bca56275b1 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorFragment.kt @@ -2071,12 +2071,20 @@ open class EditorFragment : NavigationFragment(R.layout.f vm.proceedToCreateObjectAndAddToTextAsLink(name) } - override fun onProceedWithUpdateType(id: Id) { - vm.onObjectTypeChanged(type = id, applyTemplate = false) + override fun onProceedWithUpdateType(id: Id, key: Key) { + vm.onObjectTypeChanged( + type = id, + key = key, + applyTemplate = false + ) } - override fun onProceedWithDraftUpdateType(id: Id) { - vm.onObjectTypeChanged(type = id, applyTemplate = true) + override fun onProceedWithDraftUpdateType(id: Id, key: Key) { + vm.onObjectTypeChanged( + type = id, + key = key, + applyTemplate = true + ) } override fun onAddRelationToTarget(target: Id, relationKey: Key) { diff --git a/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorModalFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorModalFragment.kt index 972242bef6..f6ec8bb378 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorModalFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/editor/EditorModalFragment.kt @@ -14,14 +14,16 @@ import com.anytypeio.anytype.ui.templates.EditorTemplateFragment class EditorModalFragment : BaseBottomSheetFragment() { private val ctx get() = arg(ARG_ID) - private val targetObjectType get() = arg(ARG_TARGET_OBJECT_TYPE) + private val targetTypeId get() = arg(ARG_TARGET_TYPE_ID) + private val targetTypeKey get() = arg(ARG_TARGET_TYPE_KEY) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setStyle(STYLE_NORMAL, R.style.AppBottomSecondarySheetDialogTheme) val editorFragment = EditorTemplateFragment.newInstance( id = ctx, - targetObjectType = targetObjectType + targetTypeId = targetTypeId, + targetTypeKey = targetTypeKey ) childFragmentManager.beginTransaction() .add(R.id.fragment_container_view, editorFragment) @@ -52,6 +54,7 @@ class EditorModalFragment : BaseBottomSheetFragment( companion object { const val ARG_ID = "arg_id" - const val ARG_TARGET_OBJECT_TYPE = "arg_target_object_type" + const val ARG_TARGET_TYPE_ID = "arg_target_object_type" + const val ARG_TARGET_TYPE_KEY = "arg_target_object_type_key" } } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreen.kt b/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreen.kt index 8c600a3cad..6263bf45eb 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreen.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreen.kt @@ -68,6 +68,7 @@ import com.anytypeio.anytype.ui.widgets.types.DataViewListWidgetCard import com.anytypeio.anytype.ui.widgets.types.LibraryWidgetCard import com.anytypeio.anytype.ui.widgets.types.LinkWidgetCard import com.anytypeio.anytype.ui.widgets.types.ListWidgetCard +import com.anytypeio.anytype.ui.widgets.types.SpaceWidgetCard import com.anytypeio.anytype.ui.widgets.types.TreeWidgetCard import org.burnoutcrew.reorderable.ReorderableItem import org.burnoutcrew.reorderable.detectReorderAfterLongPress @@ -92,10 +93,12 @@ fun HomeScreen( onExitEditMode: () -> Unit, onSearchClicked: () -> Unit, onLibraryClicked: () -> Unit, + onOpenSpacesClicked: () -> Unit, onCreateNewObjectClicked: () -> Unit, onSpaceClicked: () -> Unit, - onMove: (List, FromIndex, ToIndex) -> Unit, - onObjectCheckboxClicked: (Id, Boolean) -> Unit + onObjectCheckboxClicked: (Id, Boolean) -> Unit, + onSpaceWidgetClicked: () -> Unit, + onMove: (List, FromIndex, ToIndex) -> Unit ) { Box(modifier = Modifier.fillMaxSize()) { @@ -111,6 +114,8 @@ fun HomeScreen( onChangeWidgetView = onChangeWidgetView, onEditWidgets = onEditWidgets, onLibraryClicked = onLibraryClicked, + onOpenSpacesClicked = onOpenSpacesClicked, + onSpaceWidgetClicked = onSpaceWidgetClicked, onMove = onMove, onObjectCheckboxClicked = onObjectCheckboxClicked ) @@ -176,7 +181,9 @@ private fun WidgetList( onEditWidgets: () -> Unit, onLibraryClicked: () -> Unit, onMove: (List, FromIndex, ToIndex) -> Unit, - onObjectCheckboxClicked: (Id, Boolean) -> Unit + onObjectCheckboxClicked: (Id, Boolean) -> Unit, + onOpenSpacesClicked: () -> Unit, + onSpaceWidgetClicked: () -> Unit ) { val views = remember { mutableStateOf(widgets) } views.value = widgets @@ -208,6 +215,13 @@ private fun WidgetList( key = { _, item -> item.id } ) { index, item -> when (item) { + is WidgetView.SpaceWidget.View -> { + SpaceWidgetCard( + onClick = onSpaceWidgetClicked, + name = item.space.name.orEmpty(), + icon = item.icon + ) + } is WidgetView.Tree -> { ReorderableItem(lazyListState, key = item.id) { isDragged -> val alpha = animateFloatAsState(if (isDragged) 0.8f else 1.0f) @@ -435,6 +449,25 @@ private fun WidgetList( mode = mode ) } + is WidgetView.Space -> { + Box( + Modifier + .fillMaxWidth() + .padding(vertical = 12.dp) + .animateItemPlacement( + spring( + stiffness = Spring.StiffnessHigh, + visibilityThreshold = IntOffset.Zero + ) + ) + ) { + WidgetActionButton( + label = "Open spaces", + onClick = onOpenSpacesClicked, + modifier = Modifier.align(Alignment.TopCenter) + ) + } + } is WidgetView.Library -> { LibraryWidgetCard( onDropDownMenuAction = { action -> diff --git a/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt index 609b8cd8f0..00fb953db9 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt @@ -84,7 +84,13 @@ class HomeScreenFragment : BaseComposeFragment() { vm.onCreateNewObjectClicked() }, onSpaceClicked = { - navigation().openSettings() + findNavController().navigate(R.id.action_open_spaces) + }, + onSpaceWidgetClicked = { + findNavController().navigate(R.id.action_open_space_settings) + }, + onOpenSpacesClicked = { + findNavController().navigate(R.id.action_open_spaces) }, onBundledWidgetClicked = vm::onBundledWidgetClicked, onMove = vm::onMove, diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/ObjectTypeChangeFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/ObjectTypeChangeFragment.kt index b5adfbbc3b..4e9733a052 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/ObjectTypeChangeFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/ObjectTypeChangeFragment.kt @@ -10,6 +10,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.objects.ObjectTypeVerticalAdapter import com.anytypeio.anytype.core_ui.reactive.textChanges import com.anytypeio.anytype.core_utils.ext.argOrNull @@ -27,7 +28,7 @@ abstract class BaseObjectTypeChangeFragment : abstract fun setTitle() abstract fun startWithParams() - abstract fun onItemClicked(id: Id, name: String) + abstract fun onItemClicked(id: Id, key: Key, name: String) @Inject lateinit var factory: ObjectTypeChangeViewModelFactory @@ -66,11 +67,13 @@ abstract class BaseObjectTypeChangeFragment : jobs += subscribe(binding.searchObjectTypeInput.textChanges()) { vm.onQueryChanged(it.toString()) } + jobs += subscribe(vm.toasts) { toast -> toast(toast) } jobs += subscribe(vm.commands) { command -> when (command) { is Command.DispatchType -> { onItemClicked( id = command.id, + key = command.key, name = command.name ) } diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/AppDefaultObjectTypeFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/AppDefaultObjectTypeFragment.kt index 6298c37d86..9c61696904 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/AppDefaultObjectTypeFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/AppDefaultObjectTypeFragment.kt @@ -3,6 +3,7 @@ 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_models.Key import com.anytypeio.anytype.core_utils.ext.hideSoftInput import com.anytypeio.anytype.core_utils.ext.withParent import com.anytypeio.anytype.di.common.componentManager @@ -21,10 +22,11 @@ class AppDefaultObjectTypeFragment : BaseObjectTypeChangeFragment() { ) } - override fun onItemClicked(id: Id, name: String) { + override fun onItemClicked(id: Id, key: Key, name: String) { withParent { onProceedWithUpdateType( id = id, + key = key, name = name ) } @@ -51,6 +53,6 @@ class AppDefaultObjectTypeFragment : BaseObjectTypeChangeFragment() { } interface OnObjectTypeAction { - fun onProceedWithUpdateType(id: Id, name: String) + fun onProceedWithUpdateType(id: Id, key: Key, name: String) } } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DataViewSelectSourceFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DataViewSelectSourceFragment.kt index 9d753342df..99a1c4001d 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DataViewSelectSourceFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DataViewSelectSourceFragment.kt @@ -3,6 +3,7 @@ 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_models.Key import com.anytypeio.anytype.core_utils.ext.hideSoftInput import com.anytypeio.anytype.core_utils.ext.withParent import com.anytypeio.anytype.di.common.componentManager @@ -23,7 +24,7 @@ class DataViewSelectSourceFragment : BaseObjectTypeChangeFragment() { ) } - override fun onItemClicked(id: Id, name: String) { + override fun onItemClicked(id: Id, key: Key, name: String) { withParent { onProceedWithSelectSource(id = id) } diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DraftObjectSelectTypeFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DraftObjectSelectTypeFragment.kt index 16ad05d720..5b98c03765 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DraftObjectSelectTypeFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/DraftObjectSelectTypeFragment.kt @@ -3,6 +3,7 @@ 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_models.Key import com.anytypeio.anytype.core_utils.ext.hideSoftInput import com.anytypeio.anytype.core_utils.ext.withParent import com.anytypeio.anytype.di.common.componentManager @@ -23,9 +24,12 @@ class DraftObjectSelectTypeFragment : BaseObjectTypeChangeFragment() { ) } - override fun onItemClicked(id: Id, name: String) { + override fun onItemClicked(id: Id, key: Key, name: String) { withParent { - onProceedWithDraftUpdateType(id = id) + onProceedWithDraftUpdateType( + id = id, + key = key + ) } hideSoftInput() dismiss() diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/EmptyDataViewSelectSourceFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/EmptyDataViewSelectSourceFragment.kt index 51a0282783..a55374b6ca 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/EmptyDataViewSelectSourceFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/EmptyDataViewSelectSourceFragment.kt @@ -2,6 +2,7 @@ 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_models.Key import com.anytypeio.anytype.core_utils.ext.hideSoftInput import com.anytypeio.anytype.core_utils.ext.withParent import com.anytypeio.anytype.di.common.componentManager @@ -22,7 +23,7 @@ class EmptyDataViewSelectSourceFragment : BaseObjectTypeChangeFragment() { ) } - override fun onItemClicked(id: Id, name: String) { + override fun onItemClicked(id: Id, key: Key, name: String) { withParent { onProceedWithSelectSource(id = id) } diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/ObjectSelectTypeFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/ObjectSelectTypeFragment.kt index c601720a24..662cd15591 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/ObjectSelectTypeFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/ObjectSelectTypeFragment.kt @@ -3,6 +3,7 @@ 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_models.Key import com.anytypeio.anytype.core_utils.ext.hideSoftInput import com.anytypeio.anytype.core_utils.ext.withParent import com.anytypeio.anytype.di.common.componentManager @@ -23,9 +24,9 @@ class ObjectSelectTypeFragment : BaseObjectTypeChangeFragment() { ) } - override fun onItemClicked(id: Id, name: String) { + override fun onItemClicked(id: Id, key: Key, name: String) { withParent { - onProceedWithUpdateType(id = id) + onProceedWithUpdateType(id = id, key = key) } hideSoftInput() dismiss() diff --git a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/OnObjectSelectTypeAction.kt b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/OnObjectSelectTypeAction.kt index 7152dce511..3e5d1d16ca 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/OnObjectSelectTypeAction.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/objects/types/pickers/OnObjectSelectTypeAction.kt @@ -1,8 +1,9 @@ package com.anytypeio.anytype.ui.objects.types.pickers import com.anytypeio.anytype.core_models.Id +import com.anytypeio.anytype.core_models.Key interface OnObjectSelectTypeAction { - fun onProceedWithUpdateType(id: Id) - fun onProceedWithDraftUpdateType(id: Id) + fun onProceedWithUpdateType(id: Id, key: Key) + fun onProceedWithDraftUpdateType(id: Id, key: Key) } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/sets/ObjectSetFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/sets/ObjectSetFragment.kt index 90776ef188..530bb0694b 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/sets/ObjectSetFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/sets/ObjectSetFragment.kt @@ -52,8 +52,8 @@ import com.anytypeio.anytype.core_ui.reactive.touches import com.anytypeio.anytype.core_ui.tools.DefaultTextWatcher import com.anytypeio.anytype.core_ui.views.ButtonPrimarySmallIcon import com.anytypeio.anytype.core_ui.widgets.FeaturedRelationGroupWidget -import com.anytypeio.anytype.core_ui.widgets.TypeTemplatesWidget import com.anytypeio.anytype.core_ui.widgets.StatusBadgeWidget +import com.anytypeio.anytype.core_ui.widgets.TypeTemplatesWidget import com.anytypeio.anytype.core_ui.widgets.dv.ViewerEditWidget import com.anytypeio.anytype.core_ui.widgets.dv.ViewerLayoutWidget import com.anytypeio.anytype.core_ui.widgets.dv.ViewersWidget @@ -78,7 +78,6 @@ import com.anytypeio.anytype.databinding.FragmentObjectSetBinding import com.anytypeio.anytype.di.common.componentManager import com.anytypeio.anytype.presentation.editor.cover.CoverColor import com.anytypeio.anytype.presentation.editor.cover.CoverGradient -import com.anytypeio.anytype.presentation.sets.ViewersWidgetUi import com.anytypeio.anytype.presentation.sets.DataViewViewState import com.anytypeio.anytype.presentation.sets.ObjectSetCommand import com.anytypeio.anytype.presentation.sets.ObjectSetViewModel @@ -86,9 +85,9 @@ import com.anytypeio.anytype.presentation.sets.ObjectSetViewModelFactory import com.anytypeio.anytype.presentation.sets.SetOrCollectionHeaderState import com.anytypeio.anytype.presentation.sets.ViewEditAction import com.anytypeio.anytype.presentation.sets.ViewerLayoutWidgetUi +import com.anytypeio.anytype.presentation.sets.ViewersWidgetUi import com.anytypeio.anytype.presentation.sets.isVisible import com.anytypeio.anytype.presentation.sets.model.Viewer -import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUI import com.anytypeio.anytype.ui.base.NavigationFragment import com.anytypeio.anytype.ui.editor.cover.SelectCoverObjectSetFragment import com.anytypeio.anytype.ui.editor.modals.IconPickerFragmentBase @@ -111,7 +110,8 @@ import com.anytypeio.anytype.ui.sets.modals.ManageViewerFragment import com.anytypeio.anytype.ui.sets.modals.ObjectSetSettingsFragment import com.anytypeio.anytype.ui.sets.modals.SetObjectCreateRecordFragmentBase import com.anytypeio.anytype.ui.sets.modals.sort.ViewerSortFragment -import com.anytypeio.anytype.ui.templates.EditorTemplateFragment.Companion.ARG_TARGET_OBJECT_TYPE +import com.anytypeio.anytype.ui.templates.EditorTemplateFragment.Companion.ARG_TARGET_TYPE_ID +import com.anytypeio.anytype.ui.templates.EditorTemplateFragment.Companion.ARG_TARGET_TYPE_KEY import com.anytypeio.anytype.ui.templates.EditorTemplateFragment.Companion.ARG_TEMPLATE_ID import com.bumptech.glide.Glide import javax.inject.Inject @@ -1221,14 +1221,15 @@ open class ObjectSetFragment : inflater, container, false ) - override fun onProceedWithUpdateType(id: Id) { + override fun onProceedWithUpdateType(id: Id, key: Key) { vm.onNewTypeForViewerClicked(id) } - override fun onProceedWithDraftUpdateType(id: Id) { - // Do nothing + override fun onProceedWithDraftUpdateType(id: Id, key: Key) { + // Do nothing. } + private fun observeSelectingTemplate() { val navController = findNavController() val navBackStackEntry = navController.getBackStackEntry(R.id.objectSetScreen) @@ -1236,14 +1237,21 @@ open class ObjectSetFragment : if (event == Lifecycle.Event.ON_RESUME && navBackStackEntry.savedStateHandle.contains(ARG_TEMPLATE_ID)) { val resultTemplateId = navBackStackEntry.savedStateHandle.get(ARG_TEMPLATE_ID) - val resultObjectTypeId = navBackStackEntry.savedStateHandle.get(ARG_TARGET_OBJECT_TYPE) - if (!resultTemplateId.isNullOrBlank() && !resultObjectTypeId.isNullOrBlank()) { + val resultTypeId = navBackStackEntry.savedStateHandle.get(ARG_TARGET_TYPE_ID) + val resultTypeKey = navBackStackEntry.savedStateHandle.get(ARG_TARGET_TYPE_KEY) + if (!resultTemplateId.isNullOrBlank() && !resultTypeId.isNullOrBlank() && !resultTypeKey.isNullOrBlank()) { navBackStackEntry.savedStateHandle.remove(ARG_TEMPLATE_ID) - navBackStackEntry.savedStateHandle.remove(ARG_TARGET_OBJECT_TYPE) - vm.proceedWithSelectedTemplate(template = resultTemplateId, objectType = resultObjectTypeId) + navBackStackEntry.savedStateHandle.remove(ARG_TARGET_TYPE_ID) + navBackStackEntry.savedStateHandle.remove(ARG_TARGET_TYPE_KEY) + vm.proceedWithSelectedTemplate( + template = resultTemplateId, + typeId = resultTypeId, + typeKey = resultTypeKey + ) } } } + navBackStackEntry.lifecycle.addObserver(observer) viewLifecycleOwner.lifecycle.addObserver(LifecycleEventObserver { _, event -> diff --git a/app/src/main/java/com/anytypeio/anytype/ui/sets/modals/EditDataViewViewerFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/sets/modals/EditDataViewViewerFragment.kt index cc8c31e45d..86fdd3f6b4 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/sets/modals/EditDataViewViewerFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/sets/modals/EditDataViewViewerFragment.kt @@ -128,7 +128,12 @@ EditDataViewViewerFragment : BaseBottomSheetFragment {} + EditDataViewViewerViewModel.ViewState.Kanban -> { + toast("TODO") + } + EditDataViewViewerViewModel.ViewState.Calendar -> { + toast("TODO") + } } } diff --git a/app/src/main/java/com/anytypeio/anytype/ui/settings/OtherSettingsFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/settings/OtherSettingsFragment.kt index 53e396facf..7a913887ea 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/settings/OtherSettingsFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/settings/OtherSettingsFragment.kt @@ -6,6 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.viewModels import com.anytypeio.anytype.core_models.Id +import com.anytypeio.anytype.core_models.Key import com.anytypeio.anytype.core_utils.ext.toast import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetFragment import com.anytypeio.anytype.core_utils.ui.proceed @@ -24,8 +25,8 @@ class OtherSettingsFragment : BaseBottomSheetFragment { factory } - override fun onProceedWithUpdateType(id: Id, name: String) { - vm.proceedWithUpdateType(type = id, name = name) + override fun onProceedWithUpdateType(id: Id, key: Key, name: String) { + vm.proceedWithUpdateType(type = id, key = key, name = name) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/anytypeio/anytype/ui/settings/ProfileFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/settings/ProfileFragment.kt index 0eb6a160e7..75903cc516 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/settings/ProfileFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/settings/ProfileFragment.kt @@ -91,6 +91,13 @@ class ProfileFragment : BaseBottomSheetComposeFragment() { setupBottomSheetBehavior(PADDING_TOP) } + override fun onStart() { + super.onStart() + subscribe(vm.toasts) { + toast(it) + } + } + private fun proceedWithAccountDeletion() { vm.proceedWithAccountDeletion() val dialog = DeleteAccountWarning() diff --git a/app/src/main/java/com/anytypeio/anytype/ui/settings/space/SpaceSettingsFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/settings/space/SpaceSettingsFragment.kt new file mode 100644 index 0000000000..fa8f49747d --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/ui/settings/space/SpaceSettingsFragment.kt @@ -0,0 +1,244 @@ +package com.anytypeio.anytype.ui.settings.space + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.platform.ViewCompositionStrategy +import androidx.compose.ui.platform.rememberNestedScrollInteropConnection +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.fragment.app.viewModels +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.navigation.fragment.findNavController +import com.anytypeio.anytype.R +import com.anytypeio.anytype.core_ui.common.ComposeDialogView +import com.anytypeio.anytype.core_ui.extensions.throttledClick +import com.anytypeio.anytype.core_ui.foundation.Divider +import com.anytypeio.anytype.core_ui.foundation.Option +import com.anytypeio.anytype.core_ui.views.ButtonSize +import com.anytypeio.anytype.core_ui.views.ButtonWarning +import com.anytypeio.anytype.core_ui.views.PreviewTitle2Regular +import com.anytypeio.anytype.core_ui.views.Title1 +import com.anytypeio.anytype.core_utils.ext.toast +import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment +import com.anytypeio.anytype.core_utils.ui.ViewState +import com.anytypeio.anytype.di.common.componentManager +import com.anytypeio.anytype.presentation.spaces.SpaceSettingsViewModel +import com.anytypeio.anytype.ui.settings.typography +import com.anytypeio.anytype.ui.spaces.Section +import com.anytypeio.anytype.ui.spaces.TypeOfSpace +import com.anytypeio.anytype.ui_settings.main.SpaceHeader +import javax.inject.Inject +import timber.log.Timber + +class SpaceSettingsFragment : BaseBottomSheetComposeFragment() { + + @Inject + lateinit var factory: SpaceSettingsViewModel.Factory + + private val vm by viewModels { factory } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ) = ComposeDialogView( + context = requireContext(), dialog = requireDialog() + ).apply { + setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) + setContent { + MaterialTheme(typography = typography) { + SpaceSettingsScreen(onSpaceIconClick = {}, + onNameSet = vm::onNameSet, + spaceData = vm.spaceViewState.collectAsStateWithLifecycle().value, + onDeleteSpaceClicked = { + toast("Coming soon...") + }, + onFileStorageClick = { + findNavController().navigate(R.id.filesStorageScreen) + }, + onPersonalizationClicked = { + findNavController().navigate(R.id.personalizationScreen) + } + ) + } + } + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + expand() + skipCollapsed() + } + + override fun injectDependencies() { + componentManager().spaceSettingsComponent.get().inject(this) + } + + override fun releaseDependencies() { + componentManager().spaceSettingsComponent.release() + } +} + +@Composable +fun SpaceSettingsScreen( + spaceData: ViewState, + onSpaceIconClick: () -> Unit, + onNameSet: (String) -> Unit, + onDeleteSpaceClicked: () -> Unit, + onFileStorageClick: () -> Unit, + onPersonalizationClicked: () -> Unit, +) { + LazyColumn( + modifier = Modifier + .nestedScroll(rememberNestedScrollInteropConnection()) + .fillMaxSize(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + item { + SpaceHeader( + modifier = Modifier, + name = when (spaceData) { + is ViewState.Success -> spaceData.data.name.also { + Timber.d("Setting name: $it") + } + else -> null + }, + icon = when (spaceData) { + is ViewState.Success -> spaceData.data.icon + else -> null + }, + onSpaceIconClick = onSpaceIconClick, + onNameSet = onNameSet + ) + } + item { Divider() } + item { + Section(title = "Type") + } + item { + TypeOfSpace() + } + item { + Divider() + } + item { + Section(title = stringResource(id = R.string.settings)) + } + item { + Option(image = R.drawable.ic_file_storage, + text = stringResource(R.string.remote_storage), + onClick = throttledClick(onFileStorageClick) + ) + } + item { + Option(image = R.drawable.ic_personalization, + text = stringResource(R.string.personalization), + onClick = throttledClick(onPersonalizationClicked) + ) + } + item { + Section(title = stringResource(id = R.string.space_info)) + } + item { + Box( + modifier = Modifier + .height(92.dp) + .padding(horizontal = 20.dp) + .fillMaxWidth() + ) { + Text( + text = stringResource(id = R.string.space_id), + style = Title1, + modifier = Modifier.padding(top = 12.dp) + ) + if (spaceData is ViewState.Success) { + Text( + text = spaceData.data.spaceId ?: stringResource(id = R.string.unknown), + style = PreviewTitle2Regular, + modifier = Modifier + .align(Alignment.BottomStart) + .padding(bottom = 12.dp, end = 50.dp), + maxLines = 2 + ) + } + } + } + item { + Box( + modifier = Modifier + .height(72.dp) + .padding(horizontal = 20.dp) + .fillMaxWidth() + ) { + Text( + text = stringResource(id = R.string.created_by), + style = Title1, + modifier = Modifier.padding(top = 12.dp) + ) + if (spaceData is ViewState.Success) { + Text( + text = spaceData.data.createdBy ?: stringResource(id = R.string.unknown), + style = PreviewTitle2Regular, + modifier = Modifier + .align(Alignment.BottomStart) + .padding(bottom = 12.dp, end = 50.dp), + maxLines = 1 + ) + } + } + } + item { + Box( + modifier = Modifier + .height(72.dp) + .padding(horizontal = 20.dp) + .fillMaxWidth() + ) { + Text( + text = stringResource(id = R.string.creation_date), + style = Title1, + modifier = Modifier.padding(top = 12.dp) + ) + if (spaceData is ViewState.Success) { + Text( + text = spaceData.data.createdDate ?: stringResource(id = R.string.unknown), + style = PreviewTitle2Regular, + modifier = Modifier + .align(Alignment.BottomStart) + .padding(bottom = 12.dp, end = 50.dp), + maxLines = 1 + ) + } + } + } + item { + Box(modifier = Modifier.height(78.dp)) { + ButtonWarning( + onClick = { onDeleteSpaceClicked() }, + text = "Delete space", + modifier = Modifier + .padding(start = 20.dp, end = 20.dp, bottom = 10.dp) + .fillMaxWidth() + .align(Alignment.BottomCenter), + size = ButtonSize.Large + ) + } + } + item { + Spacer(modifier = Modifier.height(16.dp)) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceFragment.kt new file mode 100644 index 0000000000..e6615c985f --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceFragment.kt @@ -0,0 +1,66 @@ +package com.anytypeio.anytype.ui.spaces + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.compose.material.MaterialTheme +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.ViewCompositionStrategy +import androidx.fragment.app.viewModels +import com.anytypeio.anytype.core_utils.ext.toast +import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment +import com.anytypeio.anytype.di.common.componentManager +import com.anytypeio.anytype.presentation.spaces.CreateSpaceViewModel +import com.anytypeio.anytype.ui.settings.typography +import javax.inject.Inject + +class CreateSpaceFragment : BaseBottomSheetComposeFragment() { + + @Inject + lateinit var factory: CreateSpaceViewModel.Factory + + private val vm by viewModels { factory } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View = ComposeView(requireContext()).apply { + setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) + setContent { + MaterialTheme( + typography = typography + ) { + CreateSpaceScreen( + spaceIconView = vm.spaceGradient.collectAsState().value, + onCreate = vm::onCreateSpace, + onSpaceIconClicked = vm::onSpaceIconClicked, + isLoading = vm.isInProgress.collectAsState() + ) + LaunchedEffect(Unit) { vm.toasts.collect() { toast(it) } } + LaunchedEffect(Unit) { + vm.isDismissed.collect { isDismissed -> + if (isDismissed) dismiss() + } + } + } + } + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + skipCollapsed() + expand() + } + + override fun injectDependencies() { + componentManager().createSpaceComponent.get().inject(this) + } + + override fun releaseDependencies() { + componentManager().createSpaceComponent.release() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceScreen.kt b/app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceScreen.kt new file mode 100644 index 0000000000..b6b09e2909 --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/ui/spaces/CreateSpaceScreen.kt @@ -0,0 +1,279 @@ +package com.anytypeio.anytype.ui.spaces + +import androidx.compose.foundation.Image +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.text.BasicTextField +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.Text +import androidx.compose.material.TextFieldDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.State +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.input.VisualTransformation +import androidx.compose.ui.unit.dp +import com.anytypeio.anytype.R +import com.anytypeio.anytype.core_models.Name +import com.anytypeio.anytype.core_ui.foundation.Divider +import com.anytypeio.anytype.core_ui.foundation.Dragger +import com.anytypeio.anytype.core_ui.views.BodyRegular +import com.anytypeio.anytype.core_ui.views.ButtonPrimaryLoading +import com.anytypeio.anytype.core_ui.views.ButtonSize +import com.anytypeio.anytype.core_ui.views.Caption1Regular +import com.anytypeio.anytype.core_ui.views.HeadlineHeading +import com.anytypeio.anytype.core_ui.views.Title2 +import com.anytypeio.anytype.presentation.spaces.SpaceIconView +import com.anytypeio.anytype.ui_settings.main.SpaceImageBlock + +@Composable +fun CreateSpaceScreen( + spaceIconView: SpaceIconView, + onCreate: (Name) -> Unit, + onSpaceIconClicked: () -> Unit, + isLoading: State +) { + val input = remember { + mutableStateOf("") + } + Column(modifier = Modifier.fillMaxHeight()) { + Dragger( + modifier = Modifier + .padding(vertical = 6.dp) + .align(Alignment.CenterHorizontally) + ) + Header() + Spacer(modifier = Modifier.height(16.dp)) + SpaceIcon( + modifier = Modifier.align(Alignment.CenterHorizontally), + spaceIconView = spaceIconView, + onSpaceIconClicked = onSpaceIconClicked + ) + Spacer(modifier = Modifier.height(10.dp)) + SpaceNameInput(input = input) + Divider() + Section(title = "Type") + TypeOfSpace() + Divider() + Section(title = "Start with") + UseCase() + Divider() + Box(modifier = Modifier.weight(1.0f)) { + CreateSpaceButton( + onCreate = onCreate, + input = input, + modifier = Modifier.align(Alignment.BottomCenter), + isLoading = isLoading + ) + } + } +} + +@Composable +private fun CreateSpaceButton( + modifier: Modifier, + onCreate: (Name) -> Unit, + input: State, + isLoading: State +) { + Box( + modifier = modifier + .height(78.dp) + .fillMaxWidth() + ) { + ButtonPrimaryLoading( + onClick = { onCreate(input.value) }, + text = stringResource(id = R.string.create), + size = ButtonSize.Large, + modifierButton = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp) + , + modifierBox = Modifier + .padding(bottom = 10.dp) + .align(Alignment.BottomCenter) + , + loading = isLoading.value + ) + } +} + +@Composable +fun Header() { + Box( + modifier = Modifier + .height(48.dp) + .fillMaxWidth() + ) { + Text( + modifier = Modifier.align(Alignment.Center), + text = stringResource(id = R.string.create_space), + style = Title2, + color = colorResource(id = R.color.text_primary) + ) + } +} + +@Composable +fun SpaceIcon( + modifier: Modifier, + spaceIconView: SpaceIconView, + onSpaceIconClicked: () -> Unit +) { + Box(modifier = modifier.wrapContentSize()) { + SpaceImageBlock( + icon = spaceIconView, + onSpaceIconClick = onSpaceIconClicked + ) + } +} + +@OptIn(ExperimentalMaterialApi::class) +@Composable +fun SpaceNameInput( + input: MutableState +) { + val focusManager = LocalFocusManager.current + Box( + modifier = Modifier + .height(72.dp) + .fillMaxWidth() + ) { + BasicTextField( + value = input.value, + onValueChange = { input.value = it }, + keyboardActions = KeyboardActions( + onDone = { + focusManager.clearFocus() + } + ), + modifier = Modifier + .fillMaxWidth() + .padding(start = 20.dp, bottom = 12.dp) + .align(Alignment.BottomStart) + , + maxLines = 1, + singleLine = true, + textStyle = HeadlineHeading.copy( + color = colorResource(id = R.color.text_primary) + ), + decorationBox = @Composable { innerTextField -> + TextFieldDefaults.OutlinedTextFieldDecorationBox( + value = input.value, + innerTextField = innerTextField, + singleLine = true, + enabled = true, + isError = false, + placeholder = { + Text( + text = stringResource(R.string.space_name), + style = HeadlineHeading + ) + }, + colors = TextFieldDefaults.outlinedTextFieldColors( + textColor = colorResource(id = com.anytypeio.anytype.ui_settings.R.color.text_primary), + backgroundColor = Color.Transparent, + disabledBorderColor = Color.Transparent, + errorBorderColor = Color.Transparent, + focusedBorderColor = Color.Transparent, + unfocusedBorderColor = Color.Transparent, + placeholderColor = colorResource(id = com.anytypeio.anytype.ui_settings.R.color.text_tertiary), + cursorColor = colorResource(id = com.anytypeio.anytype.ui_settings.R.color.orange) + ), + contentPadding = PaddingValues( + start = 0.dp, + top = 0.dp, + end = 0.dp, + bottom = 0.dp + ), + border = {}, + interactionSource = remember { MutableInteractionSource() }, + visualTransformation = VisualTransformation.None + ) + } + ) + Text( + color = colorResource(id = R.color.text_secondary), + style = Caption1Regular, + modifier = Modifier.padding( + start = 20.dp, + top = 11.dp + ), + text = stringResource(id = R.string.space_name) + ) + } +} + +@Composable +fun Section( + title: String +) { + Box(modifier = Modifier.height(52.dp).fillMaxWidth()) { + Text( + modifier = Modifier + .padding( + start = 20.dp, + bottom = 8.dp + ) + .align(Alignment.BottomStart), + text = title, + color = colorResource(id = R.color.text_secondary) + ) + } +} + +@Composable +fun TypeOfSpace() { + Box( + modifier = Modifier + .height(52.dp) + .fillMaxWidth() + ) { + Image( + modifier = Modifier + .align(Alignment.CenterStart) + .padding(start = 18.dp), + painter = painterResource(id = R.drawable.ic_space_type_private), + contentDescription = "Private space icon" + ) + Text( + modifier = Modifier + .padding(start = 42.dp) + .align(Alignment.CenterStart), + text = "Private", + color = colorResource(id = R.color.text_primary), + style = BodyRegular + ) + } +} + +@Composable +fun UseCase() { + Box(modifier = Modifier.height(52.dp)) { + Text( + modifier = Modifier + .padding(start = 20.dp) + .align(Alignment.CenterStart), + text = "Empty space", + color = colorResource(id = R.color.text_primary), + style = BodyRegular + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/spaces/SelectSpaceFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/spaces/SelectSpaceFragment.kt new file mode 100644 index 0000000000..71d39b04cd --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/ui/spaces/SelectSpaceFragment.kt @@ -0,0 +1,99 @@ +package com.anytypeio.anytype.ui.spaces + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.compose.material.MaterialTheme +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.ViewCompositionStrategy +import androidx.fragment.app.viewModels +import androidx.navigation.fragment.findNavController +import com.anytypeio.anytype.R +import com.anytypeio.anytype.core_utils.ext.toast +import com.anytypeio.anytype.core_utils.ui.BaseBottomSheetComposeFragment +import com.anytypeio.anytype.di.common.componentManager +import com.anytypeio.anytype.presentation.spaces.Command +import com.anytypeio.anytype.presentation.spaces.SelectSpaceViewModel +import com.anytypeio.anytype.ui.settings.typography +import javax.inject.Inject + +class SelectSpaceFragment : BaseBottomSheetComposeFragment() { + + @Inject + lateinit var factory: SelectSpaceViewModel.Factory + + private val vm by viewModels { factory } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setStyle( + STYLE_NORMAL, + R.style.SelectSpaceDialogTheme + ) + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View = ComposeView(requireContext()).apply { + setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) + setContent { + MaterialTheme( + typography = typography + ) { + SelectSpaceScreen( + spaces = vm.views.collectAsState().value, + onSpaceClicked = vm::onSpaceClicked, + onAddClicked = vm::onCreateSpaceClicked, + onSpaceSettingsClicked = { + findNavController().navigate( + R.id.profileScreen + ) + }, + onProfileClicked = { + findNavController().navigate( + R.id.profileScreen + ) + } + ) + } + LaunchedEffect(Unit) { + vm.commands.collect { command -> proceedWithCommand(command) } + } + LaunchedEffect(Unit) { + vm.toasts.collect { toast(it) } + } + } + } + + private fun proceedWithCommand(command: Command) { + when (command) { + is Command.CreateSpace -> { + findNavController().navigate( + R.id.createSpaceScreen + ) + } + is Command.Dismiss -> { + findNavController().popBackStack() + } + } + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + skipCollapsed() + expand() + } + + override fun injectDependencies() { + componentManager().selectSpaceComponent.get().inject(this) + } + + override fun releaseDependencies() { + componentManager().selectSpaceComponent.release() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/spaces/SelectSpaceScreen.kt b/app/src/main/java/com/anytypeio/anytype/ui/spaces/SelectSpaceScreen.kt new file mode 100644 index 0000000000..f68ff9da3f --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/ui/spaces/SelectSpaceScreen.kt @@ -0,0 +1,288 @@ +package com.anytypeio.anytype.ui.spaces + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.GridItemSpan +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.core.graphics.toColorInt +import coil.compose.rememberAsyncImagePainter +import com.anytypeio.anytype.R +import com.anytypeio.anytype.core_ui.foundation.Dragger +import com.anytypeio.anytype.core_ui.foundation.noRippleClickable +import com.anytypeio.anytype.core_ui.views.Caption1Medium +import com.anytypeio.anytype.core_ui.views.HeadlineHeading +import com.anytypeio.anytype.core_utils.ext.orNull +import com.anytypeio.anytype.presentation.profile.ProfileIconView +import com.anytypeio.anytype.presentation.spaces.SelectSpaceView +import com.anytypeio.anytype.presentation.spaces.WorkspaceView +import com.anytypeio.anytype.ui_settings.main.SpaceImageBlock + +@Composable +fun SelectSpaceScreen( + spaces: List, + onAddClicked: () -> Unit, + onSpaceClicked: (WorkspaceView) -> Unit, + onSpaceSettingsClicked: () -> Unit, + onProfileClicked: () -> Unit +) { + Column() { + Dragger( + modifier = Modifier + .padding(vertical = 6.dp) + .align(Alignment.CenterHorizontally) + ) + LazyVerticalGrid( + columns = GridCells.Fixed(count = 3), + modifier = Modifier.padding( + bottom = 16.dp + ) + ) { + spaces.forEach { item -> + when (item) { + is SelectSpaceView.Profile -> { + item( + span = { + GridItemSpan(MAX_SPAN_COUNT) + } + ) { + SelectSpaceProfileHeader( + profile = item, + onSpaceSettingsClicked = onSpaceSettingsClicked, + onProfileClicked = onProfileClicked + ) + } + } + is SelectSpaceView.Space -> { + item( + span = { + GridItemSpan(1) + } + ) { + SelectSpaceSpaceItem(item, onSpaceClicked) + } + } + is SelectSpaceView.Create -> { + item( + span = { + GridItemSpan(1) + } + ) { + SelectSpaceCreateButton(onAddClicked) + } + } + } + } + } + } +} + +@Composable +private fun SelectSpaceCreateButton(onAddClicked: () -> Unit) { + Column(modifier = Modifier) { + Box( + modifier = Modifier + .size(96.dp) + .align(Alignment.CenterHorizontally) + .clip(RoundedCornerShape(8.dp)) + .background(Color(0x33FFFFFF)) + .clickable { onAddClicked() } + ) { + Image( + painter = painterResource(id = R.drawable.ic_plus_32_white), + contentDescription = "Plus icon", + modifier = Modifier + .align(Alignment.Center) + ) + } + Spacer(modifier = Modifier.height(10.dp)) + Spacer(modifier = Modifier.height(28.dp)) + Spacer(modifier = Modifier.height(16.dp)) + } +} + +@Composable +private fun SelectSpaceSpaceItem( + item: SelectSpaceView.Space, + onSpaceClicked: (WorkspaceView) -> Unit +) { + Column(modifier = Modifier) { + Box( + modifier = Modifier + .size(96.dp) + .align(Alignment.CenterHorizontally) + .clip(RoundedCornerShape(8.dp)) + .then( + if (item.view.isSelected) + Modifier.border( + width = if (item.view.isSelected) 2.dp else 0.dp, + color = Color.White, + shape = RoundedCornerShape(8.dp) + ) + else + Modifier + ) + ) { + SpaceImageBlock( + icon = item.view.icon, + onSpaceIconClick = { onSpaceClicked(item.view) }, + gradientBackground = colorResource(id = R.color.default_gradient_background) + ) + } + Spacer(modifier = Modifier.height(10.dp)) + Text( + modifier = Modifier.fillMaxSize(), + text = item.view.name.orEmpty(), + textAlign = TextAlign.Center, + style = Caption1Medium, + color = Color.White, + maxLines = 1 + ) + Spacer(modifier = Modifier.height(16.dp)) + } +} + +@Composable +private fun SelectSpaceProfileHeader( + profile: SelectSpaceView.Profile, + onSpaceSettingsClicked: () -> Unit, + onProfileClicked: () -> Unit +) { + Box( + modifier = Modifier + .fillMaxWidth() + .height(68.dp) + .padding(bottom = 6.dp) + ) { + SelectSpaceProfileIcon( + modifier = Modifier + .padding(start = 30.dp) + .align(Alignment.CenterStart), + name = profile.name, + icon = profile.icon, + onProfileIconClick = onProfileClicked + ) + Text( + text = profile.name.orNull() ?: stringResource(id = R.string.untitled), + style = HeadlineHeading, + color = Color.White, + modifier = Modifier + .align( + Alignment.CenterStart + ) + .padding( + start = 74.dp, + end = 74.dp + ) + .clickable { onProfileClicked() } + ) + Box( + modifier = Modifier + .padding(end = 30.dp) + .size(32.dp) + .align(Alignment.CenterEnd) + .clickable { onSpaceSettingsClicked() } + ) { + Image( + painter = painterResource(id = R.drawable.ic_space_settings), + contentDescription = "Space settings icon", + modifier = Modifier.align(Alignment.Center) + ) + } + } +} + +@Composable +fun SelectSpaceProfileIcon( + modifier: Modifier, + name: String, + icon: ProfileIconView, + onProfileIconClick: () -> Unit +) { + when (icon) { + is ProfileIconView.Image -> { + Image( + painter = rememberAsyncImagePainter( + model = icon.url, + error = painterResource(id = R.drawable.ic_home_widget_space) + ), + contentDescription = "Custom image profile", + contentScale = ContentScale.Crop, + modifier = modifier + .size(32.dp) + .clip(RoundedCornerShape(16.dp)) + .noRippleClickable { + onProfileIconClick.invoke() + } + ) + } + is ProfileIconView.Gradient -> { + val gradient = Brush.radialGradient( + colors = listOf( + Color(icon.from.toColorInt()), + Color(icon.to.toColorInt()) + ) + ) + Box(modifier = modifier + .size(32.dp) + .clip(RoundedCornerShape(16.dp)) + .background(gradient) + .noRippleClickable { + onProfileIconClick.invoke() + }) + } + else -> { + val nameFirstChar = if (name.isEmpty()) { + stringResource(id = R.string.account_default_name) + } else { + name.first().uppercaseChar().toString() + } + Box( + modifier = modifier + .size(32.dp) + .clip(RoundedCornerShape(16.dp)) + .background(colorResource(id = R.color.shape_primary)) + .noRippleClickable { + onProfileIconClick.invoke() + } + ) { + Text( + text = nameFirstChar, + style = MaterialTheme.typography.h3.copy( + color = colorResource(id = R.color.text_white), + fontSize = 12.sp + ), + modifier = Modifier.align(Alignment.Center) + ) + } + } + } +} + +const val MAX_SPAN_COUNT = 3 \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/splash/SplashFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/splash/SplashFragment.kt index a6d6df5d37..060b07f3e7 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/splash/SplashFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/splash/SplashFragment.kt @@ -14,9 +14,11 @@ import androidx.navigation.fragment.findNavController import com.anytypeio.anytype.BuildConfig import com.anytypeio.anytype.R import com.anytypeio.anytype.app.DefaultAppActionManager.Companion.ACTION_CREATE_NEW_TYPE_KEY +import com.anytypeio.anytype.core_utils.ext.gone import com.anytypeio.anytype.core_utils.ext.toast import com.anytypeio.anytype.core_utils.ext.visible import com.anytypeio.anytype.core_utils.ui.BaseFragment +import com.anytypeio.anytype.core_utils.ui.ViewState import com.anytypeio.anytype.databinding.FragmentSplashBinding import com.anytypeio.anytype.di.common.componentManager import com.anytypeio.anytype.presentation.splash.SplashViewModel @@ -43,23 +45,40 @@ class SplashFragment : BaseFragment(R.layout.fragment_spl showVersion() viewLifecycleOwner.lifecycleScope.launch { viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { - vm.commands.collect { - try { - observe(it) - } catch (e: Exception) { - toast(e.message ?: resources.getString(R.string.unknown_error)) + launch { + vm.commands.collect { + try { + observe(it) + } catch (e: Exception) { + toast(e.message ?: resources.getString(R.string.unknown_error)) + } } } + launch { + vm.state.collect { state -> + when(state) { + is ViewState.Error -> { + binding.error.text = state.error + binding.error.visible() + } + else -> { + binding.error.gone() + binding.error.text = "" + } + } + } + } + } + } + if (BuildConfig.DEBUG) { + binding.error.setOnClickListener { + vm.onErrorClicked() } } } private fun observe(command: SplashViewModel.Command) { when (command) { - is SplashViewModel.Command.Error -> { - toast(command.msg) - binding.error.visible() - } SplashViewModel.Command.NavigateToDashboard -> { try { findNavController().navigate( diff --git a/app/src/main/java/com/anytypeio/anytype/ui/templates/EditorTemplateFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/templates/EditorTemplateFragment.kt index a5d02a1432..4d352de9b1 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/templates/EditorTemplateFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/templates/EditorTemplateFragment.kt @@ -20,7 +20,8 @@ import timber.log.Timber class EditorTemplateFragment : EditorFragment() { - private val targetObjectType get() = arg(ARG_TARGET_OBJECT_TYPE) + private val targetTypeId get() = arg(ARG_TARGET_TYPE_ID) + private val targetTypeKey get() = arg(ARG_TARGET_TYPE_KEY) override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -72,7 +73,8 @@ class EditorTemplateFragment : EditorFragment() { findNavController().apply { previousBackStackEntry?.savedStateHandle?.apply { set(ARG_TEMPLATE_ID, ctx) - set(ARG_TARGET_OBJECT_TYPE, targetObjectType) + set(ARG_TARGET_TYPE_ID, targetTypeId) + set(ARG_TARGET_TYPE_KEY, targetTypeKey) } popBackStack(R.id.editorModalScreen, true) } @@ -85,15 +87,17 @@ class EditorTemplateFragment : EditorFragment() { } companion object { - fun newInstance(id: String, targetObjectType: Id): EditorTemplateFragment = + fun newInstance(id: String, targetTypeId: Id, targetTypeKey: Id): EditorTemplateFragment = EditorTemplateFragment().apply { arguments = bundleOf( ID_KEY to id, - ARG_TARGET_OBJECT_TYPE to targetObjectType + ARG_TARGET_TYPE_ID to targetTypeId, + ARG_TARGET_TYPE_KEY to targetTypeKey ) } const val ARG_TEMPLATE_ID = "template_id" - const val ARG_TARGET_OBJECT_TYPE = "target_object_type" + const val ARG_TARGET_TYPE_ID = "target_type_id" + const val ARG_TARGET_TYPE_KEY = "target_type_key" } } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/widgets/collection/CollectionDI.kt b/app/src/main/java/com/anytypeio/anytype/ui/widgets/collection/CollectionDI.kt index f53d00c24e..0935d47363 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/widgets/collection/CollectionDI.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/widgets/collection/CollectionDI.kt @@ -29,7 +29,7 @@ import com.anytypeio.anytype.domain.page.CreateObject import com.anytypeio.anytype.domain.search.ObjectSearchSubscriptionContainer import com.anytypeio.anytype.domain.search.SubscriptionEventChannel import com.anytypeio.anytype.domain.templates.GetTemplates -import com.anytypeio.anytype.domain.workspace.WorkspaceManager +import com.anytypeio.anytype.domain.workspace.SpaceManager import com.anytypeio.anytype.presentation.util.Dispatcher import com.anytypeio.anytype.presentation.widgets.WidgetDispatchEvent import com.anytypeio.anytype.presentation.widgets.collection.CollectionViewModel @@ -42,9 +42,7 @@ import kotlinx.coroutines.Dispatchers @Component( dependencies = [CollectionDependencies::class], - modules = [ - CollectionModule::class - ] + modules = [CollectionModule::class] ) @PerScreen interface CollectionComponent { @@ -153,14 +151,14 @@ object CollectionModule { @PerScreen fun getCreateObject( repo: BlockRepository, - getTemplates: GetTemplates, getDefaultPageType: GetDefaultPageType, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager ): CreateObject = CreateObject( repo = repo, - getTemplates = getTemplates, getDefaultPageType = getDefaultPageType, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager ) @JvmStatic @@ -169,13 +167,15 @@ object CollectionModule { fun provideGetDefaultPageType( userSettingsRepository: UserSettingsRepository, blockRepository: BlockRepository, - workspaceManager: WorkspaceManager, - dispatchers: AppCoroutineDispatchers + dispatchers: AppCoroutineDispatchers, + spaceManager: SpaceManager, + configStorage: ConfigStorage ): GetDefaultPageType = GetDefaultPageType( userSettingsRepository = userSettingsRepository, blockRepository = blockRepository, - workspaceManager = workspaceManager, - dispatchers = dispatchers + dispatchers = dispatchers, + spaceManager = spaceManager, + configStorage = configStorage ) @JvmStatic @@ -209,11 +209,11 @@ interface CollectionDependencies : ComponentDependencies { fun urlBuilder(): UrlBuilder fun objectStore(): ObjectStore fun subscriptionEventChannel(): SubscriptionEventChannel - fun workspaceManager(): WorkspaceManager fun analytics(): Analytics fun eventChannel(): EventChannel fun userSettingsRepository(): UserSettingsRepository fun storeOfObjectTypes(): StoreOfObjectTypes fun dispatchers(): AppCoroutineDispatchers + fun spaceManager(): SpaceManager fun logger(): Logger } \ No newline at end of file diff --git a/app/src/main/java/com/anytypeio/anytype/ui/widgets/types/SpaceWidgetCard.kt b/app/src/main/java/com/anytypeio/anytype/ui/widgets/types/SpaceWidgetCard.kt new file mode 100644 index 0000000000..4ef24bf1e0 --- /dev/null +++ b/app/src/main/java/com/anytypeio/anytype/ui/widgets/types/SpaceWidgetCard.kt @@ -0,0 +1,76 @@ +package com.anytypeio.anytype.ui.widgets.types + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.colorResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.anytypeio.anytype.R +import com.anytypeio.anytype.core_ui.foundation.noRippleClickable +import com.anytypeio.anytype.core_ui.views.PreviewTitle2Medium +import com.anytypeio.anytype.core_ui.views.Relations3 +import com.anytypeio.anytype.presentation.spaces.SpaceIconView +import com.anytypeio.anytype.ui_settings.main.SpaceImageBlock + +@Composable +fun SpaceWidgetCard( + onClick: () -> Unit, + name: String, + icon: SpaceIconView +) { + Box( + modifier = Modifier + .padding(start = 20.dp, end = 20.dp, top = 12.dp, bottom = 6.dp) + .height(68.dp) + .fillMaxWidth() + .noRippleClickable { onClick() } + .background( + shape = RoundedCornerShape(16.dp), + color = colorResource(id = R.color.dashboard_card_background) + ) + ) { + Box( + modifier = Modifier + .padding(start = 16.dp) + .align(Alignment.CenterStart) + ) { + SpaceImageBlock( + icon = icon, + onSpaceIconClick = {}, + mainSize = 40.dp, + gradientSize = 24.dp, + emojiSize = 24.dp + ) + } + Text( + modifier = Modifier + .fillMaxWidth() + .align(Alignment.TopStart) + .padding(start = 71.dp, top = 16.dp, end = 32.dp) + , + text = name.trim().ifEmpty { stringResource(id = R.string.untitled) }, + style = PreviewTitle2Medium, + color = colorResource(id = R.color.text_primary), + maxLines = 1 + ) + Text( + modifier = Modifier + .fillMaxWidth() + .align(Alignment.BottomStart) + .padding(start = 71.dp, bottom = 16.dp) + , + text = stringResource(id = R.string.personal), + style = Relations3, + color = colorResource(id = R.color.text_secondary), + maxLines = 1 + ) + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_splash.xml b/app/src/main/res/layout/fragment_splash.xml index 02560609ac..6ff74ce4b3 100644 --- a/app/src/main/res/layout/fragment_splash.xml +++ b/app/src/main/res/layout/fragment_splash.xml @@ -30,7 +30,7 @@ android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:layout_marginBottom="100dp" - android:text="@string/failed_to_launch_wallet" + android:text="@string/generic_error" android:textColor="@color/palette_system_red" android:visibility="invisible" tools:ignore="SmallSp" diff --git a/app/src/main/res/layout/fragment_viewer_relations_list.xml b/app/src/main/res/layout/fragment_viewer_relations_list.xml index e5f3e0c24d..793b569af5 100644 --- a/app/src/main/res/layout/fragment_viewer_relations_list.xml +++ b/app/src/main/res/layout/fragment_viewer_relations_list.xml @@ -33,10 +33,11 @@ + android:id="@+id/action_open_space_settings" + app:destination="@id/spaceSettingsScreen" /> + + + + + + + Exiting... please wait Loading... please wait + Personal + Create a space + + Something went wrong. Please try again. + Type\n + Space info + Creation date + Created by + Space ID + diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt index aebe4228a7..18e99328c1 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt @@ -296,7 +296,8 @@ data class Block( GRID("Grid"), LIST("List"), GALLERY("Gallery"), - BOARD("Board") + BOARD("Board"), + CALENDAR("Calendar") } enum class Size { SMALL, MEDIUM, LARGE } diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt index d5fc48c9d9..cbccfb78e6 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt @@ -1,5 +1,8 @@ package com.anytypeio.anytype.core_models +import com.anytypeio.anytype.core_models.primitives.SpaceId +import com.anytypeio.anytype.core_models.primitives.TypeKey + sealed class Command { class UploadFile( @@ -165,6 +168,7 @@ sealed class Command { */ data class CreateBlockLinkWithObject( val context: Id, + val type: TypeKey, val target: Id, val position: Position, val template: Id?, @@ -181,7 +185,9 @@ sealed class Command { data class CreateObject( val prefilled: Struct, val template: Id?, - val internalFlags: List + val internalFlags: List, + val space: SpaceId, + val type: TypeKey ) class Move( diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Config.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Config.kt index 5bcbd60e10..95200dd5df 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Config.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Config.kt @@ -5,13 +5,14 @@ package com.anytypeio.anytype.core_models * @property home id of the home dashboard * @property profile id of the current profile * @property gateway url of the gateway for fetching files. - * @property workspace id of account workspace + * @property spaceView id of space view - UI-representation of space object */ data class Config( val home: Id, val profile: Id, val gateway: Url, - val workspace: Id, + val space: Id, + val spaceView: Id, val widgets: Id, val analytics: Id, val device: Id diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Constants.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Constants.kt new file mode 100644 index 0000000000..64efc97d58 --- /dev/null +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Constants.kt @@ -0,0 +1,3 @@ +package com.anytypeio.anytype.core_models + +const val NO_VALUE = "" \ No newline at end of file diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectType.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectType.kt index da4e431b2b..40909505f1 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectType.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectType.kt @@ -43,7 +43,13 @@ data class ObjectType( SPACE(10), BOOKMARK(11), DATABASE(20), - COLLECTION(14) + RELATION_OPTION_LIST(12), + RELATION_OPTION(13), + COLLECTION(14), + AUDIO(15), + VIDEO(16), + DATE(17), + SPACE_VIEW(18) } /** diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt index a38947dd99..1d69424624 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectTypeIds.kt @@ -2,6 +2,7 @@ package com.anytypeio.anytype.core_models /** * Keys for predefined, bundled object types. + * // TODO rename to ObjectTypeUniqueKeys when finished multi-spaces refactoring */ object ObjectTypeIds { const val PAGE = "ot-page" @@ -67,5 +68,10 @@ object MarketplaceObjectTypeIds { } object Marketplace { - const val MARKETPLACE_ID = "_anytype_marketplace" -} \ No newline at end of file + const val MARKETPLACE_SPACE_ID = "_anytype_marketplace" +} + +/** + * TODO Temporary typealias - remove and rename [ObjectTypeIds] when finished multi-spaces refactoring + */ +typealias ObjectTypeUniqueKeys = ObjectTypeIds \ No newline at end of file diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt index 229eece49e..ad6c947daf 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt @@ -54,6 +54,8 @@ sealed class ObjectWrapper { val id: Id by default + val uniqueKey: String? by default + val done: Boolean? by default val snippet: String? by default @@ -154,6 +156,7 @@ sealed class ObjectWrapper { data class Type(override val map: Struct) : ObjectWrapper() { private val default = map.withDefault { null } val id: Id by default + val uniqueKey: String? by default val name: String? by default val sourceObject: Id? by default val description: String? by default @@ -166,9 +169,13 @@ sealed class ObjectWrapper { is Double -> ObjectType.Layout.values().singleOrNull { layout -> layout.code == value.toInt() } - else -> null + else -> ObjectType.Layout.BASIC } val defaultTemplateId: Id? by default + + val key: String? get() = uniqueKey + + val isValid get() = map.containsKey(Relations.UNIQUE_KEY) } data class Relation(override val map: Struct) : ObjectWrapper() { @@ -192,8 +199,9 @@ sealed class ObjectWrapper { private val relationReadonlyValue: Boolean? by default val id: Id by default + val uniqueKey: String? by default val key: Key get() = relationKey - val workspaceId: Id? by default + val spaceId: Id? by default val sourceObject: Id? by default val format: RelationFormat get() = relationFormat val name: String? by default @@ -230,6 +238,13 @@ sealed class ObjectWrapper { val color: String = relationOptionColor.orEmpty() } + data class Workspace(override val map: Struct) : ObjectWrapper() { + private val default = map.withDefault { null } + val id: Id by default + val name: String? by default + val spaceId: String? by default + } + inline fun getValue(relation: Key): T? { val value = map.getOrDefault(relation, null) return if (value is T) diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt index 62ed91e315..68a01079d1 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt @@ -2,6 +2,7 @@ package com.anytypeio.anytype.core_models /** * Keys for predefined, bundled relations. + * // TODO remove outdated or deprecated relations */ object Relations { @@ -29,7 +30,8 @@ object Relations { const val DONE = "done" const val FEATURED_RELATIONS = "featuredRelations" const val SNIPPET = "snippet" - const val WORKSPACE_ID = "workspaceId" + const val SPACE_ID = "spaceId" + const val TARGET_SPACE_ID = "targetSpaceId" const val SET_OF = "setOf" const val URL = "url" const val SOURCE = "source" @@ -48,6 +50,7 @@ object Relations { const val SIZE_IN_BYTES = "sizeInBytes" const val FILE_SYNC_STATUS = "fileSyncStatus" const val CREATED_DATE = "createdDate" + const val CREATOR = "creator" const val PAGE_COVER = "pageCover" @@ -61,6 +64,13 @@ object Relations { const val RECOMMENDED_RELATIONS = "recommendedRelations" const val DEFAULT_TEMPLATE_ID = "defaultTemplateId" + const val UNIQUE_KEY = "uniqueKey" + + /** + * Transitive relation key. + */ + const val TYPE_UNIQUE_KEY = "type.uniqueKey" + val systemRelationKeys = listOf( "id", "name", diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/exceptions/CreateAccountException.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/exceptions/CreateAccountException.kt index fe4d84a519..ca11307cb4 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/exceptions/CreateAccountException.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/exceptions/CreateAccountException.kt @@ -1,6 +1,7 @@ package com.anytypeio.anytype.core_models.exceptions sealed class CreateAccountException : Exception() { + @Deprecated("To be delete") object BadInviteCode : CreateAccountException() object NetworkError: CreateAccountException() object OfflineDevice: CreateAccountException() diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/primitives/Primitives.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/primitives/Primitives.kt new file mode 100644 index 0000000000..670acafe4e --- /dev/null +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/primitives/Primitives.kt @@ -0,0 +1,22 @@ +package com.anytypeio.anytype.core_models.primitives + +@JvmInline +value class Id(val id: String) + +@JvmInline +value class Key(val key: String) + +@JvmInline +value class SpaceId(val id: String) + +@JvmInline +value class TypeId(val id: String) + +@JvmInline +value class TypeKey(val key: String) + +@JvmInline +value class RelationId(val id: String) + +@JvmInline +value class RelationKey(val key: String) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/objects/ObjectTypeBaseAdapter.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/objects/ObjectTypeBaseAdapter.kt index 980b9b4f8e..e8601ce706 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/objects/ObjectTypeBaseAdapter.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/objects/ObjectTypeBaseAdapter.kt @@ -4,6 +4,7 @@ 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_models.Key import com.anytypeio.anytype.core_ui.R import com.anytypeio.anytype.core_ui.common.DefaultSectionViewHolder import com.anytypeio.anytype.core_ui.databinding.ItemDefaultListSectionBinding @@ -15,7 +16,7 @@ import com.anytypeio.anytype.presentation.objects.ObjectTypeItemView class ObjectTypeVerticalAdapter( private var data: ArrayList, - private val onItemClick: (Id, String) -> Unit + private val onItemClick: (Id, Key, String) -> Unit ) : RecyclerView.Adapter() { fun update(data: List) { @@ -36,7 +37,11 @@ class ObjectTypeVerticalAdapter( itemView.setOnClickListener { if (bindingAdapterPosition != RecyclerView.NO_POSITION) { val item = data[bindingAdapterPosition] as ObjectTypeItemView.Type - onItemClick(item.view.id, item.view.name) + onItemClick( + item.view.id, + item.view.key, + item.view.name + ) } } } diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/objects/ObjectTypeHorizontalListAdapter.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/objects/ObjectTypeHorizontalListAdapter.kt index c5ab159c2b..d3ad4c33c0 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/objects/ObjectTypeHorizontalListAdapter.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/features/objects/ObjectTypeHorizontalListAdapter.kt @@ -4,6 +4,7 @@ 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_models.Key import com.anytypeio.anytype.core_ui.R import com.anytypeio.anytype.core_ui.databinding.ItemObjectTypeHorizontalItemBinding import com.anytypeio.anytype.core_ui.features.objects.holders.ObjectTypeHorizontalHolder @@ -12,7 +13,7 @@ import com.anytypeio.anytype.presentation.objects.ObjectTypeView class ObjectTypeHorizontalListAdapter( private var data: ArrayList, - private val onItemClick: (Id, String) -> Unit, + private val onItemClick: (Id, Key, String) -> Unit, private val onSearchClick: (() -> Unit)? = null ) : RecyclerView.Adapter() { @@ -34,7 +35,7 @@ class ObjectTypeHorizontalListAdapter( itemView.setOnClickListener { if (bindingAdapterPosition != RecyclerView.NO_POSITION) { val item = data[bindingAdapterPosition - 1] as ObjectTypeView - onItemClick(item.id, item.name) + onItemClick(item.id, item.key, item.name) } } } diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/foundation/Foundation.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/foundation/Foundation.kt index c9a889edae..a75243a035 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/foundation/Foundation.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/foundation/Foundation.kt @@ -21,6 +21,7 @@ import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -71,10 +72,12 @@ fun Dragger(modifier: Modifier = Modifier) { @Composable fun Divider( paddingStart: Dp = 20.dp, - paddingEnd: Dp = 20.dp + paddingEnd: Dp = 20.dp, + visible: Boolean = true ) { Box( Modifier + .alpha(if (visible) 1f else 0f) .padding(start = paddingStart, end = paddingEnd) .background(color = colorResource(R.color.shape_primary)) .height(0.5.dp) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/TypeTemplatesWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/TypeTemplatesWidget.kt index 93dce2a1c9..e321ae18e3 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/TypeTemplatesWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/TypeTemplatesWidget.kt @@ -51,6 +51,7 @@ import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.drawBehind import androidx.compose.ui.draw.shadow @@ -81,6 +82,8 @@ 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.Relations +import com.anytypeio.anytype.core_models.primitives.TypeId +import com.anytypeio.anytype.core_models.primitives.TypeKey import com.anytypeio.anytype.core_ui.R import com.anytypeio.anytype.core_ui.foundation.Divider import com.anytypeio.anytype.core_ui.foundation.Dragger @@ -88,9 +91,11 @@ import com.anytypeio.anytype.core_ui.foundation.noRippleClickable import com.anytypeio.anytype.core_ui.foundation.noRippleThrottledClickable import com.anytypeio.anytype.core_ui.views.BodyCalloutMedium import com.anytypeio.anytype.core_ui.views.BodyCalloutRegular +import com.anytypeio.anytype.core_ui.views.BodyRegular import com.anytypeio.anytype.core_ui.views.Caption1Medium import com.anytypeio.anytype.core_ui.views.Caption2Semibold import com.anytypeio.anytype.core_ui.views.ModalTitle +import com.anytypeio.anytype.core_ui.views.Title1 import com.anytypeio.anytype.core_ui.views.fontInterRegular import com.anytypeio.anytype.emojifier.Emojifier import com.anytypeio.anytype.presentation.editor.cover.CoverGradient @@ -100,8 +105,8 @@ import com.anytypeio.anytype.presentation.templates.TemplateView import com.anytypeio.anytype.presentation.templates.TemplateView.Companion.DEFAULT_TEMPLATE_ID_BLANK import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUI import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUIAction -import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUIAction.TypeClick import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUIAction.TemplateClick +import com.anytypeio.anytype.presentation.widgets.TypeTemplatesWidgetUIAction.TypeClick import kotlin.math.roundToInt import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -164,7 +169,6 @@ fun TypeTemplatesWidget( var currentClickedMoreButtonCoordinates: IntOffset by remember { mutableStateOf(IntOffset(0, 0)) } - val showPlusButton = remember { mutableStateOf(false) } AnimatedVisibility( visible = currentState.showWidget, @@ -216,9 +220,11 @@ fun TypeTemplatesWidget( .padding( start = 15.dp, top = 12.dp, bottom = 12.dp, end = 16.dp ) - .noRippleClickable { doneClick() }, + .noRippleClickable { doneClick() } + .alpha(if (currentState.isPossibleToChangeTemplate) 1f else 0f) + , text = stringResource(id = R.string.done), - style = BodyCalloutRegular, + style = BodyRegular, color = colorResource(id = R.color.glyph_active) ) } else { @@ -230,9 +236,10 @@ fun TypeTemplatesWidget( bottom = 12.dp, end = 16.dp ) - .noRippleClickable { editClick() }, + .noRippleClickable { editClick() } + .alpha(if (currentState.isPossibleToChangeTemplate) 1f else 0f), text = stringResource(id = R.string.edit), - style = BodyCalloutRegular, + style = BodyRegular, color = colorResource(id = R.color.glyph_active) ) } @@ -241,32 +248,34 @@ fun TypeTemplatesWidget( Box(modifier = Modifier.align(Alignment.Center)) { Text( text = title, - style = ModalTitle, + style = Title1, color = colorResource(R.color.text_primary) ) } - if (showPlusButton.value) { - Box( - modifier = Modifier.align(Alignment.CenterEnd) - .noRippleThrottledClickable { - val templates = (currentState as? TypeTemplatesWidgetUI.Data)?.templates - val newTemplate = templates?.firstOrNull { it is TemplateView.New } - if (newTemplate != null) { - action(TemplateClick(newTemplate)) - } + Box( + modifier = Modifier + .align(Alignment.CenterEnd) + .noRippleThrottledClickable { + val templates = + (currentState as? TypeTemplatesWidgetUI.Data)?.templates + val newTemplate = + templates?.firstOrNull { it is TemplateView.New } + if (newTemplate != null) { + action(TemplateClick(newTemplate)) } - ) { - Image( - modifier = Modifier.padding( - start = 16.dp, - top = 12.dp, - bottom = 12.dp, - end = 16.dp - ), - painter = painterResource(id = R.drawable.ic_default_plus), - contentDescription = null - ) - } + } + .alpha(if (currentState.isPossibleToChangeTemplate) 1f else 0f) + ) { + Image( + modifier = Modifier.padding( + start = 16.dp, + top = 12.dp, + bottom = 12.dp, + end = 16.dp + ), + painter = painterResource(id = R.drawable.ic_default_plus), + contentDescription = null + ) } } val itemsScroll = rememberLazyListState() @@ -301,7 +310,6 @@ fun TypeTemplatesWidget( }, action = action, scrollState = itemsScroll, - showPlusButton = { showPlusButton.value = it } ) if ((currentState as TypeTemplatesWidgetUI.Data).moreMenuItem != null && itemsScroll.isScrollInProgress @@ -432,103 +440,85 @@ private fun TemplatesList( scrollState: LazyListState, state: TypeTemplatesWidgetUI.Data, action: (TypeTemplatesWidgetUIAction) -> Unit, - moreClick: (TemplateView, IntOffset) -> Unit, - showPlusButton: (Boolean) -> Unit + moreClick: (TemplateView, IntOffset) -> Unit ) { - if (state.templates.isEmpty()) { - showPlusButton.invoke(false) - Box( - modifier = Modifier.fillMaxWidth().wrapContentHeight(), - contentAlignment = Alignment.Center) { - Text( - modifier = Modifier - .wrapContentSize() - .padding(top = 111.dp, bottom = 111.dp), - text = stringResource(id = R.string.title_templates_not_allowed), - style = BodyCalloutRegular, - color = colorResource(id = R.color.text_secondary) - ) - } - } else { - showPlusButton.invoke(true) - LazyRow( - state = scrollState, - modifier = Modifier - .wrapContentHeight() - .fillMaxWidth(), - contentPadding = PaddingValues(start = 20.dp, end = 20.dp), - horizontalArrangement = Arrangement.spacedBy(5.dp) - ) - { - itemsIndexed( - items = state.templates, - itemContent = { index, item -> + LazyRow( + state = scrollState, + modifier = Modifier + .wrapContentHeight() + .fillMaxWidth(), + contentPadding = PaddingValues(start = 20.dp, end = 20.dp), + horizontalArrangement = Arrangement.spacedBy(5.dp) + ) + { + itemsIndexed( + items = state.templates, + itemContent = { index, item -> + Box( + modifier = + Modifier + .height(232.dp) + .width(127.dp), + contentAlignment = Alignment.BottomStart + ) { + val borderWidth: Dp + val borderColor: Color + if (item.isDefault) { + borderWidth = 2.dp + borderColor = colorResource(id = R.color.palette_system_amber_50) + } else { + borderWidth = 1.dp + borderColor = colorResource(id = R.color.shape_primary) + } Box( - modifier = - Modifier - .height(232.dp) - .width(127.dp), - contentAlignment = Alignment.BottomStart - ) { - val borderWidth: Dp - val borderColor: Color - if (item.isDefault) { - borderWidth = 2.dp - borderColor = colorResource(id = R.color.palette_system_amber_50) - } else { - borderWidth = 1.dp - borderColor = colorResource(id = R.color.shape_primary) - } - Box( - modifier = Modifier - .border( - width = borderWidth, - color = borderColor, - shape = RoundedCornerShape(size = 16.dp) - ) - .height(224.dp) - .width(120.dp) - .clickable { - action(TemplateClick(item)) - } - ) { - TemplateItemContent(item) - } - - val showMoreButton = (item is TemplateView.Template && state.isEditing) - AnimatedVisibility( - visible = showMoreButton, - enter = fadeIn(), - exit = fadeOut(), - modifier = Modifier - .align(Alignment.TopEnd) - .padding(1.dp) - ) { - var currentCoordinates: IntOffset by remember { - mutableStateOf(IntOffset(0, 0)) - } - Image( - modifier = Modifier - .width(28.dp) - .height(28.dp) - .clickable { moreClick(item, currentCoordinates) } - .onGloballyPositioned { coordinates -> - if (coordinates.isAttached) { - with(coordinates.positionInRoot()) { - currentCoordinates = IntOffset(x.toInt(), y.toInt()) - } - } else { - currentCoordinates = IntOffset(0, 0) - } - }, - painter = painterResource(id = R.drawable.ic_edit_temlate), - contentDescription = "Edit template button" + modifier = Modifier + .border( + width = borderWidth, + color = borderColor, + shape = RoundedCornerShape(size = 16.dp) ) + .height(224.dp) + .width(120.dp) + .clickable { + action(TemplateClick(item)) + } + ) { + TemplateItemContent(item) + } + + val showMoreButton = (item is TemplateView.Template && state.isEditing) + AnimatedVisibility( + visible = showMoreButton, + enter = fadeIn(), + exit = fadeOut(), + modifier = Modifier + .align(Alignment.TopEnd) + .padding(1.dp) + ) { + var currentCoordinates: IntOffset by remember { + mutableStateOf(IntOffset(0, 0)) } + Image( + modifier = Modifier + .width(28.dp) + .height(28.dp) + .clickable { moreClick(item, currentCoordinates) } + .onGloballyPositioned { coordinates -> + if (coordinates.isAttached) { + with(coordinates.positionInRoot()) { + currentCoordinates = IntOffset(x.toInt(), y.toInt()) + } + } else { + currentCoordinates = IntOffset(0, 0) + } + }, + painter = painterResource(id = R.drawable.ic_edit_temlate), + contentDescription = "Edit template button" + ) } } - ) - } + } + ) } } @@ -821,7 +811,7 @@ val TemplateTitleStyle = TextStyle( fontWeight = FontWeight.W600, fontSize = 11.sp, lineHeight = 14.sp, - letterSpacing = (-0.006).em + letterSpacing = (-0.00636363).em ) @Composable @@ -934,47 +924,48 @@ fun ObjectTypesList( borderWidth = 1.dp borderColor = colorResource(id = R.color.shape_primary) } - Box(modifier = Modifier - .border( - width = borderWidth, - color = borderColor, - shape = RoundedCornerShape(size = 10.dp) - ) - .wrapContentSize() - .noRippleThrottledClickable { - action(TypeClick.Item(item.type)) - }) { + Box( + modifier = Modifier + .height(48.dp) + .wrapContentWidth() + .border( + width = borderWidth, + color = borderColor, + shape = RoundedCornerShape(size = 10.dp) + ) + .noRippleThrottledClickable { + action(TypeClick.Item(item.type)) + }, + contentAlignment = Alignment.Center + ) { + val typeIcon = item.type.iconEmoji + val (rowPaddingStart, textPaddingStart) = if (typeIcon != null) { + 14.dp to 8.dp + } else { + 16.dp to 0.dp + } Row( modifier = Modifier.padding( - start = 14.dp, - end = 16.dp, - top = 13.dp, - bottom = 13.dp - ) + start = rowPaddingStart, + end = 16.dp + ), + verticalAlignment = Alignment.CenterVertically ) { - item.type.iconEmoji?.let { + if (typeIcon != null) { Box( - modifier = Modifier - .clip(RoundedCornerShape(8.dp)) - .background( - color = colorResource(id = R.color.shape_tertiary) - ) - .border( - width = 2.dp, - color = colorResource(id = R.color.background_primary), - shape = RoundedCornerShape(8.dp) - ) + modifier = Modifier.wrapContentSize() ) { Image( painter = rememberAsyncImagePainter( - model = Emojifier.safeUri(it), - error = painterResource(id = R.drawable.ic_home_widget_space) + Emojifier.safeUri( + typeIcon + ) ), - contentDescription = "Emoji template's icon", + contentDescription = "Type's icon", modifier = Modifier - .size(20.dp) + .size(18.dp) .align(Alignment.Center), - contentScale = ContentScale.Crop + alignment = Alignment.Center ) } } @@ -984,7 +975,7 @@ fun ObjectTypesList( color = colorResource(id = R.color.text_primary) ), modifier = Modifier - .padding(start = 8.dp) + .padding(start = textPaddingStart) .widthIn(max = 100.dp), maxLines = 1, overflow = TextOverflow.Ellipsis @@ -1031,14 +1022,16 @@ fun ComposablePreview() { val items = listOf( TemplateView.Blank( id = DEFAULT_TEMPLATE_ID_BLANK, - typeId = "page", + targetTypeId = TypeId("page"), + targetTypeKey = TypeKey("ot-page"), typeName = "Page", layout = ObjectType.Layout.BASIC.code ), TemplateView.Template( id = "1", name = "Template 1", - typeId = "page", + targetTypeId = TypeId("page"), + targetTypeKey = TypeKey("ot-page"), layout = ObjectType.Layout.BASIC, image = null, emoji = null, @@ -1051,7 +1044,12 @@ fun ComposablePreview() { templates = items, showWidget = true, isEditing = true, - moreMenuItem = TemplateView.Template(id = "123", name = "Template 1", typeId = "page"), + moreMenuItem = TemplateView.Template( + id = "123", + name = "Template 1", + targetTypeId = TypeId("page"), + targetTypeKey = TypeKey("ot-page"), + ), objectTypes = listOf( TemplateObjectTypeView.Search, TemplateObjectTypeView.Item( @@ -1061,7 +1059,8 @@ fun ComposablePreview() { ) ), viewerId = "", - isPossibleToChangeType = true + isPossibleToChangeType = true, + isPossibleToChangeTemplate = false ) TypeTemplatesWidget( state = state, diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewerLayoutCoverWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewerLayoutCoverWidget.kt index 9d10921725..915d1a0e48 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewerLayoutCoverWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewerLayoutCoverWidget.kt @@ -26,8 +26,6 @@ import androidx.compose.runtime.DisposableEffect import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.draw.shadow -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.colorResource @@ -40,8 +38,7 @@ import com.anytypeio.anytype.core_models.DVViewerType import com.anytypeio.anytype.core_ui.R import com.anytypeio.anytype.core_ui.foundation.Divider import com.anytypeio.anytype.core_ui.foundation.noRippleThrottledClickable -import com.anytypeio.anytype.core_ui.views.BodyCallout -import com.anytypeio.anytype.core_ui.views.TitleInter15 +import com.anytypeio.anytype.core_ui.views.BodyRegular import com.anytypeio.anytype.core_ui.widgets.DragStates import com.anytypeio.anytype.presentation.sets.ViewerLayoutWidgetUi import com.anytypeio.anytype.presentation.sets.ViewerLayoutWidgetUi.State.ImagePreview @@ -119,7 +116,7 @@ fun ViewerLayoutCoverWidget( Text( modifier = Modifier.align(Alignment.CenterStart), text = stringResource(id = R.string.none), - style = BodyCallout, + style = BodyRegular, color = colorResource(id = R.color.text_primary) ) if (uiState.cover == ImagePreview.None) { @@ -141,7 +138,7 @@ fun ViewerLayoutCoverWidget( Text( modifier = Modifier.align(Alignment.CenterStart), text = stringResource(id = R.string.page_cover), - style = BodyCallout, + style = BodyRegular, color = colorResource(id = R.color.text_primary) ) if (uiState.cover == ImagePreview.Cover) { diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewerLayoutWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewerLayoutWidget.kt index 8ddfb8db8e..d314d3516a 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewerLayoutWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewerLayoutWidget.kt @@ -158,52 +158,55 @@ fun ViewerLayoutWidget( checked = currentState.withIcon.toggled, onCheckedChanged = { action(Icon(it)) } ) - if (currentState.layoutType == DVViewerType.GALLERY) { - Divider() - ColumnItem( - modifier = Modifier - .padding(start = 20.dp, end = 20.dp), - title = stringResource(id = R.string.card_size), - value = when (currentState.cardSize) { - ViewerLayoutWidgetUi.State.CardSize.Large -> stringResource(id = R.string.large) - ViewerLayoutWidgetUi.State.CardSize.Small -> stringResource(id = R.string.small) - }, - onClick = { - action(ViewerLayoutWidgetUi.Action.CardSizeMenu) - }, - arrow = painterResource(id = R.drawable.ic_list_arrow_18), - imageModifier = Modifier - .onGloballyPositioned { coordinates -> - if (coordinates.isAttached) { - with(coordinates.boundsInRoot()) { - currentCoordinates = this - } - } else { - currentCoordinates = androidx.compose.ui.geometry.Rect.Zero + val isGallery = currentState.layoutType == DVViewerType.GALLERY + Divider(visible = isGallery) + ColumnItem( + modifier = Modifier + .padding(start = 20.dp, end = 20.dp) + .alpha(if (isGallery) 1f else 0f), + title = stringResource(id = R.string.card_size), + value = when (currentState.cardSize) { + ViewerLayoutWidgetUi.State.CardSize.Large -> stringResource(id = R.string.large) + ViewerLayoutWidgetUi.State.CardSize.Small -> stringResource(id = R.string.small) + }, + onClick = { + action(ViewerLayoutWidgetUi.Action.CardSizeMenu) + }, + arrow = painterResource(id = R.drawable.ic_list_arrow_18), + imageModifier = Modifier + .onGloballyPositioned { coordinates -> + if (coordinates.isAttached) { + with(coordinates.boundsInRoot()) { + currentCoordinates = this } + } else { + currentCoordinates = androidx.compose.ui.geometry.Rect.Zero } - ) - Divider() - ColumnItem( - modifier = Modifier.padding(start = 20.dp, end = 20.dp), - title = stringResource(id = R.string.cover), - value = when (val cover = currentState.cover) { - ViewerLayoutWidgetUi.State.ImagePreview.Cover -> stringResource(id = R.string.cover) - is ViewerLayoutWidgetUi.State.ImagePreview.Custom -> cover.name - ViewerLayoutWidgetUi.State.ImagePreview.None -> stringResource(id = R.string.none) - }, - onClick = { - action(ViewerLayoutWidgetUi.Action.CoverMenu) - }, - arrow = painterResource(id = R.drawable.ic_arrow_disclosure_18) - ) - Divider() - LayoutSwitcherItem( - text = stringResource(id = R.string.fit_image), - checked = currentState.fitImage.toggled, - onCheckedChanged = { action(FitImage(it)) } - ) - } + } + ) + Divider(visible = isGallery) + ColumnItem( + modifier = Modifier + .padding(start = 20.dp, end = 20.dp) + .alpha(if (isGallery) 1f else 0f), + title = stringResource(id = R.string.cover), + value = when (val cover = currentState.cover) { + ViewerLayoutWidgetUi.State.ImagePreview.Cover -> stringResource(id = R.string.cover) + is ViewerLayoutWidgetUi.State.ImagePreview.Custom -> cover.name + ViewerLayoutWidgetUi.State.ImagePreview.None -> stringResource(id = R.string.none) + }, + onClick = { + action(ViewerLayoutWidgetUi.Action.CoverMenu) + }, + arrow = painterResource(id = R.drawable.ic_arrow_disclosure_18) + ) + Divider(visible = isGallery) + LayoutSwitcherItem( + modifier = Modifier.alpha(if (isGallery) 1f else 0f), + text = stringResource(id = R.string.fit_image), + checked = currentState.fitImage.toggled, + onCheckedChanged = { action(FitImage(it)) } + ) } } } @@ -356,6 +359,7 @@ fun LayoutIcons(uiState: ViewerLayoutWidgetUi, action: (ViewerLayoutWidgetUi.Act @Composable fun LayoutSwitcherItem( + modifier: Modifier = Modifier, text: String, checked: Boolean, onCheckedChanged: (Boolean) -> Unit @@ -363,7 +367,7 @@ fun LayoutSwitcherItem( var switchCheckedState by remember(checked) { mutableStateOf(checked) } Box( - modifier = Modifier + modifier = modifier .fillMaxWidth() .padding(start = 20.dp, end = 20.dp) .height(58.dp) @@ -398,7 +402,7 @@ fun PreviewLayoutScreen() { ViewerLayoutWidget( uiState = ViewerLayoutWidgetUi( showWidget = true, - layoutType = DVViewerType.GALLERY, + layoutType = DVViewerType.GRID, withIcon = ViewerLayoutWidgetUi.State.Toggle.WithIcon( toggled = true ), diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewersWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewersWidget.kt index f17d099e71..4e370c4407 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewersWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/dv/ViewersWidget.kt @@ -48,7 +48,7 @@ import com.anytypeio.anytype.core_ui.R import com.anytypeio.anytype.core_ui.foundation.Divider import com.anytypeio.anytype.core_ui.foundation.Dragger import com.anytypeio.anytype.core_ui.foundation.noRippleThrottledClickable -import com.anytypeio.anytype.core_ui.views.BodyCalloutRegular +import com.anytypeio.anytype.core_ui.views.BodyRegular import com.anytypeio.anytype.core_ui.views.Caption2Regular import com.anytypeio.anytype.core_ui.views.HeadlineSubheading import com.anytypeio.anytype.core_ui.views.Title1 @@ -358,7 +358,7 @@ private fun ActionText(text: String, click: () -> Unit) { ) .noRippleThrottledClickable { click() }, text = text, - style = BodyCalloutRegular, + style = BodyRegular, color = colorResource(id = R.color.glyph_active), textAlign = TextAlign.Center ) diff --git a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/toolbar/ObjectTypesWidget.kt b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/toolbar/ObjectTypesWidget.kt index d02190ddf0..56bbcc9a3f 100644 --- a/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/toolbar/ObjectTypesWidget.kt +++ b/core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/toolbar/ObjectTypesWidget.kt @@ -5,6 +5,7 @@ import android.util.AttributeSet import android.view.LayoutInflater import androidx.constraintlayout.widget.ConstraintLayout import com.anytypeio.anytype.core_models.Id +import com.anytypeio.anytype.core_models.Key import com.anytypeio.anytype.core_ui.databinding.WidgetObjectTypesListBinding import com.anytypeio.anytype.core_ui.features.objects.ObjectTypeHorizontalListAdapter import com.anytypeio.anytype.core_utils.ext.gone @@ -18,7 +19,7 @@ class ObjectTypesWidget @JvmOverloads constructor( ) : ConstraintLayout(context, attrs, defStyleAttr) { private var isOpenState = false - private var onItemClick: ((Id) -> Unit)? = null + private var onItemClick: ((Id, Key) -> Unit)? = null private var onSearchClick: (() -> Unit)? = null private var onDoneClick: (() -> Unit)? = null @@ -61,7 +62,7 @@ class ObjectTypesWidget @JvmOverloads constructor( } } - fun setupClicks(onItemClick: (Id) -> Unit, onSearchClick: () -> Unit, onDoneClick: () -> Unit) { + fun setupClicks(onItemClick: (Id, Key) -> Unit, onSearchClick: () -> Unit, onDoneClick: () -> Unit) { this.onItemClick = onItemClick this.onSearchClick = onSearchClick this.onDoneClick = onDoneClick @@ -89,7 +90,7 @@ class ObjectTypesWidget @JvmOverloads constructor( iconArrowDown.gone() } - private fun onItemClicked(id: Id, name: String) { - onItemClick?.invoke(id) + private fun onItemClicked(id: Id, key: Key, name: String) { + onItemClick?.invoke(id, key) } } \ No newline at end of file diff --git a/core-ui/src/main/res/drawable/ic_plus_32.xml b/core-ui/src/main/res/drawable/ic_plus_32.xml new file mode 100644 index 0000000000..f68f51da41 --- /dev/null +++ b/core-ui/src/main/res/drawable/ic_plus_32.xml @@ -0,0 +1,10 @@ + + + diff --git a/core-ui/src/main/res/drawable/ic_plus_32_white.xml b/core-ui/src/main/res/drawable/ic_plus_32_white.xml new file mode 100644 index 0000000000..5a98f914ae --- /dev/null +++ b/core-ui/src/main/res/drawable/ic_plus_32_white.xml @@ -0,0 +1,10 @@ + + + diff --git a/core-ui/src/main/res/drawable/ic_space_settings.xml b/core-ui/src/main/res/drawable/ic_space_settings.xml new file mode 100644 index 0000000000..0aaeff90f8 --- /dev/null +++ b/core-ui/src/main/res/drawable/ic_space_settings.xml @@ -0,0 +1,10 @@ + + + diff --git a/core-ui/src/main/res/drawable/ic_space_type_private.xml b/core-ui/src/main/res/drawable/ic_space_type_private.xml new file mode 100644 index 0000000000..65d56adcbd --- /dev/null +++ b/core-ui/src/main/res/drawable/ic_space_type_private.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/core-ui/src/main/res/drawable/rounded_dialog_select_spaces.xml b/core-ui/src/main/res/drawable/rounded_dialog_select_spaces.xml new file mode 100644 index 0000000000..e1932cad48 --- /dev/null +++ b/core-ui/src/main/res/drawable/rounded_dialog_select_spaces.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/core-ui/src/main/res/values-night/colors.xml b/core-ui/src/main/res/values-night/colors.xml index be9221ae48..388b5c6068 100644 --- a/core-ui/src/main/res/values-night/colors.xml +++ b/core-ui/src/main/res/values-night/colors.xml @@ -97,4 +97,6 @@ #24DAD7CA #1A000000 + #1F1E1D + diff --git a/core-ui/src/main/res/values/colors.xml b/core-ui/src/main/res/values/colors.xml index c9269fdbbc..b019067d60 100644 --- a/core-ui/src/main/res/values/colors.xml +++ b/core-ui/src/main/res/values/colors.xml @@ -212,4 +212,7 @@ #E3E3E3 #1AFFFFFF + #7C7C7C + #2C2B27 + diff --git a/core-ui/src/main/res/values/styles.xml b/core-ui/src/main/res/values/styles.xml index e5f4039300..108d3e9217 100644 --- a/core-ui/src/main/res/values/styles.xml +++ b/core-ui/src/main/res/values/styles.xml @@ -40,6 +40,19 @@ @color/orange + + + +