mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-15 10:07:40 +00:00
fix: downloads now don't automatically queue for untrusted contacts and UI to handle re-downloading failed attachments
This commit is contained in:
@@ -60,9 +60,9 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper)
|
||||
return databaseAttachment.toSignalAttachmentPointer()
|
||||
}
|
||||
|
||||
override fun setAttachmentState(attachmentState: AttachmentState, attachmentId: Long, messageID: Long) {
|
||||
override fun setAttachmentState(attachmentState: AttachmentState, attachmentId: AttachmentId, messageID: Long) {
|
||||
val attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context)
|
||||
attachmentDatabase.setTransferState(messageID, AttachmentId(attachmentId, 0), attachmentState.value)
|
||||
attachmentDatabase.setTransferState(messageID, attachmentId, attachmentState.value)
|
||||
}
|
||||
|
||||
override fun getMessageForQuote(timestamp: Long, author: Address): Pair<Long, Boolean>? {
|
||||
|
@@ -13,6 +13,9 @@ import androidx.core.view.children
|
||||
import androidx.core.view.isVisible
|
||||
import kotlinx.android.synthetic.main.album_thumbnail_view.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.messaging.jobs.AttachmentDownloadJob
|
||||
import org.session.libsession.messaging.jobs.JobQueue
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment
|
||||
import org.session.libsession.utilities.ViewUtil
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.MediaPreviewActivity
|
||||
@@ -23,6 +26,7 @@ import org.thoughtcrime.securesms.loki.utilities.ActivityDispatcher
|
||||
import org.thoughtcrime.securesms.longmessage.LongMessageActivity
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.mms.Slide
|
||||
import org.thoughtcrime.securesms.video.exo.AttachmentDataSource
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class AlbumThumbnailView : FrameLayout {
|
||||
@@ -82,6 +86,13 @@ class AlbumThumbnailView : FrameLayout {
|
||||
// hit intersects with this particular child
|
||||
val slide = slides.getOrNull(index) ?: return
|
||||
// only open to downloaded images
|
||||
if (slide.isPendingDownload) {
|
||||
// restart download here
|
||||
(slide.asAttachment() as? DatabaseAttachment)?.let { attachment ->
|
||||
val attachmentId = attachment.attachmentId.rowId
|
||||
JobQueue.shared.add(AttachmentDownloadJob(attachmentId, mms.getId()))
|
||||
}
|
||||
}
|
||||
if (slide.isInProgress) return
|
||||
|
||||
ActivityDispatcher.get(context)?.dispatchIntent { context ->
|
||||
|
@@ -40,6 +40,7 @@ open class KThumbnailView: FrameLayout {
|
||||
private val image by lazy { thumbnail_image }
|
||||
private val playOverlay by lazy { play_overlay }
|
||||
val loadIndicator: View by lazy { thumbnail_load_indicator }
|
||||
val downloadIndicator: View by lazy { thumbnail_download_icon }
|
||||
|
||||
private val dimensDelegate = ThumbnailDimensDelegate()
|
||||
|
||||
@@ -108,7 +109,8 @@ open class KThumbnailView: FrameLayout {
|
||||
|
||||
this.slide = slide
|
||||
|
||||
loadIndicator.isVisible = slide.isInProgress && !mms.isFailed
|
||||
loadIndicator.isVisible = slide.isInProgress && !slide.isPendingDownload
|
||||
downloadIndicator.isVisible = slide.isPendingDownload
|
||||
|
||||
dimensDelegate.setDimens(naturalWidth, naturalHeight)
|
||||
invalidate()
|
||||
|
@@ -47,6 +47,14 @@ class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Da
|
||||
}.toSet()
|
||||
}
|
||||
|
||||
fun setContactIsTrusted(contact: Contact, isTrusted: Boolean) {
|
||||
val database = databaseHelper.writableDatabase
|
||||
val contentValues = ContentValues(1)
|
||||
contentValues.put(Companion.isTrusted, if (isTrusted) 1 else 0)
|
||||
database.insertOrUpdate(sessionContactTable, contentValues, "$sessionID = ?", arrayOf( contact.sessionID ))
|
||||
notifyConversationListListeners()
|
||||
}
|
||||
|
||||
fun setContact(contact: Contact) {
|
||||
val database = databaseHelper.writableDatabase
|
||||
val contentValues = ContentValues(8)
|
||||
|
@@ -22,6 +22,15 @@
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:src="@drawable/ic_download_circle_filled_48"
|
||||
android:id="@+id/thumbnail_download_icon"
|
||||
android:layout_width="@dimen/medium_button_height"
|
||||
android:layout_height="@dimen/medium_button_height"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/play_overlay"
|
||||
android:layout_width="48dp"
|
||||
@@ -29,8 +38,7 @@
|
||||
android:background="@drawable/circle_white"
|
||||
android:layout_gravity="center"
|
||||
android:longClickable="false"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="19dp"
|
||||
|
Reference in New Issue
Block a user