Automated import from 3rd party dictionary app

211 views
Skip to first unread message

AnkiDict

unread,
Jan 30, 2014, 12:20:24 AM1/30/14
to anki-a...@googlegroups.com
Hi - I have an Android dictionary app where the user can favorite words. Some users have favorited over a thousand words.

I want to add a feature where the user can export all those words into Anki and I've been looking at ways to do this:

1. Add a feature to AnkiDroid which can accept a broadcast intent containing all the data
2. Add a content provider to AnkiDroid
3. My app exports the words to Anki's .apkg format and then passes it to AnkiDroid

I'm leaning towards the third option, but need to see the specification of the .apkg format to see if it is feasible.

From what I understand about Anki, each dictionary entry corresponds to an Anki Note. And for each Note there will be a card for each Note Type / Model. Should these Note Types be described by AnkiDroid or by my app?

As well as export, I would also want to add a feature where AnkiDroid is automatically updated (i.e. in the background, no UI involved) as soon as the user favorites a new word in the dictionary app.

Please could someone give feedback on the best approach?

Many thanks.

Flavio Lerda

unread,
Jan 30, 2014, 6:44:36 AM1/30/14
to anki-a...@googlegroups.com
Hello,

On Thu Jan 30 2014 at 5:20:26 AM, AnkiDict <ma...@marcardar.com> wrote:
Hi - I have an Android dictionary app where the user can favorite words. Some users have favorited over a thousand words.

I want to add a feature where the user can export all those words into Anki and I've been looking at ways to do this:

1. Add a feature to AnkiDroid which can accept a broadcast intent containing all the data
2. Add a content provider to AnkiDroid
3. My app exports the words to Anki's .apkg format and then passes it to AnkiDroid

My feeling is that the APKG route is the best one in this case.

The APKG route allows you to specify the note type: since one cannot make any assumptions about which note types the user will have in their collection, adding the data directly would probably require some sort of manual intervention.

I am not so keen on having AnkiDroid provide a content provider as it would involve a significant amount of work and I imagine it will take a lot longer than the APKG route would.
 
I'm leaning towards the third option, but need to see the specification of the .apkg format to see if it is feasible.

The APKG format, as far as I know, is quite similar to the format used for the collection. AnkiDroid has Android Java code to read an APKG file, so you could use that has a starting point, but note that since AnkiDroid is GPL, you might have to release your own application as open source under GPL if you base your implementation upon the one in AnkiDroid.
 
From what I understand about Anki, each dictionary entry corresponds to an Anki Note. And for each Note there will be a card for each Note Type / Model. Should these Note Types be described by AnkiDroid or by my app?

I wanted to point out that there can be multiple cards for each note (e.g., a forward and backward card, but there are a lot of more complex options as well that advanced users do use). The notes belong to a note type, and each note type defines a set of cards that will be generated for each note of that type: you can only edit the notes, not the individual cards.

Since AnkiDroid does not itself specify the note types nor provides ways to change them, I think it would be best if your application included both the data and the note type in the APKG.
 
As well as export, I would also want to add a feature where AnkiDroid is automatically updated (i.e. in the background, no UI involved) as soon as the user favorites a new word in the dictionary app.
 
I am not so keen in updating things without user intervention. If we go this route it would probably require adding permissions to restrict which apps can do this (I can imagine apps trying to spam users' decks). The current SEND_TO action does not require any permission because the user is asked to confirm the operation. It would require some work, but it would be possible to provide a way to support this in a safe way: my suggestion would be a permission + a one-time user confirmation for each application + a way for the user to revoke/block an application.

Just my 2c, I hope it is helpful.
Flavio

AnkiDict

unread,
Jan 30, 2014, 7:16:37 AM1/30/14
to anki-a...@googlegroups.com
Very helpful, thanks!

Yes, I understand there can be multiple cards for each note. I noticed the APKG file includes both card and note data. But can the card data be auto-generated from the note and note type data?

I think it would be extremely useful to allow 3rd party apps to add notes/cards silently and you are absolutely right there needs to be some permission system in place to allow this.  Have you looked into ContentProvider permissions? I have not, but maybe they provide what you need?  Otherwise there is always:


which would allow the ContentProvider to raise a notification when a new package uses it. "Please Authorize Fancy Super Dictionary..." etc on the first ever call.

I think the existing intent support could do with some improvement because currently the note data ends up in the Saved Data menu option of CardEditor which is not so easy for the user to find and then, when there are many pending notes, not so convenient to process. Unless I'm missing something?

AnkiDict

unread,
Jan 30, 2014, 11:56:55 AM1/30/14
to anki-a...@googlegroups.com
Actually, you can disregard the part I wrote about ContentProviders because adding cards silently can be easily done with BroadcastReceivers. Securing these with permissions is described here:


So AnkiDroid would define a custom permission for the BroadcastReceiver and 3rd party apps would need the corresponding <uses-permission> to send to that receiver.  Now, there is nothing to stop any app specifying that <uses permission> but I don't think that is a problem...

Flavio Lerda

unread,
Jan 30, 2014, 4:56:14 PM1/30/14
to anki-android
I actually was thinking of implement a shared service with an AIDL definition.
This would allow for a more powerful API than a broadcast receiver, as well
as more appropriate set of methods than what a content provider would offer.

I think even with the permission, I would lean towards providing a way for the
user to authorize applications that inject content within AnkiDroid, as well as
a way to block them, as I suggested earlier.

Flavio


--
You received this message because you are subscribed to the Google Groups "AnkiDroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anki-android...@googlegroups.com.
To post to this group, send email to anki-a...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/anki-android/844b1a06-a5ad-4052-bb61-a93d272b798a%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Mark Carter

unread,
Jan 30, 2014, 10:34:51 PM1/30/14
to anki-android
In general, in the context of third party apps, Services are used to allow other apps to perform actions through your app. ContentProviders are for data sharing. Certainly in the case of adding (and potentially deleting, updating etc) flashcards, ContentProviders are the perfect way to do this. I understand the desire to create a richer, more direct API, but that would be a non-standard approach IMHO.

If you were to go ahead with a Service/ContentProvider, then I guess there would be no point me implementing Export to APKG?

Regarding authorize/block - yes, that makes sense.


--
You received this message because you are subscribed to a topic in the Google Groups "AnkiDroid" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/anki-android/Xaw3PEuz940/unsubscribe.
To unsubscribe from this group and all its topics, send an email to anki-android...@googlegroups.com.

To post to this group, send email to anki-a...@googlegroups.com.

Charles J. Daniels

unread,
Jan 31, 2014, 2:39:27 AM1/31/14
to anki-a...@googlegroups.com
I love this idea -- I think all software should work this way. Allowing some way for arbitrary apps to add cards to AnkiDroid is just a perfect idea to me.
--charlie
Reply all
Reply to author
Forward
0 new messages