mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-03-17 11:50:24 +01:00
allow sending messages to entries from the call log
This commit is contained in:
parent
f718704e5a
commit
e6cfa51519
app/src/main
@ -2,6 +2,7 @@ package com.simplemobiletools.dialer.adapters
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.provider.CallLog.Calls
|
||||
import android.text.TextUtils
|
||||
import android.util.TypedValue
|
||||
@ -55,6 +56,7 @@ class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<Re
|
||||
when (id) {
|
||||
R.id.cab_block_number -> askConfirmBlock()
|
||||
R.id.cab_add_number -> addNumberToContact()
|
||||
R.id.cab_send_sms -> sendSMS()
|
||||
R.id.cab_remove -> askConfirmRemove()
|
||||
}
|
||||
}
|
||||
@ -142,6 +144,23 @@ class RecentCallsAdapter(activity: SimpleActivity, var recentCalls: ArrayList<Re
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendSMS() {
|
||||
val numbers = getSelectedItems().map { it.phoneNumber }
|
||||
val numbersString = StringBuilder()
|
||||
numbers.forEach {
|
||||
numbersString.append("${Uri.encode(it)};")
|
||||
}
|
||||
|
||||
val uriString = "smsto:${numbersString.toString().trimEnd(';')}"
|
||||
Intent(Intent.ACTION_SENDTO, Uri.parse(uriString)).apply {
|
||||
if (resolveActivity(activity.packageManager) != null) {
|
||||
activity.startActivity(this)
|
||||
} else {
|
||||
activity.toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun askConfirmRemove() {
|
||||
ConfirmationDialog(activity, activity.getString(R.string.remove_confirmation)) {
|
||||
activity.handlePermission(PERMISSION_WRITE_CALL_LOG) {
|
||||
|
@ -13,6 +13,12 @@
|
||||
android:title="@string/block_number"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/cab_send_sms"
|
||||
android:icon="@drawable/ic_sms_vector"
|
||||
android:title="@string/send_sms"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/cab_remove"
|
||||
android:icon="@drawable/ic_delete_vector"
|
||||
|
Loading…
x
Reference in New Issue
Block a user