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() { private fun initOutgoingCall() {
try { try {
getHandleToUse(intent, callNumber.toString()) { handle -> getHandleToUse(intent, callNumber.toString()) { handle ->
Bundle().apply { if (handle != null) {
putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle) Bundle().apply {
putBoolean(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, false) putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle)
putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false) putBoolean(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, false)
telecomManager.placeCall(callNumber, this) putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false)
telecomManager.placeCall(callNumber, this)
}
} }
finish() finish()
} }

View File

@ -14,7 +14,7 @@ import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
import kotlinx.android.synthetic.main.dialog_select_sim.view.* import kotlinx.android.synthetic.main.dialog_select_sim.view.*
@SuppressLint("MissingPermission") @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 var dialog: AlertDialog? = null
private val view = activity.layoutInflater.inflate(R.layout.dialog_select_sim, 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) dialog = AlertDialog.Builder(activity)
.setOnCancelListener { callback.invoke(null) }
.create().apply { .create().apply {
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this)
} }

View File

@ -65,7 +65,7 @@ fun Activity.startContactDetailsIntent(contact: SimpleContact) {
// used at devices with multiple SIM cards // used at devices with multiple SIM cards
@SuppressLint("MissingPermission") @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) { handlePermission(PERMISSION_READ_PHONE_STATE) {
if (it) { if (it) {
val defaultHandle = telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL) val defaultHandle = telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL)