mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
adding some preparation for setting custom contact ringtones
This commit is contained in:
@ -36,7 +36,7 @@ fun Context.getEmptyContact(): Contact {
|
||||
val originalContactSource = if (hasContactPermissions()) config.lastUsedContactSource else SMT_PRIVATE
|
||||
val organization = Organization("", "")
|
||||
return Contact(0, "", "", "", "", "", "", "", ArrayList(), ArrayList(), ArrayList(), ArrayList(), originalContactSource, 0, 0, "",
|
||||
null, "", ArrayList(), organization, ArrayList(), ArrayList(), DEFAULT_MIMETYPE)
|
||||
null, "", ArrayList(), organization, ArrayList(), ArrayList(), DEFAULT_MIMETYPE, null)
|
||||
}
|
||||
|
||||
fun Context.viewContact(contact: Contact) {
|
||||
|
@ -93,6 +93,7 @@ const val SHOW_CONTACT_SOURCE_FIELD = 4096
|
||||
const val SHOW_WEBSITES_FIELD = 8192
|
||||
const val SHOW_NICKNAME_FIELD = 16384
|
||||
const val SHOW_IMS_FIELD = 32768
|
||||
const val SHOW_RINGTONE = 65536
|
||||
|
||||
const val DEFAULT_EMAIL_TYPE = CommonDataKinds.Email.TYPE_HOME
|
||||
const val DEFAULT_PHONE_NUMBER_TYPE = CommonDataKinds.Phone.TYPE_MOBILE
|
||||
|
@ -169,6 +169,7 @@ class ContactsHelper(val context: Context) {
|
||||
val addresses = ArrayList<Address>()
|
||||
val events = ArrayList<Event>()
|
||||
val starred = cursor.getIntValue(StructuredName.STARRED)
|
||||
val ringtone = cursor.getStringValue(StructuredName.CUSTOM_RINGTONE)
|
||||
val contactId = cursor.getIntValue(Data.CONTACT_ID)
|
||||
val thumbnailUri = cursor.getStringValue(StructuredName.PHOTO_THUMBNAIL_URI) ?: ""
|
||||
val notes = ""
|
||||
@ -177,7 +178,7 @@ class ContactsHelper(val context: Context) {
|
||||
val websites = ArrayList<String>()
|
||||
val ims = ArrayList<IM>()
|
||||
val contact = Contact(id, prefix, firstName, middleName, surname, suffix, nickname, photoUri, numbers, emails, addresses,
|
||||
events, accountName, starred, contactId, thumbnailUri, null, notes, groups, organization, websites, ims, mimetype)
|
||||
events, accountName, starred, contactId, thumbnailUri, null, notes, groups, organization, websites, ims, mimetype, ringtone)
|
||||
|
||||
contacts.put(id, contact)
|
||||
}
|
||||
@ -717,6 +718,7 @@ class ContactsHelper(val context: Context) {
|
||||
val notes = getNotes(id)[id] ?: ""
|
||||
val accountName = cursor.getStringValue(RawContacts.ACCOUNT_NAME) ?: ""
|
||||
val starred = cursor.getIntValue(StructuredName.STARRED)
|
||||
val ringtone = cursor.getStringValue(StructuredName.CUSTOM_RINGTONE)
|
||||
val contactId = cursor.getIntValue(Data.CONTACT_ID)
|
||||
val groups = getContactGroups(storedGroups, contactId)[contactId] ?: ArrayList()
|
||||
val thumbnailUri = cursor.getStringValue(StructuredName.PHOTO_THUMBNAIL_URI) ?: ""
|
||||
@ -724,7 +726,7 @@ class ContactsHelper(val context: Context) {
|
||||
val websites = getWebsites(id)[id] ?: ArrayList()
|
||||
val ims = getIMs(id)[id] ?: ArrayList()
|
||||
return Contact(id, prefix, firstName, middleName, surname, suffix, nickname, photoUri, number, emails, addresses, events,
|
||||
accountName, starred, contactId, thumbnailUri, null, notes, groups, organization, websites, ims, mimetype)
|
||||
accountName, starred, contactId, thumbnailUri, null, notes, groups, organization, websites, ims, mimetype, ringtone)
|
||||
}
|
||||
}
|
||||
|
||||
@ -823,6 +825,7 @@ class ContactsHelper(val context: Context) {
|
||||
StructuredName.PHOTO_URI,
|
||||
StructuredName.PHOTO_THUMBNAIL_URI,
|
||||
StructuredName.STARRED,
|
||||
StructuredName.CUSTOM_RINGTONE,
|
||||
RawContacts.ACCOUNT_NAME,
|
||||
RawContacts.ACCOUNT_TYPE
|
||||
)
|
||||
|
@ -115,6 +115,7 @@ class VcfImporter(val activity: SimpleActivity) {
|
||||
val photoData = ezContact.photos.firstOrNull()?.data
|
||||
val photo = null
|
||||
val thumbnailUri = savePhoto(photoData)
|
||||
val ringtone = null
|
||||
|
||||
val IMs = ArrayList<IM>()
|
||||
ezContact.impps.forEach {
|
||||
@ -138,7 +139,7 @@ class VcfImporter(val activity: SimpleActivity) {
|
||||
}
|
||||
|
||||
val contact = Contact(0, prefix, firstName, middleName, surname, suffix, nickname, photoUri, phoneNumbers, emails, addresses, events,
|
||||
targetContactSource, starred, contactId, thumbnailUri, photo, notes, groups, organization, websites, IMs, DEFAULT_MIMETYPE)
|
||||
targetContactSource, starred, contactId, thumbnailUri, photo, notes, groups, organization, websites, IMs, DEFAULT_MIMETYPE, ringtone)
|
||||
|
||||
// if there is no N and ORG fields at the given contact, only FN, treat it as an organization
|
||||
if (contact.getNameToDisplay().isEmpty() && contact.organization.isEmpty() && ezContact.formattedName?.value?.isNotEmpty() == true) {
|
||||
|
@ -13,8 +13,9 @@ import com.simplemobiletools.contacts.pro.helpers.SMT_PRIVATE
|
||||
data class Contact(var id: Int, var prefix: String, var firstName: String, var middleName: String, var surname: String, var suffix: String, var nickname: String,
|
||||
var photoUri: String, var phoneNumbers: ArrayList<PhoneNumber>, var emails: ArrayList<Email>, var addresses: ArrayList<Address>,
|
||||
var events: ArrayList<Event>, var source: String, var starred: Int, var contactId: Int, var thumbnailUri: String, var photo: Bitmap?, var notes: String,
|
||||
var groups: ArrayList<Group>, var organization: Organization, var websites: ArrayList<String>, var IMs: ArrayList<IM>, var mimetype: String) :
|
||||
Comparable<Contact> {
|
||||
var groups: ArrayList<Group>, var organization: Organization, var websites: ArrayList<String>, var IMs: ArrayList<IM>, var mimetype: String,
|
||||
var ringtone: String?) :
|
||||
Comparable<Contact> {
|
||||
companion object {
|
||||
var sorting = 0
|
||||
var startWithSurname = false
|
||||
@ -71,7 +72,7 @@ data class Contact(var id: Int, var prefix: String, var firstName: String, var m
|
||||
} else if (firstString.isNotEmpty() && secondString.isEmpty()) {
|
||||
-1
|
||||
} else {
|
||||
if (firstString.toLowerCase() == secondString.toLowerCase()) {
|
||||
if (firstString.equals(secondString, ignoreCase = true)) {
|
||||
getNameToDisplay().compareTo(other.getNameToDisplay(), true)
|
||||
} else {
|
||||
firstString.compareTo(secondString, true)
|
||||
@ -130,9 +131,9 @@ data class Contact(var id: Int, var prefix: String, var firstName: String, var m
|
||||
val normalizedText = if (convertLetters) text.normalizePhoneNumber() else text
|
||||
phoneNumbers.any {
|
||||
PhoneNumberUtils.compare(it.normalizedNumber, normalizedText) ||
|
||||
it.value.contains(text) ||
|
||||
it.normalizedNumber?.contains(normalizedText) == true ||
|
||||
it.value.normalizePhoneNumber().contains(normalizedText)
|
||||
it.value.contains(text) ||
|
||||
it.normalizedNumber?.contains(normalizedText) == true ||
|
||||
it.value.normalizePhoneNumber().contains(normalizedText)
|
||||
}
|
||||
} else {
|
||||
false
|
||||
|
Reference in New Issue
Block a user