forked from upstream-mirrors/quik
Fix image forwarding
This commit is contained in:
@@ -88,9 +88,14 @@ class Navigator @Inject constructor(private val context: Context, private val no
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showCompose(body: String? = null) {
|
fun showCompose(body: String? = null, images: List<Uri>? = null) {
|
||||||
val intent = Intent(context, ComposeActivity::class.java)
|
val intent = Intent(context, ComposeActivity::class.java)
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, body)
|
intent.putExtra(Intent.EXTRA_TEXT, body)
|
||||||
|
|
||||||
|
images?.takeIf { it.isNotEmpty() }?.let {
|
||||||
|
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, ArrayList(images))
|
||||||
|
}
|
||||||
|
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.telephony.PhoneNumberUtils
|
|||||||
import android.telephony.SmsMessage
|
import android.telephony.SmsMessage
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import androidx.net.toUri
|
||||||
import com.mlsdev.rximagepicker.RxImagePicker
|
import com.mlsdev.rximagepicker.RxImagePicker
|
||||||
import com.mlsdev.rximagepicker.Sources
|
import com.mlsdev.rximagepicker.Sources
|
||||||
import com.moez.QKSMS.R
|
import com.moez.QKSMS.R
|
||||||
@@ -58,6 +59,7 @@ import model.PhoneNumber
|
|||||||
import repository.ContactRepository
|
import repository.ContactRepository
|
||||||
import repository.MessageRepository
|
import repository.MessageRepository
|
||||||
import util.extensions.asObservable
|
import util.extensions.asObservable
|
||||||
|
import util.extensions.isImage
|
||||||
import java.net.URLDecoder
|
import java.net.URLDecoder
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
@@ -210,7 +212,8 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
|
|||||||
// If the entry is a valid destination, allow it as a recipient
|
// If the entry is a valid destination, allow it as a recipient
|
||||||
if (PhoneNumberUtils.isWellFormedSmsAddress(query.toString())) {
|
if (PhoneNumberUtils.isWellFormedSmsAddress(query.toString())) {
|
||||||
val newAddress = PhoneNumberUtils.formatNumber(query.toString(), Locale.getDefault().country)
|
val newAddress = PhoneNumberUtils.formatNumber(query.toString(), Locale.getDefault().country)
|
||||||
val newContact = Contact(numbers = RealmList(PhoneNumber(address = newAddress ?: query.toString())))
|
val newContact = Contact(numbers = RealmList(PhoneNumber(address = newAddress
|
||||||
|
?: query.toString())))
|
||||||
filteredContacts = listOf(newContact) + filteredContacts
|
filteredContacts = listOf(newContact) + filteredContacts
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,7 +401,10 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
|
|||||||
// Forward the message
|
// Forward the message
|
||||||
view.forwardMessageIntent
|
view.forwardMessageIntent
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { message -> navigator.showCompose(message.body) }
|
.subscribe { message ->
|
||||||
|
val images = message.parts.filter { it.isImage() }.mapNotNull { it.image?.toUri() }
|
||||||
|
navigator.showCompose(message.body, images)
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the selected message
|
// Delete the selected message
|
||||||
view.deleteMessageIntent
|
view.deleteMessageIntent
|
||||||
|
|||||||
Reference in New Issue
Block a user