mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-27 13:13:43 +00:00
Don't mark outgoing media as upload only.
This commit is contained in:
@@ -20,6 +20,7 @@ import org.greenrobot.eventbus.ThreadMode
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.attachments.Attachment
|
||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
|
||||
import org.thoughtcrime.securesms.components.RecyclerViewParentTransitionController
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.databinding.TransferControlsViewBinding
|
||||
@@ -108,7 +109,7 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
if (currentState.slides.size == 1) {
|
||||
val slide = currentState.slides.first()
|
||||
if (slide.hasVideo()) {
|
||||
if (currentState.isOutgoing) {
|
||||
if (currentState.isUpload) {
|
||||
return when (slide.transferState) {
|
||||
AttachmentTable.TRANSFER_PROGRESS_STARTED -> {
|
||||
Mode.UPLOADING_SINGLE_ITEM
|
||||
@@ -146,7 +147,7 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return if (currentState.isOutgoing) {
|
||||
return if (currentState.isUpload) {
|
||||
when (slide.transferState) {
|
||||
AttachmentTable.TRANSFER_PROGRESS_FAILED -> {
|
||||
Mode.RETRY_UPLOADING
|
||||
@@ -179,7 +180,7 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
} else {
|
||||
when (getTransferState(currentState.slides)) {
|
||||
AttachmentTable.TRANSFER_PROGRESS_STARTED -> {
|
||||
return if (currentState.isOutgoing) {
|
||||
return if (currentState.isUpload) {
|
||||
Mode.UPLOADING_GALLERY
|
||||
} else {
|
||||
Mode.DOWNLOADING_GALLERY
|
||||
@@ -195,7 +196,7 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
}
|
||||
|
||||
AttachmentTable.TRANSFER_PROGRESS_FAILED -> {
|
||||
return if (currentState.isOutgoing) {
|
||||
return if (currentState.isUpload) {
|
||||
Mode.RETRY_UPLOADING
|
||||
} else {
|
||||
Mode.RETRY_DOWNLOADING
|
||||
@@ -557,14 +558,14 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
}
|
||||
}
|
||||
val playableWhileDownloading = allStreamableOrDone
|
||||
val isOutgoing = slides.any { it.asAttachment().uploadTimestamp == 0L }
|
||||
val isUpload = slides.any { it.asAttachment().uploadTimestamp == 0L } && slides.all { (it.asAttachment() as? DatabaseAttachment)?.hasData == true }
|
||||
|
||||
val result = state.copy(
|
||||
slides = slides,
|
||||
networkProgress = networkProgress,
|
||||
compressionProgress = compressionProgress,
|
||||
playableWhileDownloading = playableWhileDownloading,
|
||||
isOutgoing = isOutgoing
|
||||
isUpload = isUpload
|
||||
)
|
||||
verboseLog("New state calculated and being returned for new slides: ${slidesAsListOfTimestamps(slides)}\n$result")
|
||||
return@updateState result
|
||||
|
||||
@@ -21,5 +21,5 @@ data class TransferControlViewState(
|
||||
val networkProgress: Map<Attachment, TransferControlView.Progress> = HashMap(),
|
||||
val compressionProgress: Map<Attachment, TransferControlView.Progress> = HashMap(),
|
||||
val playableWhileDownloading: Boolean = false,
|
||||
val isOutgoing: Boolean = false
|
||||
val isUpload: Boolean = false
|
||||
)
|
||||
|
||||
@@ -73,6 +73,7 @@ import org.signal.core.util.logging.Log;
|
||||
import org.signal.ringrtc.CallLinkRootKey;
|
||||
import org.thoughtcrime.securesms.BindableConversationItem;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId;
|
||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||
import org.thoughtcrime.securesms.badges.BadgeImageView;
|
||||
@@ -108,8 +109,8 @@ import org.thoughtcrime.securesms.database.AttachmentTable;
|
||||
import org.thoughtcrime.securesms.database.MediaTable;
|
||||
import org.thoughtcrime.securesms.database.MessageTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.Quote;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
||||
@@ -128,6 +129,7 @@ import org.thoughtcrime.securesms.mms.ImageSlide;
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
import org.thoughtcrime.securesms.mms.Slide;
|
||||
import org.thoughtcrime.securesms.mms.SlideClickListener;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.mms.SlidesClickedListener;
|
||||
import org.thoughtcrime.securesms.mms.TextSlide;
|
||||
import org.thoughtcrime.securesms.mms.VideoSlide;
|
||||
@@ -1307,7 +1309,8 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
if (joinCallLinkStub.resolved()) joinCallLinkStub.get().setVisibility(View.GONE);
|
||||
paymentViewStub.setVisibility(View.GONE);
|
||||
|
||||
List<Slide> thumbnailSlides = ((MmsMessageRecord) messageRecord).getSlideDeck().getThumbnailSlides();
|
||||
final SlideDeck slideDeck = ((MmsMessageRecord) messageRecord).getSlideDeck();
|
||||
List<Slide> thumbnailSlides = slideDeck.getThumbnailSlides();
|
||||
mediaThumbnailStub.require().setMinimumThumbnailWidth(readDimen(isCaptionlessMms(messageRecord) ? R.dimen.media_bubble_min_width_solo
|
||||
: R.dimen.media_bubble_min_width_with_content));
|
||||
mediaThumbnailStub.require().setMaximumThumbnailHeight(readDimen(isContentCondensed() ? R.dimen.media_bubble_max_height_condensed
|
||||
@@ -1328,7 +1331,11 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
mediaThumbnailStub.require().setStartTransferClickListener(downloadClickListener);
|
||||
} else {
|
||||
mediaThumbnailStub.require().setConversationColor(Color.TRANSPARENT);
|
||||
mediaThumbnailStub.require().setStartTransferClickListener(new ResendClickListener(messageRecord));
|
||||
if (doAnySlidesLackData(slideDeck)) {
|
||||
mediaThumbnailStub.require().setStartTransferClickListener(downloadClickListener);
|
||||
} else {
|
||||
mediaThumbnailStub.require().setStartTransferClickListener(new ResendClickListener(messageRecord));
|
||||
}
|
||||
}
|
||||
|
||||
mediaThumbnailStub.require().setBorderless(false);
|
||||
@@ -2017,6 +2024,15 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
return context.getResources().getDimensionPixelOffset(dimenId);
|
||||
}
|
||||
|
||||
private boolean doAnySlidesLackData(SlideDeck deck) {
|
||||
for (Attachment attachment : deck.asAttachments()) {
|
||||
if (attachment instanceof DatabaseAttachment && !((DatabaseAttachment) attachment).hasData) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Event handlers
|
||||
|
||||
private Spannable getLongMessageSpan(@NonNull MessageRecord messageRecord) {
|
||||
|
||||
Reference in New Issue
Block a user