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 value of fullscreen status in JavaScript #6470

Merged
merged 2 commits into from
Jun 16, 2020

Conversation

krmanik
Copy link
Member

@krmanik krmanik commented Jun 15, 2020

Pull Request template

Purpose / Description

When adding some function / text eg. showAnswer(); then user have to turn on full screen.
But if user turn off full screen then for hiding that buttons / text, there is way to know if full screen or not in JavaScript.

Fixes

Fixes Link to the issues.

Approach

Using JavascriptInterface, passing Action Bar isShowing

How Has This Been Tested?

Tested on emulator

false when Action Bar showing

full

true when Action Bar not showing

full2

Learning (optional, can help others)

Describe the research stage

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

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

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. Optional comment


@JavascriptInterface
public boolean ankiIsInFullscreen() {
isInFullscreen = !getSupportActionBar().isShowing();
Copy link
Member

Choose a reason for hiding this comment

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

This is now used in 3 places - might be best to extract it to a method inside AbstractFlashcardViewer

Copy link
Member Author

@krmanik krmanik Jun 15, 2020

Choose a reason for hiding this comment

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

I tried to extract inside ocreate but AnkiDroid crash everytime.
Edit:
Extracted to a function, now working

Copy link
Member

Choose a reason for hiding this comment

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

most of the interesting stuff in AnkiDroid activities needs to be done in (or called from / after) onCollectionLoaded

Copy link
Member Author

Choose a reason for hiding this comment

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

Understood, But now I have extracted it inside onCollectionLoaded but always getting false value.

So, may be extracting to function is good.

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.

Nice!
I know you have a stack of related PRs @infinyte7 - bear with us while we go through them all, I continue to appreciate the real effort you have put in / are putting in for the JS API init stuff. I believe being an "anki template developer" is going to be a real thing after this, which is exciting to me as it will help us keep UI work (and associated complaints) down in the core so we can focus on the actual scheduling - a win/win

@mikehardy mikehardy merged commit b0db787 into ankidroid:master Jun 16, 2020
@mikehardy mikehardy added this to the 2.12 release milestone Jun 16, 2020
@krmanik krmanik deleted the anki-is-fullscreen branch June 20, 2020 15:04
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