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 next time for review in WebView #6388

Merged
merged 3 commits into from
Jun 13, 2020

Conversation

krmanik
Copy link
Member

@krmanik krmanik commented Jun 6, 2020

Pull Request template

Purpose / Description

When redesigning card in CSS & JS, then it may required to show next review time below buttons. This is continuation of #6307

Fixes

Fixes Link to the issues.

Approach

Added javascript interface in WebView settings then added functions in under
@JavascriptInterface

How Has This Been Tested?

Tested on emulator,
Add following function in <script> tag in card templates, then use at/below buttons designed in css & js

<script>
    console.log(AnkiDroidJS.ankiShowNextTime1());
    console.log(AnkiDroidJS.ankiShowNextTime2());
    console.log(AnkiDroidJS.ankiShowNextTime3());
    console.log(AnkiDroidJS.ankiShowNextTime4());
</script>

Learning (optional, can help others)

https://developer.android.com/reference/android/webkit/WebView#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

This will be useful when card developer designing cards and want to show next time below custom answer buttons.

@krmanik
Copy link
Member Author

krmanik commented Jun 11, 2020

Is there any improvement for this PR?

@mikehardy
Copy link
Member

Hi @infinyte7 there is a conflict right now that needs resolution but I think the main thing is just that we're a bit constrained by available time so we haven't had a good look yet, sorry

@krmanik
Copy link
Member Author

krmanik commented Jun 11, 2020

It's okay. When you have time then review this PR.
Thank you.

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 do with a line of JavaDoc documentation about whether "2" means the second button, or always means the hard button.

What is returned when the first card is a learn card in SchedV1, and "hard" is requested?

No issues with the functionality, looks good to me!

@krmanik
Copy link
Member Author

krmanik commented Jun 12, 2020

It will be good with a page containing details and usage of all functionality related to webview / java or javascript interface in wiki page.
Like this I have done
https://github.com/ankidroid/Anki-Android/wiki/Advanced-formatting#designing-custom-cards-layout-for-buttons

May be more good way, like this
https://www.cyberciti.biz/faq/linux-unix-creating-a-manpage/
http://www.linuxhowtos.org/System/creatingman.htm

@mikehardy
Copy link
Member

Nice! I like that (the documentation adds) - would be good perhaps to cross-link to the HTML/JS debugging page, and also directly link to card.js internally as the "source of truth", plus start adding information about API registration and the reason behind it. Might be good to make a whole separate page for "AnkiDroid Javascript API" developers and link to it from where you've started adding things

And it looks like there's a conflict now in one of the files, possibly because of a related change from you that I just merged

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!

@krmanik
Copy link
Member Author

krmanik commented Jun 12, 2020

Yes, I will add the all information as suggested in a separate page.

@david-allison david-allison added the Needs Second Approval Has one approval, one more approval to merge label Jun 12, 2020
@mikehardy
Copy link
Member

Just waiting for conflict resolution then re-request review from me @infinyte7 and I'll mark it pending merge to make sure CI goes green

@krmanik
Copy link
Member Author

krmanik commented Jun 12, 2020

How can I add re-request review from you @mikehardy ?

@mikehardy
Copy link
Member

Up at the very top right you'll see our review states, and you can hit the little re-do icon for it to trigger a request to me (which gives me a notification, so I know to do it!)

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.

Except I won't even be in the review state area unless I review it :-)
Needs a conflict resolve

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.

No need to ask me to review again unless you've changed something significant. Looks as good as it did the first time!

@krmanik
Copy link
Member Author

krmanik commented Jun 13, 2020

Is conflict resolved or should I create a separate PR? @mikehardy

@david-allison
Copy link
Member

@infinyte7 If you scroll down, you should be able to see:
image

The warning at the bottom means there's still a conflict to be resolved

@krmanik
Copy link
Member Author

krmanik commented Jun 13, 2020

It seems resolved.
Capture

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.

LGTM

@mikehardy mikehardy added this to the 2.12 release milestone Jun 13, 2020
@mikehardy mikehardy removed the Needs Second Approval Has one approval, one more approval to merge label Jun 13, 2020
@mikehardy mikehardy merged commit 5892164 into ankidroid:master Jun 13, 2020
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