mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-256 Types | Enhancement | Disabled change-type option for bookmark objects (#2496)
This commit is contained in:
parent
9a656ce0c4
commit
ddc8b3748c
6 changed files with 28 additions and 14 deletions
|
@ -78,6 +78,8 @@ sealed class ObjectWrapper {
|
|||
|
||||
val url: String? by default
|
||||
|
||||
val featuredRelations: List<String>? by default
|
||||
|
||||
fun isEmpty(): Boolean = map.isEmpty()
|
||||
}
|
||||
}
|
|
@ -9,10 +9,15 @@ class ObjectTypePopupMenu(
|
|||
context: Context,
|
||||
view: View,
|
||||
onChangeTypeClicked: () -> Unit,
|
||||
onOpenSetClicked: () -> Unit
|
||||
onOpenSetClicked: () -> Unit,
|
||||
allowChangingObjectType: Boolean = false
|
||||
) : PopupMenu(context, view) {
|
||||
init {
|
||||
menuInflater.inflate(R.menu.menu_object_type, menu)
|
||||
if (allowChangingObjectType) {
|
||||
menuInflater.inflate(R.menu.menu_object_type, menu)
|
||||
} else {
|
||||
menuInflater.inflate(R.menu.menu_object_type_change_disabled, menu)
|
||||
}
|
||||
setOnMenuItemClickListener { item ->
|
||||
when(item.itemId) {
|
||||
R.id.change_type -> onChangeTypeClicked()
|
||||
|
|
|
@ -232,7 +232,8 @@ class FeaturedRelationGroupWidget : ConstraintLayout {
|
|||
},
|
||||
onOpenSetClicked = {
|
||||
click(ListenerType.Relation.ObjectTypeOpenSet(type = relation.type))
|
||||
}
|
||||
},
|
||||
allowChangingObjectType = item.allowChangingObjectType
|
||||
)
|
||||
popup.show()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/open_set"
|
||||
android:title="@string/open_set" />
|
||||
</menu>
|
|
@ -1142,7 +1142,8 @@ sealed class BlockView : ViewType {
|
|||
|
||||
data class FeaturedRelation(
|
||||
override val id: String,
|
||||
val relations: List<DocumentRelationView>
|
||||
val relations: List<DocumentRelationView>,
|
||||
val allowChangingObjectType : Boolean = true
|
||||
) : BlockView() {
|
||||
override fun getViewType(): Int = HOLDER_FEATURED_RELATION
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.Block.Content
|
|||
import com.anytypeio.anytype.core_models.CoverType
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectType.Companion.BOOKMARK_TYPE
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
|
@ -2013,19 +2014,17 @@ class DefaultBlockViewRenderer @Inject constructor(
|
|||
details: Block.Details,
|
||||
relations: List<Relation>
|
||||
): BlockView.FeaturedRelation {
|
||||
val featured = details.details[ctx]?.featuredRelations ?: emptyList()
|
||||
val views = mutableListOf<DocumentRelationView>()
|
||||
views.addAll(
|
||||
mapFeaturedRelations(
|
||||
ctx = ctx,
|
||||
ids = featured,
|
||||
details = details,
|
||||
relations = relations
|
||||
)
|
||||
val obj = ObjectWrapper.Basic(details.details[ctx]?.map ?: emptyMap())
|
||||
val views = mapFeaturedRelations(
|
||||
ctx = ctx,
|
||||
ids = obj.featuredRelations ?: emptyList(),
|
||||
details = details,
|
||||
relations = relations
|
||||
)
|
||||
return BlockView.FeaturedRelation(
|
||||
id = block.id,
|
||||
relations = views
|
||||
relations = views,
|
||||
allowChangingObjectType = !obj.type.contains(BOOKMARK_TYPE)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue