changed to not save message attachments

to media store when sharing.
fixed using wrong attachment class for vcards (use lowercase on both sides of attachment mime type comparison)
added share button to audio attachment preview
removed old fileprovider that was never used
added content provider to provide mms attachments to external activities using a filename - not mms part id - so they can be saved externally with a proper name
fix bug when re-using attachment viewholder that has previously had text
fixed bug of image attachments always being named 'image' rather than their filename
 added share button to generic file attachment type in compose message list and removed onclick handler for viewing
This commit is contained in:
gavine99
2025-02-03 19:58:40 +11:00
parent 51ba356526
commit 042bbe80a1
14 changed files with 285 additions and 93 deletions
@@ -18,12 +18,17 @@
*/
package dev.octoshrimpy.quik.model
import android.content.ContentResolver
import android.content.ContentResolver.MimeTypeInfo
import android.net.Uri
import android.webkit.MimeTypeMap
import androidx.core.net.toUri
import io.realm.RealmObject
import io.realm.RealmResults
import io.realm.annotations.Index
import io.realm.annotations.LinkingObjects
import io.realm.annotations.PrimaryKey
import java.io.File
open class MmsPart : RealmObject() {
@@ -37,13 +42,23 @@ open class MmsPart : RealmObject() {
@LinkingObjects("parts")
val messages: RealmResults<Message>? = null
fun getUri() = "content://mms/part/$id".toUri()
fun getUri(): Uri = Uri
.Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority("mms")
.encodedPath("part/$id")
.build()
fun getBestFilename(): String =
if (File(name).extension.isNotEmpty()) name ?: "unknown"
else "$name." + (MimeTypeMap.getSingleton().getExtensionFromMimeType(type)
?: type.substringAfter("/"))
fun getSummary(): String? = when {
type == "application/smil" -> null
type == "text/plain" -> text
type == "text/x-vcard" -> "Contact card"
type.startsWith("image") -> "Photo"
type.startsWith("image") -> "Picture"
type.startsWith("video") -> "Video"
type.startsWith("audio") -> "Audio"
else -> type.substring(type.indexOf('/') + 1)