mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Adding new message item
This commit is contained in:
parent
a1fb85dcdb
commit
e93e51d03c
@ -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
|
||||
}
|
||||
}
|
BIN
vector/src/main/res/drawable-hdpi/bg_no_location_map.webp
Normal file
BIN
vector/src/main/res/drawable-hdpi/bg_no_location_map.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 952 B |
BIN
vector/src/main/res/drawable-mdpi/bg_no_location_map.webp
Normal file
BIN
vector/src/main/res/drawable-mdpi/bg_no_location_map.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 638 B |
BIN
vector/src/main/res/drawable-xhdpi/bg_no_location_map.webp
Normal file
BIN
vector/src/main/res/drawable-xhdpi/bg_no_location_map.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
vector/src/main/res/drawable-xxhdpi/bg_no_location_map.webp
Normal file
BIN
vector/src/main/res/drawable-xxhdpi/bg_no_location_map.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
vector/src/main/res/drawable-xxxhdpi/bg_no_location_map.webp
Normal file
BIN
vector/src/main/res/drawable-xxxhdpi/bg_no_location_map.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
@ -6,61 +6,60 @@
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!-- Size will be overrode -->
|
||||
<!-- TODO use the correct image -->
|
||||
<ImageView
|
||||
android:id="@+id/locationLiveStartedMap"
|
||||
android:id="@+id/locationLiveStartMap"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="200dp"
|
||||
android:contentDescription="@string/a11y_static_map_image"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@tools:sample/backgrounds/scenic"
|
||||
android:src="@drawable/bg_no_location_map"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/locationLiveStartedBannerBackground"
|
||||
android:id="@+id/locationLiveStartBannerBackground"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:alpha="0.85"
|
||||
android:background="?colorSurface"
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartedMap"
|
||||
app:layout_constraintEnd_toEndOf="@id/locationLiveStartedMap"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartedMap" />
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartMap"
|
||||
app:layout_constraintEnd_toEndOf="@id/locationLiveStartMap"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartMap" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/locationLiveStartedIcon"
|
||||
android:id="@+id/locationLiveStartIcon"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginHorizontal="8dp"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="?vctr_content_quaternary"
|
||||
android:padding="3dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartedBannerBackground"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartedBannerBackground"
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartedBannerBackground"
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartBannerBackground"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartBannerBackground"
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartBannerBackground"
|
||||
app:srcCompat="@drawable/ic_attachment_location_live_white"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/locationLiveStartedTitle"
|
||||
android:id="@+id/locationLiveStartTitle"
|
||||
style="@style/Widget.Vector.TextView.Caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="8dp"
|
||||
android:text="@string/location_share_live_started"
|
||||
android:textColor="?vctr_content_tertiary"
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartedBannerBackground"
|
||||
app:layout_constraintStart_toEndOf="@id/locationLiveStartedIcon"
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartedBannerBackground" />
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartBannerBackground"
|
||||
app:layout_constraintStart_toEndOf="@id/locationLiveStartIcon"
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartBannerBackground" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/locationLiveStartedLoader"
|
||||
android:id="@+id/locationLiveStartLoader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminateTint="?vctr_content_quaternary"
|
||||
app:layout_constraintBottom_toTopOf="@id/locationLiveStartedBannerBackground"
|
||||
app:layout_constraintEnd_toEndOf="@id/locationLiveStartedMap"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartedMap"
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartedMap" />
|
||||
app:layout_constraintBottom_toTopOf="@id/locationLiveStartBannerBackground"
|
||||
app:layout_constraintEnd_toEndOf="@id/locationLiveStartMap"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartMap"
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartMap" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -59,6 +59,11 @@
|
||||
android:layout_height="wrap_content"
|
||||
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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user