Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Option to choose the default answer(Again, Hard, Good, Easy) on timeout when the "automatic display answer" setting is used #8281

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
IAmJaishree marked this conversation as resolved.
Show resolved Hide resolved

private CardTemplate mCardTemplate;

/**
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
}
}
};
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/values/10-preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
<string name="notification_minimum_cards_due_vibrate">Vibrate</string>
<string name="notification_minimum_cards_due_blink">Blink light</string>
<string name="timeout_answer_text">Automatic display answer</string>
<string name="timeout_answer">Timeout answer</string>
<string name="timeout_answer_summ">Show answer automatically without user input. Delay includes time for automatically played audio files.</string>
<string name="timeout_answer_seconds">Time to show answer</string>
<string name="timeout_answer_seconds_summ" comment="The time to wait (in seconds) in the reviewer before automatically showing the next question or answer">XXX s</string>
Expand Down
3 changes: 3 additions & 0 deletions AnkiDroid/src/main/res/values/11-arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,8 @@
<string name="gesture_toggle_whiteboard">Toggle Whiteboard</string>
<string name="record_voice">Record Voice</string>
<string name="replay_voice">Replay Voice</string>
<string name="automatic_answer_option_2">Hard (or Good if Hard is not an option)</string>
<string name="automatic_answer_option_3">Good (Default)</string>
<string name="automatic_answer_option_4">Easy (or Good if Easy is not an option)</string>

</resources>
12 changes: 12 additions & 0 deletions AnkiDroid/src/main/res/values/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@
<item>1</item>
<item>2</item>
</string-array>
<string-array name="automatic_answer_options">
<item>@string/ease_button_again</item>
<item>@string/automatic_answer_option_2</item>
<item>@string/automatic_answer_option_3</item>
<item>@string/automatic_answer_option_4</item>
</string-array>
<string-array name="automatic_answer_values">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</string-array>
<string-array name="override_font_values">
<item>0</item>
<item>1</item>
Expand Down
7 changes: 7 additions & 0 deletions AnkiDroid/src/main/res/xml/preferences_reviewing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@
android:key="timeoutAnswer"
android:summary="@string/timeout_answer_summ"
android:title="@string/timeout_answer_text" />
<ListPreference
android:entries="@array/automatic_answer_options"
android:dependency="timeoutAnswer"
android:entryValues="@array/automatic_answer_values"
android:defaultValue="3"
android:key="automaticAnswer"
android:title="@string/timeout_answer" />
<com.ichi2.ui.SeekBarPreference
android:defaultValue="20"
android:dependency="timeoutAnswer"
Expand Down