Commit 52a43534 by zhangchengbo

fix:添加呼叫直接拨打电话

parent 9f95a89f
...@@ -43,6 +43,7 @@ import com.simplemobiletools.commons.dialogs.WritePermissionDialog.WritePermissi ...@@ -43,6 +43,7 @@ import com.simplemobiletools.commons.dialogs.WritePermissionDialog.WritePermissi
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.* import com.simplemobiletools.commons.models.*
import com.simplemobiletools.commons.views.MyTextView import com.simplemobiletools.commons.views.MyTextView
import freemarker.template.utility.Constants
import java.io.* import java.io.*
import java.util.TreeSet import java.util.TreeSet
...@@ -538,9 +539,7 @@ fun Activity.launchViewContactIntent(uri: Uri) { ...@@ -538,9 +539,7 @@ fun Activity.launchViewContactIntent(uri: Uri) {
} }
fun BaseSimpleActivity.launchCallIntent(recipient: String, handle: PhoneAccountHandle? = null) { fun BaseSimpleActivity.launchCallIntent(recipient: String, handle: PhoneAccountHandle? = null) {
handlePermission(PERMISSION_CALL_PHONE) { Intent(Intent.ACTION_CALL).apply {
val action = if (it) Intent.ACTION_CALL else Intent.ACTION_DIAL
Intent(action).apply {
this.data = Uri.fromParts("tel", recipient, null) this.data = Uri.fromParts("tel", recipient, null)
if (handle != null) { if (handle != null) {
...@@ -548,18 +547,18 @@ fun BaseSimpleActivity.launchCallIntent(recipient: String, handle: PhoneAccountH ...@@ -548,18 +547,18 @@ fun BaseSimpleActivity.launchCallIntent(recipient: String, handle: PhoneAccountH
} }
if (isDefaultDialer()) { if (isDefaultDialer()) {
val packageName = "com.secspace.dialer" val packageName = Const.PACKAGE_DIALER
val className = "com.secspace.dialer.activities.DialerActivity" val className = Const.PACKAGE_DIALER_ACTIVITY
this.setClassName(packageName, className) this.setClassName(packageName, className)
} }
launchActivityIntent(this) launchActivityIntent(this)
} }
}
} }
fun Activity.launchSendSMSIntent(recipient: String) { fun Activity.launchSendSMSIntent(recipient: String) {
Intent(Intent.ACTION_SENDTO).apply { Intent(Intent.ACTION_SENDTO).apply {
data = Uri.fromParts("smsto", recipient, null) data = Uri.fromParts("smsto", recipient, null)
putExtra(Const.THREAD_TITLE, recipient)
launchActivityIntent(this) launchActivityIntent(this)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment