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

Get deck name using JS API #8500

Merged
merged 2 commits into from
Apr 8, 2021
Merged

Conversation

krmanik
Copy link
Member

@krmanik krmanik commented Apr 7, 2021

Pull Request template

Purpose / Description

It helps in getting deck name when custom card layout used/designed. The {{Deck}} or {{Subdeck}} not working when added from js-addons index.js. So, it will easier to add deck name to reviewer using JS API.

Fixes

Fixes Link to the issues.

Approach

It is implemented using existing JavascriptInterface

How Has This Been Tested?

Tested on emulator

Add following to front/back side of card in script tag

console.log(AnkiDroidJS.ankiGetDeckName());

Learning (optional, can help others)

https://developer.android.com/reference/android/webkit/JavascriptInterface

Checklist

Please, go through these checks before submitting the PR.

  • [ x ] You have not changed whitespace unnecessarily (it makes diffs hard to read)
  • [ x ] You have a descriptive commit message with a short title (first line, max 50 chars).
  • [ x ] Your code follows the style of the project (e.g. never omit braces in if statements)
  • [ x ] You have commented your code, particularly in hard-to-understand areas
  • [ x ] 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

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

Could you add a test to ensure that {{Deck}} and this method return the same string.

I'd typically be happy with using the same method for both calls, but we'll be removing template generation soon

@krmanik
Copy link
Member Author

krmanik commented Apr 7, 2021

Okay, I am implementing it.

@krmanik
Copy link
Member Author

krmanik commented Apr 7, 2021

After viewing existing code for test, I have implemented for ankiGetDeckName. I am finding solution for testing {{Deck}}.

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@david-allison david-allison added the Needs Second Approval Has one approval, one more approval to merge label Apr 7, 2021
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.

with a test too - thank you @infinyte7 !

@mikehardy mikehardy merged commit 2ec3cde into ankidroid:master Apr 8, 2021
@mikehardy mikehardy removed the Needs Second Approval Has one approval, one more approval to merge label Apr 8, 2021
@mikehardy mikehardy added this to the 2.15 release milestone Apr 8, 2021
krmanik added a commit to krmanik/Anki-Android that referenced this pull request Apr 15, 2021
* get deck name
* Added test for getting deck name using js api
prateek-singh-3212 pushed a commit to prateek-singh-3212/Anki-Android that referenced this pull request Apr 19, 2021
* get deck name
* Added test for getting deck name using js api
@mikehardy
Copy link
Member

Hi there!

Just a friendly notice that we try to process OpenCollective payments monthly - it's time for April 2021 submissions

If you are interested in compensation for this work, the process with details is here:

https://github.com/ankidroid/Anki-Android/wiki/OpenCollective-Payment-Process#how-to-get-paid

(I only post one comment per person to avoid spamming you, regardless of the number of PRs merged, but this note applies to all PRs merged in April)

Thanks!

mikehardy pushed a commit to mikehardy/Anki-Android that referenced this pull request May 14, 2021
* get deck name
* Added test for getting deck name using js api
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.

3 participants