Unverified Commit 1d502836 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito Committed by GitHub

Merge branch 'develop' into send-msg-attachments

parents fad3e0c2 4c5a07f7
...@@ -28,6 +28,8 @@ class ImageAttachmentViewHolder( ...@@ -28,6 +28,8 @@ class ImageAttachmentViewHolder(
}.build() }.build()
image_attachment.controller = controller image_attachment.controller = controller
file_name.text = data.attachmentTitle file_name.text = data.attachmentTitle
file_description.text = data.attachmentDescription
file_text.text = data.attachmentText
image_attachment.setOnClickListener { image_attachment.setOnClickListener {
ImageHelper.openImage( ImageHelper.openImage(
context, context,
......
...@@ -10,6 +10,8 @@ data class ImageAttachmentUiModel( ...@@ -10,6 +10,8 @@ data class ImageAttachmentUiModel(
override val messageId: String, override val messageId: String,
override val attachmentUrl: String, override val attachmentUrl: String,
override val attachmentTitle: CharSequence, override val attachmentTitle: CharSequence,
val attachmentText: String?,
val attachmentDescription: String?,
override val id: Long, override val id: Long,
override var reactions: List<ReactionUiModel>, override var reactions: List<ReactionUiModel>,
override var nextDownStreamMessage: BaseUiModel<*>? = null, override var nextDownStreamMessage: BaseUiModel<*>? = null,
......
...@@ -13,6 +13,7 @@ import androidx.core.text.buildSpannedString ...@@ -13,6 +13,7 @@ import androidx.core.text.buildSpannedString
import androidx.core.text.color import androidx.core.text.color
import androidx.core.text.scale import androidx.core.text.scale
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.app.RocketChatApplication.Companion.context
import chat.rocket.android.chatroom.domain.MessageReply import chat.rocket.android.chatroom.domain.MessageReply
import chat.rocket.android.dagger.scope.PerFragment import chat.rocket.android.dagger.scope.PerFragment
import chat.rocket.android.helper.MessageHelper import chat.rocket.android.helper.MessageHelper
...@@ -45,6 +46,8 @@ import kotlinx.coroutines.experimental.CommonPool ...@@ -45,6 +46,8 @@ import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.withContext import kotlinx.coroutines.experimental.withContext
import okhttp3.HttpUrl import okhttp3.HttpUrl
import java.security.InvalidParameterException import java.security.InvalidParameterException
import java.util.*
import java.util.Collections.emptyList
import javax.inject.Inject import javax.inject.Inject
@PerFragment @PerFragment
...@@ -285,10 +288,12 @@ class UiModelMapper @Inject constructor( ...@@ -285,10 +288,12 @@ class UiModelMapper @Inject constructor(
private fun mapFileAttachment(message: Message, attachment: FileAttachment): BaseUiModel<*>? { private fun mapFileAttachment(message: Message, attachment: FileAttachment): BaseUiModel<*>? {
val attachmentUrl = attachmentUrl(attachment) val attachmentUrl = attachmentUrl(attachment)
val attachmentTitle = attachmentTitle(attachment) val attachmentTitle = attachmentTitle(attachment)
val attachmentText = attachmentText(attachment)
val attachmentDescription = attachmentDescription(attachment)
val id = attachmentId(message, attachment) val id = attachmentId(message, attachment)
return when (attachment) { return when (attachment) {
is ImageAttachment -> ImageAttachmentUiModel(message, attachment, message.id, is ImageAttachment -> ImageAttachmentUiModel(message, attachment, message.id,
attachmentUrl, attachmentTitle, id, getReactions(message), attachmentUrl, attachmentTitle, attachmentText, attachmentDescription, id, getReactions(message),
preview = message.copy(message = context.getString(R.string.msg_preview_photo))) preview = message.copy(message = context.getString(R.string.msg_preview_photo)))
is VideoAttachment -> VideoAttachmentUiModel(message, attachment, message.id, is VideoAttachment -> VideoAttachmentUiModel(message, attachment, message.id,
attachmentUrl, attachmentTitle, id, getReactions(message), attachmentUrl, attachmentTitle, id, getReactions(message),
...@@ -338,6 +343,14 @@ class UiModelMapper @Inject constructor( ...@@ -338,6 +343,14 @@ class UiModelMapper @Inject constructor(
} }
} }
private fun attachmentText(attachment: FileAttachment): String? {
return attachment.text
}
private fun attachmentDescription(attachment: FileAttachment): String? {
return attachment.description
}
private suspend fun mapMessage(message: Message): MessageUiModel = withContext(CommonPool) { private suspend fun mapMessage(message: Message): MessageUiModel = withContext(CommonPool) {
val sender = getSenderName(message) val sender = getSenderName(message)
val time = getTime(message.timestamp) val time = getTime(message.timestamp)
......
...@@ -10,6 +10,20 @@ ...@@ -10,6 +10,20 @@
android:paddingEnd="@dimen/screen_edge_left_and_right_margins" android:paddingEnd="@dimen/screen_edge_left_and_right_margins"
android:paddingStart="72dp"> android:paddingStart="72dp">
<TextView
android:id="@+id/file_name"
style="@style/Message.TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Filename.png" />
<TextView
android:id="@+id/file_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Some description" />
<com.facebook.drawee.view.SimpleDraweeView <com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/image_attachment" android:id="@+id/image_attachment"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -34,10 +48,10 @@ ...@@ -34,10 +48,10 @@
</FrameLayout> </FrameLayout>
<TextView <TextView
android:id="@+id/file_name" android:id="@+id/file_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="Filename.png" /> tools:text="Some text" />
<include <include
layout="@layout/layout_reactions" layout="@layout/layout_reactions"
......
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
android:id="@+id/action_save_image" android:id="@+id/action_save_image"
android:icon="@drawable/ic_file_download_white_24dp" android:icon="@drawable/ic_file_download_white_24dp"
android:title="@string/action_save_to_gallery" android:title="@string/action_save_to_gallery"
android:showAsAction="always" /> app:showAsAction="always" />
</menu> </menu>
\ No newline at end of file
...@@ -172,9 +172,8 @@ ...@@ -172,9 +172,8 @@
<string name="permission_starring_not_allowed">Отмечивание запрещено</string> <string name="permission_starring_not_allowed">Отмечивание запрещено</string>
<!-- Favorite/Unfavorite chat room --> <!-- Favorite/Unfavorite chat room -->
<!-- TODO Add proper translation--> <string name="title_favorite_chat">Добавить чат в избранное</string>
<string name="title_favorite_chat">Favorite chat</string> <string name="title_unfavorite_chat">Удалить чат из избранного</string>
<string name="title_unfavorite_chat">Unfavorite chat</string>
<!-- Members List --> <!-- Members List -->
<string name="title_members_list">Пользователи</string> <string name="title_members_list">Пользователи</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment