mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-04-03 13:01:49 +02:00
feat: use a shared contact helper from commons.
This commit is contained in:
parent
d4e8999242
commit
107947ffe1
@ -21,6 +21,7 @@
|
|||||||
<uses-permission android:name="android.telecom.action.CONFIGURE_PHONE_ACCOUNT" />
|
<uses-permission android:name="android.telecom.action.CONFIGURE_PHONE_ACCOUNT" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
|
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||||
|
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
|
@ -22,7 +22,7 @@ import androidx.core.view.isVisible
|
|||||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||||
import com.simplemobiletools.dialer.extensions.*
|
import com.simplemobiletools.dialer.extensions.*
|
||||||
@ -36,7 +36,7 @@ import java.util.*
|
|||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class DialpadActivity : SimpleActivity() {
|
class DialpadActivity : SimpleActivity() {
|
||||||
private var allContacts = ArrayList<SimpleContact>()
|
private var allContacts = ArrayList<Contact>()
|
||||||
private var speedDialValues = ArrayList<SpeedDial>()
|
private var speedDialValues = ArrayList<SpeedDial>()
|
||||||
private val russianCharsMap = HashMap<Char, Int>()
|
private val russianCharsMap = HashMap<Char, Int>()
|
||||||
private var hasRussianLocale = false
|
private var hasRussianLocale = false
|
||||||
@ -138,7 +138,7 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
dialpad_input.onTextChangeListener { dialpadValueChanged(it) }
|
dialpad_input.onTextChangeListener { dialpadValueChanged(it) }
|
||||||
dialpad_input.requestFocus()
|
dialpad_input.requestFocus()
|
||||||
|
|
||||||
SimpleContactsHelper(this).getAvailableContacts(false) { gotContacts(it) }
|
ContactsHelper(this).getContacts{ gotContacts(it) }
|
||||||
dialpad_input.disableKeyboard()
|
dialpad_input.disableKeyboard()
|
||||||
|
|
||||||
val properPrimaryColor = getProperPrimaryColor()
|
val properPrimaryColor = getProperPrimaryColor()
|
||||||
@ -219,10 +219,10 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
dialpad_input.setText("")
|
dialpad_input.setText("")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotContacts(newContacts: ArrayList<SimpleContact>) {
|
private fun gotContacts(newContacts: ArrayList<Contact>) {
|
||||||
allContacts = newContacts
|
allContacts = newContacts
|
||||||
|
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
val privateContacts = MyContactsContentProvider.getContacts(this, privateCursor)
|
||||||
if (privateContacts.isNotEmpty()) {
|
if (privateContacts.isNotEmpty()) {
|
||||||
allContacts.addAll(privateContacts)
|
allContacts.addAll(privateContacts)
|
||||||
allContacts.sort()
|
allContacts.sort()
|
||||||
@ -270,7 +270,7 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
it.doesContainPhoneNumber(text) || (convertedName.contains(text, true))
|
it.doesContainPhoneNumber(text) || (convertedName.contains(text, true))
|
||||||
}.sortedWith(compareBy {
|
}.sortedWith(compareBy {
|
||||||
!it.doesContainPhoneNumber(text)
|
!it.doesContainPhoneNumber(text)
|
||||||
}).toMutableList() as ArrayList<SimpleContact>
|
}).toMutableList() as ArrayList<Contact>
|
||||||
|
|
||||||
letter_fastscroller.setupWithRecyclerView(dialpad_list, { position ->
|
letter_fastscroller.setupWithRecyclerView(dialpad_list, { position ->
|
||||||
try {
|
try {
|
||||||
@ -283,7 +283,7 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ContactsAdapter(this, filtered, dialpad_list, null, text) {
|
ContactsAdapter(this, filtered, dialpad_list, null, text) {
|
||||||
startCallIntent((it as SimpleContact).phoneNumbers.first().normalizedNumber)
|
startCallIntent((it as Contact).phoneNumbers.first().normalizedNumber)
|
||||||
}.apply {
|
}.apply {
|
||||||
dialpad_list.adapter = this
|
dialpad_list.adapter = this
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
|||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.FAQItem
|
import com.simplemobiletools.commons.models.FAQItem
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.dialer.BuildConfig
|
import com.simplemobiletools.dialer.BuildConfig
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.adapters.ViewPagerAdapter
|
import com.simplemobiletools.dialer.adapters.ViewPagerAdapter
|
||||||
@ -41,7 +41,7 @@ import me.grantland.widget.AutofitHelper
|
|||||||
class MainActivity : SimpleActivity() {
|
class MainActivity : SimpleActivity() {
|
||||||
private var launchedDialer = false
|
private var launchedDialer = false
|
||||||
private var storedShowTabs = 0
|
private var storedShowTabs = 0
|
||||||
var cachedContacts = ArrayList<SimpleContact>()
|
var cachedContacts = ArrayList<Contact>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
@ -83,7 +83,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupTabs()
|
setupTabs()
|
||||||
SimpleContact.sorting = config.sorting
|
Contact.sorting = config.sorting
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
@ -520,7 +520,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cacheContacts(contacts: List<SimpleContact>) {
|
fun cacheContacts(contacts: List<Contact>) {
|
||||||
try {
|
try {
|
||||||
cachedContacts.clear()
|
cachedContacts.clear()
|
||||||
cachedContacts.addAll(contacts)
|
cachedContacts.addAll(contacts)
|
||||||
|
@ -3,9 +3,10 @@ package com.simplemobiletools.dialer.activities
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.adapters.SpeedDialAdapter
|
import com.simplemobiletools.dialer.adapters.SpeedDialAdapter
|
||||||
import com.simplemobiletools.dialer.dialogs.SelectContactDialog
|
import com.simplemobiletools.dialer.dialogs.SelectContactDialog
|
||||||
@ -15,7 +16,7 @@ import com.simplemobiletools.dialer.models.SpeedDial
|
|||||||
import kotlinx.android.synthetic.main.activity_manage_speed_dial.*
|
import kotlinx.android.synthetic.main.activity_manage_speed_dial.*
|
||||||
|
|
||||||
class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
|
class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
|
||||||
private var allContacts = ArrayList<SimpleContact>()
|
private var allContacts = ArrayList<Contact>()
|
||||||
private var speedDialValues = ArrayList<SpeedDial>()
|
private var speedDialValues = ArrayList<SpeedDial>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -28,7 +29,7 @@ class ManageSpeedDialActivity : SimpleActivity(), RemoveSpeedDialListener {
|
|||||||
|
|
||||||
speedDialValues = config.getSpeedDialValues()
|
speedDialValues = config.getSpeedDialValues()
|
||||||
updateAdapter()
|
updateAdapter()
|
||||||
SimpleContactsHelper(this).getAvailableContacts(false) { contacts ->
|
ContactsHelper(this).getContacts(false) { contacts ->
|
||||||
allContacts = contacts
|
allContacts = contacts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import com.simplemobiletools.commons.helpers.isOreoPlus
|
|||||||
import com.simplemobiletools.commons.interfaces.ItemMoveCallback
|
import com.simplemobiletools.commons.interfaces.ItemMoveCallback
|
||||||
import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract
|
import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract
|
||||||
import com.simplemobiletools.commons.interfaces.StartReorderDragListener
|
import com.simplemobiletools.commons.interfaces.StartReorderDragListener
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||||
@ -41,7 +41,7 @@ import java.util.*
|
|||||||
|
|
||||||
class ContactsAdapter(
|
class ContactsAdapter(
|
||||||
activity: SimpleActivity,
|
activity: SimpleActivity,
|
||||||
var contacts: ArrayList<SimpleContact>,
|
var contacts: ArrayList<Contact>,
|
||||||
recyclerView: MyRecyclerView,
|
recyclerView: MyRecyclerView,
|
||||||
val refreshItemsListener: RefreshItemsListener? = null,
|
val refreshItemsListener: RefreshItemsListener? = null,
|
||||||
highlightText: String = "",
|
highlightText: String = "",
|
||||||
@ -135,9 +135,9 @@ class ContactsAdapter(
|
|||||||
|
|
||||||
override fun getItemCount() = contacts.size
|
override fun getItemCount() = contacts.size
|
||||||
|
|
||||||
fun updateItems(newItems: ArrayList<SimpleContact>, highlightText: String = "") {
|
fun updateItems(newItems: ArrayList<Contact>, highlightText: String = "") {
|
||||||
if (newItems.hashCode() != contacts.hashCode()) {
|
if (newItems.hashCode() != contacts.hashCode()) {
|
||||||
contacts = newItems.clone() as ArrayList<SimpleContact>
|
contacts = newItems.clone() as ArrayList<Contact>
|
||||||
textToHighlight = highlightText
|
textToHighlight = highlightText
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
finishActMode()
|
finishActMode()
|
||||||
@ -221,7 +221,7 @@ class ContactsAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSelectedItems() = contacts.filter { selectedKeys.contains(it.rawId) } as ArrayList<SimpleContact>
|
private fun getSelectedItems() = contacts.filter { selectedKeys.contains(it.rawId) } as ArrayList<Contact>
|
||||||
|
|
||||||
private fun getSelectedPhoneNumber(): String? {
|
private fun getSelectedPhoneNumber(): String? {
|
||||||
val numbers = getSelectedItems().firstOrNull()?.phoneNumbers
|
val numbers = getSelectedItems().firstOrNull()?.phoneNumbers
|
||||||
@ -270,7 +270,7 @@ class ContactsAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, contact: SimpleContact, holder: ViewHolder) {
|
private fun setupView(view: View, contact: Contact, holder: ViewHolder) {
|
||||||
view.apply {
|
view.apply {
|
||||||
findViewById<FrameLayout>(R.id.item_contact_frame).isSelected = selectedKeys.contains(contact.rawId)
|
findViewById<FrameLayout>(R.id.item_contact_frame).isSelected = selectedKeys.contains(contact.rawId)
|
||||||
findViewById<TextView>(R.id.item_contact_name).apply {
|
findViewById<TextView>(R.id.item_contact_name).apply {
|
||||||
|
@ -14,7 +14,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
|||||||
import com.simplemobiletools.commons.dialogs.FeatureLockedDialog
|
import com.simplemobiletools.commons.dialogs.FeatureLockedDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.activities.MainActivity
|
import com.simplemobiletools.dialer.activities.MainActivity
|
||||||
@ -246,11 +246,11 @@ class RecentCallsAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findContactByCall(recentCall: RecentCall): SimpleContact? {
|
private fun findContactByCall(recentCall: RecentCall): Contact? {
|
||||||
return (activity as MainActivity).cachedContacts.find { it.name == recentCall.name && it.doesHavePhoneNumber(recentCall.phoneNumber) }
|
return (activity as MainActivity).cachedContacts.find { it.name == recentCall.name && it.doesHavePhoneNumber(recentCall.phoneNumber) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchContactDetailsIntent(contact: SimpleContact?) {
|
private fun launchContactDetailsIntent(contact: Contact?) {
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
activity.startContactDetailsIntent(contact)
|
activity.startContactDetailsIntent(contact)
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,17 @@
|
|||||||
package com.simplemobiletools.dialer.dialogs
|
package com.simplemobiletools.dialer.dialogs
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.beGoneIf
|
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||||
|
import com.simplemobiletools.commons.extensions.contactsConfig
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.helpers.SORT_BY_CUSTOM
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_CREATED
|
|
||||||
import com.simplemobiletools.commons.helpers.SORT_BY_FULL_NAME
|
|
||||||
import com.simplemobiletools.commons.helpers.SORT_DESCENDING
|
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.extensions.config
|
|
||||||
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
||||||
|
|
||||||
class ChangeSortingDialog(
|
class ChangeSortingDialog(val activity: BaseSimpleActivity, private val showCustomSorting: Boolean = false, private val callback: () -> Unit) {
|
||||||
val activity: BaseSimpleActivity,
|
|
||||||
private val showCustomSorting: Boolean = false,
|
|
||||||
private val callback: () -> Unit
|
|
||||||
) {
|
|
||||||
private var currSorting = 0
|
private var currSorting = 0
|
||||||
private var config = activity.config
|
private var config = activity.contactsConfig
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null)
|
private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -51,17 +42,18 @@ class ChangeSortingDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val sortBtn = when {
|
val sortBtn = when {
|
||||||
|
currSorting and SORT_BY_FIRST_NAME != 0 -> sortingRadio.sorting_dialog_radio_first_name
|
||||||
|
currSorting and SORT_BY_MIDDLE_NAME != 0 -> sortingRadio.sorting_dialog_radio_middle_name
|
||||||
|
currSorting and SORT_BY_SURNAME != 0 -> sortingRadio.sorting_dialog_radio_surname
|
||||||
currSorting and SORT_BY_FULL_NAME != 0 -> sortingRadio.sorting_dialog_radio_full_name
|
currSorting and SORT_BY_FULL_NAME != 0 -> sortingRadio.sorting_dialog_radio_full_name
|
||||||
currSorting and SORT_BY_CUSTOM != 0 -> sortingRadio.sorting_dialog_radio_custom
|
currSorting and SORT_BY_CUSTOM != 0 -> sortingRadio.sorting_dialog_radio_custom
|
||||||
else -> sortingRadio.sorting_dialog_radio_date_created
|
else -> sortingRadio.sorting_dialog_radio_date_created
|
||||||
}
|
}
|
||||||
|
|
||||||
sortBtn.isChecked = true
|
sortBtn.isChecked = true
|
||||||
|
|
||||||
if (showCustomSorting) {
|
if (showCustomSorting) {
|
||||||
sortingRadio.sorting_dialog_radio_custom.isChecked = config.isCustomOrderSelected
|
sortingRadio.sorting_dialog_radio_custom.isChecked = config.isCustomOrderSelected
|
||||||
}
|
}
|
||||||
|
|
||||||
view.sorting_dialog_radio_custom.beGoneIf(!showCustomSorting)
|
view.sorting_dialog_radio_custom.beGoneIf(!showCustomSorting)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +70,9 @@ class ChangeSortingDialog(
|
|||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
val sortingRadio = view.sorting_dialog_radio_sorting
|
||||||
var sorting = when (sortingRadio.checkedRadioButtonId) {
|
var sorting = when (sortingRadio.checkedRadioButtonId) {
|
||||||
|
R.id.sorting_dialog_radio_first_name -> SORT_BY_FIRST_NAME
|
||||||
|
R.id.sorting_dialog_radio_middle_name -> SORT_BY_MIDDLE_NAME
|
||||||
|
R.id.sorting_dialog_radio_surname -> SORT_BY_SURNAME
|
||||||
R.id.sorting_dialog_radio_full_name -> SORT_BY_FULL_NAME
|
R.id.sorting_dialog_radio_full_name -> SORT_BY_FULL_NAME
|
||||||
R.id.sorting_dialog_radio_custom -> SORT_BY_CUSTOM
|
R.id.sorting_dialog_radio_custom -> SORT_BY_CUSTOM
|
||||||
else -> SORT_BY_DATE_CREATED
|
else -> SORT_BY_DATE_CREATED
|
||||||
@ -98,7 +93,6 @@ class ChangeSortingDialog(
|
|||||||
config.sorting = sorting
|
config.sorting = sorting
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleContact.sorting = sorting
|
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,14 @@ package com.simplemobiletools.dialer.dialogs
|
|||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||||
import kotlinx.android.synthetic.main.dialog_select_contact.view.*
|
import kotlinx.android.synthetic.main.dialog_select_contact.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class SelectContactDialog(val activity: SimpleActivity, contacts: ArrayList<SimpleContact>, val callback: (selectedContact: SimpleContact) -> Unit) {
|
class SelectContactDialog(val activity: SimpleActivity, contacts: ArrayList<Contact>, val callback: (selectedContact: Contact) -> Unit) {
|
||||||
private var dialog: AlertDialog? = null
|
private var dialog: AlertDialog? = null
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_select_contact, null)
|
private var view = activity.layoutInflater.inflate(R.layout.dialog_select_contact, null)
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ class SelectContactDialog(val activity: SimpleActivity, contacts: ArrayList<Simp
|
|||||||
})
|
})
|
||||||
|
|
||||||
select_contact_list.adapter = ContactsAdapter(activity, contacts, select_contact_list) {
|
select_contact_list.adapter = ContactsAdapter(activity, contacts, select_contact_list) {
|
||||||
callback(it as SimpleContact)
|
callback(it as Contact)
|
||||||
dialog?.dismiss()
|
dialog?.dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import android.telecom.TelecomManager
|
|||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||||
import com.simplemobiletools.dialer.dialogs.SelectSIMDialog
|
import com.simplemobiletools.dialer.dialogs.SelectSIMDialog
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ fun BaseSimpleActivity.callContactWithSim(recipient: String, useMainSIM: Boolean
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle private contacts differently, only Simple Contacts Pro can open them
|
// handle private contacts differently, only Simple Contacts Pro can open them
|
||||||
fun Activity.startContactDetailsIntent(contact: SimpleContact) {
|
fun Activity.startContactDetailsIntent(contact: Contact) {
|
||||||
val simpleContacts = "com.simplemobiletools.contacts.pro"
|
val simpleContacts = "com.simplemobiletools.contacts.pro"
|
||||||
val simpleContactsDebug = "com.simplemobiletools.contacts.pro.debug"
|
val simpleContactsDebug = "com.simplemobiletools.contacts.pro.debug"
|
||||||
if (contact.rawId > 1000000 && contact.contactId > 1000000 && contact.rawId == contact.contactId &&
|
if (contact.rawId > 1000000 && contact.contactId > 1000000 && contact.rawId == contact.contactId &&
|
||||||
|
@ -5,10 +5,8 @@ import android.util.AttributeSet
|
|||||||
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.activities.MainActivity
|
import com.simplemobiletools.dialer.activities.MainActivity
|
||||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||||
@ -20,7 +18,7 @@ import kotlinx.android.synthetic.main.fragment_letters_layout.view.*
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), RefreshItemsListener {
|
class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), RefreshItemsListener {
|
||||||
private var allContacts = ArrayList<SimpleContact>()
|
private var allContacts = ArrayList<Contact>()
|
||||||
|
|
||||||
override fun setupFragment() {
|
override fun setupFragment() {
|
||||||
val placeholderResId = if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
val placeholderResId = if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
||||||
@ -64,10 +62,10 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
|
|
||||||
override fun refreshItems(callback: (() -> Unit)?) {
|
override fun refreshItems(callback: (() -> Unit)?) {
|
||||||
val privateCursor = context?.getMyContactsCursor(false, true)
|
val privateCursor = context?.getMyContactsCursor(false, true)
|
||||||
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
|
ContactsHelper(context).getContacts { contacts ->
|
||||||
allContacts = contacts
|
allContacts = contacts
|
||||||
|
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(context, privateCursor)
|
val privateContacts = MyContactsContentProvider.getContacts(context, privateCursor)
|
||||||
if (privateContacts.isNotEmpty()) {
|
if (privateContacts.isNotEmpty()) {
|
||||||
allContacts.addAll(privateContacts)
|
allContacts.addAll(privateContacts)
|
||||||
allContacts.sort()
|
allContacts.sort()
|
||||||
@ -82,7 +80,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotContacts(contacts: ArrayList<SimpleContact>) {
|
private fun gotContacts(contacts: ArrayList<Contact>) {
|
||||||
setupLetterFastscroller(contacts)
|
setupLetterFastscroller(contacts)
|
||||||
if (contacts.isEmpty()) {
|
if (contacts.isEmpty()) {
|
||||||
fragment_placeholder.beVisible()
|
fragment_placeholder.beVisible()
|
||||||
@ -96,7 +94,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
val currAdapter = fragment_list.adapter
|
val currAdapter = fragment_list.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
ContactsAdapter(activity as SimpleActivity, contacts, fragment_list, this) {
|
ContactsAdapter(activity as SimpleActivity, contacts, fragment_list, this) {
|
||||||
val contact = it as SimpleContact
|
val contact = it as Contact
|
||||||
activity?.startContactDetailsIntent(contact)
|
activity?.startContactDetailsIntent(contact)
|
||||||
}.apply {
|
}.apply {
|
||||||
fragment_list.adapter = this
|
fragment_list.adapter = this
|
||||||
@ -111,7 +109,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLetterFastscroller(contacts: ArrayList<SimpleContact>) {
|
private fun setupLetterFastscroller(contacts: ArrayList<Contact>) {
|
||||||
letter_fastscroller.setupWithRecyclerView(fragment_list, { position ->
|
letter_fastscroller.setupWithRecyclerView(fragment_list, { position ->
|
||||||
try {
|
try {
|
||||||
val name = contacts[position].name
|
val name = contacts[position].name
|
||||||
@ -130,26 +128,37 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onSearchQueryChanged(text: String) {
|
override fun onSearchQueryChanged(text: String) {
|
||||||
val contacts = allContacts.filter {
|
val shouldNormalize = text.normalizeString() == text
|
||||||
it.doesContainPhoneNumber(text) ||
|
val filtered = allContacts.filter {
|
||||||
it.name.contains(text, true) ||
|
getProperText(it.name, shouldNormalize).contains(text, true) ||
|
||||||
it.name.normalizeString().contains(text, true) ||
|
getProperText(it.nickname, shouldNormalize).contains(text, true) ||
|
||||||
it.name.contains(text.normalizeString(), true)
|
it.phoneNumbers.any {
|
||||||
}.sortedByDescending {
|
text.normalizePhoneNumber().isNotEmpty() && it.normalizedNumber.contains(text.normalizePhoneNumber(), true)
|
||||||
it.name.startsWith(text, true)
|
} ||
|
||||||
}.toMutableList() as ArrayList<SimpleContact>
|
it.emails.any { it.value.contains(text, true) } ||
|
||||||
|
it.addresses.any { getProperText(it.value, shouldNormalize).contains(text, true) } ||
|
||||||
|
it.IMs.any { it.value.contains(text, true) } ||
|
||||||
|
getProperText(it.notes, shouldNormalize).contains(text, true) ||
|
||||||
|
getProperText(it.organization.company, shouldNormalize).contains(text, true) ||
|
||||||
|
getProperText(it.organization.jobPosition, shouldNormalize).contains(text, true) ||
|
||||||
|
it.websites.any { it.contains(text, true) }
|
||||||
|
} as ArrayList
|
||||||
|
|
||||||
fragment_placeholder.beVisibleIf(contacts.isEmpty())
|
filtered.sortBy {
|
||||||
(fragment_list.adapter as? ContactsAdapter)?.updateItems(contacts, text)
|
val nameToDisplay = it.name
|
||||||
setupLetterFastscroller(contacts)
|
!getProperText(nameToDisplay, shouldNormalize).startsWith(text, true) && !nameToDisplay.contains(text, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fragment_placeholder.beVisibleIf(filtered.isEmpty())
|
||||||
|
(fragment_list.adapter as? ContactsAdapter)?.updateItems(filtered, text)
|
||||||
|
setupLetterFastscroller(filtered)
|
||||||
|
}
|
||||||
private fun requestReadContactsPermission() {
|
private fun requestReadContactsPermission() {
|
||||||
activity?.handlePermission(PERMISSION_READ_CONTACTS) {
|
activity?.handlePermission(PERMISSION_READ_CONTACTS) {
|
||||||
if (it) {
|
if (it) {
|
||||||
fragment_placeholder.text = context.getString(R.string.no_contacts_found)
|
fragment_placeholder.text = context.getString(R.string.no_contacts_found)
|
||||||
fragment_placeholder_2.text = context.getString(R.string.create_new_contact)
|
fragment_placeholder_2.text = context.getString(R.string.create_new_contact)
|
||||||
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
|
ContactsHelper(context).getContacts(false) { contacts ->
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
gotContacts(contacts)
|
gotContacts(contacts)
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
|||||||
import com.simplemobiletools.commons.dialogs.CallConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.CallConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||||
@ -23,7 +23,7 @@ import kotlinx.android.synthetic.main.fragment_letters_layout.view.*
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), RefreshItemsListener {
|
class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), RefreshItemsListener {
|
||||||
private var allContacts = ArrayList<SimpleContact>()
|
private var allContacts = ArrayList<Contact>()
|
||||||
|
|
||||||
override fun setupFragment() {
|
override fun setupFragment() {
|
||||||
val placeholderResId = if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
val placeholderResId = if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
||||||
@ -49,17 +49,20 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
|
|
||||||
override fun refreshItems(callback: (() -> Unit)?) {
|
override fun refreshItems(callback: (() -> Unit)?) {
|
||||||
val privateCursor = context?.getMyContactsCursor(true, true)
|
val privateCursor = context?.getMyContactsCursor(true, true)
|
||||||
SimpleContactsHelper(context).getAvailableContacts(true) { contacts ->
|
ContactsHelper(context).getContacts { contacts ->
|
||||||
allContacts = contacts
|
allContacts = contacts
|
||||||
|
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(context, privateCursor)
|
val privateContacts = MyContactsContentProvider.getContacts(context, privateCursor)
|
||||||
if (privateContacts.isNotEmpty()) {
|
if (privateContacts.isNotEmpty()) {
|
||||||
allContacts.addAll(privateContacts)
|
allContacts.addAll(privateContacts)
|
||||||
allContacts.sort()
|
allContacts.sort()
|
||||||
}
|
}
|
||||||
|
val favorites = contacts.filter { it.starred == 1 } as ArrayList<Contact>
|
||||||
|
|
||||||
if (activity!!.config.isCustomOrderSelected) {
|
allContacts = if (activity!!.config.isCustomOrderSelected) {
|
||||||
allContacts = sortByCustomOrder(allContacts)
|
sortByCustomOrder(favorites)
|
||||||
|
} else {
|
||||||
|
favorites
|
||||||
}
|
}
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
@ -69,7 +72,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotContacts(contacts: ArrayList<SimpleContact>) {
|
private fun gotContacts(contacts: ArrayList<Contact>) {
|
||||||
setupLetterFastscroller(contacts)
|
setupLetterFastscroller(contacts)
|
||||||
if (contacts.isEmpty()) {
|
if (contacts.isEmpty()) {
|
||||||
fragment_placeholder.beVisible()
|
fragment_placeholder.beVisible()
|
||||||
@ -89,11 +92,11 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
enableDrag = true,
|
enableDrag = true,
|
||||||
) {
|
) {
|
||||||
if (context.config.showCallConfirmation) {
|
if (context.config.showCallConfirmation) {
|
||||||
CallConfirmationDialog(activity as SimpleActivity, (it as SimpleContact).name) {
|
CallConfirmationDialog(activity as SimpleActivity, (it as Contact).name) {
|
||||||
callContact(it)
|
callContact(it)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
callContact(it as SimpleContact)
|
callContact(it as Contact)
|
||||||
}
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
fragment_list.adapter = this
|
fragment_list.adapter = this
|
||||||
@ -117,7 +120,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sortByCustomOrder(favorites: List<SimpleContact>): ArrayList<SimpleContact> {
|
private fun sortByCustomOrder(favorites: List<Contact>): ArrayList<Contact> {
|
||||||
val favoritesOrder = activity!!.config.favoritesContactsOrder
|
val favoritesOrder = activity!!.config.favoritesContactsOrder
|
||||||
|
|
||||||
if (favoritesOrder.isEmpty()) {
|
if (favoritesOrder.isEmpty()) {
|
||||||
@ -131,7 +134,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
return ArrayList(sorted)
|
return ArrayList(sorted)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveCustomOrderToPrefs(items: ArrayList<SimpleContact>) {
|
private fun saveCustomOrderToPrefs(items: ArrayList<Contact>) {
|
||||||
activity?.apply {
|
activity?.apply {
|
||||||
val orderIds = items.map { it.contactId }
|
val orderIds = items.map { it.contactId }
|
||||||
val orderGsonString = Gson().toJson(orderIds)
|
val orderGsonString = Gson().toJson(orderIds)
|
||||||
@ -139,7 +142,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun callContact(simpleContact: SimpleContact) {
|
private fun callContact(simpleContact: Contact) {
|
||||||
val phoneNumbers = simpleContact.phoneNumbers
|
val phoneNumbers = simpleContact.phoneNumbers
|
||||||
if (phoneNumbers.size <= 1) {
|
if (phoneNumbers.size <= 1) {
|
||||||
activity?.launchCallIntent(phoneNumbers.first().normalizedNumber)
|
activity?.launchCallIntent(phoneNumbers.first().normalizedNumber)
|
||||||
@ -161,7 +164,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLetterFastscroller(contacts: ArrayList<SimpleContact>) {
|
private fun setupLetterFastscroller(contacts: ArrayList<Contact>) {
|
||||||
letter_fastscroller.setupWithRecyclerView(fragment_list, { position ->
|
letter_fastscroller.setupWithRecyclerView(fragment_list, { position ->
|
||||||
try {
|
try {
|
||||||
val name = contacts[position].name
|
val name = contacts[position].name
|
||||||
@ -184,7 +187,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||||||
it.name.contains(text, true) || it.doesContainPhoneNumber(text)
|
it.name.contains(text, true) || it.doesContainPhoneNumber(text)
|
||||||
}.sortedByDescending {
|
}.sortedByDescending {
|
||||||
it.name.startsWith(text, true)
|
it.name.startsWith(text, true)
|
||||||
}.toMutableList() as ArrayList<SimpleContact>
|
}.toMutableList() as ArrayList<Contact>
|
||||||
|
|
||||||
fragment_placeholder.beVisibleIf(contacts.isEmpty())
|
fragment_placeholder.beVisibleIf(contacts.isEmpty())
|
||||||
(fragment_list.adapter as? ContactsAdapter)?.updateItems(contacts, text)
|
(fragment_list.adapter as? ContactsAdapter)?.updateItems(contacts, text)
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import com.simplemobiletools.commons.dialogs.CallConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.CallConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CALL_LOG
|
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CALL_LOG
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||||
@ -49,8 +50,8 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
val privateCursor = context?.getMyContactsCursor(false, true)
|
val privateCursor = context?.getMyContactsCursor(false, true)
|
||||||
val groupSubsequentCalls = context?.config?.groupSubsequentCalls ?: false
|
val groupSubsequentCalls = context?.config?.groupSubsequentCalls ?: false
|
||||||
RecentsHelper(context).getRecentCalls(groupSubsequentCalls) { recents ->
|
RecentsHelper(context).getRecentCalls(groupSubsequentCalls) { recents ->
|
||||||
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
|
ContactsHelper(context).getContacts { contacts ->
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(context, privateCursor)
|
val privateContacts = MyContactsContentProvider.getContacts(context, privateCursor)
|
||||||
|
|
||||||
recents.filter { it.phoneNumber == it.name }.forEach { recent ->
|
recents.filter { it.phoneNumber == it.name }.forEach { recent ->
|
||||||
var wasNameFilled = false
|
var wasNameFilled = false
|
||||||
@ -63,7 +64,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!wasNameFilled) {
|
if (!wasNameFilled) {
|
||||||
val contact = contacts.firstOrNull { it.phoneNumbers.first().normalizedNumber == recent.phoneNumber }
|
val contact = contacts.filter { it.phoneNumbers.isNotEmpty() }.firstOrNull { it.phoneNumbers.first().normalizedNumber == recent.phoneNumber }
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
recent.name = contact.name
|
recent.name = contact.name
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,9 @@ import android.net.Uri
|
|||||||
import android.telecom.Call
|
import android.telecom.Call
|
||||||
import com.simplemobiletools.commons.extensions.getMyContactsCursor
|
import com.simplemobiletools.commons.extensions.getMyContactsCursor
|
||||||
import com.simplemobiletools.commons.extensions.getPhoneNumberTypeText
|
import com.simplemobiletools.commons.extensions.getPhoneNumberTypeText
|
||||||
|
import com.simplemobiletools.commons.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.extensions.isConference
|
import com.simplemobiletools.dialer.extensions.isConference
|
||||||
@ -35,8 +36,8 @@ fun getCallContact(context: Context, call: Call?, callback: (CallContact) -> Uni
|
|||||||
val uri = Uri.decode(handle)
|
val uri = Uri.decode(handle)
|
||||||
if (uri.startsWith("tel:")) {
|
if (uri.startsWith("tel:")) {
|
||||||
val number = uri.substringAfter("tel:")
|
val number = uri.substringAfter("tel:")
|
||||||
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
|
ContactsHelper(context).getContacts{ contacts ->
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(context, privateCursor)
|
val privateContacts = MyContactsContentProvider.getContacts(context, privateCursor)
|
||||||
if (privateContacts.isNotEmpty()) {
|
if (privateContacts.isNotEmpty()) {
|
||||||
contacts.addAll(privateContacts)
|
contacts.addAll(privateContacts)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import android.content.Context
|
|||||||
import android.provider.CallLog.Calls
|
import android.provider.CallLog.Calls
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.SimpleContact
|
import com.simplemobiletools.commons.models.contacts.Contact
|
||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||||
import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
|
import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
|
||||||
@ -24,8 +24,8 @@ class RecentsHelper(private val context: Context) {
|
|||||||
return@ensureBackgroundThread
|
return@ensureBackgroundThread
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
|
ContactsHelper(context).getContacts(false) { contacts ->
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(context, privateCursor)
|
val privateContacts = MyContactsContentProvider.getContacts(context, privateCursor)
|
||||||
if (privateContacts.isNotEmpty()) {
|
if (privateContacts.isNotEmpty()) {
|
||||||
contacts.addAll(privateContacts)
|
contacts.addAll(privateContacts)
|
||||||
}
|
}
|
||||||
@ -36,7 +36,8 @@ class RecentsHelper(private val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private fun getRecents(contacts: ArrayList<SimpleContact>, groupSubsequentCalls: Boolean, callback: (ArrayList<RecentCall>) -> Unit) {
|
private fun getRecents(contacts: ArrayList<Contact>, groupSubsequentCalls: Boolean, callback: (ArrayList<RecentCall>) -> Unit) {
|
||||||
|
|
||||||
var recentCalls = ArrayList<RecentCall>()
|
var recentCalls = ArrayList<RecentCall>()
|
||||||
var previousRecentCallFrom = ""
|
var previousRecentCallFrom = ""
|
||||||
var previousStartTS = 0
|
var previousStartTS = 0
|
||||||
@ -96,7 +97,7 @@ class RecentsHelper(private val context: Context) {
|
|||||||
} else {
|
} else {
|
||||||
val normalizedNumber = number.normalizePhoneNumber()
|
val normalizedNumber = number.normalizePhoneNumber()
|
||||||
if (normalizedNumber!!.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
|
if (normalizedNumber!!.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
|
||||||
name = contacts.firstOrNull { contact ->
|
name = contacts.filter { it.phoneNumbers.isNotEmpty() }.firstOrNull { contact ->
|
||||||
val curNumber = contact.phoneNumbers.first().normalizedNumber
|
val curNumber = contact.phoneNumbers.first().normalizedNumber
|
||||||
if (curNumber.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
|
if (curNumber.length >= COMPARABLE_PHONE_NUMBER_LENGTH) {
|
||||||
if (curNumber.substring(curNumber.length - COMPARABLE_PHONE_NUMBER_LENGTH) == normalizedNumber.substring(normalizedNumber.length - COMPARABLE_PHONE_NUMBER_LENGTH)) {
|
if (curNumber.substring(curNumber.length - COMPARABLE_PHONE_NUMBER_LENGTH) == normalizedNumber.substring(normalizedNumber.length - COMPARABLE_PHONE_NUMBER_LENGTH)) {
|
||||||
|
@ -19,23 +19,54 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="@dimen/medium_margin">
|
android:layout_marginBottom="@dimen/medium_margin">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/sorting_dialog_radio_first_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
|
android:text="@string/first_name" />
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/sorting_dialog_radio_middle_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
|
android:text="@string/middle_name" />
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/sorting_dialog_radio_surname"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
|
android:text="@string/surname" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
android:id="@+id/sorting_dialog_radio_full_name"
|
android:id="@+id/sorting_dialog_radio_full_name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
android:text="@string/full_name" />
|
android:text="@string/full_name" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
android:id="@+id/sorting_dialog_radio_date_created"
|
android:id="@+id/sorting_dialog_radio_date_created"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
android:text="@string/date_created" />
|
android:text="@string/date_created" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
android:id="@+id/sorting_dialog_radio_custom"
|
android:id="@+id/sorting_dialog_radio_custom"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
android:text="@string/custom" />
|
android:text="@string/custom" />
|
||||||
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
<include
|
<include
|
||||||
@ -53,12 +84,16 @@
|
|||||||
android:id="@+id/sorting_dialog_radio_ascending"
|
android:id="@+id/sorting_dialog_radio_ascending"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
android:text="@string/ascending" />
|
android:text="@string/ascending" />
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
android:id="@+id/sorting_dialog_radio_descending"
|
android:id="@+id/sorting_dialog_radio_descending"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
android:text="@string/descending" />
|
android:text="@string/descending" />
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user