forked from GitHub-Mirror/riotX-android
Merge branch 'feature/timeline_media' into develop
This commit is contained in:
@ -15,8 +15,9 @@ android {
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
applicationId "im.vector.riotredesign"
|
||||
minSdkVersion 21
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
multiDexEnabled true
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
@ -42,11 +43,14 @@ dependencies {
|
||||
|
||||
implementation project(":matrix-sdk-android")
|
||||
implementation project(":matrix-sdk-android-rx")
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.core:core-ktx:1.0.1'
|
||||
|
||||
// Paging
|
||||
implementation 'androidx.paging:paging-runtime:2.0.0'
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package im.vector.riotredesign
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.multidex.MultiDex
|
||||
import com.jakewharton.threetenabp.AndroidThreeTen
|
||||
import im.vector.matrix.android.BuildConfig
|
||||
import im.vector.riotredesign.core.di.AppModule
|
||||
@ -8,6 +10,7 @@ import org.koin.log.EmptyLogger
|
||||
import org.koin.standalone.StandAloneContext.startKoin
|
||||
import timber.log.Timber
|
||||
|
||||
|
||||
class Riot : Application() {
|
||||
|
||||
override fun onCreate() {
|
||||
@ -19,4 +22,9 @@ class Riot : Application() {
|
||||
startKoin(listOf(AppModule(this).definition), logger = EmptyLogger())
|
||||
}
|
||||
|
||||
override fun attachBaseContext(base: Context) {
|
||||
super.attachBaseContext(base)
|
||||
MultiDex.install(this)
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +1,16 @@
|
||||
package im.vector.riotredesign.features.home
|
||||
|
||||
import androidx.core.content.ContextCompat
|
||||
import android.widget.ImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.amulyakhare.textdrawable.TextDrawable
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import im.vector.matrix.android.api.Matrix
|
||||
import im.vector.matrix.android.api.session.room.model.RoomMember
|
||||
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.extensions.firstCharAsString
|
||||
import im.vector.riotredesign.core.glide.GlideApp
|
||||
|
||||
private const val MEDIA_URL = "https://matrix.org/_matrix/media/v1/download/"
|
||||
private const val MXC_PREFIX = "mxc://"
|
||||
|
||||
object AvatarRenderer {
|
||||
|
||||
fun render(roomMember: RoomMember, imageView: ImageView) {
|
||||
@ -27,7 +25,7 @@ object AvatarRenderer {
|
||||
if (name.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
val resolvedUrl = avatarUrl?.replace(MXC_PREFIX, MEDIA_URL)
|
||||
val resolvedUrl = Matrix.getInstance().currentSession.contentUrlResolver().resolveFullSize(avatarUrl)
|
||||
val avatarColor = ContextCompat.getColor(imageView.context, R.color.pale_teal)
|
||||
val fallbackDrawable = TextDrawable.builder().buildRound(name.firstCharAsString().toUpperCase(), avatarColor)
|
||||
|
||||
|
@ -10,6 +10,7 @@ import im.vector.riotredesign.features.home.room.detail.timeline.RoomTopicItemFa
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.TimelineDateFormatter
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.TimelineEventController
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.TimelineItemFactory
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
||||
import org.koin.dsl.module.module
|
||||
|
||||
class HomeModule {
|
||||
@ -21,7 +22,7 @@ class HomeModule {
|
||||
}
|
||||
|
||||
single {
|
||||
MessageItemFactory(get())
|
||||
MessageItemFactory(get(), get())
|
||||
}
|
||||
|
||||
single {
|
||||
@ -49,7 +50,11 @@ class HomeModule {
|
||||
}
|
||||
|
||||
factory { (roomId: String) ->
|
||||
TimelineEventController(roomId, get(), get())
|
||||
TimelineEventController(roomId, get(), get(), get())
|
||||
}
|
||||
|
||||
single {
|
||||
TimelineMediaSizeProvider()
|
||||
}
|
||||
|
||||
single {
|
||||
|
@ -0,0 +1,33 @@
|
||||
package im.vector.riotredesign.features.home.room.detail.timeline
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.LayoutRes
|
||||
import im.vector.riotredesign.core.epoxy.KotlinModel
|
||||
import im.vector.riotredesign.features.home.AvatarRenderer
|
||||
|
||||
abstract class AbsMessageItem(private val informationData: MessageInformationData,
|
||||
@LayoutRes layoutRes: Int
|
||||
) : KotlinModel(layoutRes) {
|
||||
|
||||
protected abstract val avatarImageView: ImageView
|
||||
protected abstract val memberNameView: TextView
|
||||
protected abstract val timeView: TextView
|
||||
|
||||
override fun bind() {
|
||||
if (informationData.showInformation) {
|
||||
avatarImageView.visibility = View.VISIBLE
|
||||
memberNameView.visibility = View.VISIBLE
|
||||
timeView.visibility = View.VISIBLE
|
||||
timeView.text = informationData.time
|
||||
memberNameView.text = informationData.memberName
|
||||
AvatarRenderer.render(informationData.avatarUrl, informationData.memberName?.toString(), avatarImageView)
|
||||
} else {
|
||||
avatarImageView.visibility = View.GONE
|
||||
memberNameView.visibility = View.GONE
|
||||
timeView.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package im.vector.riotredesign.features.home.room.detail.timeline
|
||||
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.features.media.MediaContentRenderer
|
||||
|
||||
class MessageImageItem(
|
||||
private val mediaData: MediaContentRenderer.Data,
|
||||
informationData: MessageInformationData
|
||||
) : AbsMessageItem(informationData, R.layout.item_timeline_event_image_message) {
|
||||
|
||||
override val avatarImageView by bind<ImageView>(R.id.messageAvatarImageView)
|
||||
override val memberNameView by bind<TextView>(R.id.messageMemberNameView)
|
||||
override val timeView by bind<TextView>(R.id.messageTimeView)
|
||||
private val imageView by bind<ImageView>(R.id.messageImageView)
|
||||
|
||||
override fun bind() {
|
||||
super.bind()
|
||||
MediaContentRenderer.render(mediaData, MediaContentRenderer.Mode.THUMBNAIL, imageView)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package im.vector.riotredesign.features.home.room.detail.timeline
|
||||
|
||||
data class MessageInformationData(
|
||||
val time: CharSequence? = null,
|
||||
val avatarUrl: String?,
|
||||
val memberName: CharSequence? = null,
|
||||
val showInformation: Boolean = true
|
||||
)
|
@ -1,40 +0,0 @@
|
||||
package im.vector.riotredesign.features.home.room.detail.timeline
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import im.vector.matrix.android.api.permalinks.MatrixLinkify
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.epoxy.KotlinModel
|
||||
import im.vector.riotredesign.features.home.AvatarRenderer
|
||||
|
||||
class MessageItem(
|
||||
val message: CharSequence? = null,
|
||||
val time: CharSequence? = null,
|
||||
val avatarUrl: String?,
|
||||
val memberName: CharSequence? = null,
|
||||
val showInformation: Boolean = true
|
||||
) : KotlinModel(R.layout.item_timeline_event_message) {
|
||||
|
||||
private val avatarImageView by bind<ImageView>(R.id.messageAvatarImageView)
|
||||
private val memberNameView by bind<TextView>(R.id.messageMemberNameView)
|
||||
private val timeView by bind<TextView>(R.id.messageTimeView)
|
||||
private val messageView by bind<TextView>(R.id.messageTextView)
|
||||
|
||||
override fun bind() {
|
||||
messageView.text = message
|
||||
MatrixLinkify.addLinkMovementMethod(messageView)
|
||||
if (showInformation) {
|
||||
avatarImageView.visibility = View.VISIBLE
|
||||
memberNameView.visibility = View.VISIBLE
|
||||
timeView.visibility = View.VISIBLE
|
||||
timeView.text = time
|
||||
memberNameView.text = memberName
|
||||
AvatarRenderer.render(avatarUrl, memberName?.toString(), avatarImageView)
|
||||
} else {
|
||||
avatarImageView.visibility = View.GONE
|
||||
memberNameView.visibility = View.GONE
|
||||
timeView.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
@ -7,39 +7,74 @@ import im.vector.matrix.android.api.permalinks.MatrixPermalinkSpan
|
||||
import im.vector.matrix.android.api.session.events.model.EventType
|
||||
import im.vector.matrix.android.api.session.events.model.TimelineEvent
|
||||
import im.vector.matrix.android.api.session.events.model.toModel
|
||||
import im.vector.matrix.android.api.session.room.model.MessageContent
|
||||
import im.vector.matrix.android.api.session.room.model.message.MessageContent
|
||||
import im.vector.matrix.android.api.session.room.model.message.MessageImageContent
|
||||
import im.vector.matrix.android.api.session.room.model.message.MessageTextContent
|
||||
import im.vector.riotredesign.core.extensions.localDateTime
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
||||
import im.vector.riotredesign.features.media.MediaContentRenderer
|
||||
|
||||
class MessageItemFactory(private val timelineDateFormatter: TimelineDateFormatter) {
|
||||
class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSizeProvider,
|
||||
private val timelineDateFormatter: TimelineDateFormatter) {
|
||||
|
||||
private val messagesDisplayedWithInformation = HashSet<String?>()
|
||||
|
||||
fun create(event: TimelineEvent,
|
||||
nextEvent: TimelineEvent?,
|
||||
callback: TimelineEventController.Callback?
|
||||
): MessageItem? {
|
||||
): AbsMessageItem? {
|
||||
|
||||
val messageContent: MessageContent? = event.root.content.toModel()
|
||||
val roomMember = event.roomMember
|
||||
if (messageContent == null) {
|
||||
return null
|
||||
}
|
||||
val nextRoomMember = nextEvent?.roomMember
|
||||
|
||||
val date = event.root.localDateTime()
|
||||
val nextDate = nextEvent?.root?.localDateTime()
|
||||
val addDaySeparator = date.toLocalDate() != nextDate?.toLocalDate()
|
||||
val isNextMessageReceivedMoreThanOneHourAgo = nextDate?.isBefore(date.minusMinutes(60))
|
||||
?: false
|
||||
?: false
|
||||
|
||||
if (addDaySeparator
|
||||
|| nextRoomMember != roomMember
|
||||
|| nextEvent?.root?.type != EventType.MESSAGE
|
||||
|| isNextMessageReceivedMoreThanOneHourAgo) {
|
||||
|| nextRoomMember != roomMember
|
||||
|| nextEvent?.root?.type != EventType.MESSAGE
|
||||
|| isNextMessageReceivedMoreThanOneHourAgo) {
|
||||
messagesDisplayedWithInformation.add(event.root.eventId)
|
||||
}
|
||||
|
||||
val message = messageContent.body?.let {
|
||||
val messageContent: MessageContent = event.root.content.toModel() ?: return null
|
||||
val showInformation = messagesDisplayedWithInformation.contains(event.root.eventId)
|
||||
val time = timelineDateFormatter.formatMessageHour(date)
|
||||
val avatarUrl = roomMember?.avatarUrl
|
||||
val memberName = roomMember?.displayName ?: event.root.sender
|
||||
val informationData = MessageInformationData(time, avatarUrl, memberName, showInformation)
|
||||
|
||||
return when (messageContent) {
|
||||
is MessageTextContent -> buildTextMessageItem(messageContent, informationData, callback)
|
||||
is MessageImageContent -> buildImageMessageItem(messageContent, informationData)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildImageMessageItem(messageContent: MessageImageContent,
|
||||
informationData: MessageInformationData): MessageImageItem? {
|
||||
|
||||
val (maxWidth, maxHeight) = timelineMediaSizeProvider.getMaxSize()
|
||||
val data = MediaContentRenderer.Data(
|
||||
url = messageContent.url,
|
||||
height = messageContent.info.height,
|
||||
maxHeight = maxHeight,
|
||||
width = messageContent.info.width,
|
||||
maxWidth = maxWidth,
|
||||
rotation = messageContent.info.rotation,
|
||||
orientation = messageContent.info.orientation
|
||||
)
|
||||
return MessageImageItem(data, informationData)
|
||||
}
|
||||
|
||||
private fun buildTextMessageItem(messageContent: MessageTextContent,
|
||||
informationData: MessageInformationData,
|
||||
callback: TimelineEventController.Callback?): MessageTextItem? {
|
||||
|
||||
val message = messageContent.body.let {
|
||||
val spannable = SpannableStringBuilder(it)
|
||||
MatrixLinkify.addLinks(spannable, object : MatrixPermalinkSpan.Callback {
|
||||
override fun onUrlClicked(url: String) {
|
||||
@ -49,13 +84,9 @@ class MessageItemFactory(private val timelineDateFormatter: TimelineDateFormatte
|
||||
Linkify.addLinks(spannable, Linkify.ALL)
|
||||
spannable
|
||||
}
|
||||
val showInformation = messagesDisplayedWithInformation.contains(event.root.eventId)
|
||||
return MessageItem(
|
||||
return MessageTextItem(
|
||||
message = message,
|
||||
avatarUrl = roomMember?.avatarUrl,
|
||||
showInformation = showInformation,
|
||||
time = timelineDateFormatter.formatMessageHour(date),
|
||||
memberName = roomMember?.displayName ?: event.root.sender
|
||||
informationData = informationData
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
package im.vector.riotredesign.features.home.room.detail.timeline
|
||||
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import im.vector.matrix.android.api.permalinks.MatrixLinkify
|
||||
import im.vector.riotredesign.R
|
||||
|
||||
class MessageTextItem(
|
||||
val message: CharSequence? = null,
|
||||
informationData: MessageInformationData
|
||||
) : AbsMessageItem(informationData, R.layout.item_timeline_event_text_message) {
|
||||
|
||||
override val avatarImageView by bind<ImageView>(R.id.messageAvatarImageView)
|
||||
override val memberNameView by bind<TextView>(R.id.messageMemberNameView)
|
||||
override val timeView by bind<TextView>(R.id.messageTimeView)
|
||||
private val messageView by bind<TextView>(R.id.messageTextView)
|
||||
|
||||
override fun bind() {
|
||||
super.bind()
|
||||
messageView.text = message
|
||||
MatrixLinkify.addLinkMovementMethod(messageView)
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package im.vector.riotredesign.features.home.room.detail.timeline
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.airbnb.epoxy.EpoxyAsyncUtil
|
||||
import com.airbnb.epoxy.EpoxyModel
|
||||
import im.vector.matrix.android.api.session.events.model.EventType
|
||||
@ -7,11 +8,13 @@ import im.vector.matrix.android.api.session.events.model.TimelineEvent
|
||||
import im.vector.matrix.android.api.session.room.timeline.TimelineData
|
||||
import im.vector.riotredesign.core.extensions.localDateTime
|
||||
import im.vector.riotredesign.features.home.LoadingItemModel_
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.paging.PagedListEpoxyController
|
||||
|
||||
class TimelineEventController(private val roomId: String,
|
||||
private val dateFormatter: TimelineDateFormatter,
|
||||
private val timelineItemFactory: TimelineItemFactory
|
||||
private val timelineItemFactory: TimelineItemFactory,
|
||||
private val timelineMediaSizeProvider: TimelineMediaSizeProvider
|
||||
) : PagedListEpoxyController<TimelineEvent>(
|
||||
EpoxyAsyncUtil.getAsyncBackgroundHandler(),
|
||||
EpoxyAsyncUtil.getAsyncBackgroundHandler()
|
||||
@ -36,6 +39,10 @@ class TimelineEventController(private val roomId: String,
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView)
|
||||
timelineMediaSizeProvider.recyclerView = recyclerView
|
||||
}
|
||||
|
||||
override fun buildItemModels(currentPosition: Int, items: List<TimelineEvent?>): List<EpoxyModel<*>> {
|
||||
if (items.isNullOrEmpty()) {
|
||||
|
@ -0,0 +1,31 @@
|
||||
package im.vector.riotredesign.features.home.room.detail.timeline.helper
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class TimelineMediaSizeProvider {
|
||||
|
||||
lateinit var recyclerView: RecyclerView
|
||||
private var cachedSize: Pair<Int, Int>? = null
|
||||
|
||||
fun getMaxSize(): Pair<Int, Int> {
|
||||
return cachedSize ?: computeMaxSize().also { cachedSize = it }
|
||||
}
|
||||
|
||||
private fun computeMaxSize(): Pair<Int, Int> {
|
||||
val width = recyclerView.width
|
||||
val height = recyclerView.height
|
||||
val maxImageWidth: Int
|
||||
val maxImageHeight: Int
|
||||
// landscape / portrait
|
||||
if (width < height) {
|
||||
maxImageWidth = Math.round(width * 0.7f)
|
||||
maxImageHeight = Math.round(height * 0.5f)
|
||||
} else {
|
||||
maxImageWidth = Math.round(width * 0.5f)
|
||||
maxImageHeight = Math.round(height * 0.7f)
|
||||
}
|
||||
return Pair(maxImageWidth, maxImageHeight)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
package im.vector.riotredesign.features.home.room.list
|
||||
|
||||
import androidx.core.content.ContextCompat
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import im.vector.riotredesign.R
|
||||
import im.vector.riotredesign.core.epoxy.KotlinModel
|
||||
|
||||
@ -21,8 +22,9 @@ data class RoomCategoryItem(
|
||||
|
||||
override fun bind() {
|
||||
val expandedArrowDrawableRes = if (isExpanded) R.drawable.ic_expand_more_white else R.drawable.ic_expand_less_white
|
||||
val expandedArrowDrawable = ContextCompat.getDrawable(rootView.context, expandedArrowDrawableRes)
|
||||
expandedArrowDrawable?.setTint(tintColor)
|
||||
val expandedArrowDrawable = ContextCompat.getDrawable(rootView.context, expandedArrowDrawableRes)?.also {
|
||||
DrawableCompat.setTint(it, tintColor)
|
||||
}
|
||||
titleView.setCompoundDrawablesWithIntrinsicBounds(expandedArrowDrawable, null, null, null)
|
||||
titleView.text = title
|
||||
rootView.setOnClickListener { listener?.invoke() }
|
||||
|
@ -0,0 +1,85 @@
|
||||
package im.vector.riotredesign.features.media
|
||||
|
||||
import android.media.ExifInterface
|
||||
import android.widget.ImageView
|
||||
import im.vector.matrix.android.api.Matrix
|
||||
import im.vector.matrix.android.api.session.content.ContentUrlResolver
|
||||
import im.vector.riotredesign.core.glide.GlideApp
|
||||
|
||||
object MediaContentRenderer {
|
||||
|
||||
data class Data(
|
||||
val url: String?,
|
||||
val height: Int,
|
||||
val maxHeight: Int,
|
||||
val width: Int,
|
||||
val maxWidth: Int = width,
|
||||
val orientation: Int,
|
||||
val rotation: Int
|
||||
)
|
||||
|
||||
enum class Mode {
|
||||
FULL_SIZE,
|
||||
THUMBNAIL
|
||||
}
|
||||
|
||||
fun render(data: Data, mode: Mode, imageView: ImageView) {
|
||||
val (width, height) = processSize(data, mode)
|
||||
imageView.layoutParams.height = height
|
||||
imageView.layoutParams.width = width
|
||||
|
||||
val contentUrlResolver = Matrix.getInstance().currentSession.contentUrlResolver()
|
||||
val resolvedUrl = when (mode) {
|
||||
Mode.FULL_SIZE -> contentUrlResolver.resolveFullSize(data.url)
|
||||
Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, width, height, ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||
}
|
||||
?: return
|
||||
|
||||
GlideApp
|
||||
.with(imageView)
|
||||
.load(resolvedUrl)
|
||||
.thumbnail(0.3f)
|
||||
.into(imageView)
|
||||
}
|
||||
|
||||
private fun processSize(data: Data, mode: Mode): Pair<Int, Int> {
|
||||
val maxImageWidth = data.maxWidth
|
||||
val maxImageHeight = data.maxHeight
|
||||
val rotationAngle = data.rotation
|
||||
val orientation = data.orientation
|
||||
var width = data.width
|
||||
var height = data.height
|
||||
var finalHeight = -1
|
||||
var finalWidth = -1
|
||||
|
||||
// if the image size is known
|
||||
// compute the expected height
|
||||
if (width > 0 && height > 0) {
|
||||
// swap width and height if the image is side oriented
|
||||
if (rotationAngle == 90 || rotationAngle == 270) {
|
||||
val tmp = width
|
||||
width = height
|
||||
height = tmp
|
||||
} else if (orientation == ExifInterface.ORIENTATION_ROTATE_90 || orientation == ExifInterface.ORIENTATION_ROTATE_270) {
|
||||
val tmp = width
|
||||
width = height
|
||||
height = tmp
|
||||
}
|
||||
if (mode == Mode.FULL_SIZE) {
|
||||
finalHeight = height
|
||||
finalWidth = width
|
||||
} else {
|
||||
finalHeight = Math.min(maxImageWidth * height / width, maxImageHeight)
|
||||
finalWidth = finalHeight * width / height
|
||||
}
|
||||
}
|
||||
// ensure that some values are properly initialized
|
||||
if (finalHeight < 0) {
|
||||
finalHeight = maxImageHeight
|
||||
}
|
||||
if (finalWidth < 0) {
|
||||
finalWidth = maxImageWidth
|
||||
}
|
||||
return Pair(finalWidth, finalHeight)
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/messageAvatarImageView"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/messageMemberNameView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="64dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/toolbarSubtitleView"
|
||||
app:layout_constraintEnd_toStartOf="@+id/messageTimeView"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/messageTimeView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textColor="@color/brown_grey"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintTop_toTopOf="@id/messageMemberNameView"
|
||||
tools:text="@tools:sample/date/hhmm" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/messageImageView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="64dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/messageMemberNameView" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Reference in New Issue
Block a user