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 options menu & navigation drawer using WebView #6387

Merged
merged 8 commits into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions AnkiDroid/src/main/assets/scripts/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ function buttonAnswerEase3() {
function buttonAnswerEase4() {
window.location.href = "signal:answer_ease4";
}
// Show options menu
function ankiShowOptionsMenu() {
window.location.href = "signal:anki_show_options_menu";
}

// Show Navigation Drawer
function ankiShowNavDrawer() {
window.location.href = "signal:anki_show_navigation_drawer";
}

/* Reload card.html */
function reloadPage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ public abstract class AbstractFlashcardViewer extends NavigationDrawerActivity i
// ETA
private int eta;

private boolean isInFullscreen;

/**
* Broadcast that informs us when the sd card is about to be unmounted
*/
Expand Down Expand Up @@ -3080,6 +3082,28 @@ private boolean filterUrl(String url) {
mFlipCardLayout.performClick();
return true;
}
// Show options menu from WebView
if (url.startsWith("signal:anki_show_options_menu")) {
isInFullscreen = !getSupportActionBar().isShowing();
if (isInFullscreen) {
openOptionsMenu();
} else {
UIUtils.showThemedToast(AbstractFlashcardViewer.this, getString(R.string.ankidroid_turn_on_fullscreen_options_menu), true);
}
return true;
}

// Show Navigation Drawer from WebView
if (url.startsWith("signal:anki_show_navigation_drawer")) {
isInFullscreen = !getSupportActionBar().isShowing();
if (isInFullscreen) {
AbstractFlashcardViewer.this.onNavigationPressed();
} else {
UIUtils.showThemedToast(AbstractFlashcardViewer.this, getString(R.string.ankidroid_turn_on_fullscreen_nav_drawer), true);
}
return true;
}

// card.html reload
if (url.startsWith("signal:reload_card_html")) {
redrawCard();
Expand Down
4 changes: 4 additions & 0 deletions AnkiDroid/src/main/res/values/02-strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,8 @@
<string name="restore_default">Restore Default</string>

<string name="reviewer_tts_cloze_spoken_replacement">Blank</string>

<!-- in options menu & Navigation Drawer -->
<string name="ankidroid_turn_on_fullscreen_nav_drawer">Please turn on fullscreen to use Show Navigation Drawer using JavaScript.</string>
<string name="ankidroid_turn_on_fullscreen_options_menu">Please turn on fullscreen to use Show Options Menu using JavaScript.</string>
</resources>