diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1ed02cc9..b14e4553 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -5,18 +5,10 @@
package="com.simplemobiletools.contacts.pro"
android:installLocation="auto">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- callContact = contact
- callContactAvatar = getCallContactAvatar()
- runOnUiThread {
- setupNotification()
- updateOtherPersonsInfo()
- }
- }
-
- addLockScreenFlags()
- initProximitySensor()
-
- CallManager.registerCallback(callCallback)
- updateCallState(CallManager.getState())
- }
-
- override fun onDestroy() {
- super.onDestroy()
- notificationManager.cancel(CALL_NOTIFICATION_ID)
- CallManager.unregisterCallback(callCallback)
- callTimer.cancel()
- if (proximityWakeLock?.isHeld == true) {
- proximityWakeLock!!.release()
- }
-
- if (CallManager.getState() == Call.STATE_DIALING) {
- endCall()
- }
- }
-
- override fun onBackPressed() {
- if (dialpad_wrapper.isVisible()) {
- dialpad_wrapper.beGone()
- return
- } else {
- super.onBackPressed()
- }
-
- if (CallManager.getState() == Call.STATE_DIALING) {
- endCall()
- }
- }
-
- private fun initButtons() {
- call_decline.setOnClickListener {
- endCall()
- }
-
- call_accept.setOnClickListener {
- acceptCall()
- }
-
- call_toggle_microphone.setOnClickListener {
- toggleMicrophone()
- }
-
- call_toggle_speaker.setOnClickListener {
- toggleSpeaker()
- }
-
- call_dialpad.setOnClickListener {
- toggleDialpadVisibility()
- }
-
- dialpad_close.setOnClickListener {
- dialpad_wrapper.beGone()
- }
-
- call_end.setOnClickListener {
- endCall()
- }
-
- dialpad_0_holder.setOnClickListener { dialpadPressed('0') }
- dialpad_1.setOnClickListener { dialpadPressed('1') }
- dialpad_2.setOnClickListener { dialpadPressed('2') }
- dialpad_3.setOnClickListener { dialpadPressed('3') }
- dialpad_4.setOnClickListener { dialpadPressed('4') }
- dialpad_5.setOnClickListener { dialpadPressed('5') }
- dialpad_6.setOnClickListener { dialpadPressed('6') }
- dialpad_7.setOnClickListener { dialpadPressed('7') }
- dialpad_8.setOnClickListener { dialpadPressed('8') }
- dialpad_9.setOnClickListener { dialpadPressed('9') }
-
- dialpad_0_holder.setOnLongClickListener { dialpadPressed('+'); true }
- dialpad_asterisk.setOnClickListener { dialpadPressed('*') }
- dialpad_hashtag.setOnClickListener { dialpadPressed('#') }
-
- dialpad_wrapper.setBackgroundColor(config.backgroundColor)
- arrayOf(call_toggle_microphone, call_toggle_speaker, call_dialpad, dialpad_close).forEach {
- it.applyColorFilter(config.textColor)
- }
- }
-
- private fun dialpadPressed(char: Char) {
- CallManager.keypad(char)
- dialpad_input.addCharacter(char)
- }
-
- private fun toggleSpeaker() {
- isSpeakerOn = !isSpeakerOn
- val drawable = if (isSpeakerOn) R.drawable.ic_speaker_on_vector else R.drawable.ic_speaker_off_vector
- call_toggle_speaker.setImageDrawable(getDrawable(drawable))
- audioManager.isSpeakerphoneOn = isSpeakerOn
- }
-
- private fun toggleMicrophone() {
- isMicrophoneOn = !isMicrophoneOn
- val drawable = if (isMicrophoneOn) R.drawable.ic_microphone_vector else R.drawable.ic_microphone_off_vector
- call_toggle_microphone.setImageDrawable(getDrawable(drawable))
- audioManager.isMicrophoneMute = !isMicrophoneOn
- }
-
- private fun toggleDialpadVisibility() {
- if (dialpad_wrapper.isVisible()) {
- dialpad_wrapper.beGone()
- } else {
- dialpad_wrapper.beVisible()
- }
- }
-
- private fun updateOtherPersonsInfo() {
- if (callContact == null) {
- return
- }
-
- caller_name_label.text = if (callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
-
- if (callContactAvatar != null) {
- caller_avatar.setImageBitmap(callContactAvatar)
- }
- }
-
- private fun updateCallState(state: Int) {
- when (state) {
- Call.STATE_RINGING -> callRinging()
- Call.STATE_ACTIVE -> callStarted()
- Call.STATE_DISCONNECTED -> endCall()
- Call.STATE_CONNECTING, Call.STATE_DIALING -> initOutgoingCallUI()
- Call.STATE_SELECT_PHONE_ACCOUNT -> showPhoneAccountPicker()
- }
-
- if (state == Call.STATE_DISCONNECTED || state == Call.STATE_DISCONNECTING) {
- callTimer.cancel()
- }
-
- val statusTextId = when (state) {
- Call.STATE_RINGING -> R.string.is_calling
- Call.STATE_DIALING -> R.string.dialing
- else -> 0
- }
-
- if (statusTextId != 0) {
- call_status_label.text = getString(statusTextId)
- }
-
- setupNotification()
- }
-
- private fun acceptCall() {
- CallManager.accept()
- }
-
- private fun initOutgoingCallUI() {
- incoming_call_holder.beGone()
- ongoing_call_holder.beVisible()
- }
-
- private fun callRinging() {
- incoming_call_holder.beVisible()
- }
-
- private fun callStarted() {
- incoming_call_holder.beGone()
- ongoing_call_holder.beVisible()
- callTimer.scheduleAtFixedRate(getCallTimerUpdateTask(), 1000, 1000)
- }
-
- private fun showPhoneAccountPicker() {
- if (callContact == null || callContact!!.number.isEmpty()) {
- toast(R.string.unknown_error_occurred)
- } else {
- startCallIntent(callContact!!.number)
- }
- }
-
- private fun endCall() {
- CallManager.reject()
- if (proximityWakeLock?.isHeld == true) {
- proximityWakeLock!!.release()
- }
-
- audioManager.mode = AudioManager.MODE_NORMAL
- if (isCallEnded) {
- finish()
- return
- }
-
- isCallEnded = true
- if (callDuration > 0) {
- runOnUiThread {
- call_status_label.text = "${callDuration.getFormattedDuration()} (${getString(R.string.call_ended)})"
- Handler().postDelayed({
- finish()
- }, 3000)
- }
- } else {
- call_status_label.text = getString(R.string.call_ended)
- finish()
- }
- }
-
- private fun getCallTimerUpdateTask() = object : TimerTask() {
- override fun run() {
- callDuration++
- runOnUiThread {
- if (!isCallEnded) {
- call_status_label.text = callDuration.getFormattedDuration()
- }
- }
- }
- }
-
- @SuppressLint("NewApi")
- private val callCallback = object : Call.Callback() {
- override fun onStateChanged(call: Call, state: Int) {
- super.onStateChanged(call, state)
- updateCallState(state)
- }
- }
-
- @SuppressLint("NewApi")
- private fun addLockScreenFlags() {
- if (isOreoMr1Plus()) {
- setShowWhenLocked(true)
- setTurnScreenOn(true)
- } else {
- window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
- }
-
- if (isOreoPlus()) {
- (getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager).requestDismissKeyguard(this, null)
- } else {
- window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD)
- }
- }
-
- private fun initProximitySensor() {
- val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
- proximityWakeLock = powerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "com.simplemobiletools.contacts.pro:wake_lock")
- proximityWakeLock!!.acquire(10 * MINUTE_SECONDS * 1000L)
- }
-
- @SuppressLint("NewApi")
- private fun setupNotification() {
- val callState = CallManager.getState()
- val channelId = "simple_contacts_call"
- if (isOreoPlus()) {
- val importance = NotificationManager.IMPORTANCE_DEFAULT
- val name = "call_notification_channel"
-
- NotificationChannel(channelId, name, importance).apply {
- setSound(null, null)
- notificationManager.createNotificationChannel(this)
- }
- }
-
- val openAppIntent = Intent(this, CallActivity::class.java)
- openAppIntent.flags = Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
- val openAppPendingIntent = PendingIntent.getActivity(this, 0, openAppIntent, 0)
-
- val acceptCallIntent = Intent(this, CallActionReceiver::class.java)
- acceptCallIntent.action = ACCEPT_CALL
- val acceptPendingIntent = PendingIntent.getBroadcast(this, 0, acceptCallIntent, PendingIntent.FLAG_CANCEL_CURRENT)
-
- val declineCallIntent = Intent(this, CallActionReceiver::class.java)
- declineCallIntent.action = DECLINE_CALL
- val declinePendingIntent = PendingIntent.getBroadcast(this, 1, declineCallIntent, PendingIntent.FLAG_CANCEL_CURRENT)
-
- val callerName = if (callContact != null && callContact!!.name.isNotEmpty()) callContact!!.name else getString(R.string.unknown_caller)
- val contentTextId = when (callState) {
- Call.STATE_RINGING -> R.string.is_calling
- Call.STATE_DIALING -> R.string.dialing
- Call.STATE_DISCONNECTED -> R.string.call_ended
- Call.STATE_DISCONNECTING -> R.string.call_ending
- else -> R.string.ongoing_call
- }
-
- val collapsedView = RemoteViews(packageName, R.layout.call_notification).apply {
- setText(R.id.notification_caller_name, callerName)
- setText(R.id.notification_call_status, getString(contentTextId))
- setVisibleIf(R.id.notification_accept_call, callState == Call.STATE_RINGING)
-
- setOnClickPendingIntent(R.id.notification_decline_call, declinePendingIntent)
- setOnClickPendingIntent(R.id.notification_accept_call, acceptPendingIntent)
-
- if (callContactAvatar != null) {
- setImageViewBitmap(R.id.notification_thumbnail, getCircularBitmap(callContactAvatar!!))
- }
- }
-
- val builder = NotificationCompat.Builder(this, channelId)
- .setSmallIcon(R.drawable.ic_phone_vector)
- .setContentIntent(openAppPendingIntent)
- .setPriority(NotificationCompat.PRIORITY_DEFAULT)
- .setCategory(Notification.CATEGORY_CALL)
- .setCustomContentView(collapsedView)
- .setOngoing(true)
- .setSound(null)
- .setUsesChronometer(callState == Call.STATE_ACTIVE)
- .setChannelId(channelId)
- .setStyle(NotificationCompat.DecoratedCustomViewStyle())
-
- val notification = builder.build()
- notificationManager.notify(CALL_NOTIFICATION_ID, notification)
- }
-
- @SuppressLint("NewApi")
- private fun getCallContactAvatar(): Bitmap? {
- var bitmap: Bitmap? = null
- if (callContact?.photoUri?.isNotEmpty() == true) {
- val photoUri = Uri.parse(callContact!!.photoUri)
- bitmap = if (isQPlus()) {
- val tmbSize = resources.getDimension(R.dimen.contact_icons_size).toInt()
- contentResolver.loadThumbnail(photoUri, Size(tmbSize, tmbSize), null)
- } else {
- MediaStore.Images.Media.getBitmap(contentResolver, photoUri)
- }
-
- bitmap = getCircularBitmap(bitmap!!)
- }
-
- return bitmap
- }
-
- private fun getCircularBitmap(bitmap: Bitmap): Bitmap {
- val output = Bitmap.createBitmap(bitmap.width, bitmap.width, Bitmap.Config.ARGB_8888)
- val canvas = Canvas(output)
- val paint = Paint()
- val rect = Rect(0, 0, bitmap.width, bitmap.height)
- val radius = bitmap.width / 2.toFloat()
-
- paint.isAntiAlias = true
- canvas.drawARGB(0, 0, 0, 0)
- canvas.drawCircle(radius, radius, radius, paint)
- paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN)
- canvas.drawBitmap(bitmap, rect, rect, paint)
- return output
- }
-}
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/DialerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/DialerActivity.kt
deleted file mode 100644
index 7d3b1a78..00000000
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/DialerActivity.kt
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.simplemobiletools.contacts.pro.activities
-
-import android.annotation.SuppressLint
-import android.content.Intent
-import android.net.Uri
-import android.os.Bundle
-import android.telecom.TelecomManager
-import android.view.Menu
-import com.simplemobiletools.commons.extensions.isDefaultDialer
-import com.simplemobiletools.commons.extensions.showErrorToast
-import com.simplemobiletools.commons.extensions.telecomManager
-import com.simplemobiletools.commons.extensions.toast
-import com.simplemobiletools.commons.helpers.REQUEST_CODE_SET_DEFAULT_DIALER
-import com.simplemobiletools.contacts.pro.R
-import com.simplemobiletools.contacts.pro.extensions.getHandleToUse
-
-class DialerActivity : SimpleActivity() {
- private var callNumber: Uri? = null
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
-
- if (intent.action == Intent.ACTION_CALL && intent.data != null) {
- callNumber = intent.data
-
- // make sure Simple Contacts is the default Phone app before initiating an outgoing call
- if (!isDefaultDialer()) {
- launchSetDefaultDialerIntent()
- } else {
- initOutgoingCall()
- }
- } else {
- toast(R.string.unknown_error_occurred)
- finish()
- }
- }
-
- override fun onCreateOptionsMenu(menu: Menu): Boolean {
- updateMenuItemColors(menu)
- return super.onCreateOptionsMenu(menu)
- }
-
- @SuppressLint("MissingPermission")
- private fun initOutgoingCall() {
- try {
- getHandleToUse(intent, callNumber.toString()) { handle ->
- Bundle().apply {
- putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle)
- putBoolean(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, false)
- putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false)
- telecomManager.placeCall(callNumber, this)
- }
- finish()
- }
- } catch (e: Exception) {
- showErrorToast(e)
- finish()
- }
- }
-
- override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
- super.onActivityResult(requestCode, resultCode, resultData)
- if (requestCode == REQUEST_CODE_SET_DEFAULT_DIALER) {
- if (!isDefaultDialer()) {
- finish()
- } else {
- initOutgoingCall()
- }
- }
- }
-}
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/SelectSIMDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/SelectSIMDialog.kt
deleted file mode 100644
index c621ceae..00000000
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/SelectSIMDialog.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.simplemobiletools.contacts.pro.dialogs
-
-import android.annotation.SuppressLint
-import android.telecom.PhoneAccountHandle
-import android.view.ViewGroup
-import android.widget.RadioButton
-import android.widget.RadioGroup
-import androidx.appcompat.app.AlertDialog
-import com.simplemobiletools.commons.activities.BaseSimpleActivity
-import com.simplemobiletools.commons.extensions.setupDialogStuff
-import com.simplemobiletools.contacts.pro.R
-import com.simplemobiletools.contacts.pro.extensions.config
-import com.simplemobiletools.contacts.pro.extensions.getAvailableSIMCardLabels
-import kotlinx.android.synthetic.main.dialog_select_sim.view.*
-
-@SuppressLint("MissingPermission")
-class SelectSIMDialog(val activity: BaseSimpleActivity, val phoneNumber: String, val callback: (handle: PhoneAccountHandle) -> Unit) {
- private var dialog: AlertDialog? = null
- private val view = activity.layoutInflater.inflate(R.layout.dialog_select_sim, null)
-
- init {
- val radioGroup = view.select_sim_radio_group
-
- activity.getAvailableSIMCardLabels().forEachIndexed { index, SIMAccount ->
- val radioButton = (activity.layoutInflater.inflate(R.layout.radio_button, null) as RadioButton).apply {
- text = SIMAccount.label
- id = index
- setOnClickListener { selectedSIM(SIMAccount.handle, SIMAccount.label) }
- }
- radioGroup!!.addView(radioButton, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
- }
-
- dialog = AlertDialog.Builder(activity)
- .create().apply {
- activity.setupDialogStuff(view, this)
- }
- }
-
- private fun selectedSIM(handle: PhoneAccountHandle, label: String) {
- if (view.select_sim_remember.isChecked) {
- activity.config.saveCustomSIM(phoneNumber, label)
- }
-
- callback(handle)
- dialog?.dismiss()
- }
-}
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt
index 6c9943ec..95a1155a 100644
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt
@@ -1,32 +1,18 @@
package com.simplemobiletools.contacts.pro.extensions
-import android.annotation.SuppressLint
-import android.content.Intent
-import android.net.Uri
-import android.telecom.PhoneAccount
-import android.telecom.PhoneAccountHandle
-import android.telecom.TelecomManager
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
-import com.simplemobiletools.commons.helpers.PERMISSION_READ_PHONE_STATE
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.contacts.pro.BuildConfig
import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
import com.simplemobiletools.contacts.pro.dialogs.CallConfirmationDialog
-import com.simplemobiletools.contacts.pro.dialogs.SelectSIMDialog
import com.simplemobiletools.contacts.pro.helpers.*
import com.simplemobiletools.contacts.pro.models.Contact
fun SimpleActivity.startCallIntent(recipient: String) {
- if (isDefaultDialer()) {
- getHandleToUse(null, recipient) { handle ->
- launchCallIntent(recipient, handle)
- }
- } else {
- launchCallIntent(recipient, null)
- }
+ launchCallIntent(recipient, null)
}
fun SimpleActivity.tryStartCall(contact: Contact) {
@@ -110,28 +96,3 @@ fun SimpleActivity.callContact(contact: Contact) {
toast(R.string.no_phone_number_found)
}
}
-
-// used at devices with multiple SIM cards
-@SuppressLint("MissingPermission")
-fun SimpleActivity.getHandleToUse(intent: Intent?, phoneNumber: String, callback: (PhoneAccountHandle) -> Unit) {
- handlePermission(PERMISSION_READ_PHONE_STATE) {
- if (it) {
- val defaultHandle = telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL)
- when {
- intent?.hasExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE) == true -> callback(intent.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE)!!)
- config.getCustomSIM(phoneNumber)?.isNotEmpty() == true -> {
- val storedLabel = Uri.decode(config.getCustomSIM(phoneNumber))
- val availableSIMs = getAvailableSIMCardLabels()
- val firstornull = availableSIMs.firstOrNull { it.label == storedLabel }?.handle ?: availableSIMs.first().handle
- callback(firstornull)
- }
- defaultHandle != null -> callback(defaultHandle)
- else -> {
- SelectSIMDialog(this, phoneNumber) { handle ->
- callback(handle)
- }
- }
- }
- }
- }
-}
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt
index edefd50a..adddf766 100644
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt
@@ -1,6 +1,5 @@
package com.simplemobiletools.contacts.pro.extensions
-import android.annotation.SuppressLint
import android.content.Context
import android.content.Context.AUDIO_SERVICE
import android.content.Intent
@@ -13,7 +12,6 @@ import android.provider.ContactsContract
import androidx.core.content.FileProvider
import com.simplemobiletools.commons.extensions.getIntValue
import com.simplemobiletools.commons.extensions.hasPermission
-import com.simplemobiletools.commons.extensions.telecomManager
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CONTACTS
@@ -29,7 +27,6 @@ import com.simplemobiletools.contacts.pro.interfaces.GroupsDao
import com.simplemobiletools.contacts.pro.models.Contact
import com.simplemobiletools.contacts.pro.models.ContactSource
import com.simplemobiletools.contacts.pro.models.Organization
-import com.simplemobiletools.contacts.pro.models.SIMAccount
import java.io.File
val Context.config: Config get() = Config.newInstance(applicationContext)
@@ -330,20 +327,3 @@ fun Context.getAllContactSources(): ArrayList {
}
fun Context.getPrivateContactSource() = ContactSource(SMT_PRIVATE, SMT_PRIVATE, getString(R.string.phone_storage_hidden))
-
-@SuppressLint("MissingPermission")
-fun Context.getAvailableSIMCardLabels(): ArrayList {
- val SIMAccounts = ArrayList()
- telecomManager.callCapablePhoneAccounts.forEach { 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 SIM = SIMAccount(phoneAccount.accountHandle, label)
- SIMAccounts.add(SIM)
- }
- return SIMAccounts
-}
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/CallManager.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/CallManager.kt
deleted file mode 100644
index 5c26710d..00000000
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/CallManager.kt
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.simplemobiletools.contacts.pro.helpers
-
-import android.annotation.SuppressLint
-import android.content.Context
-import android.net.Uri
-import android.telecom.Call
-import android.telecom.VideoProfile
-import com.simplemobiletools.commons.helpers.SimpleContactsHelper
-import com.simplemobiletools.commons.helpers.ensureBackgroundThread
-import com.simplemobiletools.contacts.pro.extensions.contactsDB
-import com.simplemobiletools.contacts.pro.models.CallContact
-
-// inspired by https://github.com/Chooloo/call_manage
-@SuppressLint("NewApi")
-class CallManager {
- companion object {
- var call: Call? = null
-
- fun accept() {
- call?.answer(VideoProfile.STATE_AUDIO_ONLY)
- }
-
- fun reject() {
- if (call != null) {
- if (call!!.state == Call.STATE_RINGING) {
- call!!.reject(false, null)
- } else {
- call!!.disconnect()
- }
- }
- }
-
- fun registerCallback(callback: Call.Callback) {
- if (call != null) {
- call!!.registerCallback(callback)
- }
- }
-
- fun unregisterCallback(callback: Call.Callback) {
- call?.unregisterCallback(callback)
- }
-
- fun getState() = if (call == null) {
- Call.STATE_DISCONNECTED
- } else {
- call!!.state
- }
-
- fun keypad(c: Char) {
- call?.playDtmfTone(c)
- call?.stopDtmfTone()
- }
-
- fun getCallContact(context: Context, callback: (CallContact?) -> Unit) {
- val callContact = CallContact("", "", "")
- if (call == null || call!!.details == null || call!!.details!!.handle == null) {
- callback(callContact)
- return
- }
-
- val uri = Uri.decode(call!!.details.handle.toString())
- if (uri.startsWith("tel:")) {
- val number = uri.substringAfter("tel:")
- callContact.number = number
- callContact.name = SimpleContactsHelper(context).getNameFromPhoneNumber(number)
- callContact.photoUri = SimpleContactsHelper(context).getPhotoUriFromPhoneNumber(number)
-
- if (callContact.name == callContact.number) {
- ensureBackgroundThread {
- val localContact = context.contactsDB.getContactWithNumber("%$number%")
- if (localContact != null) {
- val storedGroups = ContactsHelper(context).getStoredGroupsSync()
- val newContact = LocalContactsHelper(context).convertLocalContactToContact(localContact, storedGroups)
- callContact.name = newContact!!.getNameToDisplay()
- callContact.photoUri = newContact.photoUri
- }
-
- callback(callContact)
- }
- } else {
- callback(callContact)
- }
- }
- }
- }
-}
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/Constants.kt
index a7020b61..358c8d48 100644
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/Constants.kt
@@ -35,10 +35,6 @@ const val ADD_NEW_CONTACT_NUMBER = "add_new_contact_number"
const val FIRST_CONTACT_ID = 1000000
const val FIRST_GROUP_ID = 10000L
-private const val PATH = "com.simplemobiletools.contacts.action."
-const val ACCEPT_CALL = PATH + "accept_call"
-const val DECLINE_CALL = PATH + "decline_call"
-
// extras used at third party intents
const val KEY_NAME = "name"
const val KEY_EMAIL = "email"
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/models/SIMAccount.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/models/SIMAccount.kt
deleted file mode 100644
index aca810f4..00000000
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/models/SIMAccount.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.simplemobiletools.contacts.pro.models
-
-import android.telecom.PhoneAccountHandle
-
-data class SIMAccount(val handle: PhoneAccountHandle, val label: String)
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/receivers/CallActionReceiver.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/receivers/CallActionReceiver.kt
deleted file mode 100644
index 9ae27eb3..00000000
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/receivers/CallActionReceiver.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.simplemobiletools.contacts.pro.receivers
-
-import android.content.BroadcastReceiver
-import android.content.Context
-import android.content.Intent
-import com.simplemobiletools.contacts.pro.helpers.ACCEPT_CALL
-import com.simplemobiletools.contacts.pro.helpers.CallManager
-import com.simplemobiletools.contacts.pro.helpers.DECLINE_CALL
-
-class CallActionReceiver : BroadcastReceiver() {
- override fun onReceive(context: Context, intent: Intent) {
- when (intent.action) {
- ACCEPT_CALL -> CallManager.accept()
- DECLINE_CALL -> CallManager.reject()
- }
- }
-}
diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/CallService.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/CallService.kt
deleted file mode 100644
index 644628ee..00000000
--- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/services/CallService.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.simplemobiletools.contacts.pro.services
-
-import android.content.Intent
-import android.telecom.Call
-import android.telecom.InCallService
-import com.simplemobiletools.contacts.pro.activities.CallActivity
-import com.simplemobiletools.contacts.pro.helpers.CallManager
-
-class CallService : InCallService() {
- override fun onCallAdded(call: Call) {
- super.onCallAdded(call)
- val intent = Intent(this, CallActivity::class.java)
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- startActivity(intent)
- CallManager.call = call
- }
-
- override fun onCallRemoved(call: Call) {
- super.onCallRemoved(call)
- CallManager.call = null
- }
-}
diff --git a/app/src/main/res/layout/activity_call.xml b/app/src/main/res/layout/activity_call.xml
deleted file mode 100644
index 644dd093..00000000
--- a/app/src/main/res/layout/activity_call.xml
+++ /dev/null
@@ -1,202 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/call_notification.xml b/app/src/main/res/layout/call_notification.xml
deleted file mode 100644
index 94a5b06b..00000000
--- a/app/src/main/res/layout/call_notification.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/dialog_select_sim.xml b/app/src/main/res/layout/dialog_select_sim.xml
deleted file mode 100644
index 6c51bb4b..00000000
--- a/app/src/main/res/layout/dialog_select_sim.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/dialpad.xml b/app/src/main/res/layout/dialpad.xml
deleted file mode 100644
index e6235d65..00000000
--- a/app/src/main/res/layout/dialpad.xml
+++ /dev/null
@@ -1,269 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-