-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Offer import when users click on supported import files #1025
Comments
Hey @TheLastProject , would you need assistance with this issue? I'd like to help out and get any background details needed to start working on this. |
It's mostly a time issue for me, just too many issues, so help would be great :) As I understand it it should basically be about adding a few intent-filters to the AndroidManifest.xml for the ImportExportActivity and then inside the ImportExportActivity respond to the intent (LoyaltyCardEditActivity should show some code about the kind of data that'll be in the intent). |
Ok, I'll start working on this and update you on my progress. |
@TheLastProject - Any way I can (easily) generate/create/get the different file types so I can test out that my intent filters work? Also, just to make sure I am in the right direction, you want the functionality to work inside the ImportExportActivity after a user presses the Import From Filesystem button? |
You can maybe have a look at this https://github.com/CatimaLoyalty/Android/tree/master/app/src/test/res/protect/card_locker |
@TheLastProject - Would you be able to approve/reject what I have written in my comment above? Want to make sure I am on the right path. |
Ah, I didn't get an email notification for your question because you added it after your original message so I missed it :)
That seems the most logical place yeah, hooking it into the Activity instead of the task means that we you could easily hook into the existing logic for asking for a password and everything too. |
@TheLastProject , thanks for the feedback. Just as a preview, I added the following for importing zip files:
I'll add a regex to enforce the files names you listed above. |
Loyalty Card Keychain / Catima v1 is inlined in the code: Android/app/src/test/java/protect/card_locker/ImportExportTest.java Lines 985 to 1009 in 78348a6
same with Voucher Vault: Android/app/src/test/java/protect/card_locker/ImportExportTest.java Lines 1267 to 1291 in 78348a6
I totally understand that does make it harder to discover though, they should probably be moved to their own files to make the tests easier to understand and the test files easier to re-use.
That sounds great :) |
@TheLastProject , thanks for your quick response. I'm a bit confused about something. So my question is, why do we need the intent filters? I thought (initially) that you wanted the application to be associated with specific files types, where if a user presses on them in his/her file manager, the Catima application will be presented as an option to open them (similar to an application that can open PDF files). But as far as I understand from your most recent replies, this isn't the case. Because if a user can choose any file after pressing the Import From Filesystem button, there is no use for the intent filters here. If I am wrong in my understanding, please correct me. |
Ah, sorry for the confusion. What I meant to say is that the user clicking a file in their file manager should follow the same in-app flow as clicking the "Import from file system" button so Catima's internal logic wouldn't have to care if the file came from the button or from the user clicking a file in the user's file manager. Specifically, I was trying to state that I feel it would be cleaner to attach these intents to the ImportExportActivity instead of inside the ImportExportTask (as that class will need a cleanup at some point for #513 anyway). I realize now I worded this extremely poorly yeah.
This is indeed what I would like added in this issue, yeah. My apologies. |
Hi @TheLastProject, so I have been pounding my head against the wall for the last couple of days trying to find the correct string to put in the intent filter so it will only open zip/csv/json files according to what you have listed. I've tried using pathPattern, pathPrefix, but nothing seems to work. Below is the intent filter for zip files I have now:
This does offer Catima as an option to open zip files: Regardless of that, I have added the following logic in the ImportExportActivity in the onCreate method (a bit rough right now, but it shows the direction):
If you have any idea how I can overcome the regex issue, I will appreciate it. 🙏 |
Hmm, it's a shame that's apparently so difficult. I guess just grabbing all .zip, .json and .csv files would be an improvement then at least. In that case it'll be necessary to show all the import options when a file is opened, but that could be fine.
Well those strings are the whole files, just with quoting to fit in Java files. Here they are with the quotes removed: files.zip (the Catima one is an old format not in the .zip, but still uses the Catima importer). The others are in https://github.com/CatimaLoyalty/Android/tree/master/app/src/test/res/protect/card_locker. The Catima .zip is missing, but that one is extremely easily generated by just using Export in the app itself. |
@TheLastProject - I have opened a PR and am awaiting your review. I left a comment there regarding constants. |
We want to register Catima as an opener for common import file names so that users can easily start an import.
For Catima: catima.zip
For Fidme: fidme-export-request-*.zip
For Loyalty Card Keychain: LoyaltyCardKeychain.csv
For Stocard: *-sync.zip
For Voucher Vault: vouchervault.json
When the user opens such a file, Android should offer "Import data into Catima" as option. Catima should select the correct importer based on the filename.
The text was updated successfully, but these errors were encountered: