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

New JS API for bury & suspend card and bury & suspend note and tag card #9245

Merged
merged 2 commits into from
Aug 5, 2021

Conversation

krmanik
Copy link
Member

@krmanik krmanik commented Jul 11, 2021

Pull Request template

Purpose / Description

This continuation of JS API PR to add more functionality and new features to JS API.

Fixes

Fixes #9231

Approach

Added functions to JavaScriptInterface

How Has This Been Tested?

Use following functions for the API

  • To bury current card (return boolean)
<button onclick="AnkiDroidJS.ankiBuryCard();">Bury Card</button>
  • To bury current note (return boolean)
<button onclick="AnkiDroidJS.ankiBuryNote();">Bury Note</button>
  • To suspend current card (return boolean)
<button onclick="AnkiDroidJS.ankiSuspendCard();">Suspend Card</button>
  • To suspend current note (return boolean)
<button onclick="AnkiDroidJS.ankiSuspendNote();">Suspend Note</button>
  • To show Tags dialog for adding tag to current card (void function)
<button onclick="AnkiDroidJS.ankiAddTagToCard();">Show Tag Dialog to add tag</button>

Tested on devices and emulator

Learning (optional, can help others)

https://github.com/ankidroid/Anki-Android/wiki/AnkiDroid-Javascript-API

Links to blog posts, patterns, libraries or addons used to solve this problem

Checklist

Please, go through these checks before submitting the PR.

  • You have not changed whitespace unnecessarily (it makes diffs hard to read)
  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • Your code follows the style of the project (e.g. never omit braces in if statements)
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also like this idea a lot but we need to kill the boilerplate on it first thing, before a lot of these go in. I asked for advice there

@krmanik
Copy link
Member Author

krmanik commented Aug 5, 2021

JavaScriptInterface is much simpler than my previous implementation.

Copy link
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combined change looks great (that is: implementing the feature, but with @JavascriptInterface

@mikehardy mikehardy merged commit abd564c into ankidroid:master Aug 5, 2021
@david-allison david-allison added this to the 2.16 release milestone Aug 5, 2021
@david-allison david-allison removed their assignment Aug 5, 2021
@krmanik krmanik deleted the jsapi branch August 5, 2021 21:03
@BilderLoong
Copy link

Thank you guys so much!

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.

[Feature] Add new JavaScript API to bury current card and add tags to current note.
4 participants