From 0150d830d4a28d90d708ef9a35103cbe92e8aada Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 2 Dec 2021 09:46:36 +0000 Subject: [PATCH] flattening preview url view layout with custom view to reduce view hierarchy --- .../ui-styles/src/main/res/values/dimens.xml | 3 + .../detail/timeline/url/PreviewUrlView.kt | 8 +- .../src/main/res/layout/view_url_preview.xml | 136 +++++++++--------- 3 files changed, 73 insertions(+), 74 deletions(-) diff --git a/library/ui-styles/src/main/res/values/dimens.xml b/library/ui-styles/src/main/res/values/dimens.xml index 519920786c..864f3d3d7f 100644 --- a/library/ui-styles/src/main/res/values/dimens.xml +++ b/library/ui-styles/src/main/res/values/dimens.xml @@ -39,4 +39,7 @@ 320dp + + + 8dp \ No newline at end of file diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt index 3e08ce5589..1a81362618 100755 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt @@ -19,13 +19,14 @@ package im.vector.app.features.home.room.detail.timeline.url import android.content.Context import android.util.AttributeSet import android.view.View -import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.isVisible +import com.google.android.material.card.MaterialCardView import im.vector.app.R import im.vector.app.core.extensions.setTextOrHide import im.vector.app.databinding.ViewUrlPreviewBinding import im.vector.app.features.home.room.detail.timeline.TimelineEventController import im.vector.app.features.media.ImageContentRenderer +import im.vector.app.features.themes.ThemeUtils import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.session.media.PreviewUrlData @@ -36,7 +37,7 @@ class PreviewUrlView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr), View.OnClickListener { +) : MaterialCardView(context, attrs, defStyleAttr), View.OnClickListener { private lateinit var views: ViewUrlPreviewBinding @@ -44,6 +45,9 @@ class PreviewUrlView @JvmOverloads constructor( init { setupView() + radius = resources.getDimensionPixelSize(R.dimen.preview_url_view_corner_radius).toFloat() + cardElevation = 0f + setCardBackgroundColor(ThemeUtils.getColor(context, R.attr.vctr_system)) } private var state: PreviewUrlUiState = PreviewUrlUiState.Unknown diff --git a/vector/src/main/res/layout/view_url_preview.xml b/vector/src/main/res/layout/view_url_preview.xml index 772bd7d48b..f40316b77b 100644 --- a/vector/src/main/res/layout/view_url_preview.xml +++ b/vector/src/main/res/layout/view_url_preview.xml @@ -1,85 +1,77 @@ + tools:parentTag="com.google.android.material.card.MaterialCardView"> - - - - - - - - - - - - - + android:layout_height="wrap_content" + android:orientation="vertical"> + android:id="@+id/url_preview_image" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:adjustViewBounds="true" + android:importantForAccessibility="no" + android:scaleType="fitXY" + tools:src="@tools:sample/backgrounds/scenic" /> - + + + + + + + + + \ No newline at end of file