mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-03-09 16:10:25 +01:00
Dialing number refactor
This commit is contained in:
parent
41114e5f2c
commit
44547b05d0
@ -493,17 +493,7 @@ class ThreadActivity : SimpleActivity() {
|
||||
|
||||
private fun dialNumber() {
|
||||
val phoneNumber = participants.first().phoneNumbers.first()
|
||||
Intent(Intent.ACTION_DIAL).apply {
|
||||
data = Uri.fromParts("tel", phoneNumber, null)
|
||||
|
||||
try {
|
||||
startActivity(this)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
toast(R.string.no_app_found)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
dialNumber(phoneNumber)
|
||||
}
|
||||
|
||||
private fun managePeople() {
|
||||
|
@ -129,18 +129,7 @@ class ConversationsAdapter(
|
||||
|
||||
private fun dialNumber() {
|
||||
val conversation = getSelectedItems().firstOrNull() ?: return
|
||||
Intent(Intent.ACTION_DIAL).apply {
|
||||
data = Uri.fromParts("tel", conversation.phoneNumber, null)
|
||||
|
||||
try {
|
||||
activity.startActivity(this)
|
||||
finishActMode()
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
activity.toast(R.string.no_app_found)
|
||||
} catch (e: Exception) {
|
||||
activity.showErrorToast(e)
|
||||
}
|
||||
}
|
||||
activity.dialNumber(conversation.phoneNumber) { finishActMode() }
|
||||
}
|
||||
|
||||
private fun copyNumberToClipboard() {
|
||||
|
@ -5,10 +5,7 @@ import android.app.Notification
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.ContentResolver
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.*
|
||||
import android.database.Cursor
|
||||
import android.graphics.Bitmap
|
||||
import android.media.AudioAttributes
|
||||
@ -40,7 +37,6 @@ import com.simplemobiletools.smsmessenger.receivers.MarkAsReadReceiver
|
||||
import java.io.FileNotFoundException
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import java.text.Normalizer
|
||||
import me.leolin.shortcutbadger.ShortcutBadger
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
@ -897,3 +893,18 @@ fun Context.getFileSizeFromUri(uri: Uri): Long {
|
||||
return FILE_SIZE_NONE
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.dialNumber(phoneNumber: String, callback: () -> Unit = fun() {}) {
|
||||
Intent(Intent.ACTION_DIAL).apply {
|
||||
data = Uri.fromParts("tel", phoneNumber, null)
|
||||
|
||||
try {
|
||||
startActivity(this)
|
||||
callback()
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
toast(R.string.no_app_found)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user