From 4ab55c60ec1405037fcc81b97b5d9af702bae29a Mon Sep 17 00:00:00 2001 From: Brayan Oliveira <69634269+brayandso@users.noreply.github.com> Date: Wed, 25 Dec 2024 16:16:39 -0300 Subject: [PATCH] fixeeeess --- AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt | 6 ++++-- .../src/main/java/com/ichi2/anki/reviewer/Binding.kt | 3 ++- .../test/java/com/ichi2/anki/ReviewerKeyboardInputTest.kt | 8 ++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt index d4b4a3fdd55e..edffd73bcf84 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt @@ -79,6 +79,7 @@ import com.ichi2.anki.reviewer.AnswerButtons.Companion.getBackgroundColors import com.ichi2.anki.reviewer.AnswerButtons.Companion.getTextColors import com.ichi2.anki.reviewer.AnswerTimer import com.ichi2.anki.reviewer.AutomaticAnswerAction +import com.ichi2.anki.reviewer.Binding import com.ichi2.anki.reviewer.BindingProcessor import com.ichi2.anki.reviewer.CardMarker import com.ichi2.anki.reviewer.CardSide @@ -201,7 +202,7 @@ open class Reviewer : private lateinit var toolbar: Toolbar @VisibleForTesting - protected lateinit var processor: ScreenKeyMap + protected open lateinit var processor: ScreenKeyMap private val addNoteLauncher = registerForActivityResult( @@ -1671,6 +1672,7 @@ open class Reviewer : binding: ReviewerBinding, ): Boolean { if (binding.side != CardSide.BOTH && CardSide.fromAnswer(isDisplayingAnswer) != binding.side) return false - return executeCommand(action, null) + val gesture = (binding.binding as? Binding.GestureInput)?.gesture + return executeCommand(action, gesture) } } diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/Binding.kt b/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/Binding.kt index 5a61e06b7f49..4f230c7dc8df 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/Binding.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/Binding.kt @@ -136,7 +136,8 @@ sealed interface Binding { append(unicodeCharacter) } - override fun equals(other: Any?): Boolean = super.equals(other) + override fun equals(other: Any?): Boolean = + (other is UnicodeCharacter && unicodeCharacter == other.unicodeCharacter && modifierKeys == other.modifierKeys) override fun hashCode(): Int = Objects.hash(unicodeCharacter, modifierKeys) } diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/ReviewerKeyboardInputTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/ReviewerKeyboardInputTest.kt index df08a06bf34a..867dc25a3aec 100644 --- a/AnkiDroid/src/test/java/com/ichi2/anki/ReviewerKeyboardInputTest.kt +++ b/AnkiDroid/src/test/java/com/ichi2/anki/ReviewerKeyboardInputTest.kt @@ -45,6 +45,7 @@ import com.ichi2.anki.reviewer.Binding.Companion.keyCode import com.ichi2.anki.reviewer.Binding.ModifierKeys import com.ichi2.anki.reviewer.CardSide import com.ichi2.anki.reviewer.ReviewerBinding +import com.ichi2.anki.reviewer.ScreenKeyMap import com.ichi2.libanki.Card import kotlinx.coroutines.Job import org.hamcrest.MatcherAssert.assertThat @@ -56,6 +57,10 @@ import org.mockito.Mockito import org.mockito.kotlin.whenever import timber.log.Timber +// ReviewerKeyboardInputTest +// PreferencesAnalyticsTest +// PeripheralKeymapTest + @RunWith(AndroidJUnit4::class) class ReviewerKeyboardInputTest : RobolectricTest() { @Test @@ -250,6 +255,9 @@ class ReviewerKeyboardInputTest : RobolectricTest() { var replayAudioCalled = false private set + override var processor: ScreenKeyMap = + ScreenKeyMap(sharedPrefs(), ViewerCommand.entries, this) + private val cardFlips = mutableListOf() override val isDrawerOpen: Boolean get() = false