diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java index 11fc1c88dfd2..cdea1dc045b0 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java +++ b/AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.java @@ -272,6 +272,9 @@ public abstract class AbstractFlashcardViewer extends NavigationDrawerActivity i private boolean mInAnswer = false; private boolean mAnswerSoundsAdded = false; + /** Preferred option that should be selected in "Automatic answer" scenario **/ + private int mAutomaticAnswerSelection; + private CardTemplate mCardTemplate; /** @@ -1798,6 +1801,8 @@ protected void initControls() { protected SharedPreferences restorePreferences() { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); + + mAutomaticAnswerSelection = Integer.parseInt(preferences.getString("automaticAnswer", "3")); mUseInputTag = preferences.getBoolean("useInputTag", false); mDoNotUseCodeFormatting = preferences.getBoolean("noCodeFormatting", false); // On newer Androids, ignore this setting, which should be hidden in the prefs anyway. @@ -1927,9 +1932,51 @@ protected void updateDeckName() { protected final Runnable mShowQuestionTask = new Runnable() { @Override public void run() { - // Assume hitting the "Again" button when auto next question - if (mEase1Layout.isEnabled() && mEase1Layout.getVisibility() == View.VISIBLE) { - mEase1Layout.performClick(); + // Hitting button based on the user preference for "automaticdisplayanswer" scenario + switch (mAutomaticAnswerSelection) { + // Again + case 1: { + // "Again" is always present as the first button + if (mEase1Layout.isEnabled() && mEase1Layout.getVisibility() == View.VISIBLE) { + mEase1Layout.performClick(); + } + break; + } + // Hard(or Good if Hard is not an option) + case 2: { + // Second button can either be "Hard" or "Good" + // If "hard "is present it will be second button otherwise "Good" will be the second button + if (mEase2Layout.isEnabled() && mEase2Layout.getVisibility() == View.VISIBLE) { + mEase2Layout.performClick(); + } + break; + } + // "Good" + case 3: { + if (getAnswerButtonCount() == 2 && mEase2Layout.isEnabled() && mEase2Layout.getVisibility() == View.VISIBLE) { + // In case of only two buttons "Good" is the Second option + mEase2Layout.performClick(); + } else if (mEase3Layout.isEnabled() && mEase3Layout.getVisibility() == View.VISIBLE) { + // If more than two buttons are present then "Good" is the third option + mEase3Layout.performClick(); + } + break; + } + // "Easy (or Good if Easy is not an option )" + case 4: { + if (getAnswerButtonCount() == 4 && mEase4Layout.isEnabled() && mEase4Layout.getVisibility() == View.VISIBLE) { + // In case of All 4 buttons are present "Easy" is the 4th button + mEase4Layout.performClick(); + } else if (getAnswerButtonCount() == 3 && mEase3Layout.isEnabled() && mEase3Layout.getVisibility() == View.VISIBLE) { + // If 3 buttons are present then if "Easy" is present it is the third option + // or if "Easy" is not present then "Good" is the third option + mEase3Layout.performClick(); + } else if (mEase2Layout.isEnabled() && mEase2Layout.getVisibility() == View.VISIBLE) { + // If only two buttons are present then "Good" is the second option + mEase2Layout.performClick(); + } + break; + } } } }; diff --git a/AnkiDroid/src/main/res/values/10-preferences.xml b/AnkiDroid/src/main/res/values/10-preferences.xml index 84321f58aebe..1f80ed7854d4 100644 --- a/AnkiDroid/src/main/res/values/10-preferences.xml +++ b/AnkiDroid/src/main/res/values/10-preferences.xml @@ -128,6 +128,7 @@ Vibrate Blink light Automatic display answer + Timeout answer Show answer automatically without user input. Delay includes time for automatically played audio files. Time to show answer XXX s diff --git a/AnkiDroid/src/main/res/values/11-arrays.xml b/AnkiDroid/src/main/res/values/11-arrays.xml index e8884056db5f..4b2d860a00d5 100644 --- a/AnkiDroid/src/main/res/values/11-arrays.xml +++ b/AnkiDroid/src/main/res/values/11-arrays.xml @@ -95,5 +95,9 @@ Toggle Whiteboard Record Voice Replay Voice + Again + Hard (or Good if Hard is not an option) + Good (Default) + Easy (or Good if Easy is not an option) diff --git a/AnkiDroid/src/main/res/values/constants.xml b/AnkiDroid/src/main/res/values/constants.xml index 6d3ecb42cf95..4e9efad14c33 100644 --- a/AnkiDroid/src/main/res/values/constants.xml +++ b/AnkiDroid/src/main/res/values/constants.xml @@ -234,6 +234,18 @@ 1 2 + + @string/automatic_answer_option_1 + @string/automatic_answer_option_2 + @string/automatic_answer_option_3 + @string/automatic_answer_option_4 + + + 1 + 2 + 3 + 4 + 0 1 diff --git a/AnkiDroid/src/main/res/xml/preferences_reviewing.xml b/AnkiDroid/src/main/res/xml/preferences_reviewing.xml index 45e9ba4bd455..0c43360588db 100644 --- a/AnkiDroid/src/main/res/xml/preferences_reviewing.xml +++ b/AnkiDroid/src/main/res/xml/preferences_reviewing.xml @@ -145,6 +145,13 @@ android:key="timeoutAnswer" android:summary="@string/timeout_answer_summ" android:title="@string/timeout_answer_text" /> +