mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-26 11:51:10 +01:00
Renamed database classes to table classes.
Because they're not databases. They're tables.
This commit is contained in:
committed by
Cody Henthorne
parent
b190f9495a
commit
7949996c5c
@@ -7,8 +7,8 @@ import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
|
||||
import org.thoughtcrime.securesms.database.MediaDatabase
|
||||
import org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord
|
||||
import org.thoughtcrime.securesms.database.MediaTable
|
||||
import org.thoughtcrime.securesms.database.MediaTable.MediaRecord
|
||||
|
||||
object MediaIntentFactory {
|
||||
private const val ARGS_KEY = "args"
|
||||
@@ -37,7 +37,7 @@ object MediaIntentFactory {
|
||||
val hideAllMedia: Boolean = false,
|
||||
val showThread: Boolean = false,
|
||||
val allMediaInRail: Boolean = false,
|
||||
val sorting: MediaDatabase.Sorting,
|
||||
val sorting: MediaTable.Sorting,
|
||||
val isVideoGif: Boolean
|
||||
) : Parcelable
|
||||
|
||||
@@ -67,7 +67,7 @@ object MediaIntentFactory {
|
||||
attachment.caption,
|
||||
leftIsRecent,
|
||||
allMediaInRail = allMediaInRail,
|
||||
sorting = MediaDatabase.Sorting.Newest,
|
||||
sorting = MediaTable.Sorting.Newest,
|
||||
isVideoGif = attachment.isVideoGif
|
||||
)
|
||||
)
|
||||
|
||||
@@ -12,9 +12,9 @@ import org.signal.core.util.requireLong
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
|
||||
import org.thoughtcrime.securesms.conversation.ConversationIntents
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase
|
||||
import org.thoughtcrime.securesms.database.MediaDatabase
|
||||
import org.thoughtcrime.securesms.database.MediaDatabase.Sorting
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.database.MediaTable
|
||||
import org.thoughtcrime.securesms.database.MediaTable.Sorting
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase.Companion.media
|
||||
import org.thoughtcrime.securesms.sms.MessageSender
|
||||
@@ -38,11 +38,11 @@ class MediaPreviewRepository {
|
||||
fun getAttachments(startingAttachmentId: AttachmentId, threadId: Long, sorting: Sorting, limit: Int = 500): Flowable<Result> {
|
||||
return Single.fromCallable {
|
||||
media.getGalleryMediaForThread(threadId, sorting).use { cursor ->
|
||||
val mediaRecords = mutableListOf<MediaDatabase.MediaRecord>()
|
||||
val mediaRecords = mutableListOf<MediaTable.MediaRecord>()
|
||||
var startingRow = -1
|
||||
while (cursor.moveToNext()) {
|
||||
if (startingAttachmentId.rowId == cursor.requireLong(AttachmentDatabase.ROW_ID) &&
|
||||
startingAttachmentId.uniqueId == cursor.requireLong(AttachmentDatabase.UNIQUE_ID)
|
||||
if (startingAttachmentId.rowId == cursor.requireLong(AttachmentTable.ROW_ID) &&
|
||||
startingAttachmentId.uniqueId == cursor.requireLong(AttachmentTable.UNIQUE_ID)
|
||||
) {
|
||||
startingRow = cursor.position
|
||||
break
|
||||
@@ -59,7 +59,7 @@ class MediaPreviewRepository {
|
||||
cursor.moveToPosition(windowStart)
|
||||
|
||||
for (i in 0..limit) {
|
||||
val element = MediaDatabase.MediaRecord.from(cursor)
|
||||
val element = MediaTable.MediaRecord.from(cursor)
|
||||
if (element != null) {
|
||||
mediaRecords.add(element)
|
||||
}
|
||||
@@ -97,5 +97,5 @@ class MediaPreviewRepository {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
data class Result(val initialPosition: Int, val records: List<MediaDatabase.MediaRecord>)
|
||||
data class Result(val initialPosition: Int, val records: List<MediaTable.MediaRecord>)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.thoughtcrime.securesms.attachments.DatabaseAttachment
|
||||
import org.thoughtcrime.securesms.components.ViewBinderDelegate
|
||||
import org.thoughtcrime.securesms.conversation.mutiselect.forward.MultiselectForwardFragment
|
||||
import org.thoughtcrime.securesms.conversation.mutiselect.forward.MultiselectForwardFragmentArgs
|
||||
import org.thoughtcrime.securesms.database.MediaDatabase
|
||||
import org.thoughtcrime.securesms.database.MediaTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.databinding.FragmentMediaPreviewV2Binding
|
||||
import org.thoughtcrime.securesms.mediapreview.mediarail.CenterDecoration
|
||||
@@ -122,7 +122,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
}.show()
|
||||
}
|
||||
viewModel.initialize(args.showThread, args.allMediaInRail, args.leftIsRecent)
|
||||
val sorting = MediaDatabase.Sorting.deserialize(args.sorting.ordinal)
|
||||
val sorting = MediaTable.Sorting.deserialize(args.sorting.ordinal)
|
||||
viewModel.fetchAttachments(PartAuthority.requireAttachmentId(args.initialMediaUri), args.threadId, sorting)
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
}
|
||||
|
||||
val currentPosition = currentState.position
|
||||
val currentItem: MediaDatabase.MediaRecord = currentState.mediaRecords[currentPosition]
|
||||
val currentItem: MediaTable.MediaRecord = currentState.mediaRecords[currentPosition]
|
||||
|
||||
// pause all other fragments
|
||||
childFragmentManager.fragments.map { fragment ->
|
||||
@@ -235,7 +235,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
crossfadeViewIn(binding.mediaPreviewDetailsContainer)
|
||||
}
|
||||
|
||||
private fun bindTextViews(currentItem: MediaDatabase.MediaRecord, showThread: Boolean) {
|
||||
private fun bindTextViews(currentItem: MediaTable.MediaRecord, showThread: Boolean) {
|
||||
binding.toolbar.title = getTitleText(currentItem, showThread)
|
||||
binding.toolbar.subtitle = getSubTitleText(currentItem)
|
||||
val messageId: Long? = currentItem.attachment?.mmsId
|
||||
@@ -256,7 +256,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
binding.mediaPreviewCaption.visible = caption != null
|
||||
}
|
||||
|
||||
private fun bindMenuItems(currentItem: MediaDatabase.MediaRecord) {
|
||||
private fun bindMenuItems(currentItem: MediaTable.MediaRecord) {
|
||||
val menu: Menu = binding.toolbar.menu
|
||||
if (currentItem.threadId == MediaIntentFactory.NOT_IN_A_THREAD.toLong()) {
|
||||
menu.findItem(R.id.delete).isVisible = false
|
||||
@@ -274,7 +274,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindMediaPreviewPlaybackControls(currentItem: MediaDatabase.MediaRecord, currentFragment: MediaPreviewFragment?) {
|
||||
private fun bindMediaPreviewPlaybackControls(currentItem: MediaTable.MediaRecord, currentFragment: MediaPreviewFragment?) {
|
||||
val mediaType: MediaPreviewPlayerControlView.MediaMode = if (currentItem.attachment?.isVideoGif == true) {
|
||||
MediaPreviewPlayerControlView.MediaMode.IMAGE
|
||||
} else {
|
||||
@@ -293,7 +293,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
currentFragment?.setBottomButtonControls(binding.mediaPreviewPlaybackControls)
|
||||
}
|
||||
|
||||
private fun bindAlbumRail(albumThumbnailMedia: List<Media>, currentItem: MediaDatabase.MediaRecord) {
|
||||
private fun bindAlbumRail(albumThumbnailMedia: List<Media>, currentItem: MediaTable.MediaRecord) {
|
||||
val albumRail: RecyclerView = binding.mediaPreviewPlaybackControls.recyclerView
|
||||
if (albumThumbnailMedia.size > 1) {
|
||||
val albumPosition = albumThumbnailMedia.indexOfFirst { it.uri == currentItem.attachment?.uri }
|
||||
@@ -357,7 +357,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
binding.mediaPager.setCurrentItem(position, true)
|
||||
}
|
||||
|
||||
private fun getTitleText(mediaRecord: MediaDatabase.MediaRecord, showThread: Boolean): String {
|
||||
private fun getTitleText(mediaRecord: MediaTable.MediaRecord, showThread: Boolean): String {
|
||||
val recipient: Recipient = Recipient.live(mediaRecord.recipientId).get()
|
||||
val defaultFromString: String = if (mediaRecord.isOutgoing) {
|
||||
getString(R.string.MediaPreviewActivity_you)
|
||||
@@ -384,7 +384,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSubTitleText(mediaRecord: MediaDatabase.MediaRecord): CharSequence {
|
||||
private fun getSubTitleText(mediaRecord: MediaTable.MediaRecord): CharSequence {
|
||||
val text = if (mediaRecord.date > 0) {
|
||||
DateUtils.getExtendedRelativeTimeSpanString(requireContext(), Locale.getDefault(), mediaRecord.date)
|
||||
} else {
|
||||
@@ -436,7 +436,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
debouncer.clear()
|
||||
}
|
||||
|
||||
private fun forward(mediaItem: MediaDatabase.MediaRecord) {
|
||||
private fun forward(mediaItem: MediaTable.MediaRecord) {
|
||||
val attachment = mediaItem.attachment
|
||||
val uri = attachment?.uri
|
||||
if (attachment != null && uri != null) {
|
||||
@@ -451,7 +451,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
}
|
||||
}
|
||||
|
||||
private fun share(mediaItem: MediaDatabase.MediaRecord) {
|
||||
private fun share(mediaItem: MediaTable.MediaRecord) {
|
||||
val attachment = mediaItem.attachment
|
||||
val uri = attachment?.uri
|
||||
if (attachment != null && uri != null) {
|
||||
@@ -472,7 +472,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveToDisk(mediaItem: MediaDatabase.MediaRecord) {
|
||||
private fun saveToDisk(mediaItem: MediaTable.MediaRecord) {
|
||||
SaveAttachmentTask.showWarningDialog(requireContext()) { _: DialogInterface?, _: Int ->
|
||||
if (StorageUtil.canWriteToMediaStore()) {
|
||||
performSaveToDisk(mediaItem)
|
||||
@@ -488,7 +488,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
}
|
||||
}
|
||||
|
||||
fun performSaveToDisk(mediaItem: MediaDatabase.MediaRecord) {
|
||||
fun performSaveToDisk(mediaItem: MediaTable.MediaRecord) {
|
||||
val saveTask = SaveAttachmentTask(requireContext())
|
||||
val saveDate = if (mediaItem.date > 0) mediaItem.date else System.currentTimeMillis()
|
||||
val attachment = mediaItem.attachment
|
||||
@@ -498,7 +498,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteMedia(mediaItem: MediaDatabase.MediaRecord) {
|
||||
private fun deleteMedia(mediaItem: MediaTable.MediaRecord) {
|
||||
val attachment: DatabaseAttachment = mediaItem.attachment ?: return
|
||||
|
||||
MaterialAlertDialogBuilder(requireContext()).apply {
|
||||
@@ -547,7 +547,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
||||
return attachmentCount <= 1 && RemoteDeleteUtil.isValidSend(listOf(SignalDatabase.mms.getMessageRecord(mmsId)), System.currentTimeMillis())
|
||||
}
|
||||
|
||||
private fun editMediaItem(currentItem: MediaDatabase.MediaRecord) {
|
||||
private fun editMediaItem(currentItem: MediaTable.MediaRecord) {
|
||||
val media = currentItem.toMedia()
|
||||
if (media == null) {
|
||||
val rootView = view
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.thoughtcrime.securesms.mediapreview
|
||||
|
||||
import org.thoughtcrime.securesms.database.MediaDatabase
|
||||
import org.thoughtcrime.securesms.database.MediaTable
|
||||
import org.thoughtcrime.securesms.mediasend.Media
|
||||
|
||||
data class MediaPreviewV2State(
|
||||
val mediaRecords: List<MediaDatabase.MediaRecord> = emptyList(),
|
||||
val mediaRecords: List<MediaTable.MediaRecord> = emptyList(),
|
||||
val loadState: LoadState = LoadState.INIT,
|
||||
val position: Int = 0,
|
||||
val showThread: Boolean = false,
|
||||
|
||||
@@ -13,7 +13,7 @@ import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
|
||||
import org.thoughtcrime.securesms.database.MediaDatabase
|
||||
import org.thoughtcrime.securesms.database.MediaTable
|
||||
import org.thoughtcrime.securesms.mediasend.Media
|
||||
import org.thoughtcrime.securesms.util.rx.RxStore
|
||||
import java.util.Optional
|
||||
@@ -26,10 +26,10 @@ class MediaPreviewV2ViewModel : ViewModel() {
|
||||
|
||||
val state: Flowable<MediaPreviewV2State> = store.stateFlowable.observeOn(AndroidSchedulers.mainThread())
|
||||
|
||||
fun fetchAttachments(startingAttachmentId: AttachmentId, threadId: Long, sorting: MediaDatabase.Sorting, forceRefresh: Boolean = false) {
|
||||
fun fetchAttachments(startingAttachmentId: AttachmentId, threadId: Long, sorting: MediaTable.Sorting, forceRefresh: Boolean = false) {
|
||||
if (store.state.loadState == MediaPreviewV2State.LoadState.INIT || forceRefresh) {
|
||||
disposables += store.update(repository.getAttachments(startingAttachmentId, threadId, sorting)) { result: MediaPreviewRepository.Result, oldState: MediaPreviewV2State ->
|
||||
val albums = result.records.fold(mutableMapOf()) { acc: MutableMap<Long, MutableList<Media>>, mediaRecord: MediaDatabase.MediaRecord ->
|
||||
val albums = result.records.fold(mutableMapOf()) { acc: MutableMap<Long, MutableList<Media>>, mediaRecord: MediaTable.MediaRecord ->
|
||||
val attachment = mediaRecord.attachment
|
||||
if (attachment != null) {
|
||||
val convertedMedia = mediaRecord.toMedia() ?: return@fold acc
|
||||
@@ -100,7 +100,7 @@ class MediaPreviewV2ViewModel : ViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun MediaDatabase.MediaRecord.toMedia(): Media? {
|
||||
fun MediaTable.MediaRecord.toMedia(): Media? {
|
||||
val attachment = this.attachment
|
||||
val uri = attachment?.uri
|
||||
if (attachment == null || uri == null) {
|
||||
|
||||
Reference in New Issue
Block a user