add handling for Share Text intent
This commit is contained in:
parent
6d4f0bf7aa
commit
18f8b271e1
|
@ -53,6 +53,13 @@
|
||||||
<data android:scheme="mms" />
|
<data android:scheme="mms" />
|
||||||
<data android:scheme="mmsto" />
|
<data android:scheme="mmsto" />
|
||||||
</intent-filter>
|
</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>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
@ -83,7 +90,7 @@
|
||||||
<activity
|
<activity
|
||||||
android:name="com.simplemobiletools.commons.activities.ManageBlockedNumbersActivity"
|
android:name="com.simplemobiletools.commons.activities.ManageBlockedNumbersActivity"
|
||||||
android:label="@string/blocked_numbers"
|
android:label="@string/blocked_numbers"
|
||||||
android:parentActivityName=".activities.SettingsActivity"/>
|
android:parentActivityName=".activities.SettingsActivity" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".services.HeadlessSmsSendService"
|
android:name=".services.HeadlessSmsSendService"
|
||||||
|
@ -113,6 +120,7 @@
|
||||||
android:permission="android.permission.BROADCAST_WAP_PUSH">
|
android:permission="android.permission.BROADCAST_WAP_PUSH">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
|
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
|
||||||
|
|
||||||
<data android:mimeType="application/vnd.wap.mms-message" />
|
<data android:mimeType="application/vnd.wap.mms-message" />
|
||||||
<data android:mimeType="application/vnd.wap.sic" />
|
<data android:mimeType="application/vnd.wap.sic" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
@ -121,7 +129,7 @@
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".receivers.MmsReceiver"
|
android:name=".receivers.MmsReceiver"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:taskAffinity="com.klinker.android.messaging.MMS_RECEIVED"/>
|
android:taskAffinity="com.klinker.android.messaging.MMS_RECEIVED" />
|
||||||
|
|
||||||
<receiver android:name=".receivers.SmsSentReceiver" />
|
<receiver android:name=".receivers.SmsSentReceiver" />
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.simplemobiletools.smsmessenger.extensions.config
|
||||||
import com.simplemobiletools.smsmessenger.extensions.getAvailableContacts
|
import com.simplemobiletools.smsmessenger.extensions.getAvailableContacts
|
||||||
import com.simplemobiletools.smsmessenger.extensions.getThreadId
|
import com.simplemobiletools.smsmessenger.extensions.getThreadId
|
||||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_ID
|
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.helpers.THREAD_TITLE
|
||||||
import com.simplemobiletools.smsmessenger.models.Contact
|
import com.simplemobiletools.smsmessenger.models.Contact
|
||||||
import kotlinx.android.synthetic.main.activity_new_message.*
|
import kotlinx.android.synthetic.main.activity_new_message.*
|
||||||
|
@ -63,14 +64,14 @@ class NewMessageActivity : SimpleActivity() {
|
||||||
new_message_confirm.applyColorFilter(config.textColor)
|
new_message_confirm.applyColorFilter(config.textColor)
|
||||||
new_message_confirm.setOnClickListener {
|
new_message_confirm.setOnClickListener {
|
||||||
val number = new_message_to.value
|
val number = new_message_to.value
|
||||||
launchThreadActivity(number, number)
|
launchThreadActivity(number, number, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isThirdPartyIntent(): Boolean {
|
private fun isThirdPartyIntent(): Boolean {
|
||||||
if (intent.action == Intent.ACTION_SENDTO && intent.dataString != null) {
|
if (intent.action == Intent.ACTION_SENDTO && 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:").trim()
|
||||||
launchThreadActivity(number, "")
|
launchThreadActivity(number, "", "")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -79,16 +80,19 @@ class NewMessageActivity : SimpleActivity() {
|
||||||
private fun setupAdapter(contacts: ArrayList<Contact>) {
|
private fun setupAdapter(contacts: ArrayList<Contact>) {
|
||||||
ContactsAdapter(this, contacts, suggestions_list, null) {
|
ContactsAdapter(this, contacts, suggestions_list, null) {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
launchThreadActivity((it as Contact).phoneNumber, it.name)
|
|
||||||
|
val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: ""
|
||||||
|
launchThreadActivity((it as Contact).phoneNumber, it.name, text)
|
||||||
}.apply {
|
}.apply {
|
||||||
suggestions_list.adapter = this
|
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 {
|
Intent(this, ThreadActivity::class.java).apply {
|
||||||
putExtra(THREAD_ID, getThreadId(phoneNumber).toInt())
|
putExtra(THREAD_ID, getThreadId(phoneNumber).toInt())
|
||||||
putExtra(THREAD_TITLE, name)
|
putExtra(THREAD_TITLE, name)
|
||||||
|
putExtra(THREAD_TEXT, text)
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,6 +169,8 @@ class ThreadActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thread_type_message.setText(intent.getStringExtra(THREAD_TEXT))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun blockNumber() {
|
private fun blockNumber() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.greenrobot.eventbus.EventBus
|
||||||
|
|
||||||
const val THREAD_ID = "thread_id"
|
const val THREAD_ID = "thread_id"
|
||||||
const val THREAD_TITLE = "thread_title"
|
const val THREAD_TITLE = "thread_title"
|
||||||
|
const val THREAD_TEXT = "thread_text"
|
||||||
|
|
||||||
// view types for the thread list view
|
// view types for the thread list view
|
||||||
const val THREAD_DATE_TIME = 1
|
const val THREAD_DATE_TIME = 1
|
||||||
|
|
Loading…
Reference in New Issue