mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-02-17 12:10:37 +01:00
Fixed missing plus sign when opened from another app (#107)
This commit is contained in:
parent
b731348f14
commit
9b0fe07fab
@ -102,7 +102,7 @@ class NewConversationActivity : SimpleActivity() {
|
||||
|
||||
private fun isThirdPartyIntent(): Boolean {
|
||||
if ((intent.action == Intent.ACTION_SENDTO || intent.action == Intent.ACTION_SEND || intent.action == Intent.ACTION_VIEW) && intent.dataString != null) {
|
||||
val number = intent.dataString!!.removePrefix("sms:").removePrefix("smsto:").removePrefix("mms").removePrefix("mmsto:").trim()
|
||||
val number = intent.dataString!!.removePrefix("sms:").removePrefix("smsto:").removePrefix("mms").removePrefix("mmsto:").replace("+", "%2b").trim()
|
||||
launchThreadActivity(URLDecoder.decode(number), "")
|
||||
finish()
|
||||
return true
|
||||
|
@ -29,6 +29,8 @@ import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.klinker.android.send_message.Settings
|
||||
import com.klinker.android.send_message.Transaction
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
@ -376,7 +378,10 @@ class ThreadActivity : SimpleActivity() {
|
||||
private fun setupParticipants() {
|
||||
if (participants.isEmpty()) {
|
||||
participants = if (messages.isEmpty()) {
|
||||
getThreadParticipants(threadId, null)
|
||||
val intentNumbers = getPhoneNumbersFromIntent()
|
||||
val participants = getThreadParticipants(threadId, null)
|
||||
|
||||
fixParticipantNumbers(participants, intentNumbers)
|
||||
} else {
|
||||
messages.first().participants
|
||||
}
|
||||
@ -767,6 +772,41 @@ class ThreadActivity : SimpleActivity() {
|
||||
showSelectedContacts()
|
||||
}
|
||||
|
||||
private fun getPhoneNumbersFromIntent(): ArrayList<String> {
|
||||
val numberFromIntent = intent.getStringExtra(THREAD_NUMBER)
|
||||
val numbers = ArrayList<String>()
|
||||
|
||||
if (numberFromIntent != null) {
|
||||
if (numberFromIntent.startsWith('[') && numberFromIntent.endsWith(']')) {
|
||||
val type = object : TypeToken<List<String>>() {}.type
|
||||
numbers.addAll(Gson().fromJson(numberFromIntent, type))
|
||||
} else {
|
||||
numbers.add(numberFromIntent)
|
||||
}
|
||||
}
|
||||
return numbers
|
||||
}
|
||||
|
||||
private fun fixParticipantNumbers(participants: ArrayList<SimpleContact>, properNumbers: ArrayList<String>): ArrayList<SimpleContact> {
|
||||
for (number in properNumbers) {
|
||||
for (participant in participants) {
|
||||
participant.phoneNumbers = participant.phoneNumbers.map {
|
||||
val numberWithoutPlus = number.replace("+", "")
|
||||
if (numberWithoutPlus == it.trim()) {
|
||||
if (participant.name == it) {
|
||||
participant.name = number
|
||||
}
|
||||
number
|
||||
} else {
|
||||
it
|
||||
}
|
||||
} as ArrayList<String>
|
||||
}
|
||||
}
|
||||
|
||||
return participants
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Subscribe(threadMode = ThreadMode.ASYNC)
|
||||
fun refreshMessages(event: Events.RefreshMessages) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user