Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to 0.12.0 while still supporting Android API 21..25 #129

Open
AndroidDeveloperLB opened this issue Feb 5, 2023 · 6 comments
Open

Comments

@AndroidDeveloperLB
Copy link

AndroidDeveloperLB commented Feb 5, 2023

After updating to 0.12.0 , I've noticed that it has some changes that I hope I've found proper alternatives to them:

  1. Doesn't support File class as parameter for VCardWriter and maybe also others. There is Path instead, but it requires API 26 while the app I work on is for Android API 21 and above.
    Is it ok to use this instead:
vCardWriter = VCardWriter(BufferedOutputStream(FileOutputStream(vcfFile)), VCardVersion.V4_0)

?

Does it auto-close the stream?

  1. The class Birthday doesn't support providing Date class to it. I can't use Temporal as it requires API 26 . Is it ok to convert to PartialDate ? Would work the same? Meaning like this:
val vCard = VCard()
//birthdate is of type Date
val date =
    PartialDate.builder().year(birthdate.year).month(birthdate.month).date(birthdate.date).build()
vCard.birthday = Birthday(date)

I tried to find information on the repository, but found only what has changed, and not how to migrate:
https://github.com/mangstadt/ez-vcard/wiki/Changelog

Please help.

@mangstadt
Copy link
Owner

  1. Yes it's OK to pass a BufferedOutputStream into the VCardWriter constructor. The output stream is closed when you call VCardWriter.close().
  2. You can use PartialDate for the birthday property, as long as you're creating a 4.0 vCard.

@AndroidDeveloperLB
Copy link
Author

@mangstadt

  1. OK
  2. How can I convert from the old Date (or Calendar) into PartialDate? After converting, it should work fine as before, right?

@AndroidDeveloperLB
Copy link
Author

Maybe as such:

val partialDate =
    PartialDate.builder().date(birthdate.date).month(birthdate.month + 1).year(birthdate.year + 1900).build()

?

@aberaud
Copy link

aberaud commented Mar 13, 2023

Not sure why the support for File was removed?
It's an old API that is very widely used and not deprecated.
It didn't prevent adding support for Path in any way.

@mangstadt
Copy link
Owner

It was something I did as a personal project because the new APIs are more pleasant to work with.

Apart from the jump to the newer APIs, not much changed in this version (see the Changelog). So if you are worried about missing out on bug/security fixes or new features, there were none (not counting the dependency updates, which you can exclude from your build if your project does not use them).

ez-vcard is very stable and I don't expect there to be many more updates.

@mangstadt
Copy link
Owner

Self note: Support for java.time and java.nio.file was added in API 26 (Android 8.0), which was released on 8/21/2017.

See "Updated Java language support" section in: https://developer.android.com/about/versions/oreo/android-8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants