mirror of
https://github.com/FossifyOrg/Contacts.git
synced 2025-12-23 23:59:46 -05:00
chore(deps): bump com.googlecode.ez-vcard:ez-vcard from 0.11.3 to 0.12.1 (#250)
* chore(deps): bump com.googlecode.ez-vcard:ez-vcard from 0.11.3 to 0.12.1 Bumps [com.googlecode.ez-vcard:ez-vcard](https://github.com/mangstadt/ez-vcard) from 0.11.3 to 0.12.1. - [Commits](https://github.com/mangstadt/ez-vcard/compare/0.11.3...0.12.1) --- updated-dependencies: - dependency-name: com.googlecode.ez-vcard:ez-vcard dependency-version: 0.12.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * refactor: use java.time for date handling in VcfExporter * refactor: minor code formatting * fix: always export vCard V4 See: https://github.com/FossifyOrg/Contacts/discussions/196 * refactor: optimize imports * refactor: remove RequiresApi annotation * chore: update lint baselines * docs: update changelog --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Naveen Singh <snaveen935@gmail.com>
This commit is contained in:
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- All contact exports now use the vCard 4.0 format
|
||||
|
||||
## [1.2.2] - 2025-06-17
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<ID>CyclomaticComplexMethod:MyViewPagerFragment.kt$MyViewPagerFragment$fun onSearchQueryChanged(text: String)</ID>
|
||||
<ID>CyclomaticComplexMethod:MyViewPagerFragment.kt$MyViewPagerFragment$fun refreshContacts(contacts: ArrayList<Contact>, placeholderText: String? = null)</ID>
|
||||
<ID>CyclomaticComplexMethod:SelectContactsAdapter.kt$SelectContactsAdapter.ViewHolder$fun bindView(contact: Contact): View</ID>
|
||||
<ID>CyclomaticComplexMethod:VcfExporter.kt$VcfExporter$@RequiresApi(Build.VERSION_CODES.P) fun exportContacts( context: Context, outputStream: OutputStream?, contacts: ArrayList<Contact>, showExportingToast: Boolean, version: VCardVersion = VCardVersion.V4_0, callback: (result: ExportResult) -> Unit, )</ID>
|
||||
<ID>CyclomaticComplexMethod:VcfExporter.kt$VcfExporter$fun exportContacts( context: Context, outputStream: OutputStream?, contacts: ArrayList<Contact>, showExportingToast: Boolean, version: VCardVersion = VCardVersion.V4_0, callback: (result: ExportResult) -> Unit, )</ID>
|
||||
<ID>CyclomaticComplexMethod:VcfImporter.kt$VcfImporter$fun importContacts(path: String, targetContactSource: String): ImportResult</ID>
|
||||
<ID>CyclomaticComplexMethod:ViewContactActivity.kt$ViewContactActivity$private fun setupPhoneNumbers()</ID>
|
||||
<ID>EmptyCatchBlock:ContactsAdapter.kt$ContactsAdapter${ }</ID>
|
||||
@@ -21,13 +21,9 @@
|
||||
<ID>EmptyFunctionBlock:GroupsAdapter.kt$GroupsAdapter${}</ID>
|
||||
<ID>EmptyFunctionBlock:InsertOrEditContactActivity.kt$InsertOrEditContactActivity.<no name provided>${}</ID>
|
||||
<ID>EmptyFunctionBlock:MainActivity.kt$MainActivity.<no name provided>${}</ID>
|
||||
<ID>ImplicitDefaultLocale:VcfImporter.kt$VcfImporter$String.format("%02d", date.date)</ID>
|
||||
<ID>ImplicitDefaultLocale:VcfImporter.kt$VcfImporter$String.format("%02d", date.month + 1)</ID>
|
||||
<ID>ImplicitDefaultLocale:VcfImporter.kt$VcfImporter$String.format("%02d", partialDate.date)</ID>
|
||||
<ID>ImplicitDefaultLocale:VcfImporter.kt$VcfImporter$String.format("%02d", partialDate.month)</ID>
|
||||
<ID>LargeClass:EditContactActivity.kt$EditContactActivity : ContactActivity</ID>
|
||||
<ID>LargeClass:ViewContactActivity.kt$ViewContactActivity : ContactActivity</ID>
|
||||
<ID>LongMethod:VcfExporter.kt$VcfExporter$@RequiresApi(Build.VERSION_CODES.P) fun exportContacts( context: Context, outputStream: OutputStream?, contacts: ArrayList<Contact>, showExportingToast: Boolean, version: VCardVersion = VCardVersion.V4_0, callback: (result: ExportResult) -> Unit, )</ID>
|
||||
<ID>LongMethod:VcfExporter.kt$VcfExporter$fun exportContacts( context: Context, outputStream: OutputStream?, contacts: ArrayList<Contact>, showExportingToast: Boolean, version: VCardVersion = VCardVersion.V4_0, callback: (result: ExportResult) -> Unit, )</ID>
|
||||
<ID>LongMethod:VcfImporter.kt$VcfImporter$fun importContacts(path: String, targetContactSource: String): ImportResult</ID>
|
||||
<ID>MagicNumber:AutomaticBackupReceiver.kt$AutomaticBackupReceiver$3000</ID>
|
||||
<ID>MagicNumber:Constants.kt$6</ID>
|
||||
@@ -42,7 +38,6 @@
|
||||
<ID>MagicNumber:MyDatePickerDialog.kt$MyDatePickerDialog$5</ID>
|
||||
<ID>MagicNumber:MyDatePickerDialog.kt$MyDatePickerDialog$7</ID>
|
||||
<ID>MagicNumber:MyDatePickerDialog.kt$MyDatePickerDialog$8</ID>
|
||||
<ID>MagicNumber:VcfExporter.kt$VcfExporter$1900</ID>
|
||||
<ID>MagicNumber:VcfImporter.kt$VcfImporter$100</ID>
|
||||
<ID>MagicNumber:VcfImporter.kt$VcfImporter$1900</ID>
|
||||
<ID>MaxLineLength:Activity.kt$fun</ID>
|
||||
@@ -169,7 +164,6 @@
|
||||
<ID>MaxLineLength:SettingsActivity.kt$SettingsActivity$binding.settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())</ID>
|
||||
<ID>MaxLineLength:SettingsActivity.kt$SettingsActivity$updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)</ID>
|
||||
<ID>MaxLineLength:SettingsActivity.kt$SettingsActivity$}</ID>
|
||||
<ID>MaxLineLength:VcfImporter.kt$VcfImporter$.</ID>
|
||||
<ID>MaxLineLength:ViewContactActivity.kt$ViewContactActivity$.</ID>
|
||||
<ID>MaxLineLength:ViewContactActivity.kt$ViewContactActivity$// a contact cannot have different emails per contact source. Such contacts are handled as separate ones, not duplicates of each other</ID>
|
||||
<ID>MaxLineLength:ViewContactActivity.kt$ViewContactActivity$binding.contactEventsImage</ID>
|
||||
@@ -185,7 +179,7 @@
|
||||
<ID>NestedBlockDepth:EditContactActivity.kt$EditContactActivity$private fun initContact()</ID>
|
||||
<ID>NestedBlockDepth:MainActivity.kt$MainActivity$private fun getDefaultTab(): Int</ID>
|
||||
<ID>NestedBlockDepth:SelectContactsAdapter.kt$SelectContactsAdapter.ViewHolder$fun bindView(contact: Contact): View</ID>
|
||||
<ID>NestedBlockDepth:VcfExporter.kt$VcfExporter$@RequiresApi(Build.VERSION_CODES.P) fun exportContacts( context: Context, outputStream: OutputStream?, contacts: ArrayList<Contact>, showExportingToast: Boolean, version: VCardVersion = VCardVersion.V4_0, callback: (result: ExportResult) -> Unit, )</ID>
|
||||
<ID>NestedBlockDepth:VcfExporter.kt$VcfExporter$fun exportContacts( context: Context, outputStream: OutputStream?, contacts: ArrayList<Contact>, showExportingToast: Boolean, version: VCardVersion = VCardVersion.V4_0, callback: (result: ExportResult) -> Unit, )</ID>
|
||||
<ID>NestedBlockDepth:VcfImporter.kt$VcfImporter$fun importContacts(path: String, targetContactSource: String): ImportResult</ID>
|
||||
<ID>NestedBlockDepth:VcfImporter.kt$VcfImporter$private fun getContactGroups(ezContact: VCard): ArrayList<Group></ID>
|
||||
<ID>NestedBlockDepth:ViewContactActivity.kt$ViewContactActivity$private fun initContact()</ID>
|
||||
@@ -249,8 +243,6 @@
|
||||
<ID>VariableNaming:VcfImporter.kt$VcfImporter$val IMs = ArrayList<IM>()</ID>
|
||||
<ID>VariableNaming:ViewContactActivity.kt$ViewContactActivity$val IM = it</ID>
|
||||
<ID>VariableNaming:ViewContactActivity.kt$ViewContactActivity$var IMs = contact!!.IMs.toMutableSet() as LinkedHashSet<IM></ID>
|
||||
<ID>WildcardImport:Activity.kt$import org.fossify.commons.extensions.*</ID>
|
||||
<ID>WildcardImport:Activity.kt$import org.fossify.commons.helpers.*</ID>
|
||||
<ID>WildcardImport:ChangeSortingDialog.kt$import org.fossify.commons.helpers.*</ID>
|
||||
<ID>WildcardImport:ContactActivity.kt$import android.provider.ContactsContract.CommonDataKinds.*</ID>
|
||||
<ID>WildcardImport:ContactActivity.kt$import org.fossify.commons.extensions.*</ID>
|
||||
|
||||
@@ -1,71 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<issues format="6" by="lint 8.11.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.11.0)" variant="all" version="8.11.0">
|
||||
|
||||
<issue
|
||||
id="DefaultLocale"
|
||||
message="Implicitly using the default locale is a common source of bugs: Use `String.format(Locale, ...)` instead"
|
||||
errorLine1=" val month = String.format("%02d", date.month + 1)"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/main/kotlin/org/fossify/contacts/helpers/VcfImporter.kt"
|
||||
line="297"
|
||||
column="21"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="DefaultLocale"
|
||||
message="Implicitly using the default locale is a common source of bugs: Use `String.format(Locale, ...)` instead"
|
||||
errorLine1=" val day = String.format("%02d", date.date)"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/main/kotlin/org/fossify/contacts/helpers/VcfImporter.kt"
|
||||
line="298"
|
||||
column="19"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="DefaultLocale"
|
||||
message="Implicitly using the default locale is a common source of bugs: Use `String.format(Locale, ...)` instead"
|
||||
errorLine1=" val month = String.format("%02d", partialDate.month)"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/main/kotlin/org/fossify/contacts/helpers/VcfImporter.kt"
|
||||
line="303"
|
||||
column="21"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="DefaultLocale"
|
||||
message="Implicitly using the default locale is a common source of bugs: Use `String.format(Locale, ...)` instead"
|
||||
errorLine1=" val day = String.format("%02d", partialDate.date)"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/main/kotlin/org/fossify/contacts/helpers/VcfImporter.kt"
|
||||
line="304"
|
||||
column="19"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Call requires API level 28 (current min is 26): `exportContacts`"
|
||||
errorLine1=" VcfExporter().exportContacts(this, it, contacts, false, version = VCardVersion.V3_0) {"
|
||||
errorLine2=" ~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/main/kotlin/org/fossify/contacts/extensions/Activity.kt"
|
||||
line="71"
|
||||
column="23"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Call requires API level 28 (current min is 26): `exportContacts`"
|
||||
errorLine1=" VcfExporter().exportContacts("
|
||||
errorLine2=" ~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/main/kotlin/org/fossify/contacts/extensions/Context.kt"
|
||||
line="134"
|
||||
column="27"/>
|
||||
</issue>
|
||||
<issues format="6" by="lint 8.11.1" type="baseline" client="gradle" dependencies="false" name="AGP (8.11.1)" variant="all" version="8.11.1">
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
@@ -78,17 +12,6 @@
|
||||
column="13"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Call requires API level 28 (current min is 26): `exportContacts`"
|
||||
errorLine1=" VcfExporter().exportContacts(this, outputStream, contacts, true) { result ->"
|
||||
errorLine2=" ~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="src/main/kotlin/org/fossify/contacts/activities/SettingsActivity.kt"
|
||||
line="374"
|
||||
column="31"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NotificationPermission"
|
||||
message="When targeting Android 13 or higher, posting a permission requires holding the `POST_NOTIFICATIONS` permission (usage from org.fossify.commons.asynctasks.CopyMoveTask)">
|
||||
@@ -102,7 +25,7 @@
|
||||
errorLine1="app-build-targetSDK = "34""
|
||||
errorLine2=" ~~~~">
|
||||
<location
|
||||
file="$HOME/work/Contacts/Contacts/gradle/libs.versions.toml"
|
||||
file="$HOME/Projects/Fossify/FossifyOrg/Contacts/gradle/libs.versions.toml"
|
||||
line="25"
|
||||
column="23"/>
|
||||
</issue>
|
||||
@@ -168,44 +91,33 @@
|
||||
errorLine1="distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="$HOME/work/Contacts/Contacts/gradle/wrapper/gradle-wrapper.properties"
|
||||
file="$HOME/Projects/Fossify/FossifyOrg/Contacts/gradle/wrapper/gradle-wrapper.properties"
|
||||
line="3"
|
||||
column="17"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="GradleDependency"
|
||||
message="A newer version of org.fossify:commons than 4.2.0 is available: 4.3.0"
|
||||
errorLine1="commons = "4.2.0""
|
||||
errorLine2=" ~~~~~~~">
|
||||
<location
|
||||
file="$HOME/Projects/Fossify/FossifyOrg/Contacts/gradle/libs.versions.toml"
|
||||
line="20"
|
||||
column="11"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="GradleDependency"
|
||||
message="A newer version of `compileSdkVersion` than 34 is available: 36"
|
||||
errorLine1="app-build-compileSDKVersion = "34""
|
||||
errorLine2=" ~~~~">
|
||||
<location
|
||||
file="$HOME/work/Contacts/Contacts/gradle/libs.versions.toml"
|
||||
file="$HOME/Projects/Fossify/FossifyOrg/Contacts/gradle/libs.versions.toml"
|
||||
line="24"
|
||||
column="31"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewerVersionAvailable"
|
||||
message="A newer version of org.jetbrains.kotlin.android than 2.1.21 is available: 2.2.0"
|
||||
errorLine1="kotlin = "2.1.21""
|
||||
errorLine2=" ~~~~~~~~">
|
||||
<location
|
||||
file="$HOME/work/Contacts/Contacts/gradle/libs.versions.toml"
|
||||
line="3"
|
||||
column="10"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewerVersionAvailable"
|
||||
message="A newer version of com.googlecode.ez-vcard:ez-vcard than 0.11.3 is available: 0.12.1"
|
||||
errorLine1="ezvcard = "0.11.3""
|
||||
errorLine2=" ~~~~~~~~">
|
||||
<location
|
||||
file="$HOME/work/Contacts/Contacts/gradle/libs.versions.toml"
|
||||
line="14"
|
||||
column="11"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="UseCompatLoadingForDrawables"
|
||||
message="Use `ResourcesCompat.getDrawable()`"
|
||||
|
||||
@@ -371,7 +371,12 @@ class SettingsActivity : SimpleActivity() {
|
||||
if (contacts.isEmpty()) {
|
||||
toast(org.fossify.commons.R.string.no_entries_for_exporting)
|
||||
} else {
|
||||
VcfExporter().exportContacts(this, outputStream, contacts, true) { result ->
|
||||
VcfExporter().exportContacts(
|
||||
context = this,
|
||||
outputStream = outputStream,
|
||||
contacts = contacts,
|
||||
showExportingToast = true
|
||||
) { result ->
|
||||
toast(
|
||||
when (result) {
|
||||
VcfExporter.ExportResult.EXPORT_OK -> org.fossify.commons.R.string.exporting_successful
|
||||
|
||||
@@ -3,11 +3,28 @@ package org.fossify.contacts.extensions
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import ezvcard.VCardVersion
|
||||
import org.fossify.commons.activities.BaseSimpleActivity
|
||||
import org.fossify.commons.dialogs.RadioGroupDialog
|
||||
import org.fossify.commons.extensions.*
|
||||
import org.fossify.commons.helpers.*
|
||||
import org.fossify.commons.extensions.getFileOutputStream
|
||||
import org.fossify.commons.extensions.getPublicContactSourceSync
|
||||
import org.fossify.commons.extensions.getTempFile
|
||||
import org.fossify.commons.extensions.getVisibleContactSources
|
||||
import org.fossify.commons.extensions.hideKeyboard
|
||||
import org.fossify.commons.extensions.launchActivityIntent
|
||||
import org.fossify.commons.extensions.sharePathIntent
|
||||
import org.fossify.commons.extensions.showErrorToast
|
||||
import org.fossify.commons.extensions.toFileDirItem
|
||||
import org.fossify.commons.extensions.toast
|
||||
import org.fossify.commons.extensions.tryInitiateCall
|
||||
import org.fossify.commons.helpers.CONTACT_ID
|
||||
import org.fossify.commons.helpers.ContactsHelper
|
||||
import org.fossify.commons.helpers.IS_PRIVATE
|
||||
import org.fossify.commons.helpers.ON_CLICK_CALL_CONTACT
|
||||
import org.fossify.commons.helpers.ON_CLICK_EDIT_CONTACT
|
||||
import org.fossify.commons.helpers.ON_CLICK_VIEW_CONTACT
|
||||
import org.fossify.commons.helpers.PERMISSION_CALL_PHONE
|
||||
import org.fossify.commons.helpers.SMT_PRIVATE
|
||||
import org.fossify.commons.helpers.ensureBackgroundThread
|
||||
import org.fossify.commons.models.RadioItem
|
||||
import org.fossify.commons.models.contacts.Contact
|
||||
import org.fossify.contacts.BuildConfig
|
||||
@@ -66,9 +83,12 @@ fun BaseSimpleActivity.shareContacts(contacts: ArrayList<Contact>) {
|
||||
}
|
||||
|
||||
getFileOutputStream(file.toFileDirItem(this), true) {
|
||||
|
||||
// whatsApp does not support vCard version 4.0 yet
|
||||
VcfExporter().exportContacts(this, it, contacts, false, version = VCardVersion.V3_0) {
|
||||
VcfExporter().exportContacts(
|
||||
context = this,
|
||||
outputStream = it,
|
||||
contacts = contacts,
|
||||
showExportingToast = false
|
||||
) {
|
||||
if (it == VcfExporter.ExportResult.EXPORT_OK) {
|
||||
sharePathIntent(file.absolutePath, BuildConfig.APPLICATION_ID)
|
||||
} else {
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
package org.fossify.contacts.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.provider.ContactsContract.CommonDataKinds.Email
|
||||
import android.provider.ContactsContract.CommonDataKinds.Event
|
||||
import android.provider.ContactsContract.CommonDataKinds.Im
|
||||
import android.provider.ContactsContract.CommonDataKinds.Phone
|
||||
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.net.toUri
|
||||
import ezvcard.Ezvcard
|
||||
import ezvcard.VCard
|
||||
import ezvcard.VCardVersion
|
||||
import ezvcard.parameter.ImageType
|
||||
import ezvcard.property.*
|
||||
import ezvcard.util.PartialDate
|
||||
import org.fossify.commons.extensions.getDateTimeFromDateString
|
||||
import org.fossify.commons.extensions.showErrorToast
|
||||
import org.fossify.commons.extensions.toast
|
||||
import org.fossify.commons.models.contacts.Contact
|
||||
import org.fossify.contacts.helpers.VcfExporter.ExportResult.EXPORT_FAIL
|
||||
import java.io.OutputStream
|
||||
import java.util.Calendar
|
||||
import java.time.LocalDate
|
||||
|
||||
class VcfExporter {
|
||||
enum class ExportResult {
|
||||
@@ -30,7 +29,6 @@ class VcfExporter {
|
||||
private var contactsExported = 0
|
||||
private var contactsFailed = 0
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.P)
|
||||
fun exportContacts(
|
||||
context: Context,
|
||||
outputStream: OutputStream?,
|
||||
@@ -95,20 +93,25 @@ class VcfExporter {
|
||||
contact.events.forEach { event ->
|
||||
if (event.type == Event.TYPE_ANNIVERSARY || event.type == Event.TYPE_BIRTHDAY) {
|
||||
val dateTime = event.value.getDateTimeFromDateString(false)
|
||||
Calendar.getInstance().apply {
|
||||
clear()
|
||||
if (event.value.startsWith("--")) {
|
||||
set(Calendar.YEAR, 1900)
|
||||
} else {
|
||||
set(Calendar.YEAR, dateTime.year)
|
||||
if (event.value.startsWith("--")) {
|
||||
val partial = PartialDate.builder()
|
||||
.month(dateTime.monthOfYear)
|
||||
.date(dateTime.dayOfMonth)
|
||||
.build()
|
||||
|
||||
}
|
||||
set(Calendar.MONTH, dateTime.monthOfYear - 1)
|
||||
set(Calendar.DAY_OF_MONTH, dateTime.dayOfMonth)
|
||||
if (event.type == Event.TYPE_BIRTHDAY) {
|
||||
card.birthdays.add(Birthday(time))
|
||||
card.birthdays.add(Birthday(partial))
|
||||
} else {
|
||||
card.anniversaries.add(Anniversary(time))
|
||||
card.anniversaries.add(Anniversary(partial))
|
||||
}
|
||||
} else {
|
||||
val date = LocalDate
|
||||
.of(dateTime.year, dateTime.monthOfYear, dateTime.dayOfMonth)
|
||||
|
||||
if (event.type == Event.TYPE_BIRTHDAY) {
|
||||
card.birthdays.add(Birthday(date))
|
||||
} else {
|
||||
card.anniversaries.add(Anniversary(date))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.fossify.contacts.helpers.VcfImporter.ImportResult.IMPORT_PARTIAL
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.net.URLDecoder
|
||||
import java.util.Date
|
||||
import java.time.LocalDate
|
||||
import java.util.Locale
|
||||
|
||||
class VcfImporter(val activity: SimpleActivity) {
|
||||
@@ -139,7 +139,7 @@ class VcfImporter(val activity: SimpleActivity) {
|
||||
}
|
||||
|
||||
address = address.trim()
|
||||
if (address.isNotEmpty() == true) {
|
||||
if (address.isNotEmpty()) {
|
||||
addresses.add(
|
||||
Address(
|
||||
value = address,
|
||||
@@ -161,7 +161,7 @@ class VcfImporter(val activity: SimpleActivity) {
|
||||
ezContact.anniversaries.forEach { anniversary ->
|
||||
val event = if (anniversary.date != null) {
|
||||
Event(
|
||||
formatDateToDayCode(anniversary.date),
|
||||
formatDateToDayCode(LocalDate.from(anniversary.date)),
|
||||
CommonDataKinds.Event.TYPE_ANNIVERSARY
|
||||
)
|
||||
} else {
|
||||
@@ -176,7 +176,7 @@ class VcfImporter(val activity: SimpleActivity) {
|
||||
ezContact.birthdays.forEach { birthday ->
|
||||
val event = if (birthday.date != null) {
|
||||
Event(
|
||||
formatDateToDayCode(birthday.date),
|
||||
formatDateToDayCode(LocalDate.from(birthday.date)),
|
||||
CommonDataKinds.Event.TYPE_BIRTHDAY
|
||||
)
|
||||
} else {
|
||||
@@ -229,44 +229,50 @@ class VcfImporter(val activity: SimpleActivity) {
|
||||
else -> Im.PROTOCOL_CUSTOM
|
||||
}
|
||||
|
||||
val label = if (type == Im.PROTOCOL_CUSTOM) URLDecoder.decode(
|
||||
typeString,
|
||||
"UTF-8"
|
||||
) else ""
|
||||
val label = if (type == Im.PROTOCOL_CUSTOM) {
|
||||
URLDecoder.decode(
|
||||
typeString,
|
||||
"UTF-8"
|
||||
)
|
||||
} else {
|
||||
""
|
||||
}
|
||||
val IM = IM(value, type, label)
|
||||
IMs.add(IM)
|
||||
}
|
||||
|
||||
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,
|
||||
ringtone
|
||||
id = 0,
|
||||
prefix = prefix,
|
||||
firstName = firstName,
|
||||
middleName = middleName,
|
||||
surname = surname,
|
||||
suffix = suffix,
|
||||
nickname = nickname,
|
||||
photoUri = photoUri,
|
||||
phoneNumbers = phoneNumbers,
|
||||
emails = emails,
|
||||
addresses = addresses,
|
||||
events = events,
|
||||
source = targetContactSource,
|
||||
starred = starred,
|
||||
contactId = contactId,
|
||||
thumbnailUri = thumbnailUri,
|
||||
photo = photo,
|
||||
notes = notes,
|
||||
groups = groups,
|
||||
organization = organization,
|
||||
websites = websites,
|
||||
IMs = IMs,
|
||||
mimetype = DEFAULT_MIMETYPE,
|
||||
ringtone = 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
|
||||
if (
|
||||
contact.getNameToDisplay().isEmpty()
|
||||
&& contact.organization.isEmpty()
|
||||
&& ezContact.formattedName?.value?.isNotEmpty() == true
|
||||
) {
|
||||
contact.organization.company = ezContact.formattedName.value
|
||||
contact.mimetype = CommonDataKinds.Organization.CONTENT_ITEM_TYPE
|
||||
@@ -292,17 +298,21 @@ class VcfImporter(val activity: SimpleActivity) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatDateToDayCode(date: Date): String {
|
||||
val year = if (date.year == 0) "-" else "${1900 + date.year}"
|
||||
val month = String.format("%02d", date.month + 1)
|
||||
val day = String.format("%02d", date.date)
|
||||
return "$year-$month-$day"
|
||||
private fun formatDateToDayCode(date: LocalDate): String {
|
||||
if (date.year == 1900) {
|
||||
// for backward compatibility with old exports
|
||||
return "--%02d-%02d".format(date.monthValue, date.dayOfMonth)
|
||||
}
|
||||
|
||||
return "%04d-%02d-%02d".format(
|
||||
date.year, date.monthValue, date.dayOfMonth
|
||||
)
|
||||
}
|
||||
|
||||
private fun formatPartialDateToDayCode(partialDate: PartialDate): String {
|
||||
val month = String.format("%02d", partialDate.month)
|
||||
val day = String.format("%02d", partialDate.date)
|
||||
return "--$month-$day"
|
||||
return "--%02d-%02d".format(
|
||||
partialDate.month, partialDate.date
|
||||
)
|
||||
}
|
||||
|
||||
private fun getContactGroups(ezContact: VCard): ArrayList<Group> {
|
||||
|
||||
@@ -11,7 +11,7 @@ androidx-swiperefreshlayout = "1.1.0"
|
||||
#AutoFitTextView
|
||||
autofittextview = "0.2.1"
|
||||
#EzVCard
|
||||
ezvcard = "0.11.3"
|
||||
ezvcard = "0.12.1"
|
||||
#IndicatorFastScroll
|
||||
indicatorfastscroll = "4524cd0b61"
|
||||
#Room
|
||||
|
||||
Reference in New Issue
Block a user