Skip to content

Commit

Permalink
chore(deck-options): add 'saveAndExit'
Browse files Browse the repository at this point in the history
To be used in future to fix accessibility

Fixes 14438
  • Loading branch information
david-allison authored and BrayanDSO committed Feb 15, 2024
1 parent c9aa83d commit 00d4960
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/pages/DeckOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 00d4960

Please sign in to comment.