mirror of
				https://github.com/SimpleMobileTools/Simple-Contacts.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	handle the SIM picking before calling only if this is the default dialer app
This commit is contained in:
		| @@ -21,12 +21,25 @@ import com.simplemobiletools.contacts.pro.helpers.* | |||||||
| import com.simplemobiletools.contacts.pro.models.Contact | import com.simplemobiletools.contacts.pro.models.Contact | ||||||
|  |  | ||||||
| fun SimpleActivity.startCallIntent(recipient: String) { | fun SimpleActivity.startCallIntent(recipient: String) { | ||||||
|  |     if (isDefaultDialer()) { | ||||||
|  |         getHandleToUse(null, recipient) { handle -> | ||||||
|  |             launchCallIntent(recipient, handle) | ||||||
|  |         } | ||||||
|  |     } else { | ||||||
|  |         launchCallIntent(recipient, null) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | fun SimpleActivity.launchCallIntent(recipient: String, handle: PhoneAccountHandle?) { | ||||||
|     handlePermission(PERMISSION_CALL_PHONE) { |     handlePermission(PERMISSION_CALL_PHONE) { | ||||||
|         val action = if (it) Intent.ACTION_CALL else Intent.ACTION_DIAL |         val action = if (it) Intent.ACTION_CALL else Intent.ACTION_DIAL | ||||||
|         getHandleToUse(null, recipient) { handle -> |  | ||||||
|         Intent(action).apply { |         Intent(action).apply { | ||||||
|             data = Uri.fromParts("tel", recipient, null) |             data = Uri.fromParts("tel", recipient, null) | ||||||
|  |  | ||||||
|  |             if (handle != null) { | ||||||
|                 putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle) |                 putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle) | ||||||
|  |             } | ||||||
|  |  | ||||||
|             if (resolveActivity(packageManager) != null) { |             if (resolveActivity(packageManager) != null) { | ||||||
|                 startActivity(this) |                 startActivity(this) | ||||||
|             } else { |             } else { | ||||||
| @@ -35,7 +48,6 @@ fun SimpleActivity.startCallIntent(recipient: String) { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| } |  | ||||||
|  |  | ||||||
| fun SimpleActivity.tryStartCall(contact: Contact) { | fun SimpleActivity.tryStartCall(contact: Contact) { | ||||||
|     if (config.showCallConfirmation) { |     if (config.showCallConfirmation) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user