Merge pull request #11349 from nextcloud/dependabot/gradle/com.googlecode.ez-vcard-ez-vcard-0.12.0

Build(deps): Bump com.googlecode.ez-vcard:ez-vcard from 0.11.3 to 0.12.0
This commit is contained in:
Andy Scherzinger 2023-05-13 22:53:19 +02:00 committed by GitHub
commit be28bc8c61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 10 deletions

View file

@ -256,7 +256,7 @@ dependencies {
compileOnly 'com.google.code.findbugs:annotations:3.0.1u2'
implementation 'commons-io:commons-io:2.11.0'
implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.12.0'
implementation 'org.lukhnos:nnio:0.2'
implementation 'org.bouncycastle:bcpkix-jdk15to18:1.72'
implementation 'com.google.code.gson:gson:2.10.1'

View file

@ -36,7 +36,9 @@ import junit.framework.Assert.assertEquals
import junit.framework.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import java.io.BufferedInputStream
import java.io.File
import java.io.FileInputStream
class ContactsBackupIT : AbstractOnServerIT() {
val workmanager = WorkManager.getInstance(targetContext)
@ -82,13 +84,15 @@ class ContactsBackupIT : AbstractOnServerIT() {
assertTrue(DownloadFileOperation(user, backupOCFile, AbstractIT.targetContext).execute(client).isSuccess)
val backupFile = File(backupOCFile.storagePath)
val vcardInputStream = BufferedInputStream(FileInputStream(getFile(vcard)))
val backupFileInputStream = BufferedInputStream(FileInputStream(backupFile))
// verify same
val originalCards: ArrayList<VCard> = ArrayList()
originalCards.addAll(Ezvcard.parse(getFile(vcard)).all())
originalCards.addAll(Ezvcard.parse(vcardInputStream).all())
val backupCards: ArrayList<VCard> = ArrayList()
backupCards.addAll(Ezvcard.parse(backupFile).all())
backupCards.addAll(Ezvcard.parse(backupFileInputStream).all())
assertEquals(originalCards.size, backupCards.size)
assertEquals(originalCards[0].formattedName.toString(), backupCards[0].formattedName.toString())

View file

@ -34,9 +34,9 @@ import com.owncloud.android.ui.fragment.contactsbackup.VCardComparator
import ezvcard.Ezvcard
import ezvcard.VCard
import third_parties.ezvcard_android.ContactOperations
import java.io.File
import java.io.BufferedInputStream
import java.io.FileInputStream
import java.io.IOException
import java.util.ArrayList
import java.util.Collections
import java.util.TreeMap
@ -62,14 +62,14 @@ class ContactsImportWork(
val contactsAccountType = inputData.getString(ACCOUNT_TYPE)
val selectedContactsIndices = inputData.getIntArray(SELECTED_CONTACTS_INDICES) ?: IntArray(0)
val file = File(vCardFilePath)
val inputStream = BufferedInputStream(FileInputStream(vCardFilePath))
val vCards = ArrayList<VCard>()
var cursor: Cursor? = null
@Suppress("TooGenericExceptionCaught") // legacy code
try {
val operations = ContactOperations(applicationContext, contactsAccountName, contactsAccountType)
vCards.addAll(Ezvcard.parse(file).all())
vCards.addAll(Ezvcard.parse(inputStream).all())
Collections.sort(
vCards,
VCardComparator()
@ -110,6 +110,12 @@ class ContactsImportWork(
cursor?.close()
}
try {
inputStream.close()
} catch (e: IOException) {
logger.e(TAG, "Error closing vCard stream", e)
}
return Result.success()
}

View file

@ -23,15 +23,19 @@
package com.owncloud.android.ui.asynctasks;
import android.os.AsyncTask;
import android.os.Build;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.fragment.contactsbackup.BackupListFragment;
import com.owncloud.android.ui.fragment.contactsbackup.VCardComparator;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -61,7 +65,11 @@ public class LoadContactsTask extends AsyncTask<Void, Void, Boolean> {
if (!isCancelled()) {
File file = new File(ocFile.getStoragePath());
try {
vCards.addAll(Ezvcard.parse(file).all());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
vCards.addAll(Ezvcard.parse(new BufferedInputStream(Files.newInputStream(file.toPath()))).all());
} else {
vCards.addAll(Ezvcard.parse(new BufferedInputStream(new FileInputStream((file)))).all());
}
Collections.sort(vCards, new VCardComparator());
} catch (IOException e) {
Log_OC.e(this, "IO Exception: " + file.getAbsolutePath());

View file

@ -14,8 +14,8 @@ import com.owncloud.android.utils.DisplayUtils;
import java.io.ByteArrayOutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.temporal.Temporal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -478,7 +478,7 @@ public class ContactOperations {
@SuppressLint("SimpleDateFormat")
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
for (Birthday birthday : vcard.getBirthdays()) {
Date date = birthday.getDate();
Temporal date = birthday.getDate();
if (date == null) {
continue;
}