mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 02:15:35 +03:00
Align corner radius of banner on map view
This commit is contained in:
parent
26f89fa5f8
commit
e2d56e2d87
2 changed files with 41 additions and 15 deletions
|
@ -16,16 +16,19 @@
|
|||
|
||||
package im.vector.app.features.home.room.detail.timeline.item
|
||||
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
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.GranularRoundedCorners
|
||||
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
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
|
||||
@EpoxyModelClass(layout = R.layout.item_timeline_event_base)
|
||||
abstract class MessageLiveLocationStartItem : AbsMessageItem<MessageLiveLocationStartItem.Holder>() {
|
||||
|
@ -39,13 +42,16 @@ abstract class MessageLiveLocationStartItem : AbsMessageItem<MessageLiveLocation
|
|||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
renderSendState(holder.view, null)
|
||||
bindMap(holder)
|
||||
bindBottomBanner(holder)
|
||||
}
|
||||
|
||||
private fun bindMap(holder: Holder) {
|
||||
val messageLayout = attributes.informationData.messageLayout
|
||||
val dimensionConverter = DimensionConverter(holder.view.resources)
|
||||
val imageCornerTransformation = if (messageLayout is TimelineMessageLayout.Bubble) {
|
||||
val mapCornerTransformation = if (messageLayout is TimelineMessageLayout.Bubble) {
|
||||
messageLayout.cornersRadius.granularRoundedCorners()
|
||||
} else {
|
||||
RoundedCorners(dimensionConverter.dpToPx(8))
|
||||
RoundedCorners(getDefaultLayoutCornerRadiusInDp(holder))
|
||||
}
|
||||
holder.noLocationMapImageView.updateLayoutParams {
|
||||
width = mapWidth
|
||||
|
@ -53,13 +59,33 @@ abstract class MessageLiveLocationStartItem : AbsMessageItem<MessageLiveLocation
|
|||
}
|
||||
GlideApp.with(holder.noLocationMapImageView)
|
||||
.load(R.drawable.bg_no_location_map)
|
||||
.transform(imageCornerTransformation)
|
||||
.transform(mapCornerTransformation)
|
||||
.into(holder.noLocationMapImageView)
|
||||
}
|
||||
|
||||
private fun bindBottomBanner(holder: Holder) {
|
||||
val messageLayout = attributes.informationData.messageLayout
|
||||
val imageCornerTransformation = if (messageLayout is TimelineMessageLayout.Bubble) {
|
||||
GranularRoundedCorners(0f, 0f, messageLayout.cornersRadius.bottomEndRadius, messageLayout.cornersRadius.bottomStartRadius)
|
||||
} else {
|
||||
val bottomCornerRadius = getDefaultLayoutCornerRadiusInDp(holder).toFloat()
|
||||
GranularRoundedCorners(0f, 0f, bottomCornerRadius, bottomCornerRadius)
|
||||
}
|
||||
GlideApp.with(holder.bannerImageView)
|
||||
.load(ColorDrawable(ThemeUtils.getColor(holder.bannerImageView.context, R.attr.colorSurface)))
|
||||
.transform(imageCornerTransformation)
|
||||
.into(holder.bannerImageView)
|
||||
}
|
||||
|
||||
private fun getDefaultLayoutCornerRadiusInDp(holder: Holder): Int {
|
||||
val dimensionConverter = DimensionConverter(holder.view.resources)
|
||||
return dimensionConverter.dpToPx(8)
|
||||
}
|
||||
|
||||
override fun getViewStubId() = STUB_ID
|
||||
|
||||
class Holder : AbsMessageItem.Holder(STUB_ID) {
|
||||
val bannerImageView by bind<ImageView>(R.id.locationLiveStartBanner)
|
||||
val noLocationMapImageView by bind<ImageView>(R.id.locationLiveStartMap)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,20 +11,20 @@
|
|||
android:layout_width="300dp"
|
||||
android:layout_height="200dp"
|
||||
android:contentDescription="@string/a11y_static_map_image"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/bg_no_location_map"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/locationLiveStartBannerBackground"
|
||||
<ImageView
|
||||
android:id="@+id/locationLiveStartBanner"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:alpha="0.85"
|
||||
android:background="?colorSurface"
|
||||
android:src="?colorSurface"
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartMap"
|
||||
app:layout_constraintEnd_toEndOf="@id/locationLiveStartMap"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartMap" />
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartMap"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/locationLiveStartIcon"
|
||||
|
@ -34,9 +34,9 @@
|
|||
android:background="@drawable/circle"
|
||||
android:backgroundTint="?vctr_content_quaternary"
|
||||
android:padding="3dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartBannerBackground"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartBannerBackground"
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartBannerBackground"
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartBanner"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartBanner"
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartBanner"
|
||||
app:srcCompat="@drawable/ic_attachment_location_live_white"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
|
@ -48,16 +48,16 @@
|
|||
android:layout_marginHorizontal="8dp"
|
||||
android:text="@string/location_share_live_started"
|
||||
android:textColor="?vctr_content_tertiary"
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartBannerBackground"
|
||||
app:layout_constraintBottom_toBottomOf="@id/locationLiveStartBanner"
|
||||
app:layout_constraintStart_toEndOf="@id/locationLiveStartIcon"
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartBannerBackground" />
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartBanner" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/locationLiveStartLoader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminateTint="?vctr_content_quaternary"
|
||||
app:layout_constraintBottom_toTopOf="@id/locationLiveStartBannerBackground"
|
||||
app:layout_constraintBottom_toTopOf="@id/locationLiveStartBanner"
|
||||
app:layout_constraintEnd_toEndOf="@id/locationLiveStartMap"
|
||||
app:layout_constraintStart_toStartOf="@id/locationLiveStartMap"
|
||||
app:layout_constraintTop_toTopOf="@id/locationLiveStartMap" />
|
||||
|
|
Loading…
Reference in a new issue