mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 02:39:55 +01:00
Fix missing thumbnail background color.
This commit is contained in:
@@ -6,6 +6,7 @@ import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -53,15 +54,15 @@ public class BorderlessImageView extends FrameLayout {
|
||||
image.setOnLongClickListener(l);
|
||||
}
|
||||
|
||||
public void setSlide(@NonNull RequestManager requestManager, @NonNull Slide slide) {
|
||||
public void setSlide(@NonNull RequestManager requestManager, @NonNull Slide slide, @ColorInt int missingBackgroundColor) {
|
||||
boolean showControls = slide.asAttachment().getUri() == null;
|
||||
|
||||
if (slide.hasSticker()) {
|
||||
image.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
image.setImageResource(requestManager, slide, showControls, false);
|
||||
image.setImageResource(requestManager, slide, showControls, false, 0, 0, missingBackgroundColor);
|
||||
} else {
|
||||
image.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
image.setImageResource(requestManager, slide, showControls, false, slide.asAttachment().width, slide.asAttachment().height);
|
||||
image.setImageResource(requestManager, slide, showControls, false, slide.asAttachment().width, slide.asAttachment().height, missingBackgroundColor);
|
||||
}
|
||||
|
||||
missingShade.setVisibility(showControls ? View.VISIBLE : View.GONE);
|
||||
|
||||
@@ -195,7 +195,8 @@ class ConversationItemThumbnail @JvmOverloads constructor(
|
||||
requestManager: RequestManager,
|
||||
slides: List<Slide>,
|
||||
showControls: Boolean,
|
||||
isPreview: Boolean
|
||||
isPreview: Boolean,
|
||||
@ColorInt missingThumbnailBackgroundColor: Int
|
||||
) {
|
||||
if (slides.size == 1) {
|
||||
val slide = slides[0]
|
||||
@@ -223,7 +224,7 @@ class ConversationItemThumbnail @JvmOverloads constructor(
|
||||
|
||||
val attachment = slides[0].asAttachment()
|
||||
|
||||
thumbnail.get().setImageResource(requestManager, slides[0], showControls, isPreview, attachment.width, attachment.height)
|
||||
thumbnail.get().setImageResource(requestManager, slides[0], showControls, isPreview, attachment.width, attachment.height, missingThumbnailBackgroundColor)
|
||||
touchDelegate = thumbnail.get().touchDelegate
|
||||
} else {
|
||||
state = state.copy(
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -20,6 +21,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.Px;
|
||||
@@ -328,13 +330,13 @@ public class ThumbnailView extends FrameLayout {
|
||||
public ListenableFuture<Boolean> setImageResource(@NonNull RequestManager requestManager, @NonNull Slide slide,
|
||||
boolean showControls, boolean isPreview)
|
||||
{
|
||||
return setImageResource(requestManager, slide, showControls, isPreview, 0, 0);
|
||||
return setImageResource(requestManager, slide, showControls, isPreview, 0, 0, Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
@UiThread
|
||||
public ListenableFuture<Boolean> setImageResource(@NonNull RequestManager requestManager, @NonNull Slide slide,
|
||||
boolean showControls, boolean isPreview,
|
||||
int naturalWidth, int naturalHeight)
|
||||
int naturalWidth, int naturalHeight, @ColorInt int missingBackgroundColor)
|
||||
{
|
||||
if (slide.asAttachment().isPermanentlyFailed()) {
|
||||
this.slide = slide;
|
||||
@@ -347,6 +349,7 @@ public class ThumbnailView extends FrameLayout {
|
||||
|
||||
requestManager.clear(image);
|
||||
image.setImageDrawable(null);
|
||||
image.setBackgroundColor(Color.TRANSPARENT);
|
||||
|
||||
int errorImageResource;
|
||||
if (slide instanceof ImageSlide) {
|
||||
@@ -359,6 +362,8 @@ public class ThumbnailView extends FrameLayout {
|
||||
errorImage.setImageResource(errorImageResource);
|
||||
errorImage.setVisibility(View.VISIBLE);
|
||||
|
||||
image.setBackgroundColor(missingBackgroundColor);
|
||||
|
||||
return new SettableFuture<>(true);
|
||||
} else {
|
||||
errorImage.setVisibility(View.GONE);
|
||||
|
||||
Reference in New Issue
Block a user