mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 06:28:45 +03:00
[merge] Re-implement Schildi plain composer layout
Change-Id: Ie51df42a34c1ac265748658155d578d6d4debd7c
This commit is contained in:
parent
65be0039a5
commit
71eca44f4f
2 changed files with 218 additions and 7 deletions
|
@ -35,7 +35,7 @@ import im.vector.app.core.extensions.getVectorLastMessageContent
|
|||
import im.vector.app.core.extensions.setTextIfDifferent
|
||||
import im.vector.app.core.extensions.showKeyboard
|
||||
import im.vector.app.core.utils.DimensionConverter
|
||||
import im.vector.app.databinding.ComposerLayoutBinding
|
||||
import im.vector.app.databinding.ComposerLayoutScBinding
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.room.detail.TimelineViewModel
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
|
||||
|
@ -71,7 +71,7 @@ class PlainTextComposerLayout @JvmOverloads constructor(
|
|||
@Inject lateinit var imageContentRenderer: ImageContentRenderer
|
||||
@Inject lateinit var pillsPostProcessorFactory: PillsPostProcessor.Factory
|
||||
|
||||
private val views: ComposerLayoutBinding
|
||||
private val views: ComposerLayoutScBinding
|
||||
|
||||
override var callback: Callback? = null
|
||||
|
||||
|
@ -94,8 +94,8 @@ class PlainTextComposerLayout @JvmOverloads constructor(
|
|||
get() = views.attachmentButton
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.composer_layout, this)
|
||||
views = ComposerLayoutBinding.bind(this)
|
||||
inflate(context, R.layout.composer_layout_sc, this)
|
||||
views = ComposerLayoutScBinding.bind(this)
|
||||
|
||||
views.composerEditText.maxLines = MessageComposerView.MAX_LINES_WHEN_COLLAPSED
|
||||
|
||||
|
@ -129,19 +129,22 @@ class PlainTextComposerLayout @JvmOverloads constructor(
|
|||
views.relatedMessageGroup.isVisible = false
|
||||
transitionComplete?.invoke()
|
||||
callback?.onExpandOrCompactChange()
|
||||
|
||||
views.attachmentButton.isVisible = true
|
||||
}
|
||||
|
||||
private fun expand(transitionComplete: (() -> Unit)? = null) {
|
||||
views.relatedMessageGroup.isVisible = true
|
||||
transitionComplete?.invoke()
|
||||
callback?.onExpandOrCompactChange()
|
||||
|
||||
views.attachmentButton.isVisible = false
|
||||
}
|
||||
|
||||
override fun setTextIfDifferent(text: CharSequence?): Boolean {
|
||||
return views.composerEditText.setTextIfDifferent(text)
|
||||
}
|
||||
|
||||
// SC-TODO maybe just some interface instead of timelineViewModel
|
||||
override fun renderComposerMode(mode: MessageComposerMode, timelineViewModel: TimelineViewModel?) {
|
||||
val specialMode = mode as? MessageComposerMode.Special
|
||||
if (specialMode != null) {
|
||||
|
@ -154,10 +157,10 @@ class PlainTextComposerLayout @JvmOverloads constructor(
|
|||
views.sendButton.apply {
|
||||
if (mode is MessageComposerMode.Edit) {
|
||||
contentDescription = resources.getString(R.string.action_save)
|
||||
setImageResource(R.drawable.ic_composer_rich_text_save)
|
||||
setImageResource(R.drawable.ic_check_on)
|
||||
} else {
|
||||
contentDescription = resources.getString(R.string.action_send)
|
||||
setImageResource(R.drawable.ic_rich_composer_send)
|
||||
setImageResource(R.drawable.ic_send)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
208
vector/src/main/res/layout/composer_layout_sc.xml
Normal file
208
vector/src/main/res/layout/composer_layout_sc.xml
Normal file
|
@ -0,0 +1,208 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/related_message_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<View
|
||||
android:id="@+id/related_message_background"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="?colorSurface"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="@id/composer_preview_barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/related_message_background_top_separator"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:background="?vctr_list_separator"
|
||||
app:layout_constraintEnd_toEndOf="@id/related_message_background"
|
||||
app:layout_constraintStart_toStartOf="@id/related_message_background"
|
||||
app:layout_constraintTop_toTopOf="@id/related_message_background" />
|
||||
|
||||
<View
|
||||
android:id="@+id/related_message_background_bottom_separator"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:background="?vctr_list_separator"
|
||||
app:layout_constraintBottom_toBottomOf="@id/related_message_background"
|
||||
app:layout_constraintEnd_toEndOf="@id/related_message_background"
|
||||
app:layout_constraintStart_toStartOf="@+id/related_message_background" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/composerRelatedMessageAvatar"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:importantForAccessibility="no"
|
||||
app:layout_constraintBottom_toTopOf="@id/composerRelatedMessageActionIcon"
|
||||
app:layout_constraintEnd_toStartOf="@id/composerRelatedMessageTitle"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/composerRelatedMessageTitle"
|
||||
tools:src="@sample/user_round_avatars" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/composerRelatedMessageTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@id/composerRelatedMessageCloseButton"
|
||||
app:layout_constraintStart_toEndOf="@id/composerRelatedMessageAvatar"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@tools:sample/first_names" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/composerRelatedMessageContent"
|
||||
style="@style/Widget.Vector.TextView.Body"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textColor="?vctr_message_text_color"
|
||||
app:layout_constrainedHeight="true"
|
||||
app:layout_constraintEnd_toEndOf="@id/composerRelatedMessageTitle"
|
||||
app:layout_constraintStart_toStartOf="@id/composerRelatedMessageTitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/composerRelatedMessageImage"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/composerRelatedMessageActionIcon"
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginBottom="38dp"
|
||||
android:alpha="1"
|
||||
android:importantForAccessibility="no"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="@id/composerRelatedMessageAvatar"
|
||||
app:layout_constraintStart_toStartOf="@id/composerRelatedMessageAvatar"
|
||||
app:layout_constraintTop_toBottomOf="@id/composerRelatedMessageAvatar"
|
||||
app:tint="?vctr_content_primary"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:src="@drawable/ic_edit" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/composerRelatedMessageImage"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="66dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:scaleType="centerCrop"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="@id/composerRelatedMessageTitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/composerRelatedMessageTitle"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:src="@tools:sample/backgrounds/scenic"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/composerRelatedMessageCloseButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:contentDescription="@string/action_cancel"
|
||||
android:src="@drawable/ic_close_round"
|
||||
app:layout_constraintBottom_toBottomOf="@id/composer_preview_barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tint="?colorError"
|
||||
tools:ignore="MissingPrefix" />
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/composer_preview_barrier"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:barrierDirection="bottom"
|
||||
app:barrierMargin="8dp"
|
||||
app:constraint_referenced_ids="composerRelatedMessageContent,composerRelatedMessageActionIcon"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/composerEmojiButton"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_margin="1dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:contentDescription="@string/a11y_open_emoji_picker"
|
||||
android:src="@drawable/ic_insert_emoji"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/sendButton"
|
||||
app:layout_constraintEnd_toStartOf="@+id/composerEditText"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/sendButton"
|
||||
app:layout_goneMarginEnd="8dp"
|
||||
app:tint="?android:textColorHint"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<im.vector.app.features.home.room.detail.composer.ComposerEditText
|
||||
android:id="@+id/composerEditText"
|
||||
style="@style/Widget.Vector.EditText.Composer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/room_message_placeholder"
|
||||
android:nextFocusLeft="@id/composerEditText"
|
||||
android:nextFocusUp="@id/composerEditText"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/attachmentButton"
|
||||
app:layout_constraintStart_toEndOf="@id/composerEmojiButton"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_goneMarginStart="8dp"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/attachmentButton"
|
||||
android:layout_width="@dimen/composer_attachment_width"
|
||||
android:layout_height="@dimen/composer_attachment_height"
|
||||
android:layout_margin="@dimen/composer_attachment_margin"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:contentDescription="@string/option_send_files"
|
||||
android:src="@drawable/ic_attachment"
|
||||
app:tint="?android:textColorHint"
|
||||
app:layout_constraintBottom_toBottomOf="@id/sendButton"
|
||||
app:layout_constraintEnd_toStartOf="@id/sendButton"
|
||||
app:layout_constraintStart_toEndOf="@id/composerEditText"
|
||||
app:layout_constraintTop_toTopOf="@id/sendButton"
|
||||
app:layout_goneMarginBottom="57dp"
|
||||
tools:ignore="MissingPrefix" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sendButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="@dimen/composer_min_height"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:contentDescription="@string/action_send"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_send"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/attachmentButton"
|
||||
tools:ignore="MissingPrefix"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in a new issue