diff --git a/app/build.gradle b/app/build.gradle index 6693d0ab..3e099776 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.31.10' + implementation 'com.simplemobiletools:commons:5.31.11' implementation 'joda-time:joda-time:2.10.1' implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5' implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a' diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/contentproviders/MyContactsContentProvider.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/contentproviders/MyContactsContentProvider.kt index 7ba33608..ca2bfd19 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/contentproviders/MyContactsContentProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/contentproviders/MyContactsContentProvider.kt @@ -22,17 +22,24 @@ class MyContactsContentProvider : ContentProvider() { MyContactsContentProvider.COL_CONTACT_ID, MyContactsContentProvider.COL_NAME, MyContactsContentProvider.COL_PHOTO_URI, - MyContactsContentProvider.COL_PHONE_NUMBERS) + MyContactsContentProvider.COL_PHONE_NUMBERS, + MyContactsContentProvider.COL_BIRTHDAYS, + MyContactsContentProvider.COL_ANNIVERSARIES) ) LocalContactsHelper(context!!).getPrivateSimpleContactsSync(selection == MyContactsContentProvider.FAVORITES_ONLY).forEach { val phoneNumbers = Gson().toJson(it.phoneNumbers) + val birthdays = Gson().toJson(it.birthdays) + val anniversaries = Gson().toJson(it.anniversaries) + matrixCursor.newRow() .add(MyContactsContentProvider.COL_RAW_ID, it.rawId) .add(MyContactsContentProvider.COL_CONTACT_ID, it.contactId) .add(MyContactsContentProvider.COL_NAME, it.name) .add(MyContactsContentProvider.COL_PHOTO_URI, it.photoUri) .add(MyContactsContentProvider.COL_PHONE_NUMBERS, phoneNumbers) + .add(MyContactsContentProvider.COL_BIRTHDAYS, birthdays) + .add(MyContactsContentProvider.COL_ANNIVERSARIES, anniversaries) } return matrixCursor diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/String.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/String.kt deleted file mode 100644 index 33257efb..00000000 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/String.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.simplemobiletools.contacts.pro.extensions - -import android.widget.TextView -import com.simplemobiletools.commons.helpers.getDateFormats -import org.joda.time.DateTime -import org.joda.time.format.DateTimeFormat -import java.text.DateFormat -import java.text.SimpleDateFormat -import java.util.* - -fun String.getDateTimeFromDateString(viewToUpdate: TextView? = null): DateTime { - val dateFormats = getDateFormats() - var date = DateTime() - for (format in dateFormats) { - try { - date = DateTime.parse(this, DateTimeFormat.forPattern(format)) - - val formatter = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.getDefault()) - var localPattern = (formatter as SimpleDateFormat).toLocalizedPattern() - - val hasYear = format.contains("y") - if (!hasYear) { - localPattern = localPattern.replace("y", "").replace(",", "").trim() - date = date.withYear(DateTime().year) - } - - val formattedString = date.toString(localPattern) - viewToUpdate?.text = formattedString - break - } catch (ignored: Exception) { - } - } - return date -} diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/LocalContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/LocalContactsHelper.kt index 3519ab02..cb415e7a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/LocalContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/LocalContactsHelper.kt @@ -4,6 +4,7 @@ import android.content.Context import android.graphics.Bitmap import android.graphics.BitmapFactory import android.net.Uri +import android.provider.ContactsContract.CommonDataKinds.Event import android.provider.MediaStore import com.simplemobiletools.commons.extensions.getChoppedList import com.simplemobiletools.commons.models.SimpleContact @@ -158,7 +159,9 @@ class LocalContactsHelper(val context: Context) { null } else { val phoneNumbers = contact.phoneNumbers.map { it.value }.toMutableList() as ArrayList - SimpleContact(contact.id, contact.id, contact.getNameToDisplay(), contact.photoUri, phoneNumbers) + val birthdays = contact.events.filter { it.type == Event.TYPE_BIRTHDAY }.map { it.value }.toMutableList() as ArrayList + val anniversaries = contact.events.filter { it.type == Event.TYPE_ANNIVERSARY }.map { it.value }.toMutableList() as ArrayList + SimpleContact(contact.id, contact.id, contact.getNameToDisplay(), contact.photoUri, phoneNumbers, birthdays, anniversaries) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt index 972ba02a..d819f3fe 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt @@ -5,11 +5,11 @@ import android.provider.ContactsContract.CommonDataKinds import android.provider.ContactsContract.CommonDataKinds.* import android.provider.MediaStore import com.simplemobiletools.commons.activities.BaseSimpleActivity +import com.simplemobiletools.commons.extensions.getDateTimeFromDateString import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.extensions.getByteArray -import com.simplemobiletools.contacts.pro.extensions.getDateTimeFromDateString import com.simplemobiletools.contacts.pro.helpers.VcfExporter.ExportResult.EXPORT_FAIL import com.simplemobiletools.contacts.pro.models.Contact import ezvcard.Ezvcard