Adding new message item

This commit is contained in:
Maxime NATUREL 2022-04-06 17:50:52 +02:00
parent a1fb85dcdb
commit e93e51d03c
8 changed files with 93 additions and 20 deletions

View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.features.home.room.detail.timeline.item
import android.widget.ImageView
import androidx.core.view.updateLayoutParams
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import im.vector.app.R
import im.vector.app.core.glide.GlideApp
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayout
import im.vector.app.features.home.room.detail.timeline.style.granularRoundedCorners
@EpoxyModelClass(layout = R.layout.item_timeline_event_base)
abstract class MessageLiveLocationStartItem : AbsMessageItem<MessageLiveLocationStartItem.Holder>() {
@EpoxyAttribute
var mapWidth: Int = 0
@EpoxyAttribute
var mapHeight: Int = 0
override fun bind(holder: Holder) {
super.bind(holder)
renderSendState(holder.view, null)
val messageLayout = attributes.informationData.messageLayout
val dimensionConverter = DimensionConverter(holder.view.resources)
val imageCornerTransformation = if (messageLayout is TimelineMessageLayout.Bubble) {
messageLayout.cornersRadius.granularRoundedCorners()
} else {
RoundedCorners(dimensionConverter.dpToPx(8))
}
holder.noLocationMapImageView.updateLayoutParams {
width = mapWidth
height = mapHeight
}
GlideApp.with(holder.noLocationMapImageView)
.load(R.drawable.bg_no_location_map)
.transform(imageCornerTransformation)
.into(holder.noLocationMapImageView)
}
override fun getViewStubId() = STUB_ID
class Holder : AbsMessageItem.Holder(STUB_ID) {
val noLocationMapImageView by bind<ImageView>(R.id.locationLiveStartMap)
}
companion object {
private const val STUB_ID = R.id.messageContentLiveLocationStartStub
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -6,61 +6,60 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<!-- Size will be overrode --> <!-- Size will be overrode -->
<!-- TODO use the correct image -->
<ImageView <ImageView
android:id="@+id/locationLiveStartedMap" android:id="@+id/locationLiveStartMap"
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="200dp" android:layout_height="200dp"
android:contentDescription="@string/a11y_static_map_image" android:contentDescription="@string/a11y_static_map_image"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@tools:sample/backgrounds/scenic" android:src="@drawable/bg_no_location_map"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<View <View
android:id="@+id/locationLiveStartedBannerBackground" android:id="@+id/locationLiveStartBannerBackground"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="48dp" android:layout_height="48dp"
android:alpha="0.85" android:alpha="0.85"
android:background="?colorSurface" android:background="?colorSurface"
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartedMap" app:layout_constraintBottom_toBottomOf="@id/locationLiveStartMap"
app:layout_constraintEnd_toEndOf="@id/locationLiveStartedMap" app:layout_constraintEnd_toEndOf="@id/locationLiveStartMap"
app:layout_constraintStart_toStartOf="@id/locationLiveStartedMap" /> app:layout_constraintStart_toStartOf="@id/locationLiveStartMap" />
<ImageView <ImageView
android:id="@+id/locationLiveStartedIcon" android:id="@+id/locationLiveStartIcon"
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_marginHorizontal="8dp" android:layout_marginHorizontal="8dp"
android:background="@drawable/circle" android:background="@drawable/circle"
android:backgroundTint="?vctr_content_quaternary" android:backgroundTint="?vctr_content_quaternary"
android:padding="3dp" android:padding="3dp"
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartedBannerBackground" app:layout_constraintBottom_toBottomOf="@id/locationLiveStartBannerBackground"
app:layout_constraintStart_toStartOf="@id/locationLiveStartedBannerBackground" app:layout_constraintStart_toStartOf="@id/locationLiveStartBannerBackground"
app:layout_constraintTop_toTopOf="@id/locationLiveStartedBannerBackground" app:layout_constraintTop_toTopOf="@id/locationLiveStartBannerBackground"
app:srcCompat="@drawable/ic_attachment_location_live_white" app:srcCompat="@drawable/ic_attachment_location_live_white"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView <TextView
android:id="@+id/locationLiveStartedTitle" android:id="@+id/locationLiveStartTitle"
style="@style/Widget.Vector.TextView.Caption" style="@style/Widget.Vector.TextView.Caption"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp" android:layout_marginHorizontal="8dp"
android:text="@string/location_share_live_started" android:text="@string/location_share_live_started"
android:textColor="?vctr_content_tertiary" android:textColor="?vctr_content_tertiary"
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartedBannerBackground" app:layout_constraintBottom_toBottomOf="@id/locationLiveStartBannerBackground"
app:layout_constraintStart_toEndOf="@id/locationLiveStartedIcon" app:layout_constraintStart_toEndOf="@id/locationLiveStartIcon"
app:layout_constraintTop_toTopOf="@id/locationLiveStartedBannerBackground" /> app:layout_constraintTop_toTopOf="@id/locationLiveStartBannerBackground" />
<ProgressBar <ProgressBar
android:id="@+id/locationLiveStartedLoader" android:id="@+id/locationLiveStartLoader"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminateTint="?vctr_content_quaternary" android:indeterminateTint="?vctr_content_quaternary"
app:layout_constraintBottom_toTopOf="@id/locationLiveStartedBannerBackground" app:layout_constraintBottom_toTopOf="@id/locationLiveStartBannerBackground"
app:layout_constraintEnd_toEndOf="@id/locationLiveStartedMap" app:layout_constraintEnd_toEndOf="@id/locationLiveStartMap"
app:layout_constraintStart_toStartOf="@id/locationLiveStartedMap" app:layout_constraintStart_toStartOf="@id/locationLiveStartMap"
app:layout_constraintTop_toTopOf="@id/locationLiveStartedMap" /> app:layout_constraintTop_toTopOf="@id/locationLiveStartMap" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -59,6 +59,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout="@layout/item_timeline_event_location_stub" /> android:layout="@layout/item_timeline_event_location_stub" />
<ViewStub
android:id="@+id/messageContentLiveLocationStartStub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout="@layout/item_timeline_event_live_location_start_stub" />
</FrameLayout> </FrameLayout>