diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/pages/DeckOptions.kt b/AnkiDroid/src/main/java/com/ichi2/anki/pages/DeckOptions.kt index 250348bce03b..3a39160d43af 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/pages/DeckOptions.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/pages/DeckOptions.kt @@ -18,6 +18,7 @@ package com.ichi2.anki.pages import android.content.Context import android.content.Intent import android.os.Bundle +import android.view.KeyEvent import android.webkit.WebView import androidx.activity.OnBackPressedCallback import androidx.fragment.app.FragmentActivity @@ -36,6 +37,7 @@ import timber.log.Timber @NeedsTest("pressing back: icon + button should go to the previous screen") @NeedsTest("15130: pressing back: icon + button should return to options if the manual is open") +@NeedsTest("saveAndExit closes screen") class DeckOptions : PageFragment() { override val title: String get() = resources.getString(R.string.menu__deck_options) @@ -75,6 +77,15 @@ class DeckOptions : PageFragment() { } } + @Suppress("unused") + fun saveAndExit() { + // dispatch Ctrl+Enter + val downEvent = KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER, 0, KeyEvent.META_CTRL_ON) + val upEvent = KeyEvent(0, 0, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER, 0, KeyEvent.META_CTRL_ON) + webView.dispatchKeyEvent(downEvent) + webView.dispatchKeyEvent(upEvent) + } + class DeckOptionsWebClient(val deckId: Long) : PageWebViewClient() { override val promiseToWaitFor: String get() = "\$deckOptions"