From f33810d306203ff66a4b761d10716772fef70139 Mon Sep 17 00:00:00 2001 From: MorenoTropical <154519856+morenotropical@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:52:49 -0300 Subject: [PATCH] Remove Automatic Display Answer global setting People get confused when they enable Auto Advance but it doesn't work. The preference had an use when Anki didn't have Auto advance, but now it doesn't have a purpose. Example: https://forums.ankiweb.net/t/auto-advance-in-deck-options/51898 --- .../com/ichi2/anki/AbstractFlashcardViewer.kt | 3 +-- .../com/ichi2/anki/analytics/UsageAnalytics.kt | 1 - .../com/ichi2/anki/reviewer/AutomaticAnswer.kt | 17 ++++------------- .../src/main/res/values/10-preferences.xml | 2 -- AnkiDroid/src/main/res/values/constants.xml | 2 +- AnkiDroid/src/main/res/values/preferences.xml | 1 - .../src/main/res/xml/preferences_reviewing.xml | 8 -------- .../ichi2/anki/AbstractFlashcardViewerTest.kt | 2 +- .../anki/reviewer/AutomaticAnswerAndroidTest.kt | 2 +- .../ichi2/anki/reviewer/AutomaticAnswerTest.kt | 2 -- 10 files changed, 8 insertions(+), 32 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt index 56ad993bf129..2b4678b55231 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt @@ -1234,8 +1234,7 @@ abstract class AbstractFlashcardViewer : // These are preferences we pull out of the collection instead of SharedPreferences try { showNextReviewTime = col.config.get("estTimes") ?: true - val preferences = baseContext.sharedPrefs() - automaticAnswer = AutomaticAnswer.createInstance(this, preferences, col) + automaticAnswer = AutomaticAnswer.createInstance(this, col) } catch (ex: Exception) { Timber.w(ex) onCollectionLoadError() diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/analytics/UsageAnalytics.kt b/AnkiDroid/src/main/java/com/ichi2/anki/analytics/UsageAnalytics.kt index 91c9f5581634..17619041c49e 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/analytics/UsageAnalytics.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/analytics/UsageAnalytics.kt @@ -466,7 +466,6 @@ object UsageAnalytics { "dayOffset", // Start of next day "learnCutoff", // Learn ahead limit "timeLimit", // Timebox time limit - "timeoutAnswer", // Automatic display answer "keepScreenOn", // Disable screen timeout "doubleTapTimeInterval", // Double tap time interval (milliseconds) // Sync diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/AutomaticAnswer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/AutomaticAnswer.kt index b76c52ec7863..0c89a8e4ac00 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/AutomaticAnswer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/AutomaticAnswer.kt @@ -16,7 +16,6 @@ package com.ichi2.anki.reviewer -import android.content.SharedPreferences import androidx.annotation.CheckResult import androidx.annotation.VisibleForTesting import com.ichi2.anki.CollectionManager.TR @@ -149,7 +148,6 @@ class AutomaticAnswer( /** Stop any "Automatic show answer" tasks in order to avoid race conditions */ fun onDisplayQuestion() { - if (!settings.useTimer) return if (!settings.autoAdvanceIfShowingQuestion) return hasPlayedSounds = false @@ -158,7 +156,6 @@ class AutomaticAnswer( /** Stop any "Automatic show question" tasks in order to avoid race conditions */ fun onDisplayAnswer() { - if (!settings.useTimer) return if (!settings.autoAdvanceIfShowingAnswer) return hasPlayedSounds = false @@ -187,7 +184,6 @@ class AutomaticAnswer( * after a user-specified duration, plus an additional delay for media */ fun scheduleAutomaticDisplayAnswer(additionalDelay: Long = 0) { - if (!settings.useTimer) return if (!settings.autoAdvanceIfShowingQuestion) return if (hasPlayedSounds) return hasPlayedSounds = true @@ -199,7 +195,6 @@ class AutomaticAnswer( * after a user-specified duration, plus an additional delay for media */ fun scheduleAutomaticDisplayQuestion(additionalMediaDelay: Long = 0) { - if (!settings.useTimer) return if (!settings.autoAdvanceIfShowingAnswer) return if (hasPlayedSounds) return hasPlayedSounds = true @@ -228,8 +223,8 @@ class AutomaticAnswer( } @CheckResult - fun createInstance(target: AutomaticallyAnswered, preferences: SharedPreferences, col: Collection): AutomaticAnswer { - val settings = AutomaticAnswerSettings.createInstance(preferences, col) + fun createInstance(target: AutomaticallyAnswered, col: Collection): AutomaticAnswer { + val settings = AutomaticAnswerSettings.createInstance(col) return AutomaticAnswer(target, settings) } } @@ -253,7 +248,6 @@ class AutomaticAnswer( */ class AutomaticAnswerSettings( val answerAction: AutomaticAnswerAction = AutomaticAnswerAction.BURY_CARD, - @get:JvmName("useTimer") val useTimer: Boolean = false, private val secondsToShowQuestionFor: Double = 60.0, private val secondsToShowAnswerFor: Double = 20.0 ) { @@ -271,24 +265,21 @@ class AutomaticAnswerSettings( */ @NeedsTest("ensure question setting maps to question parameter") fun queryOptions( - preferences: SharedPreferences, col: Collection, selectedDid: DeckId ): AutomaticAnswerSettings { val conf = col.decks.configDictForDeckId(selectedDid) val action = getAction(conf) - val useTimer = preferences.getBoolean("timeoutAnswer", false) return AutomaticAnswerSettings( answerAction = action, - useTimer = useTimer, secondsToShowQuestionFor = conf.secondsToShowQuestion, secondsToShowAnswerFor = conf.secondsToShowAnswer ) } - fun createInstance(preferences: SharedPreferences, col: Collection): AutomaticAnswerSettings { - return queryOptions(preferences, col, col.decks.selected()) + fun createInstance(col: Collection): AutomaticAnswerSettings { + return queryOptions(col, col.decks.selected()) } private fun getAction(conf: DeckConfig): AutomaticAnswerAction { diff --git a/AnkiDroid/src/main/res/values/10-preferences.xml b/AnkiDroid/src/main/res/values/10-preferences.xml index 4c057a26ecfa..39e1cb627559 100644 --- a/AnkiDroid/src/main/res/values/10-preferences.xml +++ b/AnkiDroid/src/main/res/values/10-preferences.xml @@ -128,8 +128,6 @@ More than %d cards due Vibrate Blink light - Automatic display answer - Show answer automatically without user input. Configure from deck options. Select language Disable card hardware render Hardware render is faster but may have problems, specifically on Android 8/8.1. If you cannot see parts of the card review user interface, try this setting. diff --git a/AnkiDroid/src/main/res/values/constants.xml b/AnkiDroid/src/main/res/values/constants.xml index 0dc4e7d41153..e69ac548bb0a 100644 --- a/AnkiDroid/src/main/res/values/constants.xml +++ b/AnkiDroid/src/main/res/values/constants.xml @@ -250,7 +250,7 @@ @string/pref_cat_scheduling - @string/timeout_answer_text + @string/pref_keep_screen_on diff --git a/AnkiDroid/src/main/res/values/preferences.xml b/AnkiDroid/src/main/res/values/preferences.xml index b936fadbcf4b..8585ed7898ab 100644 --- a/AnkiDroid/src/main/res/values/preferences.xml +++ b/AnkiDroid/src/main/res/values/preferences.xml @@ -13,7 +13,6 @@ dayOffset learnCutoff timeLimit - timeoutAnswer keepScreenOn doubleTapTimeInterval diff --git a/AnkiDroid/src/main/res/xml/preferences_reviewing.xml b/AnkiDroid/src/main/res/xml/preferences_reviewing.xml index 239ef2e95b19..e75765117ff0 100644 --- a/AnkiDroid/src/main/res/xml/preferences_reviewing.xml +++ b/AnkiDroid/src/main/res/xml/preferences_reviewing.xml @@ -49,14 +49,6 @@ app:min="0" app1:summaryFormat="@plurals/pref_summ_minutes"/> - - -