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 Cards info (Review, Lapses, Interval, Due, Queue) in WebView #6393

Merged
merged 2 commits into from
Jun 9, 2020

Conversation

krmanik
Copy link
Member

@krmanik krmanik commented Jun 7, 2020

Pull Request template

Purpose / Description

There are Anki addon for getting cards info (Review, Lapses, Interval, Due, Queue). But on AnkiDroid that can not works so this is implementation for getting info in WebView.

Fixes

Fixes #4676

Approach

Added JavascriptInterface to pass value from Java code to WebView

How Has This Been Tested?

Tested on Emulator
Add following to front/back side of cards to get the values (Review, Lapses, Interval, Due, Queue)

<script>
console.log(AnkiDroidJS.ankiGetCardReps());
console.log(AnkiDroidJS.ankiGetCardLapses());
console.log(AnkiDroidJS.ankiGetCardInterval());
console.log(AnkiDroidJS.ankiGetCardDue());
console.log(AnkiDroidJS.ankiGetCardQueue());
</script>

Learning (optional, can help others)

https://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object,%20java.lang.String)

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

@krmanik
Copy link
Member Author

krmanik commented Jun 9, 2020

@mikehardy @david-allison-1
Is there any improvement needed in this and my other PR?
I had merge conflict everytime, so that I have re-forked the repo.
These are new PR.
Earlier I used Github desktop, but now using git command line is more convenient.

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.

One comment for discussion, other than that, looks good to me.

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

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 think it was just us being busy :-), thanks for your patience! Also looks good to me, thanks @infinyte7

@mikehardy mikehardy merged commit 7ace39e into ankidroid:master Jun 9, 2020
@mikehardy mikehardy added this to the 2.12 release milestone Jun 9, 2020
@Anthropos888
Copy link
Contributor

Nice feature! Thanks @infinyte7 ! Would it be possible to get the card state info in the same way? #5587

@krmanik krmanik deleted the cards-info-js branch June 12, 2020 08:06
@krmanik
Copy link
Member Author

krmanik commented Jun 12, 2020

Using above the following information of current card will be available.

Reps
Lapses
Interval
Due
Queue

Other information available can be found here #6307
Best way to check this, turn on HTML/JavaSscript Debugging in AnkiDroid and then on Chrome (computer) inpect using

chrome://inspect

1

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 Request: Additional card Fields
4 participants