mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
close the call screen if no SIM has been selected
This commit is contained in:
@ -44,12 +44,14 @@ class DialerActivity : SimpleActivity() {
|
||||
private fun initOutgoingCall() {
|
||||
try {
|
||||
getHandleToUse(intent, callNumber.toString()) { handle ->
|
||||
if (handle != null) {
|
||||
Bundle().apply {
|
||||
putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle)
|
||||
putBoolean(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, false)
|
||||
putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false)
|
||||
telecomManager.placeCall(callNumber, this)
|
||||
}
|
||||
}
|
||||
finish()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
@ -14,7 +14,7 @@ import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
|
||||
import kotlinx.android.synthetic.main.dialog_select_sim.view.*
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
class SelectSIMDialog(val activity: BaseSimpleActivity, val phoneNumber: String, val callback: (handle: PhoneAccountHandle) -> Unit) {
|
||||
class SelectSIMDialog(val activity: BaseSimpleActivity, val phoneNumber: String, val callback: (handle: PhoneAccountHandle?) -> Unit) {
|
||||
private var dialog: AlertDialog? = null
|
||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_select_sim, null)
|
||||
|
||||
@ -31,6 +31,7 @@ class SelectSIMDialog(val activity: BaseSimpleActivity, val phoneNumber: String,
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.setOnCancelListener { callback.invoke(null) }
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ fun Activity.startContactDetailsIntent(contact: SimpleContact) {
|
||||
|
||||
// used at devices with multiple SIM cards
|
||||
@SuppressLint("MissingPermission")
|
||||
fun SimpleActivity.getHandleToUse(intent: Intent?, phoneNumber: String, callback: (handle: PhoneAccountHandle) -> Unit) {
|
||||
fun SimpleActivity.getHandleToUse(intent: Intent?, phoneNumber: String, callback: (handle: PhoneAccountHandle?) -> Unit) {
|
||||
handlePermission(PERMISSION_READ_PHONE_STATE) {
|
||||
if (it) {
|
||||
val defaultHandle = telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL)
|
||||
|
Reference in New Issue
Block a user