Fix bad image rendering

This commit is contained in:
Benoit Marty 2020-12-04 11:45:05 +01:00
parent 19315fc65e
commit 679d9bae1c
7 changed files with 19 additions and 11 deletions

View File

@ -29,6 +29,7 @@ import im.vector.app.R
import im.vector.app.core.extensions.setTextOrHide
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import im.vector.app.features.media.ImageContentRenderer
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.media.PreviewUrlData
/**
@ -112,11 +113,7 @@ class PreviewUrlView @JvmOverloads constructor(
private fun renderData(previewUrlData: PreviewUrlData, imageContentRenderer: ImageContentRenderer) {
isVisible = true
titleView.setTextOrHide(previewUrlData.title)
val mxcUrl = previewUrlData.mxcUrl
imageView.isVisible = mxcUrl != null
if (mxcUrl != null) {
imageContentRenderer.render(mxcUrl, imageView)
}
imageView.isVisible = previewUrlData.mxcUrl?.let { imageContentRenderer.render(it, imageView) }.orFalse()
descriptionView.setTextOrHide(previewUrlData.description)
siteView.setTextOrHide(previewUrlData.siteName.takeIf { it != previewUrlData.title })
}

View File

@ -86,14 +86,14 @@ class ImageContentRenderer @Inject constructor(private val activeSessionHolder:
/**
* For url preview
*/
fun render(mxcUrl: String, imageView: ImageView) {
fun render(mxcUrl: String, imageView: ImageView): Boolean {
val contentUrlResolver = activeSessionHolder.getActiveSession().contentUrlResolver()
val imageUrl = contentUrlResolver.resolveFullSize(mxcUrl) ?: return
val imageUrl = contentUrlResolver.resolveFullSize(mxcUrl) ?: return false
GlideApp.with(imageView)
.load(imageUrl)
.placeholder(R.drawable.ic_image)
.into(imageView)
return true
}
/**

View File

@ -11,7 +11,7 @@
android:id="@+id/url_preview_left_border"
android:layout_width="2dp"
android:layout_height="0dp"
android:background="#8D99A5"
android:background="?riotx_text_tertiary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -32,10 +32,11 @@
<ImageView
android:id="@+id/url_preview_image"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="157dp"
android:layout_marginTop="16dp"
android:importantForAccessibility="no"
android:scaleType="fitStart"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/url_preview_title"
app:layout_constraintTop_toBottomOf="@+id/url_preview_title"
@ -64,7 +65,7 @@
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:textColor="?riotx_text_secondary"
android:textColor="?riotx_text_tertiary"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="@+id/url_preview_left_border"
app:layout_constraintTop_toBottomOf="@+id/url_preview_description"

View File

@ -107,6 +107,13 @@
<color name="riotx_text_secondary_dark">#FFA1B2D1</color>
<color name="riotx_text_secondary_black">#FFA1B2D1</color>
<attr name="riotx_text_tertiary" format="color" />
<color name="riotx_text_tertiary_light">#FF8D99A5</color>
<!-- TODO Pick color from Figma, I do not know where to find it -->
<color name="riotx_text_tertiary_dark">#FF8D99A5</color>
<!-- TODO Pick color from Figma, I do not know where to find it -->
<color name="riotx_text_tertiary_black">#FF8D99A5</color>
<attr name="riotx_text_primary_body_contrast" format="color" />
<color name="riotx_text_primary_body_contrast_light">#FF61708B</color>
<color name="riotx_text_primary_body_contrast_dark">#FFA1B2D1</color>

View File

@ -18,6 +18,7 @@
<item name="riotx_header_panel_text_secondary">@color/riotx_header_panel_text_secondary_black</item>
<item name="riotx_text_primary">@color/riotx_text_primary_black</item>
<item name="riotx_text_secondary">@color/riotx_text_secondary_black</item>
<item name="riotx_text_tertiary">@color/riotx_text_tertiary_black</item>
<item name="riotx_text_primary_body_contrast">@color/riotx_text_primary_body_contrast_black</item>
<item name="riotx_android_secondary">@color/riotx_android_secondary_black</item>
<item name="riotx_search_placeholder">@color/riotx_search_placeholder_black</item>

View File

@ -16,6 +16,7 @@
<item name="riotx_header_panel_text_secondary">@color/riotx_header_panel_text_secondary_dark</item>
<item name="riotx_text_primary">@color/riotx_text_primary_dark</item>
<item name="riotx_text_secondary">@color/riotx_text_secondary_dark</item>
<item name="riotx_text_tertiary">@color/riotx_text_tertiary_dark</item>
<item name="riotx_text_primary_body_contrast">@color/riotx_text_primary_body_contrast_dark</item>
<item name="riotx_android_secondary">@color/riotx_android_secondary_dark</item>
<item name="riotx_search_placeholder">@color/riotx_search_placeholder_dark</item>

View File

@ -16,6 +16,7 @@
<item name="riotx_header_panel_text_secondary">@color/riotx_header_panel_text_secondary_light</item>
<item name="riotx_text_primary">@color/riotx_text_primary_light</item>
<item name="riotx_text_secondary">@color/riotx_text_secondary_light</item>
<item name="riotx_text_tertiary">@color/riotx_text_tertiary_light</item>
<item name="riotx_text_primary_body_contrast">@color/riotx_text_primary_body_contrast_light</item>
<item name="riotx_android_secondary">@color/riotx_android_secondary_light</item>
<item name="riotx_search_placeholder">@color/riotx_search_placeholder_light</item>