feat: call directly instead of launching dialpad (#563)
Refs: https://github.com/FossifyOrg/Messages/issues/562
This commit is contained in:
parent
9773ccb82b
commit
f3408f1f9a
3 changed files with 20 additions and 11 deletions
|
|
@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Changed
|
||||
- Calling now works directly without launching dialpad ([#562])
|
||||
|
||||
## [1.5.0] - 2025-10-18
|
||||
### Added
|
||||
|
|
@ -187,7 +189,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
[#376]: https://github.com/FossifyOrg/Messages/issues/376
|
||||
[#456]: https://github.com/FossifyOrg/Messages/issues/456
|
||||
[#461]: https://github.com/FossifyOrg/Messages/issues/461
|
||||
[#561]: https://github.com/FossifyOrg/Messages/issues/561
|
||||
[#561]: https://github.com/FossifyOrg/Messages/pull/561
|
||||
[#562]: https://github.com/FossifyOrg/Messages/issues/562
|
||||
|
||||
[Unreleased]: https://github.com/FossifyOrg/Messages/compare/1.5.0...HEAD
|
||||
[1.5.0]: https://github.com/FossifyOrg/Messages/compare/1.4.0...1.5.0
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.content.ActivityNotFoundException
|
|||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.provider.ContactsContract
|
||||
import org.fossify.commons.activities.BaseSimpleActivity
|
||||
import org.fossify.commons.extensions.getMimeType
|
||||
import org.fossify.commons.extensions.hideKeyboard
|
||||
import org.fossify.commons.extensions.isPackageInstalled
|
||||
|
|
@ -14,6 +15,7 @@ import org.fossify.commons.extensions.showErrorToast
|
|||
import org.fossify.commons.extensions.toast
|
||||
import org.fossify.commons.helpers.CONTACT_ID
|
||||
import org.fossify.commons.helpers.IS_PRIVATE
|
||||
import org.fossify.commons.helpers.PERMISSION_CALL_PHONE
|
||||
import org.fossify.commons.helpers.SimpleContactsHelper
|
||||
import org.fossify.commons.helpers.ensureBackgroundThread
|
||||
import org.fossify.commons.models.SimpleContact
|
||||
|
|
@ -21,18 +23,21 @@ import org.fossify.messages.activities.ConversationDetailsActivity
|
|||
import org.fossify.messages.helpers.THREAD_ID
|
||||
import java.util.Locale
|
||||
|
||||
fun Activity.dialNumber(phoneNumber: String, callback: (() -> Unit)? = null) {
|
||||
fun BaseSimpleActivity.dialNumber(phoneNumber: String, callback: (() -> Unit)? = null) {
|
||||
hideKeyboard()
|
||||
Intent(Intent.ACTION_DIAL).apply {
|
||||
data = Uri.fromParts("tel", phoneNumber, null)
|
||||
handlePermission(PERMISSION_CALL_PHONE) {
|
||||
val action = if (it) Intent.ACTION_CALL else Intent.ACTION_DIAL
|
||||
Intent(action).apply {
|
||||
data = Uri.fromParts("tel", phoneNumber, null)
|
||||
|
||||
try {
|
||||
startActivity(this)
|
||||
callback?.invoke()
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
toast(org.fossify.commons.R.string.no_app_found)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
try {
|
||||
startActivity(this)
|
||||
callback?.invoke()
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
toast(org.fossify.commons.R.string.no_app_found)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue