Make link preview view use thumbnail

This commit is contained in:
Niels Andriesse 2021-06-24 15:03:29 +10:00
parent 2082a58e5a
commit 32c2762d06
22 changed files with 75 additions and 45 deletions

View File

@ -26,7 +26,7 @@ import android.widget.TextView;
import com.codewaves.stickyheadergrid.StickyHeaderGridAdapter;
import org.thoughtcrime.securesms.components.ThumbnailView;
import org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView;
import org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord;
import org.thoughtcrime.securesms.database.loaders.BucketedThreadMediaLoader.BucketedThreadMedia;
import org.thoughtcrime.securesms.mms.GlideRequests;

View File

@ -11,6 +11,8 @@ import android.widget.FrameLayout;
import android.widget.TextView;
import network.loki.messenger.R;
import org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.mms.Slide;

View File

@ -12,6 +12,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.mms.Slide;
@ -27,7 +28,7 @@ import network.loki.messenger.R;
public class ConversationItemThumbnail extends FrameLayout {
private ThumbnailView thumbnail;
private ThumbnailView thumbnail;
private AlbumThumbnailView album;
private ImageView shade;
private ConversationItemFooter footer;

View File

@ -5,6 +5,7 @@ import android.graphics.Canvas;
import android.util.AttributeSet;
import org.session.libsession.utilities.ThemeUtil;
import org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView;
import network.loki.messenger.R;

View File

@ -7,6 +7,7 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.mms.Slide;

View File

@ -423,7 +423,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
// the view) so as to not interfere with all the other gestures. Do not add
// onClickListeners directly to message content views.
view.onContentClick()
DownloadDialog(thread).show(supportFragmentManager, "Blocked Dialog")
}
}

View File

@ -14,11 +14,13 @@ import android.view.View
import android.view.ViewOutlineProvider
import android.widget.LinearLayout
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.isVisible
import kotlinx.android.synthetic.main.view_link_preview.view.*
import network.loki.messenger.R
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
import org.thoughtcrime.securesms.loki.utilities.UiModeUtilities
import org.thoughtcrime.securesms.mms.GlideRequests
import org.thoughtcrime.securesms.mms.ImageSlide
class LinkPreviewView : LinearLayout {
@ -39,10 +41,9 @@ class LinkPreviewView : LinearLayout {
mainLinkPreviewContainer.clipToOutline = true
// Thumbnail
val linkPreview = message.linkPreviews.first()
// TODO: Handle downloading state
val uri = linkPreview.thumbnail.get().dataUri ?: return
glide.load(uri).into(thumbnailImageView)
// TODO: Properly use glide and the actual thumbnail
if (linkPreview.getThumbnail().isPresent) {
thumbnailImageView.setImageResource(glide, ImageSlide(context, linkPreview.getThumbnail().get()), false, false)
}
// Title
titleTextView.text = linkPreview.title
val textColorID = if (message.isOutgoing && UiModeUtilities.isDayUiMode(context)) {

View File

@ -1,4 +1,4 @@
package org.thoughtcrime.securesms.components;
package org.thoughtcrime.securesms.conversation.v2.utilities;
import android.content.Context;
import android.content.res.TypedArray;
@ -24,6 +24,9 @@ import com.bumptech.glide.request.RequestOptions;
import network.loki.messenger.R;
import org.thoughtcrime.securesms.components.GlideBitmapListeningTarget;
import org.thoughtcrime.securesms.components.GlideDrawableListeningTarget;
import org.thoughtcrime.securesms.components.TransferControlView;
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
import org.thoughtcrime.securesms.mms.GlideRequest;
import org.thoughtcrime.securesms.mms.GlideRequests;
@ -94,10 +97,9 @@ public class ThumbnailView extends FrameLayout {
bounds[MAX_WIDTH] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_maxWidth, 0);
bounds[MIN_HEIGHT] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_minHeight, 0);
bounds[MAX_HEIGHT] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_maxHeight, 0);
radius = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_thumbnail_radius, getResources().getDimensionPixelSize(R.dimen.thumbnail_default_radius));
typedArray.recycle();
} else {
radius = getResources().getDimensionPixelSize(R.dimen.message_corner_collapse_radius);
radius = 0;
}
}
@ -275,7 +277,7 @@ public class ThumbnailView extends FrameLayout {
this.slide = slide;
this.captionIcon.setVisibility(slide.getCaption().isPresent() ? VISIBLE : GONE);
this.captionIcon.setVisibility(GONE);
dimens[WIDTH] = naturalWidth;
dimens[HEIGHT] = naturalHeight;
@ -398,6 +400,7 @@ public class ThumbnailView extends FrameLayout {
}
private class ThumbnailClickDispatcher implements View.OnClickListener {
@Override
public void onClick(View view) {
if (thumbnailClickListener != null &&
@ -413,9 +416,9 @@ public class ThumbnailView extends FrameLayout {
}
private class DownloadClickDispatcher implements View.OnClickListener {
@Override
public void onClick(View view) {
Log.i(TAG, "onClick() for download button");
if (downloadClickListener != null && slide != null) {
downloadClickListener.onClick(view, Collections.singletonList(slide));
} else {

View File

@ -10,7 +10,7 @@ import android.view.ViewGroup;
import network.loki.messenger.R;
import org.thoughtcrime.securesms.components.ThumbnailView;
import org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView;
import org.thoughtcrime.securesms.mediasend.Media;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.util.StableIdGenerator;

View File

@ -41,7 +41,7 @@ import org.thoughtcrime.securesms.MediaPreviewActivity;
import org.thoughtcrime.securesms.loki.views.MessageAudioView;
import org.thoughtcrime.securesms.components.DocumentView;
import org.thoughtcrime.securesms.components.RemovableEditableMediaView;
import org.thoughtcrime.securesms.components.ThumbnailView;
import org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView;
import org.session.libsignal.utilities.NoExternalStorageException;
import org.thoughtcrime.securesms.giph.ui.GiphyActivity;
import org.session.libsignal.utilities.Log;

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:pathData="M326.612,185.391c59.747,59.809 58.927,155.698 0.36,214.59 -0.11,0.12 -0.24,0.25 -0.36,0.37l-67.2,67.2c-59.27,59.27 -155.699,59.262 -214.96,0 -59.27,-59.26 -59.27,-155.7 0,-214.96l37.106,-37.106c9.84,-9.84 26.786,-3.3 27.294,10.606 0.648,17.722 3.826,35.527 9.69,52.721 1.986,5.822 0.567,12.262 -3.783,16.612l-13.087,13.087c-28.026,28.026 -28.905,73.66 -1.155,101.96 28.024,28.579 74.086,28.749 102.325,0.51l67.2,-67.19c28.191,-28.191 28.073,-73.757 0,-101.83 -3.701,-3.694 -7.429,-6.564 -10.341,-8.569a16.037,16.037 0,0 1,-6.947 -12.606c-0.396,-10.567 3.348,-21.456 11.698,-29.806l21.054,-21.055c5.521,-5.521 14.182,-6.199 20.584,-1.731a152.482,152.482 0,0 1,20.522 17.197zM467.547,44.449c-59.261,-59.262 -155.69,-59.27 -214.96,0l-67.2,67.2c-0.12,0.12 -0.25,0.25 -0.36,0.37 -58.566,58.892 -59.387,154.781 0.36,214.59a152.454,152.454 0,0 0,20.521 17.196c6.402,4.468 15.064,3.789 20.584,-1.731l21.054,-21.055c8.35,-8.35 12.094,-19.239 11.698,-29.806a16.037,16.037 0,0 0,-6.947 -12.606c-2.912,-2.005 -6.64,-4.875 -10.341,-8.569 -28.073,-28.073 -28.191,-73.639 0,-101.83l67.2,-67.19c28.239,-28.239 74.3,-28.069 102.325,0.51 27.75,28.3 26.872,73.934 -1.155,101.96l-13.087,13.087c-4.35,4.35 -5.769,10.79 -3.783,16.612 5.864,17.194 9.042,34.999 9.69,52.721 0.509,13.906 17.454,20.446 27.294,10.606l37.106,-37.106c59.271,-59.259 59.271,-155.699 0.001,-214.959z"
android:fillColor="@color/text"/>
</vector>

View File

@ -7,13 +7,13 @@
android:layout_width="@dimen/album_total_width"
android:layout_height="@dimen/album_2_total_height">
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_1"
android:layout_width="@dimen/album_2_cell_width"
android:layout_height="@dimen/album_2_total_height"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_2"
android:layout_width="@dimen/album_2_cell_width"
android:layout_height="@dimen/album_2_total_height"

View File

@ -6,20 +6,20 @@
android:layout_width="@dimen/album_total_width"
android:layout_height="@dimen/album_3_total_height">
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_1"
android:layout_width="@dimen/album_3_cell_width_big"
android:layout_height="@dimen/album_3_total_height"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_2"
android:layout_width="@dimen/album_3_cell_size_small"
android:layout_height="@dimen/album_3_cell_size_small"
android:layout_gravity="right|end|top"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_3"
android:layout_width="@dimen/album_3_cell_size_small"
android:layout_height="@dimen/album_3_cell_size_small"

View File

@ -6,27 +6,27 @@
android:layout_width="@dimen/album_total_width"
android:layout_height="@dimen/album_4_total_height">
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_1"
android:layout_width="@dimen/album_4_cell_size"
android:layout_height="@dimen/album_4_cell_size"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_2"
android:layout_width="@dimen/album_4_cell_size"
android:layout_height="@dimen/album_4_cell_size"
android:layout_gravity="right|end|top"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_3"
android:layout_width="@dimen/album_4_cell_size"
android:layout_height="@dimen/album_4_cell_size"
android:layout_gravity="left|start|bottom"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_4"
android:layout_width="@dimen/album_4_cell_size"
android:layout_height="@dimen/album_4_cell_size"

View File

@ -6,34 +6,34 @@
android:layout_width="@dimen/album_total_width"
android:layout_height="@dimen/album_5_total_height">
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_1"
android:layout_width="@dimen/album_5_cell_size_big"
android:layout_height="@dimen/album_5_cell_size_big"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_2"
android:layout_width="@dimen/album_5_cell_size_big"
android:layout_height="@dimen/album_5_cell_size_big"
android:layout_gravity="right|end|top"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_3"
android:layout_width="@dimen/album_5_cell_size_small"
android:layout_height="@dimen/album_5_cell_size_small"
android:layout_gravity="left|start|bottom"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_4"
android:layout_width="@dimen/album_5_cell_size_small"
android:layout_height="@dimen/album_5_cell_size_small"
android:layout_gravity="center_horizontal|bottom"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_5"
android:layout_width="@dimen/album_5_cell_size_small"
android:layout_height="@dimen/album_5_cell_size_small"

View File

@ -7,27 +7,27 @@
android:layout_width="@dimen/album_total_width"
android:layout_height="@dimen/album_5_total_height">
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_1"
android:layout_width="@dimen/album_5_cell_size_big"
android:layout_height="@dimen/album_5_cell_size_big"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_2"
android:layout_width="@dimen/album_5_cell_size_big"
android:layout_height="@dimen/album_5_cell_size_big"
android:layout_gravity="right|end|top"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_3"
android:layout_width="@dimen/album_5_cell_size_small"
android:layout_height="@dimen/album_5_cell_size_small"
android:layout_gravity="left|start|bottom"
app:thumbnail_radius="0dp"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_4"
android:layout_width="@dimen/album_5_cell_size_small"
android:layout_height="@dimen/album_5_cell_size_small"
@ -39,7 +39,7 @@
android:layout_height="@dimen/album_5_cell_size_small"
android:layout_gravity="right|end|bottom">
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/album_cell_5"
android:layout_height="match_parent"
android:layout_width="match_parent"

View File

@ -13,7 +13,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center">
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/attachment_thumbnail"
android:layout_width="230dp"
android:layout_height="150dp"

View File

@ -4,7 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/conversation_thumbnail_image"
android:layout_width="@dimen/media_bubble_default_dimens"
android:layout_height="@dimen/media_bubble_default_dimens"

View File

@ -5,7 +5,7 @@
android:layout_height="match_parent"
android:padding="2dp">
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -8,7 +8,7 @@
android:layout_margin="2dp"
android:animateLayoutChanges="true">
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/rail_item_image"
android:layout_width="56dp"
android:layout_height="56dp"

View File

@ -13,7 +13,7 @@
android:visibility="gone"
tools:visibility="visible"/>
<org.thoughtcrime.securesms.components.ThumbnailView
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/sticker_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/mainLinkPreviewContainer"
<LinearLayout android:id="@+id/mainLinkPreviewContainer"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
@ -13,11 +13,24 @@
android:orientation="horizontal"
android:gravity="center">
<ImageView
android:id="@+id/thumbnailImageView"
<RelativeLayout
android:layout_width="96dp"
android:layout_height="96dp"
android:scaleType="centerCrop" />
android:layout_height="96dp">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_link"
app:tint="@color/text" />
<org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView
android:id="@+id/thumbnailImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</RelativeLayout>
<TextView
android:id="@+id/titleTextView"