Skip to content

Add cards directly to AnkiDroid #454

Closed

Description

@timrae

Hi, Tim here from AnkiDroid.

I apologize that our last discussions on a new add intent (#264) never materialized into anything... I guess @diogovk lost the time to contribute to AnkiDroid, as is so often the case in open source projects.

However, I have some good news to report! After a lengthy discussion, we decided to abandon the idea of a more complicated add intent, and instead implement a full ContentProvider, which gives a high level interface that external developers can use to commit cards directly to the AnkiDroid database.

We have just merged a PR (ankidroid/Anki-Android#725) implementing the first version of the provider (available as of v2.5 alpha9), and there is an example app available (unrestricted free license) which demonstrates the basic usage of the provider.

I think it would be a great addition to Aedict if you use this new interface to add cards to AnkiDroid instead of the old interface. The API has not been finalized yet (for example adding new note types is not supported yet, which would be highly beneficial for Aedict), but it's ready to explore and start prototyping with, so please feel free to play around with it and suggest changes to the API according to your requirements.

Activity

  1. mvysny commented on Mar 24, 2015

    @mvysny
    Owner

    Hi Tim, thanks for letting me know - this looks very promising. I will definitely look at this and I'll let you know.

  2. mvysny commented on Apr 16, 2015

    @mvysny
    Owner

    Hi Tim, thank you very much for the example app. I have looked at the app (also on the FlashCardsContract.java file). It is however not clear to me how can I create a new deck with multiple cards via the API - for example what value should I fill into fields such as Note.GUID or the like. Can you please help me with this?

  3. timrae commented on Apr 16, 2015

    @timrae
    Author

    Hi Martin, as written in the contract, Note.GUID is read-only... This value is generated automatically by AnkiDroid when you do an insert() operation. You then use update() to set the field values and I believe a new deck will automatically be created if you set one that doesn't exist, which maybe isn't the best solution.

    I haven't really looked at the example app in detail (it was written by @federvieh who also wrote all the API code), but if it's not clear how to add cards from the example app source code, you might want to look at the test cases in AnkiDroid instead. Please create a new issue on the example app page as well to let @federvieh know how that app can be improved.

  4. federvieh commented on Apr 17, 2015

    @federvieh
  5. timrae commented on Jun 17, 2015

    @timrae
    Author

    By the way, any progress on this? I'm hoping to go into beta in the next month or so, it would be nice if we could get beta testers to test Aedict integration at the same time.

  6. mvysny commented on Jun 17, 2015

    @mvysny
    Owner

    No progress right now. I will need an example code on how to mass-import entries from Aedict. I do not use AnkiDroid myself, so I do not know what users want - they probably want to create a Deck of cards or something. Please give me API which will allow to create a Deck with a list of cards, without doing mumbo-jumbo with the low-level ContentProvider with tons of undocumented fields.

  7. timrae commented on Sep 12, 2015

    @timrae
    Author

    @mvysny
    Your wish is my command:
    https://github.com/ankidroid/Anki-Android/wiki/AnkiDroid-API

    The sample app is modeled roughly around how I'd like you to implement the feature in Aedict (as a regular user of Aedict)

  8. mvysny commented on Sep 14, 2015

    @mvysny
    Owner

    Thank you, the API looks great!

  9. timrae commented on Sep 14, 2015

    @timrae
    Author

    Thanks! I definitely urge you to check the sample app; you should be able to use parts of it verbatim such as the ACTION_SEND fallback mechanism, the custom AnkiDroid model for Japanese words, and the runtime permissions check for Android 6 compatibility, etc.

    I would recommend that you use a separate custom AnkiDroid model for Kanji, rather than trying to reuse that model for both words and kanji. For example Aedict users probably want some extra information such as the stroke count, and they probably don't need some information like the example sentences.

  10. mvysny commented on Sep 15, 2015

    @mvysny
    Owner

    Hmm, I am still using the Android Maven plugin to build Aedict. Is the com.ichi2.anki:api:1.0.0alpha2 artifact available in a Maven repository? Or can I grab jar (or sources) of the project and build it myself? Thanks :)

  11. timrae commented on Sep 15, 2015

    @timrae
    Author

    Hi Martin, yes it's on JCenter
    https://jcenter.bintray.com/com/ichi2/anki/api/1.0.0alpha2/, which is the
    Android Studio default. Can you use that with the Android Maven plugin?

    Android studio / gradle is now the official build tool for Android though,
    and it's pretty good, so you might want to consider changing over.

    On 15/09/2015 4:11 pm, "Martin Vysny" notifications@github.com wrote:

    Hmm, I am still using the Android Maven plugin to build Aedict. Is the
    com.ichi2.anki:api:1.0.0alpha2 artifact available in a Maven repository? Or
    can I grab jar (or sources) of the project and build it myself?

    —
    Reply to this email directly or view it on GitHub
    #454 (comment).

  12. mvysny commented on Sep 16, 2015

    @mvysny
    Owner

    Thanks Tim, I will give it a try and I will let you know. Yes, I am already using Gradle for several projects and I like it. Yet, I am quite new in Gradle and still gaining experience needed to port as complex project as Aedict3 is, from Maven to Gradle.

  13. timrae commented on Oct 8, 2015

    @timrae
    Author

    Any ETA for this? The whole reason why I built the API was so that I could use it with Aedict tbh! We are going into beta cycle for v2.5 very soon

  14. mvysny commented on Oct 8, 2015

    @mvysny
    Owner

    Sorry man, I was otherwise engaged. I learned that the API won't work with AnkiDroid from Google Play, so I decided to wait. I once implemented an Intent which still does not work with AnkiDroid, remember? I wanted to avoid that - I wanted to give users something that works out-of-the-box.
    If I understand correctly, I need custom build of AnkiDroid to test this, is this correct? I already migrated Aedict to Gradle, so this should be a lot easier by now.
    Do you have any recommendations for Aedict to create some more complex card model, or is the basic model enough for now?

  15. timrae commented on Oct 8, 2015

    @timrae
    Author

    @mvysny

    If I understand correctly, I need custom build of AnkiDroid to test this, is this correct?

    You don't need a "custom build" per se, but yes you do need to install the latest development version. The 2.5 beta version should be out in the next week or so, and unless the rapture comes, AnkiDroid 2.5 will be released to Google Play before the end of November!

    Do you have any recommendations for Aedict to create some more complex card model, or is the basic model enough for now?

    I recommend using the custom model provided in the sample app. I designed this model for Aedict ;)

  16. timrae commented on Oct 8, 2015

    @timrae
    Author

    I already migrated Aedict to Gradle

    Great! Any chance you could migrate the aedict 2.9 source code over to gradle as well? It would be nice to add at least rudimentary support for the AnkiDroid API to Aedict 2, as many open source enthusiasts still use it.

  17. mvysny commented on Oct 8, 2015

    @mvysny
    Owner

    Any chance you could migrate the aedict 2.9 source code over to gradle as well?

    Sorry mate, but I hardly find the time to maintain Aedict3 (and adjacent apps, say, Aedict Reader) - I have no spare time to maintain A2. I would open-source A3 gladly, but that will be an end to paid Aedict3 (and an end of my development of A3)

  18. mvysny commented on Oct 12, 2015

    @mvysny
    Owner

    In Aedict 3.38.7 a please-wait dialog is shown while the export is performed. I believe that the export is implemented from my side, closing as fixed.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions