From bdd85486957ef0491646ffa28c392ab8283d608b Mon Sep 17 00:00:00 2001 From: Mikhail Date: Tue, 24 Jan 2023 21:22:38 +0300 Subject: [PATCH] DROID-792 Editor | Enhancement | Turn on webp (#2861) --- gradle/libs.versions.toml | 2 +- .../presentation/editor/EditorViewModel.kt | 6 - .../editor/cover/SelectCoverViewModel.kt | 4 - protocol/src/main/proto/commands.proto | 360 ++++++++++++++++++ protocol/src/main/proto/events.proto | 103 +++++ protocol/src/main/proto/models.proto | 9 +- 6 files changed, 471 insertions(+), 13 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 610f7cd899..67f5d44f47 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -middlewareVersion = "v0.24.3" +middlewareVersion = "v0.25.0-rc1" kotlinVersion = '1.7.10' androidxCoreVersion = "1.9.0" androidxComposeVersion1 = '1.3.1' diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt index 9cd7f8e22c..8b1712d44a 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt @@ -3928,10 +3928,6 @@ class EditorViewModel( Timber.w("Error while getting filePath") return } - if (filePath.endsWith(FORMAT_WEBP, true)) { - sendToast(ERROR_UNSUPPORTED_WEBP) - return - } viewModelScope.launch { val uploadDescription = currentMediaUploadDescription if (uploadDescription != null) { @@ -4245,7 +4241,6 @@ class EditorViewModel( const val DELAY_REFRESH_DOCUMENT_TO_ENTER_MULTI_SELECT_MODE = 150L const val DELAY_REFRESH_DOCUMENT_ON_EXIT_MULTI_SELECT_MODE = 300L const val INITIAL_INDENT = 0 - const val FORMAT_WEBP = "webp" const val CANNOT_MOVE_BLOCK_ON_SAME_POSITION = "Selected block is already on the position" const val CANNOT_BE_DROPPED_INSIDE_ITSELF_ERROR = "A block cannot be moved inside itself." const val CANNOT_BE_PARENT_ERROR = "This block does not support nesting." @@ -4263,7 +4258,6 @@ class EditorViewModel( const val ERROR_UNSUPPORTED_BEHAVIOR = "Currently unsupported behavior." const val NOT_ALLOWED_FOR_OBJECT = "Not allowed for this object" const val NOT_ALLOWED_FOR_RELATION = "Not allowed for this relation" - const val ERROR_UNSUPPORTED_WEBP = "Currently WEBP format is unsupported" } data class MarkupAction( diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/cover/SelectCoverViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/cover/SelectCoverViewModel.kt index 5a50ef8fcb..63f8c18121 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/cover/SelectCoverViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/cover/SelectCoverViewModel.kt @@ -57,10 +57,6 @@ abstract class SelectCoverViewModel( } fun onImagePicked(ctx: Id, path: String) { - if (path.endsWith(EditorViewModel.FORMAT_WEBP, true)) { - Timber.d("onDocCoverImagePicked, not allowed to add WEBP format") - return - } viewModelScope.launch { isLoading.emit(true) setCoverImage( diff --git a/protocol/src/main/proto/commands.proto b/protocol/src/main/proto/commands.proto index bfb16693b9..17a3e5c9f2 100644 --- a/protocol/src/main/proto/commands.proto +++ b/protocol/src/main/proto/commands.proto @@ -1419,6 +1419,30 @@ message Rpc { } } + message SetSource { + + message Request { + string contextId = 1; + repeated string source = 2; + } + + message Response { + Error error = 1; + ResponseEvent event = 4; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + message SetObjectType { message Request { string contextId = 1; @@ -4224,6 +4248,7 @@ message Rpc { string contextId = 1; string blockId = 2; // id of dataview block to insert the new block anytype.model.Block.Content.Dataview.View view = 4; + repeated string source = 5; } message Response { @@ -4491,6 +4516,34 @@ message Rpc { } } + message CreateFromExistingObject { + message Request { + string contextId = 1; + string blockId = 2; + string targetObjectId = 3; + } + + message Response { + Error error = 1; + string blockId = 2; + string targetObjectId = 3; + repeated anytype.model.Block.Content.Dataview.View view = 4; + ResponseEvent event = 5; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + // ... + } + } + } + } + message CreateBookmark { message Request { string contextId = 1; @@ -4514,6 +4567,313 @@ message Rpc { } } } + + message Filter { + message Add { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + anytype.model.Block.Content.Dataview.Filter filter = 4; + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + + message Remove { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + repeated string filterIds = 4; + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + + message Replace { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + string filterId = 4; + anytype.model.Block.Content.Dataview.Filter filter = 5; + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + + message Sort { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + repeated string filterIds = 4; // new order of filters + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + } + message SSort { + message Add { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + anytype.model.Block.Content.Dataview.Sort sort = 4; + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + + message Remove { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + repeated string relationKeys = 4; + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + + message Replace { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + string relationKey = 4; + anytype.model.Block.Content.Dataview.Sort sort = 5; + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + + message Sort { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + repeated string relationKeys = 4; // new order of sorts + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + } + message ViewRelation { + message Add { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + anytype.model.Block.Content.Dataview.Relation relation = 4; + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + + message Remove { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + repeated string relationKeys = 4; + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + + message Replace { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + string relationKey = 4; + anytype.model.Block.Content.Dataview.Relation relation = 5; + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + + message Sort { + message Request { + string contextId = 1; + string blockId = 2; // id of dataview block to update + string viewId = 3; // id of view to update + repeated string relationKeys = 4; // new order of relations + } + + message Response { + Error error = 1; + ResponseEvent event = 2; + + message Error { + Code code = 1; + string description = 2; + + enum Code { + NULL = 0; + UNKNOWN_ERROR = 1; + BAD_INPUT = 2; + } + } + } + } + } } message Debug { diff --git a/protocol/src/main/proto/events.proto b/protocol/src/main/proto/events.proto index 28ac421d12..07c6b66778 100644 --- a/protocol/src/main/proto/events.proto +++ b/protocol/src/main/proto/events.proto @@ -65,6 +65,8 @@ message Event { Block.Dataview.ObjectOrderUpdate blockDataViewObjectOrderUpdate = 39; Block.Dataview.RelationDelete blockDataviewRelationDelete = 124; Block.Dataview.RelationSet blockDataviewRelationSet = 123; + Block.Dataview.ViewUpdate blockDataviewViewUpdate = 125; + Block.Dataview.TargetObjectIdSet blockDataviewTargetObjectIdSet = 126; // deprecated Block.Dataview.OldRelationDelete blockDataviewOldRelationDelete = 24; @@ -682,6 +684,102 @@ message Event { anytype.model.Block.Content.Dataview.View view = 3; } + message ViewUpdate { + string id = 1; + string viewId = 2; + repeated Filter filter = 3; + repeated Relation relation = 4; + repeated Sort sort = 5; + Fields fields = 6; + + message Fields { + anytype.model.Block.Content.Dataview.View.Type type = 1; + string name = 2; + string coverRelationKey = 3; // Relation used for cover in gallery + bool hideIcon = 4; // Hide icon near name + anytype.model.Block.Content.Dataview.View.Size cardSize = 5; // Gallery card size + bool coverFit = 6; // Image fits container + string groupRelationKey = 7; // Group view by this relationKey + bool groupBackgroundColors = 8; // Enable backgrounds in groups + int32 pageLimit = 9; + } + + message Filter { + oneof operation { + Add add = 1; + Remove remove = 2; + Update update = 3; + Move move = 4; + } + + message Add { + string afterId = 1; + repeated anytype.model.Block.Content.Dataview.Filter items = 2; + } + message Remove { + repeated string ids = 1; + } + message Update { + string id = 1; + anytype.model.Block.Content.Dataview.Filter item = 2; + } + message Move { + string afterId = 1; + repeated string ids = 2; + } + } + + message Relation { + oneof operation { + Add add = 1; + Remove remove = 2; + Update update = 3; + Move move = 4; + } + + message Add { + string afterId = 1; + repeated anytype.model.Block.Content.Dataview.Relation items = 2; + } + message Remove { + repeated string ids = 1; + } + message Update { + string id = 1; + anytype.model.Block.Content.Dataview.Relation item = 2; + } + message Move { + string afterId = 1; + repeated string ids = 2; + } + } + + message Sort { + oneof operation { + Add add = 1; + Remove remove = 2; + Update update = 3; + Move move = 4; + } + + message Add { + string afterId = 1; + repeated anytype.model.Block.Content.Dataview.Sort items = 2; + } + message Remove { + repeated string ids = 1; + } + message Update { + string id = 1; + anytype.model.Block.Content.Dataview.Sort item = 2; + } + message Move { + string afterId = 1; + repeated string ids = 2; + } + } + } + message ViewDelete { string id = 1; // dataview block's id string viewId = 2; // view id to remove @@ -746,6 +844,11 @@ message Event { SliceOperationRemove = 3; SliceOperationReplace = 4; } + + message TargetObjectIdSet { + string id = 1; // dataview block's id + string targetObjectId = 2; + } } } diff --git a/protocol/src/main/proto/models.proto b/protocol/src/main/proto/models.proto index 90b6e85769..46fa50aa97 100644 --- a/protocol/src/main/proto/models.proto +++ b/protocol/src/main/proto/models.proto @@ -316,6 +316,7 @@ message Block { repeated GroupOrder groupOrders = 12; repeated ObjectOrder objectOrders = 13; repeated anytype.model.RelationLink relationLinks = 5; + string TargetObjectId = 6; message View { string id = 1; @@ -324,12 +325,13 @@ message Block { repeated Sort sorts = 4; repeated Filter filters = 5; repeated Relation relations = 6; // relations fields/columns options, also used to provide the order - string coverRelationKey = 7; // Relation used for cover in gallery + string coverRelationKey = 7; // Relation used for cover in gallery bool hideIcon = 8; // Hide icon near name Size cardSize = 9; // Gallery card size bool coverFit = 10; // Image fits container string groupRelationKey = 11; // Group view by this relationKey - bool groupBackgroundColors = 12; // Enable backgrounds in groups + bool groupBackgroundColors = 12; // Enable backgrounds in groups + int32 pageLimit = 13; enum Type { Table = 0; @@ -373,6 +375,8 @@ message Block { string RelationKey = 1; Type type = 2; repeated google.protobuf.Value customOrder = 3; + RelationFormat format = 4; + bool includeTime = 5; enum Type { Asc = 0; @@ -382,6 +386,7 @@ message Block { } message Filter { + string id = 9; Operator operator = 1; // looks not applicable? string RelationKey = 2; string relationProperty = 5;