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

Show Toast using JavaScript function in WebView #6386

Merged
merged 4 commits into from
Jun 20, 2020

Conversation

krmanik
Copy link
Member

@krmanik krmanik commented Jun 6, 2020

Pull Request template

Purpose / Description

As sometime it needed to toast in AnkiDroid. This will create native toast of message passed by card developer
This is continuation of #6307

Fixes

Fixes Link to the issues.

Approach

Added signal for calling function
In card.js

ankiShowToast(msg)

How Has This Been Tested?

Tested on emulator,
The function accept string for showing toast message
In front side of card template add it in <script> tag

ankiShowToast("Showing native toast using javascript");

Learning (optional, can help others)

https://developer.android.com/guide/topics/ui/notifiers/toasts

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

	AbstractFlashcardViewer.java
@krmanik
Copy link
Member Author

krmanik commented Jun 13, 2020

This is not much required as using CSS it can be made. But it will be good if there because using one line by passing message can show toast in native way.

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 take a look at how the typeans functions handle this, and abstract out/copy their way of handing unicode. It was a little more complex than it initially appeared, I don't think this currently handles Mandarin for example.

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Jun 13, 2020
@krmanik
Copy link
Member Author

krmanik commented Jun 13, 2020

I will update it for other language also.

@krmanik
Copy link
Member Author

krmanik commented Jun 13, 2020

Now working for other languages.

@david-allison
Copy link
Member

I believe this will break if you enter a single percentage: 100% for example. Could you test this against that case?

@krmanik
Copy link
Member Author

krmanik commented Jun 13, 2020

Yes, it break when single % supplied,

@krmanik
Copy link
Member Author

krmanik commented Jun 13, 2020

Now working

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 last change, then good to go!

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.

Looks good to me. Thanks!

@krmanik
Copy link
Member Author

krmanik commented Jun 20, 2020

Is it okay to be 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

@david-allison david-allison added Needs Second Approval Has one approval, one more approval to merge and removed Needs Author Reply Waiting for a reply from the original author labels Jun 20, 2020
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 as well - thanks @infinyte7

@mikehardy mikehardy merged commit 7d68b87 into ankidroid:master Jun 20, 2020
@mikehardy mikehardy removed the Needs Second Approval Has one approval, one more approval to merge label Jun 20, 2020
@mikehardy mikehardy added this to the 2.12 release milestone Jun 20, 2020
@krmanik krmanik deleted the toast-from-js branch June 26, 2020 07:05
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