forked from upstream-mirrors/quik
changes to ingest all attachments in a standard manner. does not change user-facing functionality
This commit is contained in:
@@ -93,14 +93,14 @@ class AttachmentAdapter @Inject constructor(
|
||||
holder.fileName.visibility = View.GONE
|
||||
|
||||
// if attachment uri is missing
|
||||
if (!attachment.getUri().resourceExists(context)) {
|
||||
if (!attachment.uri.resourceExists(context)) {
|
||||
holder.thumbnail.setImageResource(android.R.drawable.ic_delete)
|
||||
holder.fileName.text = context.getString(R.string.attachment_missing)
|
||||
holder.fileName.visibility = View.VISIBLE
|
||||
return
|
||||
}
|
||||
|
||||
val uri = attachment.getUri()
|
||||
val uri = attachment.uri
|
||||
val mimeType = attachment.getType(context)
|
||||
|
||||
// if attachment mime type is image/* or video/*, use image/frame
|
||||
@@ -160,4 +160,4 @@ class AttachmentAdapter @Inject constructor(
|
||||
else -> VIEW_TYPE_FILE
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
|
||||
override fun requestContact() {
|
||||
val intent = Intent(Intent.ACTION_PICK)
|
||||
.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE)
|
||||
.setType(ContactsContract.Contacts.CONTENT_TYPE)
|
||||
|
||||
startActivityForResult(Intent.createChooser(intent, null), ComposeView.AttachContactRequestCode)
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class ComposeActivityModule {
|
||||
activity.intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)?.run(uris::add)
|
||||
activity.intent.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)?.run(uris::addAll)
|
||||
|
||||
return Attachments(uris.mapNotNull { Attachment(it) })
|
||||
return Attachments(uris.mapNotNull { Attachment(activity, it) })
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
package dev.octoshrimpy.quik.feature.compose
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Vibrator
|
||||
import android.provider.ContactsContract
|
||||
import android.telephony.SmsMessage
|
||||
import androidx.core.content.getSystemService
|
||||
import com.moez.QKSMS.contentproviders.MmsPartProvider
|
||||
@@ -652,8 +650,8 @@ class ComposeViewModel @Inject constructor(
|
||||
|
||||
// a file, photo or otherwise, was picked by the user
|
||||
Observable.merge(
|
||||
view.attachAnyFileSelectedIntent.map { uri -> Attachment(uri) },
|
||||
view.inputContentIntent.map { inputContent -> Attachment(inputContent = inputContent) }
|
||||
view.attachAnyFileSelectedIntent.map { uri -> Attachment(context, uri) },
|
||||
view.inputContentIntent.map { inputContent -> Attachment(context, inputContent = inputContent) }
|
||||
)
|
||||
.withLatestFrom(attachments) { attachment, attachments -> attachments + attachment }
|
||||
.doOnNext(attachments::onNext)
|
||||
@@ -677,7 +675,7 @@ class ComposeViewModel @Inject constructor(
|
||||
|
||||
// Contact was selected for attachment
|
||||
view.contactSelectedIntent
|
||||
.map { uri -> Attachment(getFullVCardUri(uri)) }
|
||||
.map { uri -> Attachment(context, uri) }
|
||||
.withLatestFrom(attachments) { attachment, attachments -> attachments + attachment }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.autoDisposable(view.scope())
|
||||
@@ -801,9 +799,7 @@ class ComposeViewModel @Inject constructor(
|
||||
// Scheduling a message
|
||||
state.scheduled != 0L -> {
|
||||
newState { copy(scheduled = 0) }
|
||||
val uris = attachments
|
||||
.map { it.getUri() }
|
||||
.map { it.toString() }
|
||||
val uris = attachments.map { it.uri.toString() }
|
||||
val params = AddScheduledMessage
|
||||
.Params(state.scheduled, subId, addresses, sendAsGroup, body, uris)
|
||||
addScheduledMessage.execute(params)
|
||||
@@ -881,17 +877,4 @@ class ComposeViewModel @Inject constructor(
|
||||
|
||||
}
|
||||
|
||||
private fun getFullVCardUri(contactData: Uri): Uri {
|
||||
val lookupKey = context.contentResolver.query(contactData, null, null, null, null)?.use {
|
||||
it.moveToFirst()
|
||||
val index = it.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)
|
||||
if (index >= 0)
|
||||
it.getString(index)
|
||||
else
|
||||
""
|
||||
}
|
||||
|
||||
return Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user