Cannot save generic files (#1391)

* Fixes #429

* Further experimentation regarding potential race condition - still not resolved

* Changed spinner mechanism away from RotateAnimation which fixes race-condition

* Removed leftover commented code

* Cleanup of unused imports

* Addressed PR feedback

* Adjusted 'visible' to use ktx
This commit is contained in:
Al Lansley
2024-01-15 16:46:48 +11:00
committed by GitHub
parent c366574521
commit 2fff9eceb7
6 changed files with 28 additions and 5 deletions

View File

@@ -1948,6 +1948,14 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
override fun saveAttachment(messages: Set<MessageRecord>) {
val message = messages.first() as MmsMessageRecord
// Do not allow the user to download a file attachment before it has finished downloading
// TODO: Localise the msg in this toast!
if (message.isMediaPending) {
Toast.makeText(this, resources.getString(R.string.conversation_activity__wait_until_attachment_has_finished_downloading), Toast.LENGTH_LONG).show()
return
}
SaveAttachmentTask.showWarningDialog(this) {
Permissions.with(this)
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)

View File

@@ -5,11 +5,13 @@ import android.content.res.ColorStateList
import android.util.AttributeSet
import android.widget.LinearLayout
import androidx.annotation.ColorInt
import androidx.core.view.isVisible
import network.loki.messenger.databinding.ViewDocumentBinding
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
class DocumentView : LinearLayout {
private val binding: ViewDocumentBinding by lazy { ViewDocumentBinding.bind(this) }
// region Lifecycle
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
@@ -22,6 +24,12 @@ class DocumentView : LinearLayout {
binding.documentTitleTextView.text = document.fileName.or("Untitled File")
binding.documentTitleTextView.setTextColor(textColor)
binding.documentViewIconImageView.imageTintList = ColorStateList.valueOf(textColor)
// Show the progress spinner if the attachment is downloading, otherwise show
// the document icon (and always remove the other, whichever one that is)
binding.documentViewProgress.isVisible = message.isMediaPending
binding.documentViewIconImageView.isVisible = !message.isMediaPending
}
// endregion
}

View File

@@ -318,4 +318,5 @@ class VisibleMessageContentView : ConstraintLayout {
}
}
// endregion
}

View File

@@ -63,7 +63,6 @@ import kotlin.math.sqrt
@AndroidEntryPoint
class VisibleMessageView : LinearLayout {
@Inject lateinit var threadDb: ThreadDatabase
@Inject lateinit var lokiThreadDb: LokiThreadDatabase
@Inject lateinit var lokiApiDb: LokiAPIDatabase
@@ -138,8 +137,7 @@ class VisibleMessageView : LinearLayout {
val isGroupThread = thread.isGroupRecipient
val isStartOfMessageCluster = isStartOfMessageCluster(message, previous, isGroupThread)
val isEndOfMessageCluster = isEndOfMessageCluster(message, next, isGroupThread)
// Show profile picture and sender name if this is a group thread AND
// the message is incoming
// Show profile picture and sender name if this is a group thread AND the message is incoming
binding.moderatorIconImageView.isVisible = false
binding.profilePictureView.visibility = when {
thread.isGroupRecipient && !message.isOutgoing && isEndOfMessageCluster -> View.VISIBLE