close the call screen if no SIM has been selected

This commit is contained in:
tibbi
2020-12-31 19:48:23 +01:00
parent a721ba7261
commit 76a6d9387c
3 changed files with 10 additions and 7 deletions

View File

@ -44,11 +44,13 @@ class DialerActivity : SimpleActivity() {
private fun initOutgoingCall() {
try {
getHandleToUse(intent, callNumber.toString()) { handle ->
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)
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()
}

View File

@ -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)
}

View File

@ -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)