add handling for Share Text intent

This commit is contained in:
tibbi 2020-04-11 23:36:03 +02:00
parent 6d4f0bf7aa
commit 18f8b271e1
4 changed files with 21 additions and 6 deletions

View File

@ -53,6 +53,13 @@
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity
@ -83,7 +90,7 @@
<activity
android:name="com.simplemobiletools.commons.activities.ManageBlockedNumbersActivity"
android:label="@string/blocked_numbers"
android:parentActivityName=".activities.SettingsActivity"/>
android:parentActivityName=".activities.SettingsActivity" />
<service
android:name=".services.HeadlessSmsSendService"
@ -113,6 +120,7 @@
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter>
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
<data android:mimeType="application/vnd.wap.mms-message" />
<data android:mimeType="application/vnd.wap.sic" />
</intent-filter>
@ -121,7 +129,7 @@
<receiver
android:name=".receivers.MmsReceiver"
android:exported="true"
android:taskAffinity="com.klinker.android.messaging.MMS_RECEIVED"/>
android:taskAffinity="com.klinker.android.messaging.MMS_RECEIVED" />
<receiver android:name=".receivers.SmsSentReceiver" />

View File

@ -11,6 +11,7 @@ import com.simplemobiletools.smsmessenger.extensions.config
import com.simplemobiletools.smsmessenger.extensions.getAvailableContacts
import com.simplemobiletools.smsmessenger.extensions.getThreadId
import com.simplemobiletools.smsmessenger.helpers.THREAD_ID
import com.simplemobiletools.smsmessenger.helpers.THREAD_TEXT
import com.simplemobiletools.smsmessenger.helpers.THREAD_TITLE
import com.simplemobiletools.smsmessenger.models.Contact
import kotlinx.android.synthetic.main.activity_new_message.*
@ -63,14 +64,14 @@ class NewMessageActivity : SimpleActivity() {
new_message_confirm.applyColorFilter(config.textColor)
new_message_confirm.setOnClickListener {
val number = new_message_to.value
launchThreadActivity(number, number)
launchThreadActivity(number, number, "")
}
}
private fun isThirdPartyIntent(): Boolean {
if (intent.action == Intent.ACTION_SENDTO && intent.dataString != null) {
val number = intent.dataString!!.removePrefix("sms:").removePrefix("smsto:").removePrefix("mms").removePrefix("mmsto:").trim()
launchThreadActivity(number, "")
launchThreadActivity(number, "", "")
return true
}
return false
@ -79,16 +80,19 @@ class NewMessageActivity : SimpleActivity() {
private fun setupAdapter(contacts: ArrayList<Contact>) {
ContactsAdapter(this, contacts, suggestions_list, null) {
hideKeyboard()
launchThreadActivity((it as Contact).phoneNumber, it.name)
val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: ""
launchThreadActivity((it as Contact).phoneNumber, it.name, text)
}.apply {
suggestions_list.adapter = this
}
}
private fun launchThreadActivity(phoneNumber: String, name: String) {
private fun launchThreadActivity(phoneNumber: String, name: String, text: String) {
Intent(this, ThreadActivity::class.java).apply {
putExtra(THREAD_ID, getThreadId(phoneNumber).toInt())
putExtra(THREAD_TITLE, name)
putExtra(THREAD_TEXT, text)
startActivity(this)
}
}

View File

@ -169,6 +169,8 @@ class ThreadActivity : SimpleActivity() {
}
}
}
thread_type_message.setText(intent.getStringExtra(THREAD_TEXT))
}
private fun blockNumber() {

View File

@ -5,6 +5,7 @@ import org.greenrobot.eventbus.EventBus
const val THREAD_ID = "thread_id"
const val THREAD_TITLE = "thread_title"
const val THREAD_TEXT = "thread_text"
// view types for the thread list view
const val THREAD_DATE_TIME = 1