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,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()
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
Reference in New Issue
Block a user