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

Added feature to export and save collection in device #53

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Abi-CP
Copy link

@Abi-CP Abi-CP commented Aug 15, 2024

Export Collection and save to Device

Additional Dependencies:

  • file_picker: ^5.0.0
  • csv: ^5.0.0
  • permission_handler: ^10.3.0

Now you can Export a collection as JSON or CSV

Code:
https://github.com/Abi-CP/mondroid.git
Branch: features/export-collection

Screenshots:
Screenshot_20240815-165824
Screenshot_20240815-170004
Screenshot_20240815-170022
Screenshot_20240815-170057
Screenshot_20240815-170103
Screenshot_20240815-170111
Screenshot_20240815-170141

Happy Coding!

@Abi-CP Abi-CP marked this pull request as draft August 15, 2024 13:13
@Abi-CP Abi-CP marked this pull request as ready for review August 15, 2024 13:23
@vedfi
Copy link
Owner

vedfi commented Aug 15, 2024

Thanks for contribution. It looks neat.

Your PR will be merged right after i complete tests on both ios and android platforms.

@Abi-CP
Copy link
Author

Abi-CP commented Aug 15, 2024

Thank you for the update. I appreciate the review and look forward to the merge once the testing is complete.

@Abi-CP Abi-CP marked this pull request as draft August 26, 2024 05:51
@Abi-CP Abi-CP force-pushed the features/export-collection branch from e9b1561 to c8a4edd Compare August 26, 2024 06:44
@Abi-CP Abi-CP marked this pull request as ready for review August 26, 2024 06:54
@Abi-CP Abi-CP marked this pull request as draft September 4, 2024 11:23
  1. If Filename exists proper renaming done
  2. Format and Directory selecting dialog is made to close after selection of the both instead of closing after success of file saving
  3. Blocked new request to save file while already a request is being processed
@Abi-CP Abi-CP marked this pull request as ready for review September 4, 2024 12:53
@Abi-CP
Copy link
Author

Abi-CP commented Sep 4, 2024

I wanted to follow up on the pull request I submitted a couple of weeks ago. Since then, I've addressed and resolved some additional bugs that were identified. I’ve also made sure that the feature for saving files is functioning correctly.

Could you please review and merge the pull request when you have a chance? Your feedback is greatly appreciated.

Thank you for your time!

@vedfi
Copy link
Owner

vedfi commented Sep 6, 2024

I could not complete the tests due to health problems. I will merge this pull request as soon as possible. Thank you for your understanding.

@Abi-CP
Copy link
Author

Abi-CP commented Sep 7, 2024

Thank you for the update. I hope you’re feeling better soon. Please take your time, and let me know if there’s anything specific you need from me regarding the pull request.

@vedfi
Copy link
Owner

vedfi commented Sep 22, 2024

Hello

I have been testing this feature since yesterday.

There is couple of problems related to Android permissions.

First of all im using an Android 13 device.
It seems like Google has changed the way we access files.

Devices with previous versions of Android can access storage with READ & WRITE permissions declared in AndroidManifest.xml. This permissions are allowed in app settings. And your pr supports that.

Starting from Android 13, we have to stick to FilePicker and let the user choose a directory. But in my tests i have picked different directories including documents, podcasts, pictures etc. Most of the directories did not work. (OS Error: Operation not permitted, errno = 1)

I have researched for fixing this error and i learned that MANAGE_EXTERNAL_STORAGE permission can be requested. But its considered very dangerous by Google and i have seen that Play Store usually blocks applications with this permission. So we cannot use this method to access storage.

Also i couldn't export as json. Due to datetime values. I am pretty sure that there is more bugs about json. There is json encode/decode helpers for unsupported types in mondroid to fix display and save issues.

We can use them while exporting to json. But it will export values like "datetime:2024-09-22" etc. I mean; exported data will not be usefull unless its imported by mondroid. We wont be able to import it to Mongodb compass or any other client. You can take a look at the custom encode/decode table in mondroid readme.md

I could export as csv but the exported values for some types are not containing the values. Only toString() values are presented. (Infinity and binary values, im sharing a screenshot of csv data below)

We need to discuss what we need in export feature. Do we need export and import data within Mondroid itself? Or do we need to share the exported data?

Our best bet is only allowing json exports with using custom json encoders that already built for Mondroid. And save our exported file to temp folder or appdata path. Then open a share dialog to allow user to send data with mail or chat applications.

Best regards.

Screenshot_20240922_210103_Microsoft 365 (Office).jpg

@Abi-CP Abi-CP marked this pull request as draft October 8, 2024 10:01
@Abi-CP Abi-CP marked this pull request as draft October 8, 2024 10:01
@Abi-CP
Copy link
Author

Abi-CP commented Oct 8, 2024

Thank You for the reply. I primarily test on Android 12 (storage was working fine) after your reply I tested on Android 14 and came to know about the issues. I was busy in my college exams so I could not reply you regarding this. Thanks for your reply and my apologies for the delay. Let me look in to this and try to solve. I'll let you know once solved. Regarding encoding issues, it would be a great help if you can share me the data which would result in improper encoding and decoding, so that I can test the app with that.

Thank You,
Regards.

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

Successfully merging this pull request may close these issues.

2 participants