adding some preparation for setting custom contact ringtones

This commit is contained in:
tibbi 2021-02-14 10:15:56 +01:00
parent b1f2316792
commit 8f050c48ee
37 changed files with 48 additions and 10 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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
)

View File

@ -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) {

View File

@ -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

View File

@ -105,6 +105,7 @@
<string name="groups">مجموعات</string>
<string name="contact_source">مصدر الاتصال</string>
<string name="instant_messaging">المراسلة الفورية (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Qruplar </string>
<string name="contact_source">Kontakt kökü</string>
<string name="instant_messaging">Instant messaging (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Skupiny</string>
<string name="contact_source">Zdroje kontaktů</string>
<string name="instant_messaging">Rychlé zprávy (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Kontakt bude vymazán ze všech zdrojů kontaktů.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Grwpiau</string>
<string name="contact_source">Ffynhonnell gyswllt</string>
<string name="instant_messaging">Negesu ar unwaith (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Groupper</string>
<string name="contact_source">Kontaktkilde</string>
<string name="instant_messaging">Instant messaging (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Gruppen</string>
<string name="contact_source">Kontaktquelle</string>
<string name="instant_messaging">Instant messaging (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Der Kontakt wird von allen Kontaktquellen entfernt.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Ομάδες</string>
<string name="contact_source">Προέλευση επαφής</string>
<string name="instant_messaging">Αμεσο μήνυμα (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Η επαφή θα καταργηθεί από όλες τις πηγές επαφών.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Grupos</string>
<string name="contact_source">Orígenes de contacto</string>
<string name="instant_messaging">Mensaje instantáneo (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">El contacto será eliminado de todos los orígenes de contactos.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Taldeak</string>
<string name="contact_source">Kontaktu jatorria</string>
<string name="instant_messaging">Instant messaging (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Ryhmät</string>
<string name="contact_source">Yhteystiedon lähde</string>
<string name="instant_messaging">Pikaviestin</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Yhteystieto poistetaan kaikista lähteistä.</string>

View File

@ -103,6 +103,7 @@
<string name="groups">Groupe</string>
<string name="contact_source">Source du contact</string>
<string name="instant_messaging">Messagerie instantanée (MI)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Le contact sera supprimé de toutes les sources de contacts.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Grupe</string>
<string name="contact_source">Izvori kontakata</string>
<string name="instant_messaging">Brzo slanje poruka (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Csoportok</string>
<string name="contact_source">Névjegy account</string>
<string name="instant_messaging">Instant messaging (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Grup</string>
<string name="contact_source">Sumber kontak</string>
<string name="instant_messaging">Pesan singkat (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Kontak akan dihapus dari semua sumber kontak.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Grup</string>
<string name="contact_source">Sumber kontak</string>
<string name="instant_messaging">Pesan singkat (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Kontak akan dihapus dari semua sumber kontak.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Gruppi</string>
<string name="contact_source">Provenienza del contatto</string>
<string name="instant_messaging">Messaggistica istantanea (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">グループ</string>
<string name="contact_source">インポート元</string>
<string name="instant_messaging">インスタントメッセージ(IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">全ての連絡先ソースから連絡先を消去します</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Groups</string>
<string name="contact_source">Contact source</string>
<string name="instant_messaging">Instant messaging (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Grupės</string>
<string name="contact_source">Kontakto šaltinis</string>
<string name="instant_messaging">Instant messaging (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">ഗ്രൂപ്പുകൾ</string>
<string name="contact_source">കോൺ‌ടാക്റ്റ് ഉറവിടം</string>
<string name="instant_messaging">തത്സമയ സന്ദേശം അയക്കൽ</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">എല്ലാ കോൺ‌ടാക്റ്റ് ഉറവിടങ്ങളിൽ‌ നിന്നും ഈ കോൺ‌ടാക്റ്റ് നീക്കംചെയ്യും.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Groepen</string>
<string name="contact_source">Account</string>
<string name="instant_messaging">Instant messaging (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">De contactpersoon zal worden verwijderd uit alle accounts.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Grupy</string>
<string name="contact_source">Miejsce przechowywania kontaktu</string>
<string name="instant_messaging">Komunikator</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Grupos</string>
<string name="contact_source">Origem do contato</string>
<string name="instant_messaging">Mensageiro instantâneo (MI)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">O contato será removido de todas removido de todas as fontes de contato.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Grupos</string>
<string name="contact_source">Origem do contacto</string>
<string name="instant_messaging">Mensagem instantânea (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">O contacto será apagado de todas as origens.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Группы</string>
<string name="contact_source">Источник контакта</string>
<string name="instant_messaging">Мессенджеры</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Контакт будет удалён из всех источников контактов.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Skupiny</string>
<string name="contact_source">Zdroje kontaktov</string>
<string name="instant_messaging">Rýchle správy (IM)</string>
<string name="ringtone">Zvonenie</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Kontakt bude vymazaný zo všetkých zdrojov kontaktov.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Grupper</string>
<string name="contact_source">Kontaktkälla</string>
<string name="instant_messaging">Snabbmeddelanden (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Kontakten kommer att tas bort från alla kontaktkällor.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Gruplar</string>
<string name="contact_source">Kişi kaynağı</string>
<string name="instant_messaging">Anlık mesajlaşma (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">Kişi tüm kişi kaynaklarından kaldırılacak.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Групи</string>
<string name="contact_source">Походження контакту</string>
<string name="instant_messaging">Мессенджери</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>

View File

@ -105,6 +105,7 @@
<string name="groups">群组</string>
<string name="contact_source">联系人来源</string>
<string name="instant_messaging">即时通讯 (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">该联系人将会被从所有联系人来源移除。</string>

View File

@ -105,6 +105,7 @@
<string name="groups">群組</string>
<string name="contact_source">聯絡人來源</string>
<string name="instant_messaging">即時通訊 (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">這聯絡人將從全部通訊錄來源移除。</string>

View File

@ -105,6 +105,7 @@
<string name="groups">Groups</string>
<string name="contact_source">Contact source</string>
<string name="instant_messaging">Instant messaging (IM)</string>
<string name="ringtone">Ringtone</string>
<!-- Confirmation dialog -->
<string name="delete_from_all_sources">The contact will be removed from all contact sources.</string>