mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
make dialNumber callback nullable for easier reading
This commit is contained in:
@@ -34,10 +34,10 @@ import com.simplemobiletools.smsmessenger.interfaces.MessagesDao
|
|||||||
import com.simplemobiletools.smsmessenger.models.*
|
import com.simplemobiletools.smsmessenger.models.*
|
||||||
import com.simplemobiletools.smsmessenger.receivers.DirectReplyReceiver
|
import com.simplemobiletools.smsmessenger.receivers.DirectReplyReceiver
|
||||||
import com.simplemobiletools.smsmessenger.receivers.MarkAsReadReceiver
|
import com.simplemobiletools.smsmessenger.receivers.MarkAsReadReceiver
|
||||||
|
import me.leolin.shortcutbadger.ShortcutBadger
|
||||||
import java.io.FileNotFoundException
|
import java.io.FileNotFoundException
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
import me.leolin.shortcutbadger.ShortcutBadger
|
|
||||||
|
|
||||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||||
|
|
||||||
@@ -894,13 +894,13 @@ fun Context.getFileSizeFromUri(uri: Uri): Long {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.dialNumber(phoneNumber: String, callback: () -> Unit = fun() {}) {
|
fun Context.dialNumber(phoneNumber: String, callback: (() -> Unit)? = null) {
|
||||||
Intent(Intent.ACTION_DIAL).apply {
|
Intent(Intent.ACTION_DIAL).apply {
|
||||||
data = Uri.fromParts("tel", phoneNumber, null)
|
data = Uri.fromParts("tel", phoneNumber, null)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
callback()
|
callback?.invoke()
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
toast(R.string.no_app_found)
|
toast(R.string.no_app_found)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Reference in New Issue
Block a user