adding an initial implementation of the PhoneAccount picker
This commit is contained in:
parent
8fef03fa03
commit
f177cbd011
|
@ -57,7 +57,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.27.1'
|
||||
implementation 'com.simplemobiletools:commons:5.27.2'
|
||||
implementation 'joda-time:joda-time:2.10.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
|
||||
|
|
|
@ -16,11 +16,10 @@ import android.util.Size
|
|||
import android.view.WindowManager
|
||||
import android.widget.RemoteViews
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.MINUTE_SECONDS
|
||||
import com.simplemobiletools.commons.helpers.isOreoMr1Plus
|
||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||
import com.simplemobiletools.commons.helpers.isQPlus
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.contacts.pro.R
|
||||
import com.simplemobiletools.contacts.pro.extensions.audioManager
|
||||
import com.simplemobiletools.contacts.pro.extensions.config
|
||||
|
@ -163,6 +162,7 @@ class CallActivity : SimpleActivity() {
|
|||
Call.STATE_ACTIVE -> callStarted()
|
||||
Call.STATE_DISCONNECTED -> endCall()
|
||||
Call.STATE_CONNECTING -> initOutgoingCallUI()
|
||||
Call.STATE_SELECT_PHONE_ACCOUNT -> showPhoneAccountPicker()
|
||||
}
|
||||
|
||||
if (state == Call.STATE_DISCONNECTED || state == Call.STATE_DISCONNECTING) {
|
||||
|
@ -202,6 +202,31 @@ class CallActivity : SimpleActivity() {
|
|||
callTimer.scheduleAtFixedRate(getCallTimerUpdateTask(), 1000, 1000)
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun showPhoneAccountPicker() {
|
||||
if (!hasPermission(PERMISSION_READ_PHONE_STATE)) {
|
||||
return
|
||||
}
|
||||
|
||||
val items = ArrayList<RadioItem>()
|
||||
telecomManager.callCapablePhoneAccounts.forEachIndexed { index, account ->
|
||||
val phoneAccount = telecomManager.getPhoneAccount(account)
|
||||
var label = phoneAccount.label.toString()
|
||||
var address = phoneAccount.address.toString()
|
||||
if (address.startsWith("tel:") && address.substringAfter("tel:").isNotEmpty()) {
|
||||
address = Uri.decode(address.substringAfter("tel:"))
|
||||
label += " ($address)"
|
||||
}
|
||||
|
||||
val radioItem = RadioItem(index, label, phoneAccount.accountHandle)
|
||||
items.add(radioItem)
|
||||
}
|
||||
|
||||
RadioGroupDialog(this, items, titleId = R.string.select_sim) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun endCall() {
|
||||
CallManager.reject()
|
||||
if (proximityWakeLock?.isHeld == true) {
|
||||
|
|
Loading…
Reference in New Issue