add a new field to ContactSource, publicName
This commit is contained in:
parent
dcc2490f86
commit
cb7e281051
|
@ -568,15 +568,19 @@ class EditContactActivity : ContactActivity() {
|
|||
}
|
||||
|
||||
private fun setupContactSource() {
|
||||
contact_source.text = getPublicContactSource(contact!!.source)
|
||||
originalContactSource = contact!!.source
|
||||
getPublicContactSource(contact!!.source) {
|
||||
contact_source.text = it
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupNewContact() {
|
||||
supportActionBar?.title = resources.getString(R.string.new_contact)
|
||||
originalContactSource = if (hasContactPermissions()) config.lastUsedContactSource else SMT_PRIVATE
|
||||
contact = getEmptyContact()
|
||||
contact_source.text = getPublicContactSource(contact!!.source)
|
||||
getPublicContactSource(contact!!.source) {
|
||||
contact_source.text = it
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupTypePickers() {
|
||||
|
@ -831,7 +835,9 @@ class EditContactActivity : ContactActivity() {
|
|||
private fun showSelectContactSourceDialog() {
|
||||
showContactSourcePicker(contact!!.source) {
|
||||
contact!!.source = if (it == getString(R.string.phone_storage_hidden)) SMT_PRIVATE else it
|
||||
contact_source.text = getPublicContactSource(it)
|
||||
getPublicContactSource(it) {
|
||||
contact_source.text = it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -446,11 +446,12 @@ class ViewContactActivity : ContactActivity() {
|
|||
|
||||
private fun setupContactSource() {
|
||||
if (showFields and SHOW_CONTACT_SOURCE_FIELD != 0) {
|
||||
val contactSourceValue = getPublicContactSource(contact!!.source)
|
||||
contact_source.text = contactSourceValue
|
||||
getPublicContactSource(contact!!.source) {
|
||||
contact_source.text = it
|
||||
contact_source.copyOnLongClick(it)
|
||||
}
|
||||
contact_source_image.beVisible()
|
||||
contact_source.beVisible()
|
||||
contact_source.copyOnLongClick(contactSourceValue)
|
||||
} else {
|
||||
contact_source_image.beGone()
|
||||
contact_source.beGone()
|
||||
|
|
|
@ -62,7 +62,7 @@ class FilterContactSourcesAdapter(val activity: SimpleActivity, private val cont
|
|||
itemView.apply {
|
||||
filter_contact_source_checkbox.isChecked = isSelected
|
||||
filter_contact_source_checkbox.setColors(activity.config.textColor, activity.getAdjustedPrimaryColor(), activity.config.backgroundColor)
|
||||
filter_contact_source_checkbox.text = contactSource.name
|
||||
filter_contact_source_checkbox.text = contactSource.publicName
|
||||
filter_contact_source_holder.setOnClickListener { viewClicked(!isSelected, contactSource) }
|
||||
}
|
||||
|
||||
|
|
|
@ -36,12 +36,14 @@ class CreateNewGroupDialog(val activity: BaseSimpleActivity, val callback: (newG
|
|||
|
||||
val contactSources = ArrayList<ContactSource>()
|
||||
if (activity.config.localAccountName.isNotEmpty()) {
|
||||
contactSources.add(ContactSource(activity.config.localAccountName, activity.config.localAccountType))
|
||||
val localAccountName = activity.config.localAccountName
|
||||
contactSources.add(ContactSource(localAccountName, activity.config.localAccountType, localAccountName))
|
||||
}
|
||||
|
||||
ContactsHelper(activity).getContactSources {
|
||||
it.filter { it.type.contains("google", true) }.mapTo(contactSources, { ContactSource(it.name, it.type) })
|
||||
contactSources.add(ContactSource(activity.getString(R.string.phone_storage_hidden), SMT_PRIVATE))
|
||||
it.filter { it.type.contains("google", true) }.mapTo(contactSources) { ContactSource(it.name, it.type, it.name) }
|
||||
val phoneSecret = activity.getString(R.string.phone_storage_hidden)
|
||||
contactSources.add(ContactSource(phoneSecret, SMT_PRIVATE, phoneSecret))
|
||||
|
||||
val items = ArrayList<RadioItem>()
|
||||
contactSources.forEachIndexed { index, contactSource ->
|
||||
|
|
|
@ -20,11 +20,16 @@ class ImportContactsDialog(val activity: SimpleActivity, val path: String, priva
|
|||
init {
|
||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_import_contacts, null) as ViewGroup).apply {
|
||||
targetContactSource = activity.config.lastUsedContactSource
|
||||
import_contacts_title.text = activity.getPublicContactSource(targetContactSource)
|
||||
activity.getPublicContactSource(targetContactSource) {
|
||||
import_contacts_title.text = it
|
||||
}
|
||||
|
||||
import_contacts_title.setOnClickListener {
|
||||
activity.showContactSourcePicker(targetContactSource) {
|
||||
targetContactSource = if (it == activity.getString(R.string.phone_storage_hidden)) SMT_PRIVATE else it
|
||||
import_contacts_title.text = activity.getPublicContactSource(it)
|
||||
activity.getPublicContactSource(it) {
|
||||
import_contacts_title.text = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,12 +193,13 @@ fun Context.getPhotoThumbnailSize(): Int {
|
|||
|
||||
fun Context.hasContactPermissions() = hasPermission(PERMISSION_READ_CONTACTS) && hasPermission(PERMISSION_WRITE_CONTACTS)
|
||||
|
||||
fun Context.getPublicContactSource(source: String): String {
|
||||
return when (source) {
|
||||
fun Context.getPublicContactSource(source: String, callback: (String) -> Unit) {
|
||||
val newSource = when (source) {
|
||||
config.localAccountName -> getString(R.string.phone_storage)
|
||||
SMT_PRIVATE -> getString(R.string.phone_storage_hidden)
|
||||
else -> source
|
||||
}
|
||||
callback(newSource)
|
||||
}
|
||||
|
||||
fun Context.sendSMSToContacts(contacts: ArrayList<Contact>) {
|
||||
|
@ -289,7 +290,8 @@ fun Context.getContactPublicUri(contact: Contact): Uri {
|
|||
|
||||
fun Context.getVisibleContactSources(): ArrayList<String> {
|
||||
val sources = ContactsHelper(this).getDeviceContactSources()
|
||||
sources.add(ContactSource(getString(R.string.phone_storage_hidden), SMT_PRIVATE))
|
||||
val phoneSecret = getString(R.string.phone_storage_hidden)
|
||||
sources.add(ContactSource(phoneSecret, SMT_PRIVATE, phoneSecret))
|
||||
val sourceNames = ArrayList(sources).map { if (it.type == SMT_PRIVATE) SMT_PRIVATE else it.name }.toMutableList() as ArrayList<String>
|
||||
sourceNames.removeAll(config.ignoredContactSources)
|
||||
return sourceNames
|
||||
|
|
|
@ -108,7 +108,12 @@ class ContactsHelper(val context: Context) {
|
|||
do {
|
||||
val name = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_NAME) ?: ""
|
||||
val type = cursor.getStringValue(ContactsContract.RawContacts.ACCOUNT_TYPE) ?: ""
|
||||
val source = ContactSource(name, type)
|
||||
var publicName = name
|
||||
if (type == TELEGRAM_PACKAGE) {
|
||||
publicName += " (${context.getString(R.string.telegram)})"
|
||||
}
|
||||
|
||||
val source = ContactSource(name, type, publicName)
|
||||
sources.add(source)
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
|
@ -831,7 +836,8 @@ class ContactsHelper(val context: Context) {
|
|||
|
||||
private fun getContactSourcesSync(): ArrayList<ContactSource> {
|
||||
val sources = getDeviceContactSources()
|
||||
sources.add(ContactSource(context.getString(R.string.phone_storage_hidden), SMT_PRIVATE))
|
||||
val phoneSecret = context.getString(R.string.phone_storage_hidden)
|
||||
sources.add(ContactSource(phoneSecret, SMT_PRIVATE, phoneSecret))
|
||||
return ArrayList(sources)
|
||||
}
|
||||
|
||||
|
@ -844,7 +850,11 @@ class ContactsHelper(val context: Context) {
|
|||
val accounts = AccountManager.get(context).accounts
|
||||
accounts.forEach {
|
||||
if (ContentResolver.getIsSyncable(it, ContactsContract.AUTHORITY) == 1) {
|
||||
val contactSource = ContactSource(it.name, it.type)
|
||||
var publicName = it.name
|
||||
if (it.type == TELEGRAM_PACKAGE) {
|
||||
publicName += " (${context.getString(R.string.telegram)})"
|
||||
}
|
||||
val contactSource = ContactSource(it.name, it.type, publicName)
|
||||
sources.add(contactSource)
|
||||
}
|
||||
}
|
||||
|
@ -855,7 +865,7 @@ class ContactsHelper(val context: Context) {
|
|||
sources.addAll(contentResolverAccounts)
|
||||
|
||||
if (sources.isEmpty() && context.config.localAccountName.isEmpty() && context.config.localAccountType.isEmpty()) {
|
||||
sources.add(ContactSource("", ""))
|
||||
sources.add(ContactSource("", "", ""))
|
||||
}
|
||||
|
||||
return sources
|
||||
|
|
|
@ -119,7 +119,7 @@ data class Contact(var id: Int, var prefix: String, var firstName: String, var m
|
|||
|
||||
fun getHashToCompare() = getStringToCompare().hashCode()
|
||||
|
||||
fun getFullCompany(): String {
|
||||
private fun getFullCompany(): String {
|
||||
var fullOrganization = if (organization.company.isEmpty()) "" else "${organization.company}, "
|
||||
fullOrganization += organization.jobPosition
|
||||
return fullOrganization.trim().trimEnd(',')
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package com.simplemobiletools.contacts.pro.models
|
||||
|
||||
data class ContactSource(var name: String, var type: String)
|
||||
data class ContactSource(var name: String, var type: String, var publicName: String)
|
||||
|
|
Loading…
Reference in New Issue