fix: remove transfer controls from KThumbnailView.kt to prevent view stub being inflated

This commit is contained in:
jubb 2021-06-29 13:35:46 +10:00
parent c68781fffb
commit 60f9f0edfb
3 changed files with 6 additions and 22 deletions

View file

@ -150,7 +150,7 @@ public class AlbumThumbnailView extends FrameLayout {
private void setSlide(@NonNull GlideRequests glideRequests, @NonNull Slide slide, @IdRes int id) {
KThumbnailView cell = findViewById(id);
cell.setImageResource(glideRequests, slide, false, false);
cell.setImageResource(glideRequests, slide, false);
cell.setThumbnailClickListener(defaultThumbnailClickListener);
cell.setOnLongClickListener(defaultLongClickListener);
}

View file

@ -1,7 +1,6 @@
package org.thoughtcrime.securesms.conversation.v2
import android.content.Context
import android.content.Intent
import android.graphics.Canvas
import android.graphics.Rect
import android.util.AttributeSet
@ -11,7 +10,6 @@ import android.widget.FrameLayout
import android.widget.TextView
import androidx.core.view.children
import androidx.core.view.isVisible
import kotlinx.android.synthetic.main.album_thumbnail_many.view.*
import kotlinx.android.synthetic.main.album_thumbnail_view.view.*
import network.loki.messenger.R
import org.thoughtcrime.securesms.MediaPreviewActivity
@ -110,7 +108,7 @@ class AlbumThumbnailView : FrameLayout {
// iterate binding
slides.take(5).forEachIndexed { position, slide ->
val thumbnailView = getThumbnailView(position)
thumbnailView.setImageResource(glideRequests, slide, showControls = false, isPreview = false)
thumbnailView.setImageResource(glideRequests, slide, isPreview = false)
}
albumCellBodyParent.isVisible = message.body.isNotEmpty()
albumCellBodyText.text = message.body

View file

@ -7,7 +7,6 @@ import android.net.Uri
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import android.widget.ProgressBar
import androidx.core.view.isVisible
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
@ -18,12 +17,10 @@ import kotlinx.android.synthetic.main.thumbnail_view.view.*
import network.loki.messenger.R
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentTransferProgress
import org.session.libsession.utilities.Util.equals
import org.session.libsession.utilities.ViewUtil
import org.session.libsignal.utilities.ListenableFuture
import org.session.libsignal.utilities.SettableFuture
import org.thoughtcrime.securesms.components.GlideBitmapListeningTarget
import org.thoughtcrime.securesms.components.GlideDrawableListeningTarget
import org.thoughtcrime.securesms.components.TransferControlView
import org.thoughtcrime.securesms.mms.*
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri
@ -43,7 +40,6 @@ open class KThumbnailView: FrameLayout {
private val playOverlay by lazy { play_overlay }
private val captionIcon by lazy { thumbnail_caption_icon }
val loadIndicator: View by lazy { thumbnail_load_indicator }
private val transferControls by lazy { ViewUtil.inflateStub<TransferControlView>(this, R.id.transfer_controls_stub) }
private val dimensDelegate = ThumbnailDimensDelegate()
@ -88,23 +84,16 @@ open class KThumbnailView: FrameLayout {
// endregion
// region Interaction
fun setImageResource(glide: GlideRequests, slide: Slide, showControls: Boolean, isPreview: Boolean): ListenableFuture<Boolean> {
return setImageResource(glide, slide, showControls, isPreview, 0, 0)
fun setImageResource(glide: GlideRequests, slide: Slide, isPreview: Boolean): ListenableFuture<Boolean> {
return setImageResource(glide, slide, isPreview, 0, 0)
}
fun setImageResource(glide: GlideRequests, slide: Slide,
showControls: Boolean, isPreview: Boolean,
naturalWidth: Int, naturalHeight: Int): ListenableFuture<Boolean> {
isPreview: Boolean, naturalWidth: Int,
naturalHeight: Int): ListenableFuture<Boolean> {
val currentSlide = this.slide
if (showControls) {
transferControls.setSlide(slide)
// transferControls.setDownloadClickListener() TODO: re-add this
} else {
transferControls.isVisible = false
}
playOverlay.isVisible = (slide.thumbnailUri != null && slide.hasPlayOverlay() &&
(slide.transferState == AttachmentTransferProgress.TRANSFER_PROGRESS_DONE || isPreview))
@ -182,15 +171,12 @@ open class KThumbnailView: FrameLayout {
open fun clear(glideRequests: GlideRequests) {
glideRequests.clear(image)
transferControls.clear()
slide = null
}
fun setImageResource(glideRequests: GlideRequests, uri: Uri): ListenableFuture<Boolean> {
val future = SettableFuture<Boolean>()
transferControls.isVisible = false
var request: GlideRequest<Drawable> = glideRequests.load(DecryptableUri(uri))
.diskCacheStrategy(DiskCacheStrategy.NONE)
.transition(DrawableTransitionOptions.withCrossFade())