Instant Video design improvements.
This commit is contained in:
parent
a763e1729c
commit
ab66567db6
8 changed files with 103 additions and 34 deletions
|
@ -78,6 +78,12 @@ public class AlbumThumbnailView extends FrameLayout {
|
|||
downloadClickListener.onClick(v, slides);
|
||||
}
|
||||
});
|
||||
transferControlsStub.get().setCancelClickListener(
|
||||
v -> {
|
||||
if (cancelDownloadClickListener != null) {
|
||||
cancelDownloadClickListener.onClick(v, slides);
|
||||
}
|
||||
});
|
||||
transferControlsStub.get().setSlides(slides);
|
||||
} else {
|
||||
if (transferControlsStub.resolved()) {
|
||||
|
|
|
@ -26,8 +26,10 @@ import org.thoughtcrime.securesms.events.PartProgressEvent
|
|||
import org.thoughtcrime.securesms.mms.Slide
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.ViewUtil
|
||||
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture
|
||||
import org.thoughtcrime.securesms.util.visible
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.ExecutionException
|
||||
|
||||
class TransferControlView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
private val uuid = UUID.randomUUID().toString()
|
||||
|
@ -65,6 +67,11 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
private fun applyState(currentState: TransferControlViewState) {
|
||||
val mode = deriveMode(currentState)
|
||||
verboseLog("New state applying, mode = $mode")
|
||||
|
||||
children.forEach {
|
||||
it.clearAnimation()
|
||||
}
|
||||
|
||||
when (mode) {
|
||||
Mode.PENDING_GALLERY -> displayPendingGallery(currentState)
|
||||
Mode.PENDING_GALLERY_CONTAINS_PLAYABLE -> displayPendingGalleryWithPlayable(currentState)
|
||||
|
@ -223,9 +230,9 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
binding.primaryBackground.setOnClickListener(currentState.downloadClickedListener)
|
||||
|
||||
binding.primaryDetailsText.translationX = if (ViewUtil.isLtr(this)) {
|
||||
ViewUtil.dpToPx(-8).toFloat()
|
||||
ViewUtil.dpToPx(-PRIMARY_TEXT_OFFSET_DP).toFloat()
|
||||
} else {
|
||||
ViewUtil.dpToPx(8).toFloat()
|
||||
ViewUtil.dpToPx(PRIMARY_TEXT_OFFSET_DP).toFloat()
|
||||
}
|
||||
val remainingSlides = currentState.slides.filterNot { it.transferState == AttachmentTable.TRANSFER_PROGRESS_DONE }
|
||||
val downloadCount = remainingSlides.size
|
||||
|
@ -250,7 +257,11 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
)
|
||||
|
||||
binding.secondaryProgressView.setStopped(false)
|
||||
|
||||
binding.secondaryDetailsText.translationX = if (ViewUtil.isLtr(this)) {
|
||||
ViewUtil.dpToPx(-SECONDARY_TEXT_OFFSET_DP).toFloat()
|
||||
} else {
|
||||
ViewUtil.dpToPx(SECONDARY_TEXT_OFFSET_DP).toFloat()
|
||||
}
|
||||
val byteCount = currentState.slides.sumOf { it.asAttachment().size }
|
||||
binding.secondaryDetailsText.text = Formatter.formatShortFileSize(context, byteCount)
|
||||
}
|
||||
|
@ -266,6 +277,11 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
secondaryDetailsText = currentState.showSecondaryText
|
||||
)
|
||||
val byteCount = currentState.slides.sumOf { it.asAttachment().size }
|
||||
binding.secondaryDetailsText.translationX = if (ViewUtil.isLtr(this)) {
|
||||
ViewUtil.dpToPx(-SECONDARY_TEXT_OFFSET_DP).toFloat()
|
||||
} else {
|
||||
ViewUtil.dpToPx(SECONDARY_TEXT_OFFSET_DP).toFloat()
|
||||
}
|
||||
binding.secondaryDetailsText.text = Formatter.formatShortFileSize(context, byteCount)
|
||||
}
|
||||
|
||||
|
@ -280,6 +296,11 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
secondaryDetailsText = currentState.showSecondaryText,
|
||||
secondaryProgressView = currentState.showSecondaryText
|
||||
)
|
||||
binding.secondaryDetailsText.translationX = if (ViewUtil.isLtr(this)) {
|
||||
ViewUtil.dpToPx(-SECONDARY_TEXT_OFFSET_DP).toFloat()
|
||||
} else {
|
||||
ViewUtil.dpToPx(SECONDARY_TEXT_OFFSET_DP).toFloat()
|
||||
}
|
||||
val byteCount = currentState.slides.sumOf { it.asAttachment().size }
|
||||
binding.secondaryDetailsText.text = Formatter.formatShortFileSize(context, byteCount)
|
||||
}
|
||||
|
@ -300,7 +321,7 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
binding.secondaryProgressView.cancelClickListener = currentState.cancelDownloadClickedListener
|
||||
binding.secondaryProgressView.setDownloading(progress)
|
||||
}
|
||||
|
||||
binding.secondaryDetailsText.translationX = 0f
|
||||
binding.secondaryDetailsText.text = deriveSecondaryDetailsText(currentState)
|
||||
}
|
||||
|
||||
|
@ -320,7 +341,7 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
} else {
|
||||
binding.primaryProgressView.setDownloading(progress)
|
||||
}
|
||||
|
||||
binding.secondaryDetailsText.translationX = 0f
|
||||
binding.secondaryDetailsText.text = deriveSecondaryDetailsText(currentState)
|
||||
}
|
||||
|
||||
|
@ -341,6 +362,7 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
} else {
|
||||
binding.secondaryProgressView.setDownloading(progress)
|
||||
}
|
||||
binding.secondaryDetailsText.translationX = 0f
|
||||
binding.secondaryDetailsText.text = deriveSecondaryDetailsText(currentState)
|
||||
}
|
||||
|
||||
|
@ -357,6 +379,7 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
val progress = calculateProgress(currentState)
|
||||
binding.secondaryProgressView.setUploading(progress)
|
||||
|
||||
binding.secondaryDetailsText.translationX = 0f
|
||||
binding.secondaryDetailsText.text = deriveSecondaryDetailsText(currentState)
|
||||
}
|
||||
|
||||
|
@ -376,6 +399,7 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
val progress = calculateProgress(currentState)
|
||||
binding.secondaryProgressView.setUploading(progress)
|
||||
|
||||
binding.secondaryDetailsText.translationX = 0f
|
||||
binding.secondaryDetailsText.text = deriveSecondaryDetailsText(currentState)
|
||||
}
|
||||
|
||||
|
@ -396,7 +420,11 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
primaryDetailsText = false,
|
||||
secondaryDetailsText = currentState.showSecondaryText
|
||||
)
|
||||
|
||||
binding.secondaryDetailsText.translationX = if (ViewUtil.isLtr(this)) {
|
||||
ViewUtil.dpToPx(-RETRY_SECONDARY_TEXT_OFFSET_DP).toFloat()
|
||||
} else {
|
||||
ViewUtil.dpToPx(RETRY_SECONDARY_TEXT_OFFSET_DP).toFloat()
|
||||
}
|
||||
binding.secondaryBackground.setOnClickListener(currentState.downloadClickedListener)
|
||||
binding.secondaryDetailsText.setOnClickListener(currentState.downloadClickedListener)
|
||||
binding.secondaryProgressView.setStopped(isUploading)
|
||||
|
@ -405,7 +433,9 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
|
||||
private fun displayChildrenAsGone() {
|
||||
children.forEach {
|
||||
it.visible = false
|
||||
if (it.visible && it.animation == null) {
|
||||
ViewUtil.fadeOut(it, 250).addListener(AnimationCleanup(it))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -435,7 +465,11 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
binding.secondaryProgressView.visible = secondaryProgressView
|
||||
binding.secondaryDetailsText.visible = secondaryDetailsText
|
||||
binding.secondaryBackground.visible = secondaryProgressView || secondaryDetailsText
|
||||
val textPadding = if (secondaryProgressView) 0 else context.resources.getDimensionPixelSize(R.dimen.transfer_control_view_progressbar_to_textview_margin)
|
||||
val textPadding = if (secondaryProgressView) {
|
||||
context.resources.getDimensionPixelSize(R.dimen.transfer_control_view_progressbar_to_textview_margin)
|
||||
} else {
|
||||
context.resources.getDimensionPixelSize(R.dimen.transfer_control_view_parent_to_textview_margin)
|
||||
}
|
||||
ViewUtil.setPaddingStart(binding.secondaryDetailsText, textPadding)
|
||||
if (ViewUtil.isLtr(binding.secondaryDetailsText)) {
|
||||
(binding.secondaryDetailsText.layoutParams as MarginLayoutParams).leftMargin = textPadding
|
||||
|
@ -481,12 +515,20 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
|
||||
if (event.type == PartProgressEvent.Type.COMPRESSION) {
|
||||
val mutableMap = it.compressionProgress.toMutableMap()
|
||||
mutableMap[attachment] = Progress.fromEvent(event)
|
||||
val updateEvent = Progress.fromEvent(event)
|
||||
val existingEvent = mutableMap[attachment]
|
||||
if (existingEvent == null || updateEvent.completed > existingEvent.completed) {
|
||||
mutableMap[attachment] = updateEvent
|
||||
}
|
||||
verboseLog("onEventAsync compression update")
|
||||
return@updateState it.copy(compressionProgress = mutableMap.toMap())
|
||||
} else {
|
||||
val mutableMap = it.networkProgress.toMutableMap()
|
||||
mutableMap[attachment] = Progress.fromEvent(event)
|
||||
val updateEvent = Progress.fromEvent(event)
|
||||
val existingEvent = mutableMap[attachment]
|
||||
if (existingEvent == null || updateEvent.completed > existingEvent.completed) {
|
||||
mutableMap[attachment] = updateEvent
|
||||
}
|
||||
verboseLog("onEventAsync network update")
|
||||
return@updateState it.copy(networkProgress = mutableMap.toMap())
|
||||
}
|
||||
|
@ -619,7 +661,7 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
} else {
|
||||
val progressText = Formatter.formatShortFileSize(context, currentState.networkProgress.sumCompleted())
|
||||
val totalText = Formatter.formatShortFileSize(context, currentState.networkProgress.sumTotal())
|
||||
"$progressText/$totalText"
|
||||
context.resources.getString(R.string.TransferControlView__download_progress, progressText, totalText)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -636,6 +678,9 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
private const val TAG = "TransferControlView"
|
||||
private const val VERBOSE_DEVELOPMENT_LOGGING = false
|
||||
private const val UPLOAD_TASK_WEIGHT = 1
|
||||
private const val SECONDARY_TEXT_OFFSET_DP = 3
|
||||
private const val RETRY_SECONDARY_TEXT_OFFSET_DP = 6
|
||||
private const val PRIMARY_TEXT_OFFSET_DP = 4
|
||||
|
||||
/**
|
||||
* A weighting compared to [UPLOAD_TASK_WEIGHT]
|
||||
|
@ -695,4 +740,14 @@ class TransferControlView @JvmOverloads constructor(context: Context, attrs: Att
|
|||
RETRY_UPLOADING,
|
||||
GONE
|
||||
}
|
||||
|
||||
private class AnimationCleanup(val animatedView: View) : ListenableFuture.Listener<Boolean> {
|
||||
override fun onSuccess(result: Boolean?) {
|
||||
animatedView.clearAnimation()
|
||||
}
|
||||
|
||||
override fun onFailure(e: ExecutionException?) {
|
||||
animatedView.clearAnimation()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,10 +32,10 @@ class TransferProgressView @JvmOverloads constructor(
|
|||
) : View(context, attrs, defStyleAttr, defStyleRes) {
|
||||
companion object {
|
||||
const val TAG = "TransferProgressView"
|
||||
private const val PROGRESS_ARC_STROKE_WIDTH_DP = 1.5f
|
||||
private const val PROGRESS_ARC_STROKE_WIDTH_DP = 2f
|
||||
private const val ICON_SIZE_DP = 24f
|
||||
private const val STOP_CORNER_RADIUS_DP = 4f
|
||||
private const val PROGRESS_BAR_INSET_DP = 3
|
||||
private const val PROGRESS_BAR_INSET_DP = 2
|
||||
}
|
||||
|
||||
private val iconColor: Int
|
||||
|
|
|
@ -277,7 +277,10 @@ public final class AttachmentCompressionJob extends BaseJob {
|
|||
}
|
||||
|
||||
attachmentDatabase.markAttachmentAsTransformed(attachment.getAttachmentId(), true);
|
||||
|
||||
eventBus.postSticky(new PartProgressEvent(attachment,
|
||||
PartProgressEvent.Type.COMPRESSION,
|
||||
100,
|
||||
100));
|
||||
return Objects.requireNonNull(attachmentDatabase.getAttachment(attachment.getAttachmentId()));
|
||||
} else {
|
||||
Log.i(TAG, "Transcode was not required (in-memory transcoder)");
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2023 Signal Messenger, LLC
|
||||
~ SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
@ -7,9 +6,9 @@
|
|||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:animateLayoutChanges="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
tools:parentTag="org.thoughtcrime.securesms.components.transfercontrols.TransferControlView">
|
||||
|
||||
<View
|
||||
|
@ -37,33 +36,33 @@
|
|||
|
||||
<org.thoughtcrime.securesms.components.transfercontrols.TransferProgressView
|
||||
android:id="@+id/secondary_progress_view"
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_gravity="center"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingEnd="-4dp"
|
||||
android:paddingBottom="4dp"
|
||||
app:iconSize="12dp"
|
||||
app:stopIconSize="6dp"
|
||||
app:stopIconCornerRadius="1dp"
|
||||
app:iconSize="16dp"
|
||||
app:layout_constraintStart_toStartOf="@+id/vertical_guideline"
|
||||
app:layout_constraintTop_toTopOf="@+id/horizontal_guideline" />
|
||||
app:layout_constraintTop_toTopOf="@+id/horizontal_guideline"
|
||||
app:stopIconCornerRadius="1dp"
|
||||
app:stopIconSize="8dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/secondary_details_text"
|
||||
style="@style/Signal.Text.Caption"
|
||||
android:includeFontPadding="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="26dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginStart="@dimen/transfer_control_view_progressbar_to_textview_margin"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:longClickable="false"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingEnd="9dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:textColor="@color/signal_colorOnCustom"
|
||||
app:layout_constrainedWidth="true"
|
||||
|
@ -75,24 +74,26 @@
|
|||
android:layout_width="@dimen/transfer_control_view_primary_background_height"
|
||||
android:layout_height="@dimen/transfer_control_view_primary_background_height"
|
||||
app:iconSize="24dp"
|
||||
app:stopIconSize="14dp"
|
||||
app:stopIconCornerRadius="2dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/primary_details_text"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:stopIconCornerRadius="2dp"
|
||||
app:stopIconSize="14dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/primary_details_text"
|
||||
style="@style/Signal.Text.BodyLarge"
|
||||
android:includeFontPadding="false"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:longClickable="false"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:textColor="@color/signal_colorOnCustom"
|
||||
app:layout_constrainedWidth="true"
|
||||
|
@ -124,12 +125,12 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_begin="6dp" />
|
||||
app:layout_constraintGuide_begin="4dp" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/horizontal_guideline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_begin="6dp" />
|
||||
app:layout_constraintGuide_begin="4dp" />
|
||||
</merge>
|
||||
|
|
|
@ -160,8 +160,9 @@
|
|||
<dimen name="transfer_top_padding">64dp</dimen>
|
||||
<dimen name="transfer_split_top_padding">32dp</dimen>
|
||||
<dimen name="transfer_item_spacing">24dp</dimen>
|
||||
<dimen name="transfer_control_view_progressbar_to_textview_margin">4dp</dimen>
|
||||
<dimen name="transfer_control_view_primary_background_height">50dp</dimen>
|
||||
<dimen name="transfer_control_view_progressbar_to_textview_margin">2dp</dimen>
|
||||
<dimen name="transfer_control_view_parent_to_textview_margin">8dp</dimen>
|
||||
<dimen name="transfer_control_view_primary_background_height">44dp</dimen>
|
||||
|
||||
<dimen name="create_payment_key_width">80dp</dimen>
|
||||
<dimen name="create_payment_key_height">70dp</dimen>
|
||||
|
|
|
@ -2361,6 +2361,8 @@
|
|||
</plurals>
|
||||
<!-- Status update label used while the device is transcoding video as a prerequisite to uploading -->
|
||||
<string name="TransferControlView__processing">Processing…</string>
|
||||
<!-- Status update label used while the device is transcoding video as a prerequisite to uploading -->
|
||||
<string name="TransferControlView__download_progress">%1$s/%2$s</string>
|
||||
|
||||
|
||||
<!-- UnauthorizedReminder -->
|
||||
|
|
|
@ -1510,6 +1510,7 @@ public class PushServiceSocket {
|
|||
listener.onAttachmentProgress(body.contentLength() + offset, totalRead);
|
||||
if (listener.shouldCancel()) {
|
||||
call.cancel();
|
||||
throw new PushNetworkException("Canceled by listener check.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue