mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-10 10:00:44 +09:00
parent
5e09f51537
commit
84d89305d8
8 changed files with 24 additions and 131 deletions
|
@ -114,7 +114,6 @@ abstract class BlockActionToolbar : Fragment() {
|
|||
is BlockView.MediaPlaceholder.Picture -> addButtons(view, ACTIONS.VIDEO_PICTURE)
|
||||
is BlockView.Picture.Error -> addButtons(view, ACTIONS.VIDEO_PICTURE)
|
||||
is BlockView.Upload.Picture -> addButtons(view, ACTIONS.VIDEO_PICTURE)
|
||||
BlockView.Footer -> TODO()
|
||||
}
|
||||
if (BuildConfig.DEBUG) {
|
||||
log(getBlock())
|
||||
|
|
|
@ -37,7 +37,6 @@ object BlockActionToolbarFactory {
|
|||
is BlockView.MediaPlaceholder.Picture -> newInstance(block, dimensions)
|
||||
is BlockView.Picture.Error -> newInstance(block, dimensions)
|
||||
is BlockView.Upload.Picture -> newInstance(block, dimensions)
|
||||
BlockView.Footer -> TODO()
|
||||
}
|
||||
|
||||
fun newInstance(block: BlockView.Page, dimensions: BlockDimensions): PageBlockActionToolbar =
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.agileburo.anytype.core_ui.features.editor.holders
|
||||
|
||||
import android.view.View
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockView
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder
|
||||
import com.agileburo.anytype.core_ui.features.page.ListenerType
|
||||
import com.agileburo.anytype.core_ui.widgets.text.EditorLongClickListener
|
||||
|
||||
class Divider(view: View) : BlockViewHolder(view) {
|
||||
|
||||
fun bind(
|
||||
item: BlockView.Divider,
|
||||
clicked: (ListenerType) -> Unit
|
||||
) {
|
||||
itemView.setOnLongClickListener(
|
||||
EditorLongClickListener(
|
||||
t = item.id,
|
||||
click = { onBlockLongClick(itemView, it, clicked) }
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
|
@ -21,13 +21,11 @@ import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOL
|
|||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_BULLET
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_CHECKBOX
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_CODE_SNIPPET
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_CONTACT
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_DIVIDER
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_FILE
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_FILE_ERROR
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_FILE_PLACEHOLDER
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_FILE_UPLOAD
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_FOOTER
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_HEADER_ONE
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_HEADER_THREE
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_HEADER_TWO
|
||||
|
@ -197,15 +195,6 @@ class BlockAdapter(
|
|||
onMarkupActionClicked = onMarkupActionClicked
|
||||
)
|
||||
}
|
||||
HOLDER_CONTACT -> {
|
||||
BlockViewHolder.Contact(
|
||||
view = inflater.inflate(
|
||||
R.layout.item_block_contact,
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
HOLDER_FILE -> {
|
||||
BlockViewHolder.File(
|
||||
view = inflater.inflate(
|
||||
|
@ -351,7 +340,7 @@ class BlockAdapter(
|
|||
)
|
||||
}
|
||||
HOLDER_DIVIDER -> {
|
||||
BlockViewHolder.Divider(
|
||||
Divider(
|
||||
view = inflater.inflate(
|
||||
R.layout.item_block_divider,
|
||||
parent,
|
||||
|
@ -369,15 +358,6 @@ class BlockAdapter(
|
|||
onMarkupActionClicked = onMarkupActionClicked
|
||||
)
|
||||
}
|
||||
HOLDER_FOOTER -> {
|
||||
BlockViewHolder.Footer(
|
||||
view = inflater.inflate(
|
||||
R.layout.item_block_footer,
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
else -> throw IllegalStateException("Unexpected view type: $viewType")
|
||||
}
|
||||
}
|
||||
|
@ -712,11 +692,6 @@ class BlockAdapter(
|
|||
clicked = onClickListener
|
||||
)
|
||||
}
|
||||
is BlockViewHolder.Contact -> {
|
||||
holder.bind(
|
||||
item = blocks[position] as BlockView.Contact
|
||||
)
|
||||
}
|
||||
is BlockViewHolder.File -> {
|
||||
holder.bind(
|
||||
item = blocks[position] as BlockView.File.View,
|
||||
|
@ -822,10 +797,7 @@ class BlockAdapter(
|
|||
onSelectionChanged = onSelectionChanged
|
||||
)
|
||||
}
|
||||
is BlockViewHolder.Footer -> {
|
||||
holder.bind(onFooterClicked)
|
||||
}
|
||||
is BlockViewHolder.Divider -> {
|
||||
is Divider -> {
|
||||
holder.bind(
|
||||
item = blocks[position] as BlockView.Divider,
|
||||
clicked = onClickListener
|
||||
|
|
|
@ -14,7 +14,6 @@ import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOL
|
|||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_FILE_ERROR
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_FILE_PLACEHOLDER
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_FILE_UPLOAD
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_FOOTER
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_HEADER_ONE
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_HEADER_THREE
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_HEADER_TWO
|
||||
|
@ -33,7 +32,6 @@ import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOL
|
|||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_VIDEO_ERROR
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_VIDEO_PLACEHOLDER
|
||||
import com.agileburo.anytype.core_ui.features.page.BlockViewHolder.Companion.HOLDER_VIDEO_UPLOAD
|
||||
import kotlinx.android.parcel.IgnoredOnParcel
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
/**
|
||||
|
@ -745,20 +743,5 @@ sealed class BlockView : ViewType, Parcelable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Footer block. Just holds space at the end of the page.
|
||||
*/
|
||||
@Parcelize
|
||||
object Footer : BlockView() {
|
||||
@IgnoredOnParcel
|
||||
override val id: String = FOOTER_ID
|
||||
|
||||
override fun getViewType() = HOLDER_FOOTER
|
||||
}
|
||||
|
||||
enum class Mode { READ, EDIT }
|
||||
|
||||
companion object {
|
||||
const val FOOTER_ID = "FOOTER"
|
||||
}
|
||||
}
|
|
@ -36,10 +36,7 @@ import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory
|
|||
import com.google.android.exoplayer2.util.Util
|
||||
import kotlinx.android.synthetic.main.item_block_bookmark.view.*
|
||||
import kotlinx.android.synthetic.main.item_block_bookmark_error.view.*
|
||||
import kotlinx.android.synthetic.main.item_block_bulleted.view.*
|
||||
import kotlinx.android.synthetic.main.item_block_checkbox.view.*
|
||||
import kotlinx.android.synthetic.main.item_block_code_snippet.view.*
|
||||
import kotlinx.android.synthetic.main.item_block_contact.view.*
|
||||
import kotlinx.android.synthetic.main.item_block_file.view.*
|
||||
import kotlinx.android.synthetic.main.item_block_highlight.view.*
|
||||
import kotlinx.android.synthetic.main.item_block_page.view.*
|
||||
|
@ -222,17 +219,6 @@ open class BlockViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|||
}
|
||||
}
|
||||
|
||||
class Contact(view: View) : BlockViewHolder(view) {
|
||||
|
||||
private val name = itemView.name
|
||||
private val avatar = itemView.avatar
|
||||
|
||||
fun bind(item: BlockView.Contact) {
|
||||
name.text = item.name
|
||||
avatar.bind(item.name)
|
||||
}
|
||||
}
|
||||
|
||||
class File(view: View) : BlockViewHolder(view), IndentableHolder {
|
||||
|
||||
private val icon = itemView.fileIcon
|
||||
|
@ -742,21 +728,6 @@ open class BlockViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|||
}
|
||||
}
|
||||
|
||||
class Divider(view: View) : BlockViewHolder(view) {
|
||||
|
||||
fun bind(
|
||||
item: BlockView.Divider,
|
||||
clicked: (ListenerType) -> Unit
|
||||
) {
|
||||
itemView.setOnLongClickListener(
|
||||
EditorLongClickListener(
|
||||
t = item.id,
|
||||
click = { onBlockLongClick(itemView, it, clicked) }
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class Highlight(
|
||||
view: View,
|
||||
onMarkupActionClicked: (Markup.Type, IntRange) -> Unit
|
||||
|
@ -840,17 +811,6 @@ open class BlockViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|||
}
|
||||
}
|
||||
|
||||
class Footer(view: View) : BlockViewHolder(view) {
|
||||
|
||||
private val footer = itemView
|
||||
|
||||
fun bind(
|
||||
onFooterClicked: () -> Unit
|
||||
) {
|
||||
footer.setOnClickListener { onFooterClicked() }
|
||||
}
|
||||
}
|
||||
|
||||
fun onBlockLongClick(root: View, target: String, clicked: (ListenerType) -> Unit) {
|
||||
val rect = PopupExtensions.calculateRectInWindow(root)
|
||||
val dimensions = BlockDimensions(
|
||||
|
@ -873,15 +833,12 @@ open class BlockViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|||
const val HOLDER_HEADER_THREE = 4
|
||||
const val HOLDER_CODE_SNIPPET = 5
|
||||
const val HOLDER_CHECKBOX = 6
|
||||
const val HOLDER_TASK = 7
|
||||
const val HOLDER_BULLET = 8
|
||||
const val HOLDER_NUMBERED = 9
|
||||
const val HOLDER_TOGGLE = 10
|
||||
const val HOLDER_CONTACT = 11
|
||||
const val HOLDER_PAGE = 13
|
||||
const val HOLDER_DIVIDER = 16
|
||||
const val HOLDER_HIGHLIGHT = 17
|
||||
const val HOLDER_FOOTER = 18
|
||||
|
||||
const val HOLDER_VIDEO = 19
|
||||
const val HOLDER_VIDEO_PLACEHOLDER = 20
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/default_document_item_padding_start"
|
||||
android:paddingEnd="@dimen/default_document_item_padding_end">
|
||||
|
||||
<com.agileburo.anytype.core_ui.widgets.AvatarWidget
|
||||
android:background="@drawable/circle_solid_default"
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="24dp"
|
||||
tools:background="@drawable/circle_solid_default"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:contentDescription="@string/content_description_avatar_image"
|
||||
tools:src="@drawable/circle_solid_default" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
style="@style/BlockContactContentStyle"
|
||||
tools:text="Konstantin Ivanov" />
|
||||
|
||||
<ImageView
|
||||
android:src="@drawable/ic_block_more"
|
||||
android:id="@+id/more"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:contentDescription="@string/content_description_more_button" />
|
||||
|
||||
</FrameLayout>
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/footer_default_height" />
|
Loading…
Add table
Add a link
Reference in a new issue